-
Notifications
You must be signed in to change notification settings - Fork 0
/
workingdirwidget.h
79 lines (69 loc) · 2.36 KB
/
workingdirwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef WORKINGDIRWIDGET_H
#define WORKINGDIRWIDGET_H
#include <QTreeWidget>
#include <QWidget>
#include <QMenu>
#include <QAction>
#include <QString>
#include <QStringList>
#include <QMap>
#include <QFileSystemWatcher>
class WorkingDirWidget : public QTreeWidget
{
Q_OBJECT
public:
WorkingDirWidget(QWidget *parent = nullptr);
WorkingDirWidget(QString directory, QWidget *parent = nullptr);
WorkingDirWidget(QStringList directories, QWidget *parent = nullptr);
virtual ~WorkingDirWidget();
void addDirectory(QString directory);
void addDirectories(QStringList directories);
void attachModalsTo(QWidget *widget);
public slots:
void addprojectFolderRequested();
void removeprojectFolderRequested();
private slots:
void showContextMenu(const QPoint& pos);
void showFolderContent(QTreeWidgetItem *item);
void renameItemRequested();
void deleteItemRequested();
void newFolderRequested();
void newFileRequested();
void openFileRequested();
void stopMonitoringFolder(QTreeWidgetItem *folder);
private:
void init();
void initContextMenu();
void initContextMenuActions();
void connectContextMenuActions();
void makeConnections();
QString itemAbsPath(QTreeWidgetItem *item);
void insertFolders(QTreeWidgetItem *item);
void insertFiles(QTreeWidgetItem *item);
void clearItem(QTreeWidgetItem *item);
QTreeWidgetItem* getTopLevelParent(QTreeWidgetItem *item);
QString getParentPathForTopLevelItem(QTreeWidgetItem *item);
void connectToMonitoringEvents();
void warn(QString title, QString msg);
QStringList absolutePaths; // Record the absolute path for toplevel items
// Context Menu
QMenu *contextMenu;
QAction *addProjectFolder;
QAction *removeProjectFolder;
QAction *newFolder;
QAction *newFile;
QAction *open;
QAction *deleteItem;
QAction *renameItem;
QWidget *modalsParent;
// Monitor changes in expanded dirs
QFileSystemWatcher monitor;
QMap<QString,QTreeWidgetItem*> monitoredDirsWidgets;
signals:
void openFile(QString path);
void fileDeleted(QString path);
void fileRenamed(QString oldPath, QString newPath);
void folderDeleted(QString path);
void folderRenamed(QString oldPath, QString newPath);
};
#endif // WORKINGDIRWIDGET_H