AutoTest: Make delegate independent from sub-classes...

...of TestTreeItem.

Change-Id: Ieacaeff64dced5e2a4dd3bd3a853cfb1081f5146
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
Christian Stenger
2016-04-29 11:15:14 +02:00
parent f429b95b0e
commit 70394b29af
3 changed files with 8 additions and 8 deletions

View File

@@ -88,6 +88,8 @@ QVariant TestTreeItem::data(int /*column*/, int role) const
return false;
case TypeRole:
return m_type;
case EnabledRole:
return true;
}
return QVariant();
}
@@ -869,8 +871,7 @@ QVariant GoogleTestTreeItem::data(int column, int role) const
if (type() == TestTreeItem::Root)
break;
const QString &displayName = (m_state & GoogleTestTreeItem::Disabled)
? name().mid(9) : name();
const QString &displayName = (m_state & Disabled) ? name().mid(9) : name();
return QVariant(displayName + nameSuffix());
}
case Qt::CheckStateRole:
@@ -883,8 +884,8 @@ QVariant GoogleTestTreeItem::data(int column, int role) const
}
case ItalicRole:
return false;
case StateRole:
return (int)m_state;
case EnabledRole:
return !(m_state & Disabled);
default:
break;
}

View File

@@ -36,7 +36,7 @@ namespace {
LinkRole = Qt::UserRole + 2, // can be removed if AnnotationRole comes back
ItalicRole, // used only inside the delegate
TypeRole,
StateRole
EnabledRole
};
}

View File

@@ -25,7 +25,6 @@
#include "testtreeitem.h"
#include "testtreeitemdelegate.h"
#include "testtreemodel.h"
#include <QPainter>
@@ -70,8 +69,8 @@ void TestTreeItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
}
}
// paint disabled googletests in gray
if (index.data(StateRole).toInt() & GoogleTestTreeItem::Disabled)
// paint disabled items in gray
if (!index.data(EnabledRole).toBool())
opt.palette.setColor(QPalette::Text, QColor(0xa0, 0xa0, 0xa0));
QStyledItemDelegate::paint(painter, opt, index);