vnote/vfilelist.h
Le Tan b55ebe8f91 use itemClicked signal instead of currentItemChanged to trigger opening a file
This will handle the corner case: when user open file "f" and close it,
this file is still current item, so if user want to re-open it by
clicking on it, it won't work.

Signed-off-by: Le Tan <tamlokveer@gmail.com>
2016-10-07 11:07:43 +08:00

48 lines
1.1 KiB
C++

#ifndef VFILELIST_H
#define VFILELIST_H
#include <QListWidget>
#include <QJsonObject>
class QAction;
class VFileList : public QListWidget
{
Q_OBJECT
public:
explicit VFileList(QWidget *parent = 0);
signals:
void fileClicked(QJsonObject fileJson);
private slots:
void newFile();
void deleteFile();
void contextMenuRequested(QPoint pos);
void handleItemClicked(QListWidgetItem *currentItem);
public slots:
void setDirectory(QJsonObject dirJson);
private:
void updateFileList();
QListWidgetItem *insertFileListItem(QJsonObject fileJson, bool atFront = false);
void removeFileListItem(QListWidgetItem *item);
void initActions();
bool isConflictNameWithExisting(const QString &name);
QListWidgetItem *createFileAndUpdateList(const QString &name,
const QString &description);
void deleteFileAndUpdateList(QListWidgetItem *item);
void clearDirectoryInfo();
QString rootPath;
QString relativePath;
QString directoryName;
// Actions
QAction *newFileAct;
QAction *deleteFileAct;
};
#endif // VFILELIST_H