From 84e76c37a5fb040e63f1eabf2fb7010d782a7106 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 10 Jun 2020 17:18:59 +0200 Subject: 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 --- .../gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index 65c99d34b5..04a3fe7a62 100644 --- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -31,6 +31,7 @@ #include #include +#include #include 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 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(); -- cgit v1.2.3