forked from qt-creator/qt-creator
QtVersion: Allow for variables in Qt version names
* Supported variables are %{Qt:version}, %{Qt:type} and %{Qt:mkspec}
* Qt version display names need no longer be unique. This simplifies
the code a bit and makes the Qt versions behave like the Kits do now.
* The default Qt version name now contains %{Qt:version}. The method
to find the default version name no longer takes a Qt version string.
Change-Id: Ibca1e3daffe5a81f3c158e8bbc1779d033b03872
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -45,19 +45,8 @@ namespace QtSupport {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QtKitInformationMacroExpander : public ProjectExplorer::KitInformationMacroExpander
|
||||
static bool resolveQtMacro(const BaseQtVersion *version, const QString &name, QString *ret)
|
||||
{
|
||||
public:
|
||||
QtKitInformationMacroExpander(const ProjectExplorer::Kit *k) :
|
||||
ProjectExplorer::KitInformationMacroExpander(k)
|
||||
{ }
|
||||
|
||||
bool resolveMacro(const QString &name, QString *ret);
|
||||
};
|
||||
|
||||
bool QtKitInformationMacroExpander::resolveMacro(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";
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user