QTreeView - emit expanded on expandAll
When we call QTreeView::expand expanded is emitted. For the same reason we should emit expanded on expandAll() This partly solves: Task-number: QTBUG-8176 Change-Id: Ie85e724eec50980c68f626ec47dec5c1e08cc085 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
508bbe9507
commit
80fa4b6c8e
@ -3194,8 +3194,8 @@ void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninit
|
|||||||
item->total = 0;
|
item->total = 0;
|
||||||
item->hasMoreSiblings = false;
|
item->hasMoreSiblings = false;
|
||||||
if ((recursiveExpanding && !(current.flags() & Qt::ItemNeverHasChildren)) || isIndexExpanded(current)) {
|
if ((recursiveExpanding && !(current.flags() & Qt::ItemNeverHasChildren)) || isIndexExpanded(current)) {
|
||||||
if (recursiveExpanding)
|
if (recursiveExpanding && storeExpanded(current))
|
||||||
expandedIndexes.insert(current);
|
emit q->expanded(current);
|
||||||
item->expanded = true;
|
item->expanded = true;
|
||||||
layout(last, recursiveExpanding, afterIsUninitialized);
|
layout(last, recursiveExpanding, afterIsUninitialized);
|
||||||
item = &viewItems[last];
|
item = &viewItems[last];
|
||||||
|
@ -257,6 +257,7 @@ private slots:
|
|||||||
void taskQTBUG_13567_removeLastItemRegression();
|
void taskQTBUG_13567_removeLastItemRegression();
|
||||||
void taskQTBUG_25333_adjustViewOptionsForIndex();
|
void taskQTBUG_25333_adjustViewOptionsForIndex();
|
||||||
void taskQTBUG_18539_emitLayoutChanged();
|
void taskQTBUG_18539_emitLayoutChanged();
|
||||||
|
void taskQTBUG_8176_emitOnExpandAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
class QtTestModel: public QAbstractItemModel
|
class QtTestModel: public QAbstractItemModel
|
||||||
@ -1621,13 +1622,10 @@ void tst_QTreeView::expandAndCollapseAll()
|
|||||||
for (int r = 0; r < rows; ++r)
|
for (int r = 0; r < rows; ++r)
|
||||||
parents.push(model.index(r, 0, p));
|
parents.push(model.index(r, 0, p));
|
||||||
}
|
}
|
||||||
// ### why is expanded() signal not emitted?
|
QCOMPARE(expandedSpy.count(), 12); // == (3+1)*(2+1) from QtTestModel model(3, 2);
|
||||||
// QCOMPARE(expandedSpy.count(), count);
|
|
||||||
|
|
||||||
view.collapseAll();
|
view.collapseAll();
|
||||||
|
|
||||||
QCOMPARE(expandedSpy.count(), 0);
|
|
||||||
|
|
||||||
parents.push(QModelIndex());
|
parents.push(QModelIndex());
|
||||||
count = 0;
|
count = 0;
|
||||||
while (!parents.isEmpty()) {
|
while (!parents.isEmpty()) {
|
||||||
@ -4198,6 +4196,27 @@ void tst_QTreeView::taskQTBUG_18539_emitLayoutChanged()
|
|||||||
QCOMPARE(afterRISpy.size(), 0);
|
QCOMPARE(afterRISpy.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QTreeView::taskQTBUG_8176_emitOnExpandAll()
|
||||||
|
{
|
||||||
|
QTreeWidget tw;
|
||||||
|
QTreeWidgetItem *item = new QTreeWidgetItem(&tw, QStringList(QString("item 1")));
|
||||||
|
QTreeWidgetItem *item2 = new QTreeWidgetItem(item, QStringList(QString("item 2")));
|
||||||
|
new QTreeWidgetItem(item2, QStringList(QString("item 3")));
|
||||||
|
new QTreeWidgetItem(item2, QStringList(QString("item 4")));
|
||||||
|
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);
|
||||||
|
spy.clear();
|
||||||
|
tw.collapseAll();
|
||||||
|
item2->setExpanded(true);
|
||||||
|
spy.clear();
|
||||||
|
tw.expandAll();
|
||||||
|
QCOMPARE(spy.size(), 5);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_ANIMATION
|
#ifndef QT_NO_ANIMATION
|
||||||
void tst_QTreeView::quickExpandCollapse()
|
void tst_QTreeView::quickExpandCollapse()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user