When expanding up the tree, there is no need to expand above root.

The index set by setRootIndex is the root of the visible part of the
model. Expanding more than that is not needed.

Change-Id: I0015e313ef046ff63c67338c4f00c37e1aa71ca7
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
Stephen Kelly 2013-01-31 12:38:09 +01:00 committed by The Qt Project
parent 316d8ececa
commit 5764f10323

View File

@ -1097,7 +1097,7 @@ void QTreeView::scrollTo(const QModelIndex &index, ScrollHint hint)
// Expand all parents if the parent(s) of the node are not expanded.
QModelIndex parent = index.parent();
while (parent.isValid() && state() == NoState && d->itemsExpandable) {
while (parent != d->root && parent.isValid() && state() == NoState && d->itemsExpandable) {
if (!isExpanded(parent))
expand(parent);
parent = d->model->parent(parent);