Commit 4a52d821 authored by Tobias Hunger's avatar Tobias Hunger Committed by hjk

Kit: Introduce variables for Kit display names

This change also adds a AbstractMacroExpander for the QtKitInformation.

It supports the following variables in the Kit display name:

 %{Qt:version} - Qt version number
 %{Qt:type}    - Qt type
 %{Qt:name}    - Qt version name
 %{Qt:mkspec}  - mkspec used by the Qt version

Task-number: QTCREATORBUG-11118
Change-Id: I7263781336ab561c34880b187ebd55e81e6ca215
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 351abd03
......@@ -1147,7 +1147,7 @@ void AndroidConfigurations::updateAutomaticKitList()
foreach (Kit *kit, newKits) {
AndroidToolChain *tc = static_cast<AndroidToolChain *>(ToolChainKitInformation::toolChain(kit));
AndroidQtVersion *qt = static_cast<AndroidQtVersion *>(QtSupport::QtKitInformation::qtVersion(kit));
kit->setDisplayName(tr("Android for %1 (GCC %2, Qt %3)")
kit->setUnexpandedDisplayName(tr("Android for %1 (GCC %2, Qt %3)")
.arg(qt->targetArch())
.arg(tc->ndkToolChainVersion())
.arg(qt->qtVersionString()));
......
......@@ -308,7 +308,7 @@ void IosConfigurations::updateAutomaticKitList()
if (unique) break;
displayName = baseDisplayName + QLatin1String("-") + QString::number(iVers);
}
kitAtt->setDisplayName(displayName);
kitAtt->setUnexpandedDisplayName(displayName);
}
kitAtt->setIconPath(Utils::FileName::fromString(
QLatin1String(Constants::IOS_SETTINGS_CATEGORY_ICON)));
......
......@@ -35,6 +35,8 @@
#include <utils/algorithm.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <QApplication>
#include <QFileInfo>
......@@ -62,6 +64,33 @@ const char STICKY_INFO_KEY[] = "PE.Profile.StickyInfo";
namespace ProjectExplorer {
// --------------------------------------------------------------------
// KitMacroExpander:
// --------------------------------------------------------------------
class KitMacroExpander : public Utils::AbstractMacroExpander
{
public:
KitMacroExpander(const QList<Utils::AbstractMacroExpander *> &children) :
m_childExpanders(children)
{ }
~KitMacroExpander() { qDeleteAll(m_childExpanders); }
bool resolveMacro(const QString &name, QString *ret);
private:
QList<Utils::AbstractMacroExpander *> m_childExpanders;
};
bool KitMacroExpander::resolveMacro(const QString &name, QString *ret)
{
foreach (Utils::AbstractMacroExpander *expander, m_childExpanders) {
if (expander->resolveMacro(name, ret))
return true;
}
return false;
}
// -------------------------------------------------------------------------
// KitPrivate
// -------------------------------------------------------------------------
......@@ -71,7 +100,7 @@ namespace Internal {
class KitPrivate
{
public:
KitPrivate(Id id) :
KitPrivate(Id id, Kit *k) :
m_id(id),
m_nestedBlockingLevel(0),
m_autodetected(false),
......@@ -81,16 +110,37 @@ public:
m_hasWarning(false),
m_hasValidityInfo(false),
m_mustNotify(false),
m_mustNotifyAboutDisplayName(false)
m_mustNotifyAboutDisplayName(false),
m_macroExpander(0)
{
if (!id.isValid())
m_id = Id::fromString(QUuid::createUuid().toString());
m_displayName = QCoreApplication::translate("ProjectExplorer::Kit", "Unnamed");
m_previousDisplayName = m_displayName;
m_iconPath = Utils::FileName::fromLatin1(":///DESKTOP///");
QList<Utils::AbstractMacroExpander *> expanders;
foreach (const KitInformation *ki, KitManager::kitInformation()) {
Utils::AbstractMacroExpander *tmp = ki->createMacroExpander(k);
if (tmp)
expanders.append(tmp);
}
m_macroExpander = new KitMacroExpander(expanders);
}
~KitPrivate()
{ delete m_macroExpander; }
void updatePreviousDisplayName()
{
QTC_ASSERT(m_macroExpander, return);
m_previousDisplayName = Utils::expandMacros(m_displayName, m_macroExpander);
}
QString m_displayName;
QString m_previousDisplayName;
QString m_fileSystemFriendlyName;
Id m_id;
int m_nestedBlockingLevel;
......@@ -108,6 +158,7 @@ public:
QHash<Core::Id, QVariant> m_data;
QSet<Core::Id> m_sticky;
QSet<Core::Id> m_mutable;
Utils::AbstractMacroExpander *m_macroExpander;
};
} // namespace Internal
......@@ -117,16 +168,17 @@ public:
// -------------------------------------------------------------------------
Kit::Kit(Core::Id id) :
d(new Internal::KitPrivate(id))
d(new Internal::KitPrivate(id, this))
{
foreach (KitInformation *sti, KitManager::kitInformation())
d->m_data.insert(sti->id(), sti->defaultValue(this));
d->m_icon = icon(d->m_iconPath);
d->updatePreviousDisplayName();
}
Kit::Kit(const QVariantMap &data) :
d(new Internal::KitPrivate(Core::Id()))
d(new Internal::KitPrivate(Core::Id(), this))
{
d->m_id = Id::fromSetting(data.value(QLatin1String(ID_KEY)));
......@@ -160,6 +212,8 @@ Kit::Kit(const QVariantMap &data) :
QStringList stickyInfoList = data.value(QLatin1String(STICKY_INFO_KEY)).toStringList();
foreach (const QString &stickyInfo, stickyInfoList)
d->m_sticky.insert(Core::Id::fromString(stickyInfo));
d->updatePreviousDisplayName();
}
Kit::~Kit()
......@@ -201,6 +255,7 @@ Kit *Kit::clone(bool keepName) const
k->d->m_iconPath = d->m_iconPath;
k->d->m_sticky = d->m_sticky;
k->d->m_mutable = d->m_mutable;
k->d->updatePreviousDisplayName();
return k;
}
......@@ -215,9 +270,10 @@ void Kit::copyFrom(const Kit *k)
d->m_displayName = k->d->m_displayName;
d->m_fileSystemFriendlyName = k->d->m_fileSystemFriendlyName;
d->m_mustNotify = true;
d->m_mustNotifyAboutDisplayName = true;
d->m_mustNotifyAboutDisplayName = false;
d->m_sticky = k->d->m_sticky;
d->m_mutable = k->d->m_mutable;
d->updatePreviousDisplayName();
}
bool Kit::isValid() const
......@@ -277,11 +333,16 @@ void Kit::setup()
info.at(i)->setup(this);
}
QString Kit::displayName() const
QString Kit::unexpandedDisplayName() const
{
return d->m_displayName;
}
QString Kit::displayName() const
{
return Utils::expandMacros(unexpandedDisplayName(), macroExpander());
}
static QString candidateName(const QString &name, const QString &postfix)
{
if (name.contains(postfix))
......@@ -293,11 +354,13 @@ static QString candidateName(const QString &name, const QString &postfix)
return candidate;
}
void Kit::setDisplayName(const QString &name)
void Kit::setUnexpandedDisplayName(const QString &name)
{
if (d->m_displayName == name)
return;
d->m_displayName = name;
d->updatePreviousDisplayName();
kitDisplayNameChanged();
}
......@@ -310,7 +373,7 @@ QStringList Kit::candidateNameList(const QString &base) const
if (!postfix.isEmpty()) {
QString tmp = candidateName(base, postfix);
if (!tmp.isEmpty())
result << candidateName(base, postfix);
result << tmp;
}
}
return result;
......@@ -621,14 +684,26 @@ bool Kit::hasFeatures(const FeatureSet &features) const
return availableFeatures().contains(features);
}
Utils::AbstractMacroExpander *Kit::macroExpander() const
{
QTC_CHECK(d->m_macroExpander);
return d->m_macroExpander;
}
void Kit::kitUpdated()
{
if (d->m_nestedBlockingLevel > 0 && !d->m_mustNotifyAboutDisplayName) {
if (d->m_nestedBlockingLevel > 0) {
if (!d->m_mustNotifyAboutDisplayName)
d->m_mustNotify = true;
return;
}
d->m_hasValidityInfo = false;
if (displayName() != d->m_previousDisplayName) {
d->updatePreviousDisplayName();
KitManager::notifyAboutDisplayNameChange(this);
} else {
KitManager::notifyAboutUpdate(this);
}
}
void Kit::kitDisplayNameChanged()
......
......@@ -38,7 +38,10 @@
#include <QSet>
#include <QVariant>
namespace Utils { class Environment; }
namespace Utils {
class AbstractMacroExpander;
class Environment;
} // namespace Utils
namespace ProjectExplorer {
class IOutputParser;
......@@ -71,8 +74,9 @@ public:
// Fix will not look at other information in the kit!
void setup(); // Apply advanced magic(TM). Used only once on each kit during initial setup.
QString unexpandedDisplayName() const;
QString displayName() const;
void setDisplayName(const QString &name);
void setUnexpandedDisplayName(const QString &name);
QStringList candidateNameList(const QString &base) const;
......@@ -122,6 +126,8 @@ public:
Core::FeatureSet availableFeatures() const;
bool hasFeatures(const Core::FeatureSet &features) const;
Utils::AbstractMacroExpander *macroExpander() const;
private:
void setSdkProvided(bool sdkProvided);
......
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "kitinformationmacroexpander.h"
#include <utils/qtcassert.h>
namespace ProjectExplorer {
KitInformationMacroExpander::KitInformationMacroExpander(const Kit *k) :
m_kit(k)
{
QTC_CHECK(k);
}
const Kit *KitInformationMacroExpander::kit() const
{
return m_kit;
}
// --------------------------------------------------------------------------
// KitInformationMacroExpander:
// --------------------------------------------------------------------------
} // namespace ProjectExplorer
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef KITINFORMATIONMACROEXPANDER_H
#define KITINFORMATIONMACROEXPANDER_H
#include "projectexplorer_export.h"
#include <utils/stringutils.h>
namespace ProjectExplorer {
class Kit;
// --------------------------------------------------------------------------
// KitInformationMacroExpander:
// --------------------------------------------------------------------------
class PROJECTEXPLORER_EXPORT KitInformationMacroExpander : public Utils::AbstractMacroExpander
{
public:
KitInformationMacroExpander(const Kit *k);
const Kit *kit() const;
private:
const Kit *m_kit;
};
} // namespace ProjectExplorer
#endif // KITINFORMATIONMACROEXPANDER_H
......@@ -41,6 +41,7 @@
#include <utils/persistentsettings.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <utils/environment.h>
#include <utils/algorithm.h>
......@@ -243,7 +244,7 @@ void KitManager::restoreKits()
if (kits().isEmpty()) {
Kit *defaultKit = new Kit; // One kit using default values
defaultKit->setDisplayName(tr("Desktop"));
defaultKit->setUnexpandedDisplayName(tr("Desktop"));
defaultKit->setSdkProvided(false);
defaultKit->setAutoDetected(false);
defaultKit->setIconPath(Utils::FileName::fromLatin1(":///DESKTOP///"));
......@@ -476,7 +477,7 @@ void KitManager::deleteKit(Kit *k)
delete k;
}
QString KitManager::uniqueKitName(const Kit *k, const QString &name, const QList<Kit *> &allKits)
QString KitManager::uniqueKitName(const Kit *k, const QList<Kit *> &allKits)
{
QStringList nameList;
nameList << QString(); // Disallow empty kit names!
......@@ -486,20 +487,21 @@ QString KitManager::uniqueKitName(const Kit *k, const QString &name, const QList
nameList.append(tmp->candidateNameList(tmp->displayName()));
}
QStringList candidateNames = k->candidateNameList(name);
const QString dn = k->displayName();
const QString udn = k->unexpandedDisplayName();
QString uniqueName = Project::makeUnique(name, nameList);
if (uniqueName != name) {
QString uniqueName = Project::makeUnique(dn, nameList);
if (uniqueName == dn)
return udn;
QStringList candidateNames = k->candidateNameList(udn);
foreach (const QString &candidate, candidateNames) {
const QString tmp = Project::makeUnique(candidate, nameList);
if (tmp == candidate) {
uniqueName = tmp;
break;
}
}
QString expandedCandidate = Utils::expandMacros(candidate, k->macroExpander());
if (!nameList.contains(expandedCandidate))
return candidate;
}
return uniqueName;
return udn + uniqueName.mid(dn.count());
}
void KitManager::notifyAboutDisplayNameChange(Kit *k)
......@@ -507,7 +509,7 @@ void KitManager::notifyAboutDisplayNameChange(Kit *k)
if (!k)
return;
if (d->m_kitList.contains(k) && d->m_keepDisplayNameUnique)
k->setDisplayName(uniqueKitName(k, k->displayName(), kits()));
k->setUnexpandedDisplayName(uniqueKitName(k, kits()));
int pos = d->m_kitList.indexOf(k);
if (pos >= 0 && d->m_initialized)
d->moveKit(pos);
......@@ -537,7 +539,7 @@ bool KitManager::registerKit(ProjectExplorer::Kit *k)
if (kits().contains(k))
return false;
k->setDisplayName(uniqueKitName(k, k->displayName(), kits()));
k->setUnexpandedDisplayName(uniqueKitName(k, kits()));
// make sure we have all the information in our kits:
m_instance->addKit(k);
......
......@@ -41,6 +41,7 @@
#include <functional>
namespace Utils {
class AbstractMacroExpander;
class FileName;
class Environment;
}
......@@ -97,6 +98,9 @@ public:
virtual QString displayNameForPlatform(const ProjectExplorer::Kit *k, const QString &platform) const;
virtual Core::FeatureSet availableFeatures(const Kit *k) const;
virtual Utils::AbstractMacroExpander *createMacroExpander(const Kit *k) const
{ Q_UNUSED(k); return 0; }
protected:
void setId(Core::Id id) { m_id = id; }
void setPriority(int priority) { m_priority = priority; }
......@@ -140,7 +144,7 @@ public:
static void deleteKit(Kit *k);
static QString uniqueKitName(const Kit *k, const QString &name, const QList<Kit *> &allKits);
static QString uniqueKitName(const Kit *k, const QList<Kit *> &allKits);
static bool registerKit(ProjectExplorer::Kit *k);
static void deregisterKit(ProjectExplorer::Kit *k);
......
......@@ -35,6 +35,7 @@
#include <utils/detailswidget.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <QAction>
#include <QRegExp>
......@@ -129,7 +130,7 @@ KitManagerConfigWidget::~KitManagerConfigWidget()
QString KitManagerConfigWidget::displayName() const
{
return m_nameEdit->text();
return m_modifiedKit->displayName();
}
void KitManagerConfigWidget::apply()
......@@ -162,7 +163,7 @@ void KitManagerConfigWidget::discard()
m_isDefaultKit = false;
}
m_iconButton->setIcon(m_modifiedKit->icon());
m_nameEdit->setText(m_modifiedKit->displayName());
m_nameEdit->setText(m_modifiedKit->unexpandedDisplayName());
m_fileSystemFriendlyNameLineEdit->setText(m_modifiedKit->customFileSystemFriendlyName());
emit dirty();
}
......@@ -292,7 +293,7 @@ void KitManagerConfigWidget::setIcon()
void KitManagerConfigWidget::setDisplayName()
{
int pos = m_nameEdit->cursorPosition();
m_modifiedKit->setDisplayName(m_nameEdit->text());
m_modifiedKit->setUnexpandedDisplayName(m_nameEdit->text());
m_nameEdit->setCursorPosition(pos);
}
......@@ -314,7 +315,10 @@ void KitManagerConfigWidget::workingCopyWasUpdated(Kit *k)
foreach (KitConfigWidget *w, m_widgets)
w->refresh();
m_nameEdit->setText(k->displayName());
if (k->unexpandedDisplayName() != m_nameEdit->text())
m_nameEdit->setText(k->unexpandedDisplayName());
m_fileSystemFriendlyNameLineEdit->setText(k->customFileSystemFriendlyName());
m_iconButton->setIcon(k->icon());
updateVisibility();
......
......@@ -339,7 +339,7 @@ Kit *KitModel::markForAddition(Kit *baseKit)
k->copyFrom(baseKit);
k->setAutoDetected(false); // Make sure we have a manual kit!
k->setSdkProvided(false);
k->setDisplayName(tr("Clone of %1").arg(k->displayName()));
k->setUnexpandedDisplayName(tr("Clone of %1").arg(k->unexpandedDisplayName()));
} else {
k->setup();
}
......@@ -352,10 +352,10 @@ Kit *KitModel::markForAddition(Kit *baseKit)
return k;
}
QString KitModel::findNameFor(Kit *k, const QString &baseName)
QString KitModel::findNameFor(Kit *k)
{
QList<Kit *> kits = kitList(m_root);
return KitManager::uniqueKitName(k, baseName, kits);
return KitManager::uniqueKitName(k, kits);
}
QModelIndex KitModel::index(KitNode *node, int column) const
......@@ -470,7 +470,7 @@ void KitModel::removeKit(Kit *k)
void KitModel::updateKit(Kit *k)
{
if (m_keepUnique)
k->setDisplayName(findNameFor(k, k->displayName()));
k->setUnexpandedDisplayName(findNameFor(k));
}
void KitModel::changeDefaultKit()
......
......@@ -86,7 +86,7 @@ public:
void markForRemoval(Kit *k);
Kit *markForAddition(Kit *baseKit);
QString findNameFor(Kit *k, const QString &baseName);
QString findNameFor(Kit *k);
signals:
void kitStateChanged();
......
......@@ -29,6 +29,7 @@ HEADERS += projectexplorer.h \
kitinformation.h \
kitinformationconfigwidget.h \
kitfeatureprovider.h \
kitinformationmacroexpander.h \
kitmanager.h \
kitmanagerconfigwidget.h \
kitmodel.h \
......@@ -176,6 +177,7 @@ SOURCES += projectexplorer.cpp \
kitconfigwidget.cpp \
kitinformation.cpp \
kitinformationconfigwidget.cpp \
kitinformationmacroexpander.cpp \
kitmanager.cpp \
kitmanagerconfigwidget.cpp \
kitmodel.cpp \
......
......@@ -92,6 +92,7 @@ QtcPlugin {
"kitfeatureprovider.h",
"kitinformation.cpp", "kitinformation.h",
"kitinformationconfigwidget.cpp", "kitinformationconfigwidget.h",
"kitinformationmacroexpander.cpp", "kitinformationmacroexpander.h",
"kitmanager.cpp", "kitmanager.h",
"kitmanagerconfigwidget.cpp", "kitmanagerconfigwidget.h",
"kitmodel.cpp", "kitmodel.h",
......
......@@ -60,7 +60,7 @@ void ProjectImporter::markTemporary(Kit *k)
setIsUpdating(true);
const QString name = k->displayName();
k->setDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectImporter",
k->setUnexpandedDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectImporter",
"%1 - temporary").arg(name));
k->setValue(KIT_TEMPORARY_NAME, k->displayName());
......@@ -81,7 +81,7 @@ void ProjectImporter::makePermanent(Kit *k)
k->removeKey(TEMPORARY_OF_PROJECTS);
const QString tempName = k->value(KIT_TEMPORARY_NAME).toString();
if (!tempName.isNull() && k->displayName() == tempName)
k->setDisplayName(k->value(KIT_FINAL_NAME).toString());
k->setUnexpandedDisplayName(k->value(KIT_FINAL_NAME).toString());
k->removeKey(KIT_TEMPORARY_NAME);
k->removeKey(KIT_FINAL_NAME);
......
......@@ -2127,7 +2127,7 @@ QVariantMap UserFileVersion11Upgrader::upgrade(const QVariantMap &map)
tmpKit->setValue("PE.Profile.Device", devId);
// Set display name last:
tmpKit->setDisplayName(extraTargetData.value(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName")).toString());
tmpKit->setUnexpandedDisplayName(extraTargetData.value(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName")).toString());
Kit *k = uniqueKit(tmpKit);
......
......@@ -278,7 +278,7 @@ ProjectExplorer::Kit *QmakeProjectImporter::createTemporaryKit(QtSupport::BaseQt
ki->setup(k);
}
k->setDisplayName(version->displayName());
k->setUnexpandedDisplayName(version->displayName());
setIsUpdating(true);
ProjectExplorer::KitManager::registerKit(k);
......
......@@ -250,7 +250,7 @@ Kit *BlackBerryApiLevelConfiguration::createKit(
DeviceTypeKitInformation::setDeviceTypeId(kit, Constants::QNX_BB_OS_TYPE);
SysRootKitInformation::setSysRoot(kit, m_sysRoot);
kit->setDisplayName(version->displayName());
kit->setUnexpandedDisplayName(version->displayName());
kit->setIconPath(FileName::fromString(QLatin1String(Constants::QNX_BB_CATEGORY_ICON)));
kit->setAutoDetected(true);
......
......@@ -228,7 +228,7 @@ ProjectExplorer::Kit *QnxConfiguration::createKit(QnxArchitecture arch,
DeviceTypeKitInformation::setDeviceTypeId(kit, Constants::QNX_QNX_OS_TYPE);
// TODO: Add sysroot?
kit->setDisplayName(displayName);
kit->setUnexpandedDisplayName(displayName);
kit->setIconPath(FileName::fromString(QLatin1String(Constants::QNX_CATEGORY_ICON)));
kit->setAutoDetected(true);
......
......@@ -34,6 +34,8 @@
#include "qtversionmanager.h"
#include "qtparser.h"
#include <projectexplorer/kitinformationmacroexpander.h>
#include <utils/buildablehelperlibrary.h>
#include <utils/qtcassert.h>
......@@ -41,6 +43,41 @@ using namespace ProjectExplorer;
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)
{
BaseQtVersion *version = QtKitInformation::qtVersion(kit());
const QString noInfo = QCoreApplication::translate("QtSupport::QtKitInformation", "none");
if (name == QLatin1String("Qt:version")) {
*ret = version ? version->qtVersionString() : noInfo;
return true;
} else if (name == QLatin1String("Qt:name")) {
*ret = version ? version->displayName() : noInfo;
return true;
} else if (name == QLatin1String("Qt:type")) {
*ret = version ? version->type() : noInfo;
return true;
} else if (name == QLatin1String("Qt:mkspec")) {
*ret = version ? version->mkspec().toUserOutput() : noInfo;
return true;
}
return false;
}
} // namespace Internal
QtKitInformation::QtKitInformation()
{
setObjectName(QLatin1String("QtKitInformation"));
......@@ -127,6 +164,11 @@ ProjectExplorer::IOutputParser *QtKitInformation::createOutputParser(const Proje
return 0;
}