Commit 1cfe46df authored by Christian Stenger's avatar Christian Stenger
Browse files

Make gtest related items checkable



This is a preparation for supporting 'Run Selected Tests' for gtest
related tests.

Change-Id: I4fc46b9c394d8c748b42b2cda2d27d3597a1c273
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
parent 650be0e4
......@@ -39,6 +39,9 @@ TestTreeItem::TestTreeItem(const QString &name, const QString &filePath, Type ty
switch (m_type) {
case TestClass:
case TestFunction:
case GTestCase:
case GTestName:
case GTestNameDisabled:
m_checked = Qt::Checked;
break;
default:
......@@ -105,13 +108,13 @@ QVariant TestTreeItem::data(int /*column*/, int role) const
case TestDataFunction:
case TestSpecialFunction:
case TestDataTag:
case GTestCase:
case GTestName:
case GTestNameDisabled:
return QVariant();
case TestClass:
case GTestCase:
return m_name.isEmpty() ? QVariant() : checked();
case TestFunction:
case GTestName:
case GTestNameDisabled:
if (parentItem() && parentItem()->name().isEmpty())
return QVariant();
return checked();
......@@ -180,12 +183,15 @@ bool TestTreeItem::modifyContent(const TestTreeItem *modified)
void TestTreeItem::setChecked(const Qt::CheckState checkState)
{
switch (m_type) {
case TestFunction: {
case TestFunction:
case GTestName:
case GTestNameDisabled: {
m_checked = (checkState == Qt::Unchecked ? Qt::Unchecked : Qt::Checked);
parentItem()->revalidateCheckState();
break;
}
case TestClass: {
case TestClass:
case GTestCase: {
Qt::CheckState usedState = (checkState == Qt::Unchecked ? Qt::Unchecked : Qt::Checked);
for (int row = 0, count = childCount(); row < count; ++row)
childItem(row)->setChecked(usedState);
......@@ -201,6 +207,9 @@ Qt::CheckState TestTreeItem::checked() const
switch (m_type) {
case TestClass:
case TestFunction:
case GTestCase:
case GTestName:
case GTestNameDisabled:
return m_checked;
case TestDataFunction:
case TestSpecialFunction:
......
......@@ -139,10 +139,13 @@ bool TestTreeModel::setData(const QModelIndex &index, const QVariant &value, int
if (role == Qt::CheckStateRole) {
switch (item->type()) {
case TestTreeItem::TestClass:
case TestTreeItem::GTestCase:
if (item->childCount() > 0)
emit dataChanged(index.child(0, 0), index.child(item->childCount() - 1, 0));
break;
case TestTreeItem::TestFunction:
case TestTreeItem::GTestName:
case TestTreeItem::GTestNameDisabled:
emit dataChanged(index.parent(), index.parent());
break;
default: // avoid warning regarding unhandled enum member
......@@ -162,10 +165,13 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const
TestTreeItem *item = static_cast<TestTreeItem *>(itemForIndex(index));
switch(item->type()) {
case TestTreeItem::TestClass:
case TestTreeItem::GTestCase:
if (item->name().isEmpty())
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate | Qt::ItemIsUserCheckable;
case TestTreeItem::TestFunction:
case TestTreeItem::GTestName:
case TestTreeItem::GTestNameDisabled:
if (item->parentItem()->name().isEmpty())
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
......@@ -174,9 +180,6 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const
case TestTreeItem::TestDataFunction:
case TestTreeItem::TestSpecialFunction:
case TestTreeItem::TestDataTag:
case TestTreeItem::GTestCase:
case TestTreeItem::GTestName:
case TestTreeItem::GTestNameDisabled:
default:
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
......
Supports Markdown
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