mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00

Add menu action importNoteAct to import notes from files. Currently only HTML and Markdown files are supported. Importing other files (such as txt) may not work correctly. Signed-off-by: Le Tan <tamlokveer@gmail.com>
49 lines
1.2 KiB
C++
49 lines
1.2 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);
|
|
bool importFile(const QString &name);
|
|
|
|
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
|