forked from qt-creator/qt-creator
ProjectExplorer: Code cosmetics
rename KitManager::kitInformation() to kitAspects, make it return a const list to be able to use clutter-free ranged for. Polish vicinity. Change-Id: Ibe187586152eb0053efa8c571adbd73158f109c4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -86,8 +86,8 @@ public:
|
|||||||
[kit] { return kit->id().toString(); });
|
[kit] { return kit->id().toString(); });
|
||||||
m_macroExpander.registerVariable("Kit:FileSystemName", tr("Kit filesystem-friendly name"),
|
m_macroExpander.registerVariable("Kit:FileSystemName", tr("Kit filesystem-friendly name"),
|
||||||
[kit] { return kit->fileSystemFriendlyName(); });
|
[kit] { return kit->fileSystemFriendlyName(); });
|
||||||
foreach (KitAspect *ki, KitManager::kitInformation())
|
for (KitAspect *aspect : KitManager::kitAspects())
|
||||||
ki->addToMacroExpander(kit, &m_macroExpander);
|
aspect->addToMacroExpander(kit, &m_macroExpander);
|
||||||
|
|
||||||
// This provides the same global fall back as the global expander
|
// This provides the same global fall back as the global expander
|
||||||
// without relying on the currentKit() discovery process there.
|
// without relying on the currentKit() discovery process there.
|
||||||
@@ -134,8 +134,8 @@ public:
|
|||||||
Kit::Kit(Id id) :
|
Kit::Kit(Id id) :
|
||||||
d(std::make_unique<Internal::KitPrivate>(id, this))
|
d(std::make_unique<Internal::KitPrivate>(id, this))
|
||||||
{
|
{
|
||||||
foreach (KitAspect *sti, KitManager::kitInformation())
|
for (KitAspect *aspect : KitManager::kitAspects())
|
||||||
d->m_data.insert(sti->id(), sti->defaultValue(this));
|
d->m_data.insert(aspect->id(), aspect->defaultValue(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
Kit::Kit(const QVariantMap &data) :
|
Kit::Kit(const QVariantMap &data) :
|
||||||
@@ -246,11 +246,9 @@ bool Kit::hasWarning() const
|
|||||||
QList<Task> Kit::validate() const
|
QList<Task> Kit::validate() const
|
||||||
{
|
{
|
||||||
QList<Task> result;
|
QList<Task> result;
|
||||||
QList<KitAspect *> infoList = KitManager::kitInformation();
|
for (KitAspect *aspect : KitManager::kitAspects())
|
||||||
for (KitAspect *i : infoList) {
|
result.append(aspect->validate(this));
|
||||||
QList<Task> tmp = i->validate(this);
|
|
||||||
result.append(tmp);
|
|
||||||
}
|
|
||||||
d->m_hasError = containsType(result, Task::TaskType::Error);
|
d->m_hasError = containsType(result, Task::TaskType::Error);
|
||||||
d->m_hasWarning = containsType(result, Task::TaskType::Warning);
|
d->m_hasWarning = containsType(result, Task::TaskType::Warning);
|
||||||
|
|
||||||
@@ -262,27 +260,27 @@ QList<Task> Kit::validate() const
|
|||||||
void Kit::fix()
|
void Kit::fix()
|
||||||
{
|
{
|
||||||
KitGuard g(this);
|
KitGuard g(this);
|
||||||
foreach (KitAspect *i, KitManager::kitInformation())
|
for (KitAspect *aspect : KitManager::kitAspects())
|
||||||
i->fix(this);
|
aspect->fix(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kit::setup()
|
void Kit::setup()
|
||||||
{
|
{
|
||||||
KitGuard g(this);
|
KitGuard g(this);
|
||||||
// Process the KitInfos in reverse order: They may only be based on other information lower in
|
// Process the KitAspects in reverse order: They may only be based on other information
|
||||||
// the stack.
|
// lower in the stack.
|
||||||
QList<KitAspect *> info = KitManager::kitInformation();
|
const QList<KitAspect *> aspects = KitManager::kitAspects();
|
||||||
for (int i = info.count() - 1; i >= 0; --i)
|
for (int i = aspects.count() - 1; i >= 0; --i)
|
||||||
info.at(i)->setup(this);
|
aspects.at(i)->setup(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kit::upgrade()
|
void Kit::upgrade()
|
||||||
{
|
{
|
||||||
KitGuard g(this);
|
KitGuard g(this);
|
||||||
// Process the KitInfos in reverse order: They may only be based on other information lower in
|
// Process the KitAspects in reverse order: They may only be based on other information
|
||||||
// the stack.
|
// lower in the stack.
|
||||||
for (KitAspect *ki : KitManager::kitInformation())
|
for (KitAspect *aspect : KitManager::kitAspects())
|
||||||
ki->upgrade(this);
|
aspect->upgrade(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Kit::unexpandedDisplayName() const
|
QString Kit::unexpandedDisplayName() const
|
||||||
@@ -503,17 +501,15 @@ QVariantMap Kit::toMap() const
|
|||||||
|
|
||||||
void Kit::addToEnvironment(Environment &env) const
|
void Kit::addToEnvironment(Environment &env) const
|
||||||
{
|
{
|
||||||
QList<KitAspect *> infoList = KitManager::kitInformation();
|
for (KitAspect *aspect : KitManager::kitAspects())
|
||||||
foreach (KitAspect *ki, infoList)
|
aspect->addToEnvironment(this, env);
|
||||||
ki->addToEnvironment(this, env);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IOutputParser *Kit::createOutputParser() const
|
IOutputParser *Kit::createOutputParser() const
|
||||||
{
|
{
|
||||||
auto first = new OsParser;
|
auto first = new OsParser;
|
||||||
QList<KitAspect *> infoList = KitManager::kitInformation();
|
for (KitAspect *aspect : KitManager::kitAspects())
|
||||||
foreach (KitAspect *ki, infoList)
|
first->appendOutputParser(aspect->createOutputParser(this));
|
||||||
first->appendOutputParser(ki->createOutputParser(this));
|
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,10 +524,9 @@ QString Kit::toHtml(const QList<Task> &additional) const
|
|||||||
str << "<p>" << ProjectExplorer::toHtml(additional + validate()) << "</p>";
|
str << "<p>" << ProjectExplorer::toHtml(additional + validate()) << "</p>";
|
||||||
|
|
||||||
str << "<table>";
|
str << "<table>";
|
||||||
QList<KitAspect *> infoList = KitManager::kitInformation();
|
for (KitAspect *aspect : KitManager::kitAspects()) {
|
||||||
foreach (KitAspect *ki, infoList) {
|
const KitAspect::ItemList list = aspect->toUserOutput(this);
|
||||||
KitAspect::ItemList list = ki->toUserOutput(this);
|
for (const KitAspect::Item &j : list) {
|
||||||
foreach (const KitAspect::Item &j, list) {
|
|
||||||
QString contents = j.second;
|
QString contents = j.second;
|
||||||
if (contents.count() > 256) {
|
if (contents.count() > 256) {
|
||||||
int pos = contents.lastIndexOf("<br>", 256);
|
int pos = contents.lastIndexOf("<br>", 256);
|
||||||
@@ -573,9 +568,9 @@ void Kit::setSdkProvided(bool sdkProvided)
|
|||||||
|
|
||||||
void Kit::makeSticky()
|
void Kit::makeSticky()
|
||||||
{
|
{
|
||||||
foreach (KitAspect *ki, KitManager::kitInformation()) {
|
for (KitAspect *aspect : KitManager::kitAspects()) {
|
||||||
if (hasValue(ki->id()))
|
if (hasValue(aspect->id()))
|
||||||
setSticky(ki->id(), true);
|
setSticky(aspect->id(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,8 +614,8 @@ bool Kit::isMutable(Id id) const
|
|||||||
QSet<Id> Kit::supportedPlatforms() const
|
QSet<Id> Kit::supportedPlatforms() const
|
||||||
{
|
{
|
||||||
QSet<Id> platforms;
|
QSet<Id> platforms;
|
||||||
foreach (const KitAspect *ki, KitManager::kitInformation()) {
|
for (const KitAspect *aspect : KitManager::kitAspects()) {
|
||||||
const QSet<Id> ip = ki->supportedPlatforms(this);
|
const QSet<Id> ip = aspect->supportedPlatforms(this);
|
||||||
if (ip.isEmpty())
|
if (ip.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (platforms.isEmpty())
|
if (platforms.isEmpty())
|
||||||
@@ -634,8 +629,8 @@ QSet<Id> Kit::supportedPlatforms() const
|
|||||||
QSet<Id> Kit::availableFeatures() const
|
QSet<Id> Kit::availableFeatures() const
|
||||||
{
|
{
|
||||||
QSet<Id> features;
|
QSet<Id> features;
|
||||||
foreach (const KitAspect *ki, KitManager::kitInformation())
|
for (const KitAspect *aspect : KitManager::kitAspects())
|
||||||
features |= ki->availableFeatures(this);
|
features |= aspect->availableFeatures(this);
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -152,11 +152,11 @@ void KitManager::restoreKits()
|
|||||||
Kit *ptr = i->get();
|
Kit *ptr = i->get();
|
||||||
|
|
||||||
// Overwrite settings that the SDK sets to those values:
|
// Overwrite settings that the SDK sets to those values:
|
||||||
foreach (const KitAspect *ki, KitManager::kitInformation()) {
|
for (const KitAspect *aspect : KitManager::kitAspects()) {
|
||||||
// Copy sticky settings over:
|
// Copy sticky settings over:
|
||||||
if (ptr->isSticky(ki->id())) {
|
if (ptr->isSticky(aspect->id())) {
|
||||||
ptr->setValue(ki->id(), toStore->value(ki->id()));
|
ptr->setValue(aspect->id(), toStore->value(aspect->id()));
|
||||||
ptr->setSticky(ki->id(), true);
|
ptr->setSticky(aspect->id(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toStore = std::move(*i);
|
toStore = std::move(*i);
|
||||||
@@ -365,7 +365,7 @@ Kit *KitManager::defaultKit()
|
|||||||
return d->m_defaultKit;
|
return d->m_defaultKit;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<KitAspect *> KitManager::kitInformation()
|
const QList<KitAspect *> KitManager::kitAspects()
|
||||||
{
|
{
|
||||||
return Utils::toRawPointer<QList>(d->m_informationList);
|
return Utils::toRawPointer<QList>(d->m_informationList);
|
||||||
}
|
}
|
||||||
@@ -373,8 +373,8 @@ QList<KitAspect *> KitManager::kitInformation()
|
|||||||
KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k)
|
KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k)
|
||||||
{
|
{
|
||||||
auto *result = new KitManagerConfigWidget(k);
|
auto *result = new KitManagerConfigWidget(k);
|
||||||
foreach (KitAspect *ki, kitInformation())
|
for (KitAspect *aspect : kitAspects())
|
||||||
result->addAspectToWorkingCopy(ki);
|
result->addAspectToWorkingCopy(aspect);
|
||||||
|
|
||||||
result->updateVisibility();
|
result->updateVisibility();
|
||||||
|
|
||||||
|
@@ -168,7 +168,7 @@ public:
|
|||||||
static Kit *kit(Core::Id id);
|
static Kit *kit(Core::Id id);
|
||||||
static Kit *defaultKit();
|
static Kit *defaultKit();
|
||||||
|
|
||||||
static QList<KitAspect *> kitInformation();
|
static const QList<KitAspect *> kitAspects();
|
||||||
|
|
||||||
static Internal::KitManagerConfigWidget *createConfigWidget(Kit *k);
|
static Internal::KitManagerConfigWidget *createConfigWidget(Kit *k);
|
||||||
|
|
||||||
|
@@ -589,11 +589,11 @@ void KitAreaWidget::setKit(Kit *k)
|
|||||||
m_labels.clear();
|
m_labels.clear();
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
foreach (KitAspect *ki, KitManager::kitInformation()) {
|
for (KitAspect *aspect : KitManager::kitAspects()) {
|
||||||
if (k && k->isMutable(ki->id())) {
|
if (k && k->isMutable(aspect->id())) {
|
||||||
KitAspectWidget *widget = ki->createConfigWidget(k);
|
KitAspectWidget *widget = aspect->createConfigWidget(k);
|
||||||
m_widgets << widget;
|
m_widgets << widget;
|
||||||
QLabel *label = new QLabel(ki->displayName());
|
QLabel *label = new QLabel(aspect->displayName());
|
||||||
m_labels << label;
|
m_labels << label;
|
||||||
|
|
||||||
widget->setStyle(QStyleFactory::create(QLatin1String("fusion")));
|
widget->setStyle(QStyleFactory::create(QLatin1String("fusion")));
|
||||||
@@ -619,8 +619,8 @@ void KitAreaWidget::updateKit(Kit *k)
|
|||||||
bool addedMutables = false;
|
bool addedMutables = false;
|
||||||
QList<Core::Id> knownIdList = Utils::transform(m_widgets, &KitAspectWidget::kitInformationId);
|
QList<Core::Id> knownIdList = Utils::transform(m_widgets, &KitAspectWidget::kitInformationId);
|
||||||
|
|
||||||
foreach (KitAspect *ki, KitManager::kitInformation()) {
|
for (KitAspect *aspect : KitManager::kitAspects()) {
|
||||||
Core::Id currentId = ki->id();
|
const Core::Id currentId = aspect->id();
|
||||||
if (m_kit->isMutable(currentId) && !knownIdList.removeOne(currentId)) {
|
if (m_kit->isMutable(currentId) && !knownIdList.removeOne(currentId)) {
|
||||||
addedMutables = true;
|
addedMutables = true;
|
||||||
break;
|
break;
|
||||||
|
@@ -294,13 +294,13 @@ Kit *ProjectImporter::createTemporaryKit(const KitSetupFunction &setup) const
|
|||||||
k->setUnexpandedDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectImporter", "Imported Kit"));;
|
k->setUnexpandedDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectImporter", "Imported Kit"));;
|
||||||
|
|
||||||
// Set up values:
|
// Set up values:
|
||||||
foreach (KitAspect *ki, KitManager::kitInformation())
|
for (KitAspect *aspect : KitManager::kitAspects())
|
||||||
ki->setup(kptr);
|
aspect->setup(kptr);
|
||||||
|
|
||||||
setup(kptr);
|
setup(kptr);
|
||||||
|
|
||||||
foreach (KitAspect *ki, KitManager::kitInformation())
|
for (KitAspect *aspect : KitManager::kitAspects())
|
||||||
ki->fix(kptr);
|
aspect->fix(kptr);
|
||||||
|
|
||||||
markKitAsTemporary(kptr);
|
markKitAsTemporary(kptr);
|
||||||
addProject(kptr);
|
addProject(kptr);
|
||||||
|
Reference in New Issue
Block a user