Commit c6180467 authored by hjk's avatar hjk

QtSupport: Use the new MacroExpander base

Change-Id: I8a3f3d461179ab1abf1704166ad3861645d49f99
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 46c4ab7b
......@@ -895,7 +895,11 @@ void BaseQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
AbstractMacroExpander *BaseQtVersion::createMacroExpander() const
{
return QtKitInformation::createMacroExpander(this);
return new MacroExpander([this](const QString &name, QString *ret) -> bool {
if (name == QLatin1String("Qt:name"))
return false;
return QtKitInformation::resolveQtMacro(this, name, ret);
});
}
FileName BaseQtVersion::mkspec() const
......
......@@ -40,50 +40,11 @@
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
using namespace Utils;
namespace QtSupport {
namespace Internal {
static bool resolveQtMacro(const BaseQtVersion *version, const QString &name, QString *ret)
{
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;
}
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:
......@@ -93,7 +54,7 @@ public:
bool resolveMacro(const QString &name, QString *ret)
{
return resolveQtMacro(QtKitInformation::qtVersion(kit()), name, ret);
return QtKitInformation::resolveQtMacro(QtKitInformation::qtVersion(kit()), name, ret);
}
};
......@@ -109,6 +70,26 @@ QtKitInformation::QtKitInformation()
this, SLOT(kitsWereLoaded()));
}
bool QtKitInformation::resolveQtMacro(const BaseQtVersion *version, const QString &name, QString *ret)
{
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;
}
QVariant QtKitInformation::defaultValue(ProjectExplorer::Kit *k) const
{
Q_UNUSED(k);
......@@ -190,11 +171,6 @@ 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,7 +62,7 @@ public:
Utils::AbstractMacroExpander *createMacroExpander(const ProjectExplorer::Kit *k) const;
static Utils::AbstractMacroExpander *createMacroExpander(const BaseQtVersion *v);
static bool resolveQtMacro(const BaseQtVersion *version, const QString &name, QString *ret);
static Core::Id id();
static int qtVersionId(const ProjectExplorer::Kit *k);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment