katefiletreeplugin.h 3.34 KB
Newer Older
1
/* This file is part of the KDE project
2
   SPDX-FileCopyrightText: 2010 Thomas Fjellstrom <thomas@fjellstrom.ca>
3

4
   SPDX-License-Identifier: LGPL-2.0-or-later
5 6 7 8 9
*/

#ifndef KATE_FILETREE_PLUGIN_H
#define KATE_FILETREE_PLUGIN_H

Michal Humpula's avatar
Michal Humpula committed
10
#include <QIcon>
11

12
#include <KTextEditor/Command>
13
#include <KTextEditor/Plugin>
14
#include <ktexteditor/document.h>
Vegard Øye's avatar
Vegard Øye committed
15
#include <ktexteditor/editor.h>
16 17
#include <ktexteditor/mainwindow.h>
#include <ktexteditor/sessionconfiginterface.h>
18

19 20
#include "katefiletreepluginsettings.h"

21 22
#include <KXMLGUIClient>

23 24
class KToolBar;

25 26 27
class KateFileTree;
class KateFileTreeModel;
class KateFileTreeProxyModel;
28 29
class KateFileTreeConfigPage;
class KateFileTreePluginView;
30

31 32
class QLineEdit;

33
class KateFileTreePlugin : public KTextEditor::Plugin
34
{
Dominik Haumann's avatar
Dominik Haumann committed
35
    Q_OBJECT
36

Dominik Haumann's avatar
Dominik Haumann committed
37
public:
38
    explicit KateFileTreePlugin(QObject *parent = nullptr, const QList<QVariant> & = QList<QVariant>());
Kevin Funk's avatar
Kevin Funk committed
39
    ~KateFileTreePlugin() override;
40

Kevin Funk's avatar
Kevin Funk committed
41
    QObject *createView(KTextEditor::MainWindow *mainWindow) override;
42

Kevin Funk's avatar
Kevin Funk committed
43 44
    int configPages() const override;
    KTextEditor::ConfigPage *configPage(int number = 0, QWidget *parent = nullptr) override;
45 46 47

    const KateFileTreePluginSettings &settings();

48
    void applyConfig(bool shadingEnabled, const QColor &viewShade, const QColor &editShade, bool listMode, int sortRole, bool showFulPath);
Christoph Cullmann's avatar
Christoph Cullmann committed
49

Dominik Haumann's avatar
Dominik Haumann committed
50 51
public Q_SLOTS:
    void viewDestroyed(QObject *view);
52

Dominik Haumann's avatar
Dominik Haumann committed
53
private:
54
    QList<KateFileTreePluginView *> m_views;
55
    KateFileTreeConfigPage *m_confPage = nullptr;
56
    KateFileTreePluginSettings m_settings;
57 58
};

59
class KateFileTreePluginView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface
60
{
Dominik Haumann's avatar
Dominik Haumann committed
61
    Q_OBJECT
62

Dominik Haumann's avatar
Dominik Haumann committed
63 64 65
    Q_INTERFACES(KTextEditor::SessionConfigInterface)

public:
66
    /**
67 68
     * Constructor.
     */
Dominik Haumann's avatar
Dominik Haumann committed
69
    KateFileTreePluginView(KTextEditor::MainWindow *mainWindow, KateFileTreePlugin *plug);
70 71 72 73

    /**
     * Virtual destructor.
     */
Kevin Funk's avatar
Kevin Funk committed
74
    ~KateFileTreePluginView() override;
75

Kevin Funk's avatar
Kevin Funk committed
76 77
    void readSessionConfig(const KConfigGroup &config) override;
    void writeSessionConfig(KConfigGroup &config) override;
78

Vegard Øye's avatar
Vegard Øye committed
79 80 81 82
    /**
     * The file tree model.
     * @return the file tree model
     */
83
    KateFileTreeModel *model();
Vegard Øye's avatar
Vegard Øye committed
84 85 86 87
    /**
     * The file tree proxy model.
     * @return the file tree proxy model
     */
88
    KateFileTreeProxyModel *proxy();
Vegard Øye's avatar
Vegard Øye committed
89 90 91 92
    /**
     * The file tree.
     * @return the file tree
     */
93
    KateFileTree *tree();
94 95

    void setListMode(bool listMode);
96 97 98

    bool hasLocalPrefs();
    void setHasLocalPrefs(bool);
Christoph Cullmann's avatar
Christoph Cullmann committed
99

Dominik Haumann's avatar
Dominik Haumann committed
100
protected:
101 102
    void setupActions();

Dominik Haumann's avatar
Dominik Haumann committed
103
private:
104
    QWidget *m_toolView;
105
    KToolBar *m_toolbar;
106 107
    KateFileTree *m_fileTree;
    KateFileTreeProxyModel *m_proxyModel;
108
    QLineEdit *m_filter;
109
    KateFileTreeModel *m_documentModel;
110
    bool m_hasLocalPrefs = false;
111
    bool m_loadingDocuments;
112
    KateFileTreePlugin *m_plug;
113
    KTextEditor::MainWindow *m_mainWindow;
Christoph Cullmann's avatar
Christoph Cullmann committed
114

Dominik Haumann's avatar
Dominik Haumann committed
115
private Q_SLOTS:
116 117
    void showToolView();
    void hideToolView();
118 119
    void showActiveDocument();
    void activateDocument(KTextEditor::Document *);
Christoph Cullmann's avatar
Christoph Cullmann committed
120
    void viewChanged(KTextEditor::View * = nullptr);
121 122
    void documentOpened(KTextEditor::Document *);
    void documentClosed(KTextEditor::Document *);
123 124
    void viewModeChanged(bool);
    void sortRoleChanged(int);
125 126
    void slotAboutToCreateDocuments();
    void slotDocumentsCreated(const QList<KTextEditor::Document *> &);
Christoph Cullmann's avatar
Christoph Cullmann committed
127 128
    void slotDocumentSave();
    void slotDocumentSaveAs();
129 130
};

131
#endif // KATE_FILETREE_PLUGIN_H