diff options
author | Adam Reichold <adam.reichold@t-online.de> | 2014-02-20 19:16:01 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-28 07:47:16 +0100 |
commit | 0d0fb04d505d105fb4b2fc71d68f729ce670b12e (patch) | |
tree | 6b53825fbd9581982ca2e7cc966ab9b9fb1f4697 /src/widgets | |
parent | e5870b61c6efb4b31d675fa4ea88ea6a5f9e1db4 (diff) |
Make QTreeView::expand/collapse check for ineffectual invocations
Added checks if item is already expanded/collapsed to
QTreeView::expand/collapse since the following computations
can be quite expensive. (This is useful when saving/restoring a
lot of item expansion state e.g. after a model reset.)
Task-number: QTBUG-35939
Change-Id: I82c4489f9fe0b8ac61994652a60312e34c46f628
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qtreeview.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index dd430435f3..781dd345bd 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -754,6 +754,8 @@ void QTreeView::expand(const QModelIndex &index) return; if (index.flags() & Qt::ItemNeverHasChildren) return; + if (d->isIndexExpanded(index)) + return; if (d->delayedPendingLayout) { //A complete relayout is going to be performed, just store the expanded index, no need to layout. if (d->storeExpanded(index)) @@ -785,6 +787,8 @@ void QTreeView::collapse(const QModelIndex &index) Q_D(QTreeView); if (!d->isIndexValid(index)) return; + if (!d->isIndexExpanded(index)) + return; //if the current item is now invisible, the autoscroll will expand the tree to see it, so disable the autoscroll d->delayedAutoScroll.stop(); |