diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp index c8ad5102f79..84c2ec28611 100644 --- a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp +++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp @@ -610,5 +610,5 @@ void ExternalToolConfig::addCategory() void ExternalToolConfig::updateEffectiveArguments() { ui->arguments->setToolTip(Utils::QtcProcess::expandMacros(ui->arguments->text(), - Core::VariableManager::instance()->macroExpander())); + Core::VariableManager::macroExpander())); } diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 52f37ad9d80..31281f078a4 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -465,13 +465,12 @@ void EditorManager::init() d->m_openEditorsFactory = new OpenEditorsViewFactory(); ExtensionSystem::PluginManager::addObject(d->m_openEditorsFactory); - VariableManager *vm = VariableManager::instance(); - vm->registerFileVariables(kCurrentDocumentPrefix, tr("Current document")); - vm->registerVariable(kCurrentDocumentXPos, + VariableManager::registerFileVariables(kCurrentDocumentPrefix, tr("Current document")); + VariableManager::registerVariable(kCurrentDocumentXPos, tr("X-coordinate of the current editor's upper left corner, relative to screen.")); - vm->registerVariable(kCurrentDocumentYPos, + VariableManager::registerVariable(kCurrentDocumentYPos, tr("Y-coordinate of the current editor's upper left corner, relative to screen.")); - connect(vm, SIGNAL(variableUpdateRequested(QByteArray)), + connect(VariableManager::instance(), SIGNAL(variableUpdateRequested(QByteArray)), this, SLOT(updateVariable(QByteArray))); } @@ -2293,21 +2292,21 @@ void EditorManager::updateVariable(const QByteArray &variable) if (curEditor) { QString fileName = curEditor->document()->fileName(); if (!fileName.isEmpty()) - value = VariableManager::instance()->fileVariableValue(variable, kCurrentDocumentPrefix, + value = VariableManager::fileVariableValue(variable, kCurrentDocumentPrefix, fileName); } - VariableManager::instance()->insert(variable, value); + VariableManager::insert(variable, value); } else if (variable == kCurrentDocumentXPos) { QString value; IEditor *curEditor = currentEditor(); if (curEditor) value = QString::number(curEditor->widget()->mapToGlobal(QPoint(0,0)).x()); - VariableManager::instance()->insert(variable, value); + VariableManager::insert(variable, value); } else if (variable == kCurrentDocumentYPos) { QString value; IEditor *curEditor = currentEditor(); if (curEditor) value = QString::number(curEditor->widget()->mapToGlobal(QPoint(0,0)).y()); - VariableManager::instance()->insert(variable, value); + VariableManager::insert(variable, value); } } diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp index 9c1703e01f6..2549639c2c1 100644 --- a/src/plugins/coreplugin/externaltool.cpp +++ b/src/plugins/coreplugin/externaltool.cpp @@ -556,7 +556,7 @@ bool ExternalToolRunner::resolve() QStringList expandedExecutables; /* for error message */ foreach (const QString &executable, m_tool->executables()) { QString expanded = Utils::expandMacros(executable, - Core::VariableManager::instance()->macroExpander()); + Core::VariableManager::macroExpander()); expandedExecutables << expanded; m_resolvedExecutable = Utils::Environment::systemEnvironment().searchInPath(expanded); @@ -577,15 +577,15 @@ bool ExternalToolRunner::resolve() } { // arguments m_resolvedArguments = Utils::QtcProcess::expandMacros(m_tool->arguments(), - Core::VariableManager::instance()->macroExpander()); + Core::VariableManager::macroExpander()); } { // input m_resolvedInput = Utils::expandMacros(m_tool->input(), - Core::VariableManager::instance()->macroExpander()); + Core::VariableManager::macroExpander()); } { // working directory m_resolvedWorkingDirectory = Utils::expandMacros(m_tool->workingDirectory(), - Core::VariableManager::instance()->macroExpander()); + Core::VariableManager::macroExpander()); } return true; } diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index d886ef025a0..0bd8a307927 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -96,7 +96,7 @@ public: static EditorManager *editorManager(); static ProgressManager *progressManager(); static ScriptManager *scriptManager(); - static VariableManager *variableManager(); + static QT_DEPRECATED VariableManager *variableManager(); // Use VariableManager::... directly. static VcsManager *vcsManager(); static QT_DEPRECATED ModeManager *modeManager(); // Use ModeManager::... directly. static MimeDatabase *mimeDatabase(); diff --git a/src/plugins/coreplugin/variablechooser.cpp b/src/plugins/coreplugin/variablechooser.cpp index a96212c681b..7a1404278be 100644 --- a/src/plugins/coreplugin/variablechooser.cpp +++ b/src/plugins/coreplugin/variablechooser.cpp @@ -58,8 +58,7 @@ VariableChooser::VariableChooser(QWidget *parent) : setFocusPolicy(Qt::StrongFocus); setFocusProxy(ui->variableList); - VariableManager *vm = VariableManager::instance(); - foreach (const QByteArray &variable, vm->variables()) + foreach (const QByteArray &variable, VariableManager::variables()) ui->variableList->addItem(QString::fromLatin1(variable)); connect(ui->variableList, SIGNAL(currentTextChanged(QString)), @@ -82,7 +81,7 @@ void VariableChooser::updateDescription(const QString &variable) if (variable.isNull()) ui->variableDescription->setText(m_defaultDescription); else - ui->variableDescription->setText(VariableManager::instance()->variableDescription(variable.toUtf8())); + ui->variableDescription->setText(VariableManager::variableDescription(variable.toUtf8())); } void VariableChooser::updateCurrentEditor(QWidget *old, QWidget *widget) diff --git a/src/plugins/coreplugin/variablemanager.cpp b/src/plugins/coreplugin/variablemanager.cpp index 4904fbac915..ea4e6f22523 100644 --- a/src/plugins/coreplugin/variablemanager.cpp +++ b/src/plugins/coreplugin/variablemanager.cpp @@ -53,7 +53,7 @@ public: virtual bool resolveMacro(const QString &name, QString *ret) { bool found; - *ret = Core::VariableManager::instance()->value(name.toUtf8(), &found); + *ret = Core::VariableManager::value(name.toUtf8(), &found); return found; } }; @@ -77,9 +77,12 @@ public: */ static VariableManager *variableManagerInstance = 0; +static VariableManagerPrivate *d; -VariableManager::VariableManager() : d(new VariableManagerPrivate) + +VariableManager::VariableManager() { + d = new VariableManagerPrivate; variableManagerInstance = this; } @@ -101,7 +104,7 @@ bool VariableManager::remove(const QByteArray &variable) QString VariableManager::value(const QByteArray &variable, bool *found) { - emit variableUpdateRequested(variable); + variableManagerInstance->variableUpdateRequested(variable); if (found) *found = d->m_map.contains(variable); return d->m_map.value(variable); @@ -158,12 +161,12 @@ QString VariableManager::fileVariableValue(const QByteArray &variable, const QBy return QString(); } -QList VariableManager::variables() const +QList VariableManager::variables() { return d->m_descriptions.keys(); } -QString VariableManager::variableDescription(const QByteArray &variable) const +QString VariableManager::variableDescription(const QByteArray &variable) { return d->m_descriptions.value(variable); } diff --git a/src/plugins/coreplugin/variablemanager.h b/src/plugins/coreplugin/variablemanager.h index d156f10da84..df94527cb46 100644 --- a/src/plugins/coreplugin/variablemanager.h +++ b/src/plugins/coreplugin/variablemanager.h @@ -54,30 +54,27 @@ public: static VariableManager *instance(); - void insert(const QByteArray &variable, const QString &value); - bool remove(const QByteArray &variable); - QString value(const QByteArray &variable, bool *found = 0); - Utils::AbstractMacroExpander *macroExpander(); + 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 Utils::AbstractMacroExpander *macroExpander(); - void registerVariable(const QByteArray &variable, + static void registerVariable(const QByteArray &variable, const QString &description); - void registerFileVariables(const QByteArray &prefix, + static void registerFileVariables(const QByteArray &prefix, const QString &heading); - bool isFileVariable(const QByteArray &variable, const QByteArray &prefix); - QString fileVariableValue(const QByteArray &variable, const QByteArray &prefix, + static bool isFileVariable(const QByteArray &variable, const QByteArray &prefix); + static QString fileVariableValue(const QByteArray &variable, const QByteArray &prefix, const QString &fileName); - QString fileVariableValue(const QByteArray &variable, const QByteArray &prefix, + static QString fileVariableValue(const QByteArray &variable, const QByteArray &prefix, const QFileInfo &fileInfo); - QList variables() const; - QString variableDescription(const QByteArray &variable) const; + static QList variables(); + static QString variableDescription(const QByteArray &variable); signals: void variableUpdateRequested(const QByteArray &variable); - -private: - VariableManagerPrivate *d; }; } // namespace Core diff --git a/src/plugins/locator/executefilter.cpp b/src/plugins/locator/executefilter.cpp index c6545515d38..1db49545028 100644 --- a/src/plugins/locator/executefilter.cpp +++ b/src/plugins/locator/executefilter.cpp @@ -89,11 +89,10 @@ void ExecuteFilter::accept(FilterEntry selection) const if (index != 0) p->m_commandHistory.prepend(value); - VariableManager *vm = Core::VariableManager::instance(); bool found; - QString workingDirectory = vm->value("CurrentDocument:Path", &found); + QString workingDirectory = Core::VariableManager::value("CurrentDocument:Path", &found); if (!found || workingDirectory.isEmpty()) - workingDirectory = vm->value("CurrentProject:Path", &found); + workingDirectory = Core::VariableManager::value("CurrentProject:Path", &found); ExecuteData d; d.workingDirectory = workingDirectory; diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index 05bd88e4eb2..5d9dd7f2f64 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -73,7 +73,7 @@ bool BuildConfigMacroExpander::resolveMacro(const QString &name, QString *ret) *ret = QDir::toNativeSeparators(m_bc->buildDirectory()); return true; } - *ret = Core::VariableManager::instance()->value(name.toUtf8()); + *ret = Core::VariableManager::value(name.toUtf8()); return !ret->isEmpty(); } } // namespace Internal diff --git a/src/plugins/projectexplorer/localapplicationrunconfiguration.cpp b/src/plugins/projectexplorer/localapplicationrunconfiguration.cpp index 0fa55d91cf3..ad8dba196f3 100644 --- a/src/plugins/projectexplorer/localapplicationrunconfiguration.cpp +++ b/src/plugins/projectexplorer/localapplicationrunconfiguration.cpp @@ -57,7 +57,7 @@ Utils::AbstractMacroExpander *LocalApplicationRunConfiguration::macroExpander() { if (BuildConfiguration *bc = activeBuildConfiguration()) return bc->macroExpander(); - return Core::VariableManager::instance()->macroExpander(); + return Core::VariableManager::macroExpander(); } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/processstep.cpp b/src/plugins/projectexplorer/processstep.cpp index 553dc053d2e..043f05fcfc0 100644 --- a/src/plugins/projectexplorer/processstep.cpp +++ b/src/plugins/projectexplorer/processstep.cpp @@ -86,7 +86,7 @@ bool ProcessStep::init() if (!bc) bc = target()->activeBuildConfiguration(); ProcessParameters *pp = processParameters(); - pp->setMacroExpander(bc ? bc->macroExpander() : Core::VariableManager::instance()->macroExpander()); + pp->setMacroExpander(bc ? bc->macroExpander() : Core::VariableManager::macroExpander()); pp->setEnvironment(bc ? bc->environment() : Utils::Environment::systemEnvironment()); pp->setWorkingDirectory(workingDirectory()); pp->setCommand(m_command); @@ -274,7 +274,7 @@ void ProcessStepConfigWidget::updateDetails() BuildConfiguration *bc = m_step->buildConfiguration(); if (!bc) // iff the step is actually in the deploy list bc = m_step->target()->activeBuildConfiguration(); - param.setMacroExpander(bc ? bc->macroExpander() : Core::VariableManager::instance()->macroExpander()); + param.setMacroExpander(bc ? bc->macroExpander() : Core::VariableManager::macroExpander()); param.setEnvironment(bc ? bc->environment() : Utils::Environment::systemEnvironment()); param.setWorkingDirectory(m_step->workingDirectory()); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 553f4da8d0e..52571ceac8f 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1004,19 +1004,18 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er updateWelcomePage(); - Core::VariableManager *vm = Core::VariableManager::instance(); - vm->registerFileVariables(Constants::VAR_CURRENTPROJECT_PREFIX, tr("Current project's main file")); - vm->registerVariable(Constants::VAR_CURRENTPROJECT_BUILDPATH, + Core::VariableManager::registerFileVariables(Constants::VAR_CURRENTPROJECT_PREFIX, tr("Current project's main file")); + Core::VariableManager::registerVariable(Constants::VAR_CURRENTPROJECT_BUILDPATH, tr("Full build path of the current project's active build configuration.")); - vm->registerVariable(Constants::VAR_CURRENTPROJECT_NAME, tr("The current project's name.")); - vm->registerVariable(Constants::VAR_CURRENTKIT_NAME, tr("The currently active kit's name.")); - vm->registerVariable(Constants::VAR_CURRENTKIT_FILESYSTEMNAME, + Core::VariableManager::registerVariable(Constants::VAR_CURRENTPROJECT_NAME, tr("The current project's name.")); + Core::VariableManager::registerVariable(Constants::VAR_CURRENTKIT_NAME, tr("The currently active kit's name.")); + Core::VariableManager::registerVariable(Constants::VAR_CURRENTKIT_FILESYSTEMNAME, tr("The currently active kit's name in a filesystem friendly version.")); - vm->registerVariable(Constants::VAR_CURRENTKIT_ID, tr("The currently active kit's id.")); - vm->registerVariable(Constants::VAR_CURRENTBUILD_NAME, tr("The currently active build configuration's name.")); - vm->registerVariable(Constants::VAR_CURRENTBUILD_TYPE, tr("The currently active build configuration's type.")); + Core::VariableManager::registerVariable(Constants::VAR_CURRENTKIT_ID, tr("The currently active kit's id.")); + Core::VariableManager::registerVariable(Constants::VAR_CURRENTBUILD_NAME, tr("The currently active build configuration's name.")); + Core::VariableManager::registerVariable(Constants::VAR_CURRENTBUILD_TYPE, tr("The currently active build configuration's type.")); - connect(vm, SIGNAL(variableUpdateRequested(QByteArray)), + connect(Core::VariableManager::instance(), SIGNAL(variableUpdateRequested(QByteArray)), this, SLOT(updateVariable(QByteArray))); return true; @@ -1144,10 +1143,10 @@ void ProjectExplorerPlugin::updateVariable(const QByteArray &variable) { if (variable == Constants::VAR_CURRENTPROJECT_BUILDPATH) { if (currentProject() && currentProject()->activeTarget() && currentProject()->activeTarget()->activeBuildConfiguration()) { - Core::VariableManager::instance()->insert(variable, + Core::VariableManager::insert(variable, currentProject()->activeTarget()->activeBuildConfiguration()->buildDirectory()); } else { - Core::VariableManager::instance()->remove(variable); + Core::VariableManager::remove(variable); } } else if (variable == Constants::VAR_CURRENTBUILD_TYPE) { if (currentProject() && currentProject()->activeTarget() && currentProject()->activeTarget()->activeBuildConfiguration()) { @@ -1159,9 +1158,9 @@ void ProjectExplorerPlugin::updateVariable(const QByteArray &variable) typeString = tr("release"); else typeString = tr("unknown"); - Core::VariableManager::instance()->insert(variable, typeString); + Core::VariableManager::insert(variable, typeString); } else { - Core::VariableManager::instance()->remove(variable); + Core::VariableManager::remove(variable); } } else { QString projectName; @@ -1182,9 +1181,9 @@ void ProjectExplorerPlugin::updateVariable(const QByteArray &variable) ProjectExpander expander(projectFilePath, projectName, kit, buildConfigurationName); QString result; if (expander.resolveProjectMacro(QString::fromUtf8(variable), &result)) - Core::VariableManager::instance()->insert(variable, result); + Core::VariableManager::insert(variable, result); else - Core::VariableManager::instance()->remove(variable); + Core::VariableManager::remove(variable); } } diff --git a/src/plugins/projectexplorer/projectmacroexpander.cpp b/src/plugins/projectexplorer/projectmacroexpander.cpp index 439792f1030..32730d3a95b 100644 --- a/src/plugins/projectexplorer/projectmacroexpander.cpp +++ b/src/plugins/projectexplorer/projectmacroexpander.cpp @@ -49,10 +49,10 @@ bool ProjectExpander::resolveProjectMacro(const QString &name, QString *ret) result = m_projectName; found = true; } - } else if (Core::VariableManager::instance()->isFileVariable( + } else if (Core::VariableManager::isFileVariable( name.toUtf8(), ProjectExplorer::Constants::VAR_CURRENTPROJECT_PREFIX)) { if (!m_projectFile.filePath().isEmpty()) { - result = Core::VariableManager::instance()->fileVariableValue(name.toUtf8(), + result = Core::VariableManager::fileVariableValue(name.toUtf8(), ProjectExplorer::Constants::VAR_CURRENTPROJECT_PREFIX, m_projectFile); found = true; @@ -79,7 +79,7 @@ bool ProjectExpander::resolveMacro(const QString &name, QString *ret) { bool found = resolveProjectMacro(name, ret); if (!found) { - QString result = Core::VariableManager::instance()->value(name.toUtf8(), &found); + QString result = Core::VariableManager::value(name.toUtf8(), &found); if (ret) *ret = result; } diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp index 793ae378f25..01fff203533 100644 --- a/src/plugins/qtsupport/qtsupportplugin.cpp +++ b/src/plugins/qtsupport/qtsupportplugin.cpp @@ -90,13 +90,12 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes void QtSupportPlugin::extensionsInitialized() { - Core::VariableManager *vm = Core::VariableManager::instance(); - vm->registerVariable(kHostBins, + Core::VariableManager::registerVariable(kHostBins, tr("Full path to the host bin directory of the current project's Qt version.")); - vm->registerVariable(kInstallBins, + Core::VariableManager::registerVariable(kInstallBins, tr("Full path to the target bin directory of the current project's Qt version." " You probably want %1 instead.").arg(QString::fromLatin1(kHostBins))); - connect(vm, SIGNAL(variableUpdateRequested(QByteArray)), + connect(Core::VariableManager::instance(), SIGNAL(variableUpdateRequested(QByteArray)), this, SLOT(updateVariable(QByteArray))); QtVersionManager::instance()->extensionsInitialized(); diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index 00f14d4b135..ab26fca731b 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -231,20 +231,19 @@ void TextEditorPlugin::extensionsInitialized() addAutoReleasedObject(new FindInCurrentFile); addAutoReleasedObject(new FindInOpenFiles); - Core::VariableManager *vm = Core::VariableManager::instance(); - vm->registerVariable(kCurrentDocumentSelection, + Core::VariableManager::registerVariable(kCurrentDocumentSelection, tr("Selected text within the current document.")); - vm->registerVariable(kCurrentDocumentRow, + Core::VariableManager::registerVariable(kCurrentDocumentRow, tr("Line number of the text cursor position in current document (starts with 1).")); - vm->registerVariable(kCurrentDocumentColumn, + Core::VariableManager::registerVariable(kCurrentDocumentColumn, tr("Column number of the text cursor position in current document (starts with 0).")); - vm->registerVariable(kCurrentDocumentRowCount, + Core::VariableManager::registerVariable(kCurrentDocumentRowCount, tr("Number of lines visible in current document.")); - vm->registerVariable(kCurrentDocumentColumnCount, + Core::VariableManager::registerVariable(kCurrentDocumentColumnCount, tr("Number of columns visible in current document.")); - vm->registerVariable(kCurrentDocumentFontSize, + Core::VariableManager::registerVariable(kCurrentDocumentFontSize, tr("Current document's font size in points.")); - connect(vm, SIGNAL(variableUpdateRequested(QByteArray)), + connect(Core::VariableManager::instance(), SIGNAL(variableUpdateRequested(QByteArray)), this, SLOT(updateVariable(QByteArray))); connect(Core::ExternalToolManager::instance(), SIGNAL(replaceSelectionRequested(QString)), this, SLOT(updateCurrentSelection(QString))); @@ -313,7 +312,7 @@ void TextEditorPlugin::updateVariable(const QByteArray &variable) value = QString::number(editor->widget()->font().pointSize()); } } - Core::VariableManager::instance()->insert(variable, value); + Core::VariableManager::insert(variable, value); } }