#ifndef TESTPLUGIN_H #define TESTPLUGIN_H #include <../../src/interface.h> #include #include #include #include #include #include #include #include #include #include class FileExplorerPlugin : public QObject, public Interface { Q_OBJECT Q_PLUGIN_METADATA(IID "org.SOM.Interface" FILE "FileExplorerPlugin.json") Q_INTERFACES(Interface) public: QString pname() override; QString pdesc() override; QWidget *pcontent() override; void connectToHost(QObject* host) override; private slots: void onDirSelected(const QModelIndex &index); void onFileActivated(const QModelIndex &index); void showFileContextMenu(const QPoint &pos); void showDirContextMenu(const QPoint &pos); private: QWidget *mainWidget = nullptr; // Models + views QFileSystemModel *dirModel = nullptr; // directories only, left pane QTreeView *dirTree = nullptr; QFileSystemModel *fileModel = nullptr; // files+dirs, right pane QListView *fileList = nullptr; // Project root (left pane root). Default: application current path QString projectRoot; // Helpers QString selectedFilePath(const QModelIndex &index) const; QString selectedDirPath(const QModelIndex &index) const; void createFileInCurrentRoot(); void createFolderInCurrentRoot(); void editFile(const QString &path); bool removePath(const QString &path); bool renamePath(const QString &oldPath, const QString &newName); signals: void fileSelected(const QString& path); }; #endif