From 0d9e4b7405808241dc7c85f901101c786214ba61 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Wed, 20 Jun 2012 15:43:01 +0200 Subject: [PATCH] QMakeProfileInformation: Report mkspec in a better way Report teh effective, default and set mkspec separately to improve the importing and the UI. Change-Id: I6087950cd961829d7fcf60b3f6de317a02444631 Reviewed-by: Daniel Teske --- .../qmakeprofileinformation.cpp | 47 +++++++++++++------ .../qmakeprofileinformation.h | 5 +- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/plugins/qt4projectmanager/qmakeprofileinformation.cpp b/src/plugins/qt4projectmanager/qmakeprofileinformation.cpp index 348e939c31c..1aa4e5e7746 100644 --- a/src/plugins/qt4projectmanager/qmakeprofileinformation.cpp +++ b/src/plugins/qt4projectmanager/qmakeprofileinformation.cpp @@ -63,19 +63,8 @@ unsigned int QmakeProfileInformation::priority() const QVariant QmakeProfileInformation::defaultValue(ProjectExplorer::Profile *p) const { - QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(p); - if (!version) // No version, so no qmake - return QString(); - - ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(p); - - const QList tcSpecList = tc ? tc->suggestedMkspecList() : QList(); - foreach (const Utils::FileName &tcSpec, tcSpecList) { - if (version->hasMkspec(tcSpec)) - return tcSpec.toString(); - } - - return version ? version->mkspec().toString() : QString(); + Q_UNUSED(p); + return QString(); } QList QmakeProfileInformation::validate(ProjectExplorer::Profile *p) const @@ -115,9 +104,39 @@ Utils::FileName QmakeProfileInformation::mkspec(const ProjectExplorer::Profile * return Utils::FileName::fromString(p->value(Core::Id(Internal::MKSPEC_INFORMATION)).toString()); } +Utils::FileName QmakeProfileInformation::effectiveMkspec(const ProjectExplorer::Profile *p) +{ + if (!p) + return Utils::FileName(); + Utils::FileName spec = mkspec(p); + if (spec.isEmpty()) + return defaultMkspec(p); + return spec; +} + void QmakeProfileInformation::setMkspec(ProjectExplorer::Profile *p, const Utils::FileName &fn) { - p->setValue(Core::Id(Internal::MKSPEC_INFORMATION), fn.toString()); + if (fn == defaultMkspec(p)) + p->setValue(Core::Id(Internal::MKSPEC_INFORMATION), QString()); + else + p->setValue(Core::Id(Internal::MKSPEC_INFORMATION), fn.toString()); +} + +Utils::FileName QmakeProfileInformation::defaultMkspec(const ProjectExplorer::Profile *p) +{ + QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(p); + if (!version) // No version, so no qmake + return Utils::FileName(); + + ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainProfileInformation::toolChain(p); + + const QList tcSpecList = tc ? tc->suggestedMkspecList() : QList(); + foreach (const Utils::FileName &tcSpec, tcSpecList) { + if (version->hasMkspec(tcSpec)) + return tcSpec; + } + + return version ? version->mkspec() : Utils::FileName(); } } // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qmakeprofileinformation.h b/src/plugins/qt4projectmanager/qmakeprofileinformation.h index 013f102e49f..8b002c42c74 100644 --- a/src/plugins/qt4projectmanager/qmakeprofileinformation.h +++ b/src/plugins/qt4projectmanager/qmakeprofileinformation.h @@ -58,8 +58,11 @@ public: ItemList toUserOutput(ProjectExplorer::Profile *p) const; - static Utils::FileName mkspec(const ProjectExplorer::Profile *p); static void setMkspec(ProjectExplorer::Profile *p, const Utils::FileName &fn); + static Utils::FileName mkspec(const ProjectExplorer::Profile *p); + static Utils::FileName effectiveMkspec(const ProjectExplorer::Profile *p); + static Utils::FileName defaultMkspec(const ProjectExplorer::Profile *p); + }; } // namespace Qt4ProjectManager