From cf52c268b036d808901313acc554587465bdd746 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Mon, 30 Jan 2012 11:04:07 +1000 Subject: Add public role names setter to QStandardItemModel This allows QStandardItemModel to be usable in QML without requiring clients to subclass it. Task-number: QTBUG-15067 Change-Id: I867fcd8137132affdf21f37a9fa293e855a09a13 Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qstandarditemmodel.cpp | 9 +++++++++ src/widgets/itemviews/qstandarditemmodel.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/widgets/itemviews/qstandarditemmodel.cpp b/src/widgets/itemviews/qstandarditemmodel.cpp index 0fa82cbd42..112b533f4f 100644 --- a/src/widgets/itemviews/qstandarditemmodel.cpp +++ b/src/widgets/itemviews/qstandarditemmodel.cpp @@ -2079,6 +2079,15 @@ QStandardItemModel::~QStandardItemModel() { } +/*! + Sets the item role names to \a roleNames. +*/ +void QStandardItemModel::setItemRoleNames(const QHash &roleNames) +{ + Q_D(QStandardItemModel); + d->roleNames = roleNames; +} + /*! Removes all items (including header items) from the model and sets the number of rows and columns to zero. diff --git a/src/widgets/itemviews/qstandarditemmodel.h b/src/widgets/itemviews/qstandarditemmodel.h index 10a44ffe39..e374665f20 100644 --- a/src/widgets/itemviews/qstandarditemmodel.h +++ b/src/widgets/itemviews/qstandarditemmodel.h @@ -324,6 +324,8 @@ public: QStandardItemModel(int rows, int columns, QObject *parent = 0); ~QStandardItemModel(); + void setItemRoleNames(const QHash &roleNames); + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; QModelIndex parent(const QModelIndex &child) const; -- cgit v1.2.3