Commit c160433a authored by Tobias Hunger's avatar Tobias Hunger

Kit: Simplify validation of kits

Change-Id: I562e6f8d5fef36eea543c208cdd855db048b7f33
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent eac5a646
......@@ -155,8 +155,16 @@ QList<Task> Kit::validate()
{
QList<Task> result;
QList<KitInformation *> infoList = KitManager::instance()->kitInformation();
foreach (KitInformation *i, infoList)
result.append(i->validate(this));
d->m_isValid = true;
foreach (KitInformation *i, infoList) {
QList<Task> tmp = i->validate(this);
foreach (const Task &t, tmp) {
if (t.type == Task::Error)
d->m_isValid = false;
}
result.append(tmp);
}
qSort(result);
return result;
}
......@@ -387,13 +395,9 @@ void Kit::setAutoDetected(bool detected)
d->m_autodetected = detected;
}
void Kit::setValid(bool valid)
{
d->m_isValid = valid;
}
void Kit::kitUpdated()
{
validate();
KitManager::instance()->notifyAboutUpdate(this);
}
......
......@@ -93,7 +93,6 @@ private:
void operator=(const Kit &other);
void setAutoDetected(bool detected);
void setValid(bool valid);
void kitUpdated();
......@@ -103,7 +102,6 @@ private:
Internal::KitPrivate *d;
friend class KitManager;
friend class Internal::KitManagerPrivate;
};
} // namespace ProjectExplorer
......
......@@ -80,7 +80,6 @@ class KitManagerPrivate
public:
KitManagerPrivate();
~KitManagerPrivate();
QList<Task> validateKit(Kit *k) const;
Kit *m_defaultKit;
bool m_initialized;
......@@ -101,22 +100,6 @@ KitManagerPrivate::~KitManagerPrivate()
delete m_writer;
}
QList<Task> KitManagerPrivate::validateKit(Kit *k) const
{
Q_ASSERT(k);
QList<Task> result;
bool hasError = false;
foreach (KitInformation *ki, m_informationList) {
QList<Task> tmp = ki->validate(k);
foreach (const Task &t, tmp)
if (t.type == Task::Error)
hasError = true;
result << tmp;
}
k->setValid(!hasError);
return result;
}
} // namespace Internal
// --------------------------------------------------------------------------
......@@ -388,7 +371,6 @@ void KitManager::notifyAboutUpdate(ProjectExplorer::Kit *k)
{
if (!k || !kits().contains(k))
return;
d->validateKit(k);
emit kitUpdated(k);
}
......@@ -432,13 +414,6 @@ void KitManager::deregisterKit(Kit *k)
delete k;
}
QList<Task> KitManager::validateKit(Kit *k)
{
QList<Task> result = d->validateKit(k);
qSort(result);
return result;
}
void KitManager::setDefaultKit(Kit *k)
{
if (d->m_defaultKit == k)
......@@ -452,7 +427,7 @@ void KitManager::setDefaultKit(Kit *k)
void KitManager::validateKits()
{
foreach (Kit *k, kits())
d->validateKit(k);
k->validate();
}
void KitManager::addKit(Kit *k)
......@@ -460,7 +435,6 @@ void KitManager::addKit(Kit *k)
if (!k)
return;
k->setDisplayName(k->displayName()); // make name unique
d->validateKit(k);
d->m_kitList.append(k);
if (!d->m_defaultKit ||
(!d->m_defaultKit->isValid() && k->isValid()))
......
......@@ -115,7 +115,6 @@ public:
public slots:
bool registerKit(ProjectExplorer::Kit *k);
void deregisterKit(ProjectExplorer::Kit *k);
QList<Task> validateKit(ProjectExplorer::Kit *k);
void setDefaultKit(ProjectExplorer::Kit *k);
void saveKits();
......
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