diff options
author | hjk <hjk121@nokiamail.com> | 2014-06-23 16:57:56 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-06-24 15:25:56 +0200 |
commit | 2982a763ac69043400e624c2c199344be2b2ba6f (patch) | |
tree | 883241797f1fdf78a946835139d9552026d3d17c /src/plugins/coreplugin/variablemanager.h | |
parent | 000fbe63bcfee71605c485645ca4b337f71737be (diff) | |
download | qt-creator-2982a763ac69043400e624c2c199344be2b2ba6f.tar.gz |
Variables: Use lambdas as callbacks to resolve variables
Instead of broadcasting for each resolution we ask the code
that knows about a specific variable directly.
Change-Id: I2f0f4f2acceba85a236995d236980594a3166bd8
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Diffstat (limited to 'src/plugins/coreplugin/variablemanager.h')
-rw-r--r-- | src/plugins/coreplugin/variablemanager.h | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/plugins/coreplugin/variablemanager.h b/src/plugins/coreplugin/variablemanager.h index 4612bd8f4f..a9d08b65ba 100644 --- a/src/plugins/coreplugin/variablemanager.h +++ b/src/plugins/coreplugin/variablemanager.h @@ -32,10 +32,10 @@ #include "core_global.h" -#include <QObject> -#include <QString> +#include <functional> -QT_FORWARD_DECLARE_CLASS(QFileInfo) +#include <QFileInfo> +#include <QString> namespace Utils { class AbstractMacroExpander; } @@ -43,37 +43,30 @@ namespace Core { namespace Internal { class MainWindow; } -class CORE_EXPORT VariableManager : public QObject +class CORE_EXPORT VariableManager { - Q_OBJECT - public: - static QObject *instance(); - - static void insert(const QByteArray &variable, const QString &value); - static bool remove(const QByteArray &variable); static QString value(const QByteArray &variable, bool *found = 0); static QString expandedString(const QString &stringWithVariables); static Utils::AbstractMacroExpander *macroExpander(); + + typedef std::function<QString()> StringFunction; + typedef std::function<int()> IntFunction; + static void registerVariable(const QByteArray &variable, - const QString &description); + const QString &description, const StringFunction &value); + + static void registerIntVariable(const QByteArray &variable, + const QString &description, const IntFunction &value); static void registerFileVariables(const QByteArray &prefix, - const QString &heading); - static bool isFileVariable(const QByteArray &variable, const QByteArray &prefix); - static QString fileVariableValue(const QByteArray &variable, const QByteArray &prefix, - const QString &fileName); - static QString fileVariableValue(const QByteArray &variable, const QByteArray &prefix, - const QFileInfo &fileInfo); + const QString &heading, const StringFunction &value); static QList<QByteArray> variables(); static QString variableDescription(const QByteArray &variable); -signals: - void variableUpdateRequested(const QByteArray &variable); - private: VariableManager(); ~VariableManager(); |