summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels/qabstractitemmodel.h
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2011-12-27 17:02:33 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-10 11:37:28 +0100
commitc3ad8c1c062a972b7fb75d8b51a1f80cb371d503 (patch)
tree47bd4f0b698a16a7a475c19e7c3c9acab60f0ba5 /src/corelib/itemmodels/qabstractitemmodel.h
parent1e10e4deb97885472c36f5b10a5888979f24cee0 (diff)
Make the roleNames a virtual accessor.
This is consistent with the rest of the API of QAbstractItemModel (which is virtual) and removes the need for code like this in the constructor (where it doesn't belong): QHash<int, QByteArray> myRoleNames = roleNames(); myRoleNames.insert(Qt::UserRole + 1, "myCustomRole"); setRoleNames(myRoleNames); in favor of MyModel::roleNames() const { QHash<int, QByteArray> myRoleNames = QAbstractItemModel::roleNames(); myRoleNames.insert(Qt::UserRole + 1, "myCustomRole"); return myRoleNames; } which is consistent with all other QAIM API (eg, flags()). This is a source compatible change. Change-Id: I7e1ce17f8dab2292c4c7b6dbd3c09ec71b5c793b Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Marius Bugge Monsen <marius@cutehacks.com>
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.h')
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 0ac297e57b..8c9615f7cb 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -222,7 +222,7 @@ public:
Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
virtual QSize span(const QModelIndex &index) const;
- const QHash<int,QByteArray> &roleNames() const;
+ virtual QHash<int,QByteArray> roleNames() const;
#ifdef Q_NO_USING_KEYWORD
inline QObject *parent() const { return QObject::parent(); }
@@ -302,9 +302,16 @@ protected:
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to);
QModelIndexList persistentIndexList() const;
- void setRoleNames(const QHash<int,QByteArray> &roleNames);
+#if QT_DEPRECATED_SINCE(5,0)
+ QT_DEPRECATED void setRoleNames(const QHash<int,QByteArray> &roleNames)
+ {
+ doSetRoleNames(roleNames);
+ }
+#endif
private:
+ void doSetRoleNames(const QHash<int,QByteArray> &roleNames);
+
Q_DECLARE_PRIVATE(QAbstractItemModel)
Q_DISABLE_COPY(QAbstractItemModel)
};