diff options
-rw-r--r-- | src/plugins/android/androidqtversion.cpp | 2 | ||||
-rw-r--r-- | src/plugins/ios/iosqtversion.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qnx/blackberryapilevelconfiguration.cpp | 3 | ||||
-rw-r--r-- | src/plugins/qnx/qnxqtversion.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qtsupport/baseqtversion.cpp | 36 | ||||
-rw-r--r-- | src/plugins/qtsupport/baseqtversion.h | 22 | ||||
-rw-r--r-- | src/plugins/qtsupport/desktopqtversion.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtkitinformation.cpp | 50 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtkitinformation.h | 2 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtoptionspage.cpp | 59 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtoptionspage.h | 2 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtversionmanager.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qtsupport/simulatorqtversion.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qtsupport/winceqtversion.cpp | 2 | ||||
-rw-r--r-- | src/plugins/remotelinux/embeddedlinuxqtversion.cpp | 2 | ||||
-rw-r--r-- | src/plugins/winrt/winrtqtversion.cpp | 2 |
16 files changed, 102 insertions, 90 deletions
diff --git a/src/plugins/android/androidqtversion.cpp b/src/plugins/android/androidqtversion.cpp index c808ecfb29..9ec40c9b4b 100644 --- a/src/plugins/android/androidqtversion.cpp +++ b/src/plugins/android/androidqtversion.cpp @@ -57,7 +57,7 @@ AndroidQtVersion::AndroidQtVersion() AndroidQtVersion::AndroidQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource) : QtSupport::BaseQtVersion(path, isAutodetected, autodetectionSource) { - setDisplayName(defaultDisplayName(qtVersionString(), path, false)); + setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); } AndroidQtVersion *AndroidQtVersion::clone() const diff --git a/src/plugins/ios/iosqtversion.cpp b/src/plugins/ios/iosqtversion.cpp index 2ff4096f04..3f4e21b083 100644 --- a/src/plugins/ios/iosqtversion.cpp +++ b/src/plugins/ios/iosqtversion.cpp @@ -58,7 +58,7 @@ IosQtVersion::IosQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource) : QtSupport::BaseQtVersion(path, isAutodetected, autodetectionSource) { - setDisplayName(defaultDisplayName(qtVersionString(), path, false)); + setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); } IosQtVersion *IosQtVersion::clone() const diff --git a/src/plugins/qnx/blackberryapilevelconfiguration.cpp b/src/plugins/qnx/blackberryapilevelconfiguration.cpp index 1879d2057e..95d3434531 100644 --- a/src/plugins/qnx/blackberryapilevelconfiguration.cpp +++ b/src/plugins/qnx/blackberryapilevelconfiguration.cpp @@ -220,7 +220,8 @@ QnxAbstractQtVersion *BlackBerryApiLevelConfiguration::createQtVersion( { QnxAbstractQtVersion *version = new BlackBerryQtVersion( arch, qmakePath, true, QString(), envFile().toString()); - version->setDisplayName(tr("Qt %1 for %2").arg(version->qtVersionString(), versionName)); + version->setUnexpandedDisplayName(tr("Qt %{Qt:version} for %2") + .arg(version->qtVersionString(), versionName)); QtVersionManager::addVersion(version); return version; } diff --git a/src/plugins/qnx/qnxqtversion.cpp b/src/plugins/qnx/qnxqtversion.cpp index 9b35062212..82fb1da7f5 100644 --- a/src/plugins/qnx/qnxqtversion.cpp +++ b/src/plugins/qnx/qnxqtversion.cpp @@ -51,7 +51,7 @@ QnxQtVersion::QnxQtVersion() QnxQtVersion::QnxQtVersion(QnxArchitecture arch, const Utils::FileName &path, bool isAutoDetected, const QString &autoDetectionSource) : QnxAbstractQtVersion(arch, path, isAutoDetected, autoDetectionSource) { - setDisplayName(defaultDisplayName(qtVersionString(), path, false)); + setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); } QnxQtVersion *QnxQtVersion::clone() const diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index c570d9c2b1..50eda06c9b 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -42,12 +42,14 @@ #include <projectexplorer/projectexplorer.h> #include <projectexplorer/headerpath.h> #include <qtsupport/debugginghelperbuildtask.h> +#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtsupportconstants.h> #include <utils/algorithm.h> #include <utils/hostosinfo.h> #include <utils/qtcassert.h> #include <utils/runextensions.h> +#include <utils/stringutils.h> #include <utils/synchronousprocess.h> #include <utils/winutils.h> #include <utils/algorithm.h> @@ -189,14 +191,15 @@ void BaseQtVersion::ctor(const FileName &qmakePath) m_hasQtAbis = false; m_qtVersionString.clear(); m_sourcePath.clear(); + m_expander = 0; } BaseQtVersion::~BaseQtVersion() { + delete m_expander; } -QString BaseQtVersion::defaultDisplayName(const QString &versionString, const FileName &qmakePath, - bool fromPath) +QString BaseQtVersion::defaultUnexpandedDisplayName(const FileName &qmakePath, bool fromPath) { QString location; if (qmakePath.isEmpty()) { @@ -222,8 +225,8 @@ QString BaseQtVersion::defaultDisplayName(const QString &versionString, const Fi } return fromPath ? - QCoreApplication::translate("QtVersion", "Qt %1 in PATH (%2)").arg(versionString, location) : - QCoreApplication::translate("QtVersion", "Qt %1 (%2)").arg(versionString, location); + QCoreApplication::translate("QtVersion", "Qt %{Qt:version} in PATH (%2)").arg(location) : + QCoreApplication::translate("QtVersion", "Qt %{Qt:version} (%2)").arg(location); } FeatureSet BaseQtVersion::availableFeatures() const @@ -409,7 +412,7 @@ void BaseQtVersion::fromMap(const QVariantMap &map) m_id = map.value(QLatin1String(Constants::QTVERSIONID)).toInt(); if (m_id == -1) // this happens on adding from installer, see updateFromInstaller => get a new unique id m_id = QtVersionManager::getUniqueId(); - m_displayName = map.value(QLatin1String(Constants::QTVERSIONNAME)).toString(); + m_unexpandedDisplayName = map.value(QLatin1String(Constants::QTVERSIONNAME)).toString(); m_isAutodetected = map.value(QLatin1String(QTVERSIONAUTODETECTED)).toBool(); if (m_isAutodetected) m_autodetectionSource = map.value(QLatin1String(QTVERSIONAUTODETECTIONSOURCE)).toString(); @@ -534,12 +537,17 @@ void BaseQtVersion::setAutoDetectionSource(const QString &autodetectionSource) QString BaseQtVersion::displayName() const { - return m_displayName; + return Utils::expandMacros(unexpandedDisplayName(), macroExpander()); } -void BaseQtVersion::setDisplayName(const QString &name) +QString BaseQtVersion::unexpandedDisplayName() const { - m_displayName = name; + return m_unexpandedDisplayName; +} + +void BaseQtVersion::setUnexpandedDisplayName(const QString &name) +{ + m_unexpandedDisplayName = name; } QString BaseQtVersion::toHtml(bool verbose) const @@ -837,6 +845,11 @@ void BaseQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const m_mkspecValues.insert(ns, evaluator->value(ns)); } +AbstractMacroExpander *BaseQtVersion::createMacroExpander() const +{ + return QtKitInformation::createMacroExpander(this); +} + FileName BaseQtVersion::mkspec() const { updateMkspec(); @@ -1046,6 +1059,13 @@ QStringList BaseQtVersion::qtConfigValues() const return m_qtConfigValues; } +AbstractMacroExpander *BaseQtVersion::macroExpander() const +{ + if (!m_expander) + m_expander = createMacroExpander(); + return m_expander; +} + QList<HeaderPath> BaseQtVersion::systemHeaderPathes(const Kit *k) const { Q_UNUSED(k); diff --git a/src/plugins/qtsupport/baseqtversion.h b/src/plugins/qtsupport/baseqtversion.h index ec91d6ea58..f7448770c8 100644 --- a/src/plugins/qtsupport/baseqtversion.h +++ b/src/plugins/qtsupport/baseqtversion.h @@ -39,7 +39,10 @@ #include <QStringList> #include <QVariantMap> -namespace Utils { class Environment; } +namespace Utils { +class Environment; +class AbstractMacroExpander; +} // namespace Utils namespace Core { class FeatureSet; } @@ -96,7 +99,8 @@ public: QString autodetectionSource() const; QString displayName() const; - void setDisplayName(const QString &name); + QString unexpandedDisplayName() const; + void setUnexpandedDisplayName(const QString &name); // All valid Ids are >= 0 int uniqueId() const; @@ -194,8 +198,7 @@ public: virtual QtConfigWidget *createConfigurationWidget() const; - static QString defaultDisplayName(const QString &versionString, - const Utils::FileName &qmakePath, + static QString defaultUnexpandedDisplayName(const Utils::FileName &qmakePath, bool fromPath = false); virtual Core::FeatureSet availableFeatures() const; @@ -222,6 +225,8 @@ public: QStringList configValues() const; QStringList qtConfigValues() const; + Utils::AbstractMacroExpander *macroExpander() const; // owned by the Qt version + protected: BaseQtVersion(); BaseQtVersion(const Utils::FileName &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); @@ -238,6 +243,11 @@ protected: void ensureMkSpecParsed() const; virtual void parseMkSpec(ProFileEvaluator *) const; + + // Create the macro expander. This pointer will be cached by the Qt version (which will take + // ownership). + virtual Utils::AbstractMacroExpander *createMacroExpander() const; + private: void setAutoDetectionSource(const QString &autodetectionSource); static int getUniqueId(); @@ -270,7 +280,7 @@ private: mutable QStringList m_configValues; mutable QStringList m_qtConfigValues; - QString m_displayName; + QString m_unexpandedDisplayName; QString m_autodetectionSource; mutable Utils::FileName m_sourcePath; @@ -290,6 +300,8 @@ private: mutable QString m_qmlviewerCommand; mutable QList<ProjectExplorer::Abi> m_qtAbis; + + mutable Utils::AbstractMacroExpander *m_expander; }; } diff --git a/src/plugins/qtsupport/desktopqtversion.cpp b/src/plugins/qtsupport/desktopqtversion.cpp index 17dd565b98..ff20684c04 100644 --- a/src/plugins/qtsupport/desktopqtversion.cpp +++ b/src/plugins/qtsupport/desktopqtversion.cpp @@ -46,7 +46,7 @@ DesktopQtVersion::DesktopQtVersion() DesktopQtVersion::DesktopQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource) : BaseQtVersion(path, isAutodetected, autodetectionSource) { - setDisplayName(defaultDisplayName(qtVersionString(), path, false)); + setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); } DesktopQtVersion::~DesktopQtVersion() diff --git a/src/plugins/qtsupport/qtkitinformation.cpp b/src/plugins/qtsupport/qtkitinformation.cpp index e86c8674ce..c4bd44d0b8 100644 --- a/src/plugins/qtsupport/qtkitinformation.cpp +++ b/src/plugins/qtsupport/qtkitinformation.cpp @@ -45,19 +45,8 @@ namespace QtSupport { namespace Internal { -class QtKitInformationMacroExpander : public ProjectExplorer::KitInformationMacroExpander -{ -public: - QtKitInformationMacroExpander(const ProjectExplorer::Kit *k) : - ProjectExplorer::KitInformationMacroExpander(k) - { } - - bool resolveMacro(const QString &name, QString *ret); -}; - -bool QtKitInformationMacroExpander::resolveMacro(const QString &name, QString *ret) +static bool resolveQtMacro(const BaseQtVersion *version, const QString &name, QString *ret) { - BaseQtVersion *version = QtKitInformation::qtVersion(kit()); const QString noInfo = QCoreApplication::translate("QtSupport::QtKitInformation", "none"); if (name == QLatin1String("Qt:version")) { @@ -76,6 +65,38 @@ bool QtKitInformationMacroExpander::resolveMacro(const QString &name, QString *r return false; } +class QtVersionMacroExpander : public Utils::AbstractMacroExpander +{ +public: + QtVersionMacroExpander(const BaseQtVersion *v) : + qtVersion(v) + { } + + bool resolveMacro(const QString &name, QString *ret) + { + if (name == QLatin1String("Qt:name")) + return false; + return resolveQtMacro(qtVersion, name, ret); + } + +private: + const BaseQtVersion *qtVersion; +}; + + +class QtKitInformationMacroExpander : public ProjectExplorer::KitInformationMacroExpander +{ +public: + QtKitInformationMacroExpander(const ProjectExplorer::Kit *k) : + ProjectExplorer::KitInformationMacroExpander(k) + { } + + bool resolveMacro(const QString &name, QString *ret) + { + return resolveQtMacro(QtKitInformation::qtVersion(kit()), name, ret); + } +}; + } // namespace Internal QtKitInformation::QtKitInformation() @@ -169,6 +190,11 @@ Utils::AbstractMacroExpander *QtKitInformation::createMacroExpander(const Projec return new Internal::QtKitInformationMacroExpander(k); } +Utils::AbstractMacroExpander *QtKitInformation::createMacroExpander(const BaseQtVersion *v) +{ + return new Internal::QtVersionMacroExpander(v); +} + Core::Id QtKitInformation::id() { return "QtSupport.QtInformation"; diff --git a/src/plugins/qtsupport/qtkitinformation.h b/src/plugins/qtsupport/qtkitinformation.h index 1598660e70..c1e6e4136e 100644 --- a/src/plugins/qtsupport/qtkitinformation.h +++ b/src/plugins/qtsupport/qtkitinformation.h @@ -62,6 +62,8 @@ public: Utils::AbstractMacroExpander *createMacroExpander(const ProjectExplorer::Kit *k) const; + static Utils::AbstractMacroExpander *createMacroExpander(const BaseQtVersion *v); + static Core::Id id(); static int qtVersionId(const ProjectExplorer::Kit *k); static void setQtVersionId(ProjectExplorer::Kit *k, const int id); diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index 50587914c2..54da126db4 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -88,8 +88,6 @@ void QtOptionsPage::apply() { if (!m_widget) // page was never shown return; - m_widget->finish(); - m_widget->apply(); } @@ -683,8 +681,8 @@ void QtOptionsPageWidget::editPath() } // same type, replace version->setId(current->uniqueId()); - if (current->displayName() != current->defaultDisplayName(current->qtVersionString(), current->qmakeCommand())) - version->setDisplayName(current->displayName()); + if (current->unexpandedDisplayName() != current->defaultUnexpandedDisplayName(current->qmakeCommand())) + version->setUnexpandedDisplayName(current->displayName()); m_versions.replace(m_versions.indexOf(current), version); delete current; @@ -872,9 +870,8 @@ QTreeWidgetItem *QtOptionsPageWidget::treeItemForIndex(int index) const void QtOptionsPageWidget::versionChanged(QTreeWidgetItem *newItem, QTreeWidgetItem *old) { - Q_UNUSED(newItem) - if (old) - fixQtVersionName(indexForTreeItem(old)); + Q_UNUSED(newItem); + Q_UNUSED(old); userChangedCurrentVersion(); } @@ -884,7 +881,7 @@ void QtOptionsPageWidget::updateWidgets() m_configurationWidget = 0; BaseQtVersion *version = currentVersion(); if (version) { - m_versionUi->nameEdit->setText(version->displayName()); + m_versionUi->nameEdit->setText(version->unexpandedDisplayName()); m_versionUi->qmakePath->setText(version->qmakeCommand().toUserOutput()); m_configurationWidget = version->createConfigurationWidget(); if (m_configurationWidget) { @@ -912,18 +909,11 @@ void QtOptionsPageWidget::updateCurrentQtName() int currentItemIndex = indexForTreeItem(currentItem); if (currentItemIndex < 0) return; - m_versions[currentItemIndex]->setDisplayName(m_versionUi->nameEdit->text()); + m_versions[currentItemIndex]->setUnexpandedDisplayName(m_versionUi->nameEdit->text()); currentItem->setText(0, m_versions[currentItemIndex]->displayName()); updateDescriptionLabel(); } - -void QtOptionsPageWidget::finish() -{ - if (QTreeWidgetItem *item = m_ui->qtdirList->currentItem()) - fixQtVersionName(indexForTreeItem(item)); -} - void QtOptionsPageWidget::apply() { disconnect(QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)), @@ -935,43 +925,6 @@ void QtOptionsPageWidget::apply() this, SLOT(updateQtVersions(QList<int>,QList<int>,QList<int>))); } -/* Checks that the Qt version name is unique - * and otherwise changes the name - * - */ -void QtOptionsPageWidget::fixQtVersionName(int index) -{ - if (index < 0) - return; - int count = m_versions.count(); - QString name = m_versions.at(index)->displayName(); - if (name.isEmpty()) - return; - for (int i = 0; i < count; ++i) { - if (i != index) { - if (m_versions.at(i)->displayName() == m_versions.at(index)->displayName()) { - // Same name, find new name - QRegExp regexp(QLatin1String("^(.*)\\((\\d)\\)$")); - if (regexp.exactMatch(name)) { - // Already in Name (#) format - name = regexp.cap(1); - name += QLatin1Char('('); - name += QString::number(regexp.cap(2).toInt() + 1); - name += QLatin1Char(')'); - } else { - name += QLatin1String(" (2)"); - } - // set new name - m_versions[index]->setDisplayName(name); - treeItemForIndex(index)->setText(0, name); - - // Now check again... - fixQtVersionName(index); - } - } - } -} - QList<BaseQtVersion *> QtOptionsPageWidget::versions() const { QList<BaseQtVersion *> result; diff --git a/src/plugins/qtsupport/qtoptionspage.h b/src/plugins/qtsupport/qtoptionspage.h index 2e762da58d..0b1a0bf8d4 100644 --- a/src/plugins/qtsupport/qtoptionspage.h +++ b/src/plugins/qtsupport/qtoptionspage.h @@ -65,7 +65,6 @@ public: QtOptionsPageWidget(QWidget *parent = 0); ~QtOptionsPageWidget(); QList<BaseQtVersion *> versions() const; - void finish(); void apply(); private: @@ -73,7 +72,6 @@ private: void userChangedCurrentVersion(); void updateWidgets(); void updateDebuggingHelperUi(); - void fixQtVersionName(int index); int indexForTreeItem(const QTreeWidgetItem *item) const; QTreeWidgetItem *treeItemForIndex(int index) const; BaseQtVersion *currentVersion() const; diff --git a/src/plugins/qtsupport/qtversionmanager.cpp b/src/plugins/qtsupport/qtversionmanager.cpp index 8d79fa5a8f..a257cffa1f 100644 --- a/src/plugins/qtsupport/qtversionmanager.cpp +++ b/src/plugins/qtsupport/qtversionmanager.cpp @@ -441,7 +441,7 @@ static void findSystemQt() BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(systemQMakePath); if (version) { - version->setDisplayName(BaseQtVersion::defaultDisplayName(version->qtVersionString(), systemQMakePath, true)); + version->setUnexpandedDisplayName(BaseQtVersion::defaultUnexpandedDisplayName(systemQMakePath, true)); m_versions.insert(version->uniqueId(), version); } } diff --git a/src/plugins/qtsupport/simulatorqtversion.cpp b/src/plugins/qtsupport/simulatorqtversion.cpp index c28082c675..b9759e788a 100644 --- a/src/plugins/qtsupport/simulatorqtversion.cpp +++ b/src/plugins/qtsupport/simulatorqtversion.cpp @@ -46,7 +46,7 @@ SimulatorQtVersion::SimulatorQtVersion() SimulatorQtVersion::SimulatorQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource) : BaseQtVersion(path, isAutodetected, autodetectionSource) { - setDisplayName(defaultDisplayName(qtVersionString(), path, false)); + setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); } SimulatorQtVersion::~SimulatorQtVersion() diff --git a/src/plugins/qtsupport/winceqtversion.cpp b/src/plugins/qtsupport/winceqtversion.cpp index 760f8ec2e5..d374a81250 100644 --- a/src/plugins/qtsupport/winceqtversion.cpp +++ b/src/plugins/qtsupport/winceqtversion.cpp @@ -51,7 +51,7 @@ WinCeQtVersion::WinCeQtVersion(const Utils::FileName &path, const QString &archT m_archType = ProjectExplorer::Abi::X86Architecture; else if (0 == archType.compare(QLatin1String("mipsii"), Qt::CaseInsensitive)) m_archType = ProjectExplorer::Abi::MipsArchitecture; - setDisplayName(defaultDisplayName(qtVersionString(), path, false)); + setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); } WinCeQtVersion::~WinCeQtVersion() diff --git a/src/plugins/remotelinux/embeddedlinuxqtversion.cpp b/src/plugins/remotelinux/embeddedlinuxqtversion.cpp index ae4bc9788f..18ddd8133b 100644 --- a/src/plugins/remotelinux/embeddedlinuxqtversion.cpp +++ b/src/plugins/remotelinux/embeddedlinuxqtversion.cpp @@ -45,7 +45,7 @@ EmbeddedLinuxQtVersion::EmbeddedLinuxQtVersion() EmbeddedLinuxQtVersion::EmbeddedLinuxQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource) : BaseQtVersion(path, isAutodetected, autodetectionSource) { - setDisplayName(defaultDisplayName(qtVersionString(), path, false)); + setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); } EmbeddedLinuxQtVersion::~EmbeddedLinuxQtVersion() diff --git a/src/plugins/winrt/winrtqtversion.cpp b/src/plugins/winrt/winrtqtversion.cpp index 51b51407c1..5374db0464 100644 --- a/src/plugins/winrt/winrtqtversion.cpp +++ b/src/plugins/winrt/winrtqtversion.cpp @@ -45,7 +45,7 @@ WinRtQtVersion::WinRtQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource) : BaseQtVersion(path, isAutodetected, autodetectionSource) { - setDisplayName(defaultDisplayName(qtVersionString(), path, false)); + setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); } QtSupport::BaseQtVersion *WinRtQtVersion::clone() const |