AutoTest: Redo check state handling

Simplify and re-arrange to avoid wrong indirections and
unnecessary delegation.
Beside this ensure correct check states of group nodes
when adding them.

Change-Id: I24a32249d785e48c9d27111d062c2a06a17327ef
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2018-01-23 16:12:47 +01:00
parent ebede577b6
commit 5ef822da9f
6 changed files with 66 additions and 96 deletions

View File

@@ -71,7 +71,7 @@ void TestTreeView::changeCheckStateAll(const Qt::CheckState checkState)
int funcCount = model->rowCount(classesIndex);
TestTreeItem *item = static_cast<TestTreeItem *>(classesIndex.internalPointer());
if (item) {
item->setChecked(checkState);
item->setData(0, checkState, Qt::CheckStateRole);
if (!item->childCount())
last = classesIndex;
}
@@ -79,12 +79,12 @@ void TestTreeView::changeCheckStateAll(const Qt::CheckState checkState)
last = model->index(functionRow, 0, classesIndex);
TestTreeItem *item = static_cast<TestTreeItem *>(last.internalPointer());
if (item)
item->setChecked(checkState);
item->setData(0, checkState, Qt::CheckStateRole);
}
}
if (count == 0) {
if (auto item = static_cast<TestTreeItem *>(currentRootIndex.internalPointer()))
item->setChecked(checkState);
item->setData(0, checkState, Qt::CheckStateRole);
}
emit dataChanged(currentRootIndex, last);
}