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