Commit d0587c95 authored by Tobias Hunger's avatar Tobias Hunger

Kit: Display warning and error icons

Display warning and error icons in the kit options page. This is more
consistent with what we do elsewhere.

Change-Id: I31786054da3ad8c55931156f0124740eea2d68d3
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent b6ca2fc1
......@@ -87,6 +87,7 @@ public:
m_id(id),
m_autodetected(false),
m_isValid(true),
m_hasWarning(false),
m_nestedBlockingLevel(0),
m_mustNotify(false)
{
......@@ -98,6 +99,7 @@ public:
Id m_id;
bool m_autodetected;
bool m_isValid;
bool m_hasWarning;
QIcon m_icon;
QString m_iconPath;
int m_nestedBlockingLevel;
......@@ -176,16 +178,24 @@ bool Kit::isValid() const
return d->m_id.isValid() && d->m_isValid;
}
bool Kit::hasWarning() const
{
return d->m_hasWarning;
}
QList<Task> Kit::validate() const
{
QList<Task> result;
QList<KitInformation *> infoList = KitManager::instance()->kitInformation();
d->m_isValid = true;
d->m_hasWarning = false;
foreach (KitInformation *i, infoList) {
QList<Task> tmp = i->validate(this);
foreach (const Task &t, tmp) {
if (t.type == Task::Error)
d->m_isValid = false;
if (t.type == Task::Warning)
d->m_hasWarning = true;
}
result.append(tmp);
}
......@@ -411,7 +421,7 @@ QString Kit::toHtml()
str << "<h3>" << displayName() << "</h3>";
str << "<table>";
if (!isValid()) {
if (!isValid() || hasWarning()) {
QList<Task> issues = validate();
str << "<p>";
foreach (const Task &t, issues) {
......
......@@ -64,6 +64,7 @@ public:
void unblockNotification();
bool isValid() const;
bool hasWarning() const;
QList<Task> validate() const;
void fix(); // Fix the individual kit information.
void setup(); // Apply advanced magic(TM). Used only once on each kit during initial setup.
......
......@@ -157,6 +157,11 @@ bool KitManagerConfigWidget::isValid() const
return m_modifiedKit->isValid();
}
bool KitManagerConfigWidget::hasWarning() const
{
return m_modifiedKit->hasWarning();
}
QString KitManagerConfigWidget::validityMessage() const
{
return m_modifiedKit->toHtml();
......
......@@ -60,6 +60,7 @@ public:
void discard();
bool isDirty() const;
bool isValid() const;
bool hasWarning() const;
QString validityMessage() const;
void addConfigWidget(ProjectExplorer::KitConfigWidget *widget);
void makeReadOnly();
......
......@@ -154,6 +154,7 @@ int KitModel::columnCount(const QModelIndex &parent) const
QVariant KitModel::data(const QModelIndex &index, int role) const
{
static QIcon warningIcon(QLatin1String(":/projectexplorer/images/compile_warning.png"));
static QIcon errorIcon(QLatin1String(":/projectexplorer/images/compile_error.png"));
if (!index.isValid() || index.column() != 0)
return QVariant();
......@@ -179,7 +180,11 @@ QVariant KitModel::data(const QModelIndex &index, int role) const
baseName = tr("%1 (default)").arg(baseName);
return baseName;
} else if (role == Qt::DecorationRole) {
return node->widget->isValid() ? QIcon() : warningIcon;
if (!node->widget->isValid())
return errorIcon;
if (node->widget->hasWarning())
return warningIcon;
return QIcon();
} else if (role == Qt::ToolTipRole) {
return node->widget->validityMessage();
}
......
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