QStandardItemModel: Reset the flags on clear()
Pass modeltest after clear(). Otherwise it fails because more flags than Qt::ItemIsDropEnabled get returned for the QModelIndex(). Change-Id: I8f11515cc7dc9383f528f785312ffb77b3c2699d Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
a44d7862c8
commit
bfeb2fdd79
@ -2168,6 +2168,7 @@ void QStandardItemModel::clear()
|
||||
Q_D(QStandardItemModel);
|
||||
beginResetModel();
|
||||
d->root.reset(new QStandardItem);
|
||||
d->root->setFlags(Qt::ItemIsDropEnabled);
|
||||
d->root->d_func()->setModel(this);
|
||||
qDeleteAll(d->columnHeaderItems);
|
||||
d->columnHeaderItems.clear();
|
||||
|
@ -4,6 +4,10 @@ TARGET = tst_qstandarditemmodel
|
||||
QT += widgets widgets-private testlib
|
||||
QT += core-private gui-private
|
||||
|
||||
SOURCES += tst_qstandarditemmodel.cpp
|
||||
mtdir = ../../../other/modeltest
|
||||
|
||||
INCLUDEPATH += $${mtdir}
|
||||
|
||||
SOURCES += $${mtdir}/modeltest.cpp tst_qstandarditemmodel.cpp
|
||||
HEADERS += $${mtdir}/modeltest.h
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <qstandarditemmodel.h>
|
||||
#include <QTreeView>
|
||||
#include <private/qtreeview_p.h>
|
||||
#include "modeltest.h"
|
||||
|
||||
class tst_QStandardItemModel : public QObject
|
||||
{
|
||||
@ -734,6 +735,9 @@ void tst_QStandardItemModel::clear()
|
||||
QSignalSpy modelResetSpy(&model, SIGNAL(modelReset()));
|
||||
QSignalSpy layoutChangedSpy(&model, SIGNAL(layoutChanged()));
|
||||
QSignalSpy rowsRemovedSpy(&model, SIGNAL(rowsRemoved(QModelIndex,int,int)));
|
||||
|
||||
ModelTest mt(&model);
|
||||
|
||||
model.clear();
|
||||
|
||||
QCOMPARE(modelResetSpy.count(), 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user