Restore default role names in QStandardItemModel::roleNames()
Amends 32b586864e3a4398da38c045f4ac0823c3dc3c57, which added an override of QStandardItemModel::roleNames(). It's good for it to have its own QHash so that roles can be added, and because QStandardItemModel::setItemRoleNames() remains un-deprecated; but before that change, they were the roles that QAbstractItemModel had initialized from QAbstractItemModelPrivate::defaultRoleNames(). In particular, we need "display" to map to Qt::DisplayRole by default; several tests in qtdeclarative depend on that. Change-Id: I58b2d6aa6b6c78b1d618335ddc4ecb834af57274 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
7ec12b2902
commit
84e76c37a5
@ -442,6 +442,7 @@ void QStandardItemModelPrivate::init()
|
||||
Q_Q(QStandardItemModel);
|
||||
QObject::connect(q, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
|
||||
q, SLOT(_q_emitItemChanged(QModelIndex,QModelIndex)));
|
||||
roleNames = QAbstractItemModelPrivate::defaultRoleNames();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QTreeView>
|
||||
#include <private/qabstractitemmodel_p.h>
|
||||
#include <private/qtreeview_p.h>
|
||||
|
||||
class tst_QStandardItemModel : public QObject
|
||||
@ -126,6 +127,7 @@ private slots:
|
||||
#endif
|
||||
void removeRowsAndColumns();
|
||||
|
||||
void defaultItemRoles();
|
||||
void itemRoleNames();
|
||||
void getMimeDataWithInvalidModelIndex();
|
||||
void supportedDragDropActions();
|
||||
@ -1598,6 +1600,12 @@ void tst_QStandardItemModel::removeRowsAndColumns()
|
||||
VERIFY_MODEL
|
||||
}
|
||||
|
||||
void tst_QStandardItemModel::defaultItemRoles()
|
||||
{
|
||||
QStandardItemModel model;
|
||||
QCOMPARE(model.roleNames(), QAbstractItemModelPrivate::defaultRoleNames());
|
||||
}
|
||||
|
||||
void tst_QStandardItemModel::itemRoleNames()
|
||||
{
|
||||
QVector<QString> row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',').toVector();
|
||||
|
Loading…
x
Reference in New Issue
Block a user