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>
This commit is contained in:
hjk
2014-06-23 16:57:56 +02:00
parent 000fbe63bc
commit 2982a763ac
15 changed files with 292 additions and 414 deletions

View File

@@ -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();