1 | /* |
2 | SPDX-FileCopyrightText: 2019 Dominik Haumann <dhaumann@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KTEXTEDITOR_VARIABLE_MANAGER |
8 | #define KTEXTEDITOR_VARIABLE_MANAGER |
9 | |
10 | #include <QList> |
11 | #include <QString> |
12 | #include <QWidget> |
13 | |
14 | #include "variable.h" |
15 | |
16 | namespace KTextEditor |
17 | { |
18 | class View; |
19 | } |
20 | |
21 | /** |
22 | * Manager class for variable expansion. |
23 | */ |
24 | class KateVariableExpansionManager : public QObject |
25 | { |
26 | public: |
27 | /** |
28 | * Constructor with @p parent that takes ownership. |
29 | */ |
30 | KateVariableExpansionManager(QObject *parent); |
31 | |
32 | /** |
33 | * Adds @p variable to the expansion list view. |
34 | */ |
35 | bool addVariable(const KTextEditor::Variable &variable); |
36 | |
37 | /** |
38 | * Removes variable @p name. |
39 | */ |
40 | bool removeVariable(const QString &name); |
41 | |
42 | /** |
43 | * Returns the variable called @p name. |
44 | */ |
45 | KTextEditor::Variable variable(const QString &name) const; |
46 | |
47 | /** |
48 | * Returns all registered variables. |
49 | */ |
50 | const QList<KTextEditor::Variable> &variables() const; |
51 | |
52 | bool expandVariable(const QString &variable, KTextEditor::View *view, QString &output) const; |
53 | |
54 | static QString expandText(const QString &text, KTextEditor::View *view); |
55 | |
56 | void showDialog(const QList<QWidget *> &widgets, const QStringList &names) const; |
57 | |
58 | private: |
59 | QList<KTextEditor::Variable> m_variables; |
60 | }; |
61 | |
62 | #endif // KTEXTEDITOR_VARIABLE_MANAGER |
63 | |
64 | // kate: space-indent on; indent-width 4; replace-tabs on; |
65 | |