File indexing completed on 2024-05-12 11:32:44

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2020 Sirgienko Nikita <warquark@gmail.com>
0004 */
0005 
0006 #ifndef _FILEBROWSERPANELPLUGIN_H
0007 #define _FILEBROWSERPANELPLUGIN_H
0008 
0009 #include <QPointer>
0010 #include <QVector>
0011 
0012 #include "panelplugin.h"
0013 
0014 class QTreeView;
0015 class QWidget;
0016 class QModelIndex;
0017 class QFileSystemModel;
0018 class QPushButton;
0019 class QLineEdit;
0020 class QComboBox;
0021 
0022 class FileBrowserPanelPlugin : public Cantor::PanelPlugin
0023 {
0024   Q_OBJECT
0025   public:
0026     FileBrowserPanelPlugin (QObject* parent, const QList<QVariant>& args);
0027     ~FileBrowserPanelPlugin() override;
0028 
0029     QWidget* widget() override;
0030 
0031     bool showOnStartup() override;
0032 
0033     void connectToShell(QObject * cantorShell) override;
0034 
0035     // No use restore files, because the FileBrowser Panel can be shared between session
0036 
0037   Q_SIGNALS:
0038     void requestOpenWorksheet(const QUrl&);
0039 
0040   private Q_SLOTS:
0041     void handleDoubleClicked(const QModelIndex&);
0042     void dirPreviousButtonHandle();
0043     void dirUpButtonHandle();
0044     void homeButtonHandle();
0045     void dirNextButtonHandle();
0046     void setNewRootPath();
0047     void handleFilterChanging(int index);
0048 
0049   private:
0050     void constructMainWidget();
0051     void moveFileBrowserRoot(const QString& path);
0052     void setRootPath(const QString& path);
0053 
0054   private:
0055     QPointer<QWidget> m_mainWidget;
0056     QPointer<QTreeView> m_treeview;
0057     QPointer<QLineEdit> m_pathEdit;
0058     QPointer<QComboBox> m_filterCombobox;
0059     QFileSystemModel* m_model = nullptr;
0060     QVector<QString> m_rootDirsHistory;
0061     int historyBackCount = 0;
0062 };
0063 
0064 #endif /* _FILEBROWSERPANELPLUGIN_H */