QTreeView - emit collapsed in collapseAll()
When we call call collapase we emit collapsed. Therefore it should also be emitted on collapseAll() This partly solves: Task-number: QTBUG-8176 Change-Id: I20c1388fcbbb60d12debb4a0b3b0d9fed41e2563 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
80fa4b6c8e
commit
3260aec38e
@ -2646,7 +2646,15 @@ void QTreeView::expandAll()
|
||||
void QTreeView::collapseAll()
|
||||
{
|
||||
Q_D(QTreeView);
|
||||
QSet<QPersistentModelIndex> old_expandedIndexes;
|
||||
old_expandedIndexes = d->expandedIndexes;
|
||||
d->expandedIndexes.clear();
|
||||
QSet<QPersistentModelIndex>::const_iterator i = old_expandedIndexes.constBegin();
|
||||
for (; i != old_expandedIndexes.constEnd(); ++i) {
|
||||
const QPersistentModelIndex &mi = (*i);
|
||||
if (mi.isValid() && !(mi.flags() & Qt::ItemNeverHasChildren))
|
||||
emit collapsed(mi);
|
||||
}
|
||||
doItemsLayout();
|
||||
}
|
||||
|
||||
|
@ -1637,8 +1637,7 @@ void tst_QTreeView::expandAndCollapseAll()
|
||||
for (int r = 0; r < rows; ++r)
|
||||
parents.push(model.index(r, 0, p));
|
||||
}
|
||||
// ### why is collapsed() signal not emitted?
|
||||
// QCOMPARE(collapsedSpy.count(), count);
|
||||
QCOMPARE(collapsedSpy.count(), 12);
|
||||
}
|
||||
|
||||
void tst_QTreeView::expandWithNoChildren()
|
||||
@ -4206,6 +4205,7 @@ void tst_QTreeView::taskQTBUG_8176_emitOnExpandAll()
|
||||
QTreeWidgetItem *item5 = new QTreeWidgetItem(&tw, QStringList(QString("item 5")));
|
||||
new QTreeWidgetItem(item5, QStringList(QString("item 6")));
|
||||
QSignalSpy spy(&tw, SIGNAL(expanded(const QModelIndex&)));
|
||||
|
||||
// expand all
|
||||
tw.expandAll();
|
||||
QCOMPARE(spy.size(), 6);
|
||||
@ -4215,6 +4215,16 @@ void tst_QTreeView::taskQTBUG_8176_emitOnExpandAll()
|
||||
spy.clear();
|
||||
tw.expandAll();
|
||||
QCOMPARE(spy.size(), 5);
|
||||
|
||||
// collapse all
|
||||
QSignalSpy spy2(&tw, SIGNAL(collapsed(const QModelIndex&)));
|
||||
tw.collapseAll();
|
||||
QCOMPARE(spy2.size(), 6);
|
||||
tw.expandAll();
|
||||
item2->setExpanded(false);
|
||||
spy2.clear();
|
||||
tw.collapseAll();
|
||||
QCOMPARE(spy2.size(), 5);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
|
Loading…
Reference in New Issue
Block a user