From 15be8a6b259a5cb4f528b1c765bfcddfc9edd044 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 22 Jul 2009 13:19:52 +1000 Subject: Make setRoleNames() protected and improve docs. --- src/corelib/kernel/qabstractitemmodel.cpp | 10 +++++++++- src/corelib/kernel/qabstractitemmodel.h | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index aa99b47..6e1d5c4 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -1879,6 +1879,13 @@ QSize QAbstractItemModel::span(const QModelIndex &) const /*! Sets the model's role names to \a roleNames. + + This function is provided to allow mapping of role identifiers to + role property names in Declarative UI. This function must be called + before the model is used. Modifying the role names after the model + has been set may result in undefined behaviour. + + \sa roleNames() */ void QAbstractItemModel::setRoleNames(const QHash &roleNames) { @@ -1888,11 +1895,12 @@ void QAbstractItemModel::setRoleNames(const QHash &roleNames) /*! Returns the model's role names. + + \sa setRoleNames */ const QHash &QAbstractItemModel::roleNames() const { Q_D(const QAbstractItemModel); - qDebug() << "roles" << d->roleNames; return d->roleNames; } diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/kernel/qabstractitemmodel.h index 0a29af6..a6bbff4 100644 --- a/src/corelib/kernel/qabstractitemmodel.h +++ b/src/corelib/kernel/qabstractitemmodel.h @@ -220,7 +220,6 @@ public: Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const; virtual QSize span(const QModelIndex &index) const; - void setRoleNames(const QHash &roleNames); const QHash &roleNames() const; #ifdef Q_NO_USING_KEYWORD @@ -285,6 +284,8 @@ protected: void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to); QModelIndexList persistentIndexList() const; + void setRoleNames(const QHash &roleNames); + private: Q_DECLARE_PRIVATE(QAbstractItemModel) Q_DISABLE_COPY(QAbstractItemModel) -- cgit v0.12