From b0e7368d5859030cadd5fcdf9739a22bde6f29d2 Mon Sep 17 00:00:00 2001
From: hjk <hjk@theqtcompany.com>
Date: Mon, 7 Sep 2015 12:13:03 +0200
Subject: [PATCH] Debugger: Mark bad debuggger entries with an error icon

Change-Id: If3f7ab4ea015be6f580f748f9d0ee19c608a0239
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
---
 src/plugins/debugger/debuggeritem.cpp        | 12 ++++++++++++
 src/plugins/debugger/debuggeritem.h          |  3 +++
 src/plugins/debugger/debuggeroptionspage.cpp | 11 +++++++++++
 3 files changed, 26 insertions(+)

diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp
index fc4c6bcffb3..338449ee519 100644
--- a/src/plugins/debugger/debuggeritem.cpp
+++ b/src/plugins/debugger/debuggeritem.cpp
@@ -202,6 +202,18 @@ QStringList DebuggerItem::abiNames() const
     return list;
 }
 
+bool DebuggerItem::isGood() const
+{
+    return m_engineType != NoEngineType;
+}
+
+QString DebuggerItem::validityMessage() const
+{
+    if (m_engineType == NoEngineType)
+        return DebuggerOptionsPage::tr("Could not determine debugger type");
+    return QString();
+}
+
 bool DebuggerItem::operator==(const DebuggerItem &other) const
 {
     return m_id == other.m_id
diff --git a/src/plugins/debugger/debuggeritem.h b/src/plugins/debugger/debuggeritem.h
index 6ffb2e7873d..8a1748a7b50 100644
--- a/src/plugins/debugger/debuggeritem.h
+++ b/src/plugins/debugger/debuggeritem.h
@@ -98,6 +98,9 @@ public:
 
     QStringList abiNames() const;
 
+    bool isGood() const;
+    QString validityMessage() const;
+
     bool operator==(const DebuggerItem &other) const;
     bool operator!=(const DebuggerItem &other) const { return !operator==(other); }
 
diff --git a/src/plugins/debugger/debuggeroptionspage.cpp b/src/plugins/debugger/debuggeroptionspage.cpp
index a6870fea0a0..ea310b1a548 100644
--- a/src/plugins/debugger/debuggeroptionspage.cpp
+++ b/src/plugins/debugger/debuggeroptionspage.cpp
@@ -32,6 +32,8 @@
 #include "debuggeritemmanager.h"
 #include "debuggeritem.h"
 
+#include <coreplugin/coreconstants.h>
+
 #include <projectexplorer/projectexplorerconstants.h>
 
 #include <utils/detailswidget.h>
@@ -68,6 +70,8 @@ public:
 
     QVariant data(int column, int role) const
     {
+        static QIcon errorIcon(QString::fromLatin1(Core::Constants::ICON_ERROR));
+
         switch (role) {
             case Qt::DisplayRole:
                 switch (column) {
@@ -81,6 +85,13 @@ public:
                 font.setBold(m_changed);
                 return font;
             }
+            case Qt::DecorationRole: {
+                if (column == 0 && !m_item.isGood())
+                    return errorIcon;
+            }
+            case Qt::ToolTipRole: {
+                return m_item.validityMessage();
+            }
         }
         return QVariant();
     }
-- 
GitLab