diff --git a/plugins/autotest/testtreeitem.cpp b/plugins/autotest/testtreeitem.cpp
index 78d91c4490c643ab41928a2567d9759d87a3d6ad..bea7766287b6615c91bf1486917493d4efb1b7e4 100644
--- a/plugins/autotest/testtreeitem.cpp
+++ b/plugins/autotest/testtreeitem.cpp
@@ -17,10 +17,16 @@
 **
 ****************************************************************************/
 
+#include "autotestconstants.h"
 #include "testtreeitem.h"
 
 #include <utils/qtcassert.h>
 
+#include <QIcon>
+#include <QVariant>
+
+#include <texteditor/texteditor.h>
+
 namespace Autotest {
 namespace Internal {
 
@@ -78,6 +84,85 @@ void TestTreeItem::appendChild(TestTreeItem *child)
     m_children.append(child);
 }
 
+static QIcon testTreeIcon(TestTreeItem::Type type)
+{
+    static QIcon icons[] = {
+        QIcon(),
+        QIcon(QLatin1String(":/images/class.png")),
+        QIcon(QLatin1String(":/images/func.png")),
+        QIcon(QLatin1String(":/images/data.png"))
+    };
+    if (type >= sizeof(icons))
+        return icons[2];
+    return icons[type];
+}
+
+QVariant TestTreeItem::data(int /*column*/, int role) const
+{
+    switch (role) {
+    case Qt::DisplayRole:
+        if (m_type == ROOT && childCount() == 0)
+            return QString(m_name + QObject::tr(" (none)"));
+        else if (m_name.isEmpty())
+            return QObject::tr(Constants::UNNAMED_QUICKTESTS);
+        else
+            return m_name;
+    case Qt::ToolTipRole:
+        if (m_type == TEST_CLASS && m_name.isEmpty()) {
+            return QObject::tr("<p>Give all test cases a name to ensure correct behavior "
+                               "when running test cases and to be able to select them.</p>");
+        }
+        return m_filePath;
+    case Qt::DecorationRole:
+        return testTreeIcon(m_type);
+    case Qt::CheckStateRole:
+        switch (m_type) {
+        case ROOT:
+        case TEST_DATAFUNCTION:
+        case TEST_SPECIALFUNCTION:
+            return QVariant();
+        case TEST_CLASS:
+            return m_name.isEmpty() ? QVariant() : checked();
+        case TEST_FUNCTION:
+            if (m_parent && m_parent->name().isEmpty())
+                return QVariant();
+            return checked();
+        default:
+            return checked();
+        }
+    case LinkRole: {
+        QVariant itemLink;
+        itemLink.setValue(TextEditor::TextEditorWidget::Link(m_filePath, m_line, m_column));
+        return itemLink;
+    }
+    case ItalicRole:
+        switch (m_type) {
+        case TEST_DATAFUNCTION:
+        case TEST_SPECIALFUNCTION:
+            return true;
+        case TEST_CLASS:
+            return m_name.isEmpty();
+        case TEST_FUNCTION:
+            return m_parent ? m_parent->name().isEmpty() : false;
+        default:
+            return false;
+        }
+    case TypeRole:
+        return m_type;
+    }
+    return QVariant();
+}
+
+bool TestTreeItem::setData(int /*column*/, const QVariant &data, int role)
+{
+    if (role == Qt::CheckStateRole) {
+        Qt::CheckState old = checked();
+        setChecked((Qt::CheckState)data.toInt());
+        return checked() != old;
+    }
+    return false;
+}
+
 int TestTreeItem::row() const
 {
     if (m_parent)
diff --git a/plugins/autotest/testtreeitem.h b/plugins/autotest/testtreeitem.h
index 79bb7e6c18850587ab8b3557e5fc3a7da8f2e153..8a442e7f842c6795ba0c16ff2c567c2bfd2dfff7 100644
--- a/plugins/autotest/testtreeitem.h
+++ b/plugins/autotest/testtreeitem.h
@@ -24,6 +24,18 @@
 #include <QString>
 #include <QMetaType>
 
+QT_BEGIN_NAMESPACE
+class QVariant;
+QT_END_NAMESPACE
+
+namespace {
+    enum ItemRole {
+        LinkRole = Qt::UserRole + 2, // can be removed if AnnotationRole comes back
+        ItalicRole, // used only inside the delegate
+        TypeRole
+    };
+}
+
 namespace Autotest {
 namespace Internal {
 
@@ -48,6 +60,8 @@ public:
     TestTreeItem *child(int row) const;
     TestTreeItem *parent() const;
     void appendChild(TestTreeItem *child);
+    QVariant data(int column, int role) const;
+    bool setData(int column, const QVariant &data, int role);
     int row() const;
     int childCount() const;
     void removeChildren();
diff --git a/plugins/autotest/testtreeitemdelegate.cpp b/plugins/autotest/testtreeitemdelegate.cpp
index 1e5952c7a027c39d3728a6453145eda9d56822d2..7068c064724dfa0e92b4875617097bb5241b0588 100644
--- a/plugins/autotest/testtreeitemdelegate.cpp
+++ b/plugins/autotest/testtreeitemdelegate.cpp
@@ -17,6 +17,7 @@
 **
 ****************************************************************************/
 
+#include "testtreeitem.h"
 #include "testtreeitemdelegate.h"
 #include "testtreemodel.h"
 
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp
index ccc7616df45e5afd4b1a873ad289a5778792baa8..e6ff3a2b74c50637e8f2341e528aedf37dad5e5b 100644
--- a/plugins/autotest/testtreemodel.cpp
+++ b/plugins/autotest/testtreemodel.cpp
@@ -33,8 +33,6 @@
 
 #include <utils/qtcassert.h>
 
-#include <QIcon>
-
 namespace Autotest {
 namespace Internal {
 
@@ -176,19 +174,6 @@ int TestTreeModel::columnCount(const QModelIndex &) const
     return 1;
 }
 
-static QIcon testTreeIcon(TestTreeItem::Type type)
-{
-    static QIcon icons[] = {
-        QIcon(),
-        QIcon(QLatin1String(":/images/class.png")),
-        QIcon(QLatin1String(":/images/func.png")),
-        QIcon(QLatin1String(":/images/data.png"))
-    };
-    if (type >= sizeof(icons) / sizeof(icons[0]))
-        return icons[2];
-    return icons[type];
-}
-
 QVariant TestTreeModel::data(const QModelIndex &index, int role) const
 {
     if (!index.isValid())
@@ -198,73 +183,7 @@ QVariant TestTreeModel::data(const QModelIndex &index, int role) const
     if (!item)
         return QVariant();
 
-    if (role == Qt::DisplayRole) {
-        if ((item == m_autoTestRootItem && m_autoTestRootItem->childCount() == 0)
-                || (item == m_quickTestRootItem && m_quickTestRootItem->childCount() == 0)) {
-            return QString(item->name() + tr(" (none)"));
-        } else {
-            if (item->name().isEmpty() && item->type() == TestTreeItem::TEST_CLASS)
-                return tr(Constants::UNNAMED_QUICKTESTS);
-            return item->name();
-        }
-
-        return QVariant(); // TODO ?
-    }
-    switch(role) {
-    case Qt::ToolTipRole:
-        if (item->type() == TestTreeItem::TEST_CLASS && item->name().isEmpty())
-            return tr("<p>Give all test cases a name to ensure correct behavior "
-                      "when running test cases and to be able to select them.</p>");
-        return item->filePath();
-    case Qt::DecorationRole:
-        return testTreeIcon(item->type());
-    case Qt::CheckStateRole:
-        switch (item->type()) {
-        case TestTreeItem::ROOT:
-        case TestTreeItem::TEST_DATATAG:
-        case TestTreeItem::TEST_DATAFUNCTION:
-        case TestTreeItem::TEST_SPECIALFUNCTION:
-            return QVariant();
-        case TestTreeItem::TEST_CLASS:
-            if (item->name().isEmpty())
-                return QVariant();
-            else
-                return item->checked();
-        case TestTreeItem::TEST_FUNCTION:
-            if (TestTreeItem *parent = item->parent())
-                return parent->name().isEmpty() ? QVariant() : item->checked();
-            else
-                return item->checked();
-        default:
-            return item->checked();
-        }
-    case LinkRole: {
-        QVariant itemLink;
-        TextEditor::TextEditorWidget::Link link(item->filePath(), item->line(), item->column());
-        itemLink.setValue(link);
-        return itemLink;
-    }
-    case ItalicRole:
-        switch (item->type()) {
-        case TestTreeItem::TEST_DATAFUNCTION:
-        case TestTreeItem::TEST_SPECIALFUNCTION:
-            return true;
-        case TestTreeItem::TEST_CLASS:
-            return item->name().isEmpty();
-        case TestTreeItem::TEST_FUNCTION:
-            if (TestTreeItem *parent = item->parent())
-                return parent->name().isEmpty();
-            else
-                return false;
-        default:
-            return false;
-        }
-    case TypeRole:
-        return item->type();
-    }
-
-    // TODO ?
-    return QVariant();
+    return item->data(index.column(), role);
 }
 
 bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
@@ -272,27 +191,23 @@ bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int
     if (!index.isValid())
         return false;
 
-    if (role == Qt::CheckStateRole) {
-        TestTreeItem *item = static_cast<TestTreeItem *>(index.internalPointer());
-        Qt::CheckState old = item->checked();
-        item->setChecked((Qt::CheckState)value.toInt());
-        if (item->checked() != old) {
-            switch(item->type()) {
+    TestTreeItem *item = static_cast<TestTreeItem *>(index.internalPointer());
+    if (item && item->setData(index.column(), value, role)) {
+        emit dataChanged(index, index);
+        if (role == Qt::CheckStateRole) {
+            switch (item->type()) {
             case TestTreeItem::TEST_CLASS:
-                emit dataChanged(index, index);
-                if (item->childCount() > 0) {
+                if (item->childCount() > 0)
                     emit dataChanged(index.child(0, 0), index.child(item->childCount() - 1, 0));
-                }
                 break;
             case TestTreeItem::TEST_FUNCTION:
-                emit dataChanged(index, index);
                 emit dataChanged(index.parent(), index.parent());
                 break;
             default: // avoid warning regarding unhandled enum member
                 break;
             }
-            return true;
         }
+        return true;
     }
     return false;
 }
diff --git a/plugins/autotest/testtreemodel.h b/plugins/autotest/testtreemodel.h
index 7a7deaeb1352ac2330252d48a48c68dbe53b549a..7bcbe5e8b1051a7a7488c18062680442f96b57ea 100644
--- a/plugins/autotest/testtreemodel.h
+++ b/plugins/autotest/testtreemodel.h
@@ -27,15 +27,6 @@
 #include <QAbstractItemModel>
 #include <QSortFilterProxyModel>
 
-namespace {
-    enum ItemRole {
-//        AnnotationRole = Qt::UserRole + 1,
-        LinkRole = Qt::UserRole + 2, // can be removed if AnnotationRole comes back
-        ItalicRole, // used only inside the delegate
-        TypeRole
-    };
-}
-
 namespace Autotest {
 namespace Internal {