File indexing completed on 2024-04-14 03:55:31

0001 /*
0002     SPDX-FileCopyrightText: 2019 Dominik Haumann <dhaumann@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KTEXTEDITOR_VARIABLE_MANAGER
0008 #define KTEXTEDITOR_VARIABLE_MANAGER
0009 
0010 #include <QList>
0011 #include <QString>
0012 #include <QWidget>
0013 
0014 #include "variable.h"
0015 
0016 namespace KTextEditor
0017 {
0018 class View;
0019 }
0020 
0021 /**
0022  * Manager class for variable expansion.
0023  */
0024 class KateVariableExpansionManager : public QObject
0025 {
0026 public:
0027     /**
0028      * Constructor with @p parent that takes ownership.
0029      */
0030     KateVariableExpansionManager(QObject *parent);
0031 
0032     /**
0033      * Adds @p variable to the expansion list view.
0034      */
0035     bool addVariable(const KTextEditor::Variable &variable);
0036 
0037     /**
0038      * Removes variable @p name.
0039      */
0040     bool removeVariable(const QString &name);
0041 
0042     /**
0043      * Returns the variable called @p name.
0044      */
0045     KTextEditor::Variable variable(const QString &name) const;
0046 
0047     /**
0048      * Returns all registered variables.
0049      */
0050     const QList<KTextEditor::Variable> &variables() const;
0051 
0052     bool expandVariable(const QString &variable, KTextEditor::View *view, QString &output) const;
0053 
0054     static QString expandText(const QString &text, KTextEditor::View *view);
0055 
0056     void showDialog(const QList<QWidget *> &widgets, const QStringList &names) const;
0057 
0058 private:
0059     QList<KTextEditor::Variable> m_variables;
0060 };
0061 
0062 #endif // KTEXTEDITOR_VARIABLE_MANAGER
0063 
0064 // kate: space-indent on; indent-width 4; replace-tabs on;