forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user