Changeset View
Changeset View
Standalone View
Standalone View
addons/openselection/plugin_kateopenselection.h
- This file was added.
1 | /* This file is part of the KDE project | ||||
---|---|---|---|---|---|
2 | Copyright (C) 2019 Arnaud Ruiz | ||||
3 | | ||||
4 | Created from large parts of: | ||||
5 | - openheader plugin | ||||
6 | Copyright (C) 2001 Joseph Wenninger | ||||
7 | Copyright (C) 2009 Erlend Hamberg <ehamberg@gmail.com> | ||||
8 | - search plugin | ||||
9 | Copyright (C) 2011-2013 by Kåre Särs <kare.sars@iki.fi> | ||||
10 | | ||||
11 | This library is free software; you can redistribute it and/or | ||||
12 | modify it under the terms of the GNU Library General Public | ||||
13 | License version 2 as published by the Free Software Foundation. | ||||
14 | | ||||
15 | This library is distributed in the hope that it will be useful, | ||||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
18 | Library General Public License for more details. | ||||
19 | | ||||
20 | You should have received a copy of the GNU Library General Public License | ||||
21 | along with this library; see the file COPYING.LIB. If not, write to | ||||
22 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
23 | Boston, MA 02110-1301, USA. | ||||
24 | */ | ||||
25 | | ||||
26 | | ||||
27 | #ifndef PLUGIN_KATEOPENSELECTION_H | ||||
28 | #define PLUGIN_KATEOPENSELECTION_H | ||||
29 | | ||||
30 | #include <ktexteditor/plugin.h> | ||||
31 | #include <ktexteditor/mainwindow.h> | ||||
32 | #include <KTextEditor/Command> | ||||
33 | #include <KXMLGUIClient> | ||||
34 | #include <kpluginfactory.h> | ||||
35 | #include <QObject> | ||||
36 | #include <QUrl> | ||||
37 | | ||||
38 | class PluginCommandKateOpenSelection; | ||||
39 | | ||||
40 | class PluginKateOpenSelection : public KTextEditor::Plugin | ||||
41 | { | ||||
42 | Q_OBJECT | ||||
43 | | ||||
44 | public: | ||||
45 | explicit PluginKateOpenSelection(QObject* parent = nullptr, const QList<QVariant>& = QList<QVariant>()); | ||||
46 | ~PluginKateOpenSelection() override; | ||||
47 | | ||||
48 | QObject *createView(KTextEditor::MainWindow *mainWindow) override; | ||||
49 | | ||||
50 | public Q_SLOTS: | ||||
51 | void slotOpenSelection(); | ||||
52 | | ||||
53 | private: | ||||
54 | QString findPathAtCursor(KTextEditor::View* editView); | ||||
55 | bool fileExists(const QUrl &url); | ||||
56 | PluginCommandKateOpenSelection* m_openSelectionCommand; | ||||
57 | }; | ||||
58 | | ||||
59 | class PluginViewKateOpenSelection | ||||
60 | : public QObject, public KXMLGUIClient | ||||
61 | { | ||||
62 | Q_OBJECT | ||||
63 | public: | ||||
64 | PluginViewKateOpenSelection(PluginKateOpenSelection* plugin, KTextEditor::MainWindow *mainwindow); | ||||
65 | ~PluginViewKateOpenSelection() override; | ||||
66 | | ||||
67 | private: | ||||
68 | KTextEditor::MainWindow *m_mainWindow; | ||||
69 | }; | ||||
70 | | ||||
71 | class PluginCommandKateOpenSelection | ||||
72 | : public KTextEditor::Command | ||||
73 | { | ||||
74 | Q_OBJECT | ||||
75 | public: | ||||
76 | PluginCommandKateOpenSelection(QObject* parent = nullptr); | ||||
77 | ~PluginCommandKateOpenSelection() override; | ||||
78 | | ||||
79 | bool exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range = KTextEditor::Range::invalid()) override; | ||||
80 | bool help(KTextEditor::View *view, const QString &cmd, QString &msg) override; | ||||
81 | | ||||
82 | Q_SIGNALS: | ||||
83 | void openSelection(); | ||||
84 | }; | ||||
85 | | ||||
86 | #endif // PLUGIN_KATEOPENSELECTION_H |