summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-11-07 15:04:31 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-02 08:10:55 +0100
commit08a632ac1ac48eebdb60d9b87b221e7dbd3c22c4 (patch)
treed4d9eb52c8820a5d467245acdcd8c4ce27b9292c /src
parentebca7d2ea71440b0a5e465774e3abd98ff6298a8 (diff)
QTreeView::expandToDepth - add missing emit of expanded and collapsed
Just like other functions this function should emit expanded and collapsed. A part of fixing Task-number: QTBUG-8176 Change-Id: I6d801f61e6f0cb8836634cc52f0be2b610f6c728 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/itemviews/qtreeview.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index df6ba708a9..fb26343af2 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -2668,6 +2668,8 @@ void QTreeView::expandToDepth(int depth)
{
Q_D(QTreeView);
d->viewItems.clear();
+ QSet<QPersistentModelIndex> old_expandedIndexes;
+ old_expandedIndexes = d->expandedIndexes;
d->expandedIndexes.clear();
d->interruptDelayedItemsLayout();
d->layout(-1);
@@ -2678,6 +2680,24 @@ void QTreeView::expandToDepth(int depth)
d->storeExpanded(d->viewItems.at(i).index);
}
}
+
+ // emit signals
+ QSet<QPersistentModelIndex> collapsedIndexes = old_expandedIndexes - d->expandedIndexes;
+ QSet<QPersistentModelIndex>::const_iterator i = collapsedIndexes.constBegin();
+ for (; i != collapsedIndexes.constEnd(); ++i) {
+ const QPersistentModelIndex &mi = (*i);
+ if (mi.isValid() && !(mi.flags() & Qt::ItemNeverHasChildren))
+ emit collapsed(mi);
+ }
+
+ QSet<QPersistentModelIndex> expandedIndexs = d->expandedIndexes - old_expandedIndexes;
+ i = expandedIndexs.constBegin();
+ for (; i != expandedIndexs.constEnd(); ++i) {
+ const QPersistentModelIndex &mi = (*i);
+ if (mi.isValid() && !(mi.flags() & Qt::ItemNeverHasChildren))
+ emit expanded(mi);
+ }
+
updateGeometries();
d->viewport->update();
}