summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qabstractitemmodel.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-30 02:05:11 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-31 01:23:42 (GMT)
commitc257996dfdc87b9a9682d35419792730e477d3ac (patch)
tree20f0af6513585089cbae6667fea62f6c9576a052 /src/corelib/kernel/qabstractitemmodel.cpp
parent13e3bbf2c46077f2b970bc6c0bc9850112b81cb7 (diff)
downloadQt-c257996dfdc87b9a9682d35419792730e477d3ac.zip
Qt-c257996dfdc87b9a9682d35419792730e477d3ac.tar.gz
Qt-c257996dfdc87b9a9682d35419792730e477d3ac.tar.bz2
Make setRoleNames() protected and improve docs.
(cherry picked from commit 15be8a6b259a5cb4f528b1c765bfcddfc9edd044) Authored-by: Martin Jones Reviewed-by: mbm
Diffstat (limited to 'src/corelib/kernel/qabstractitemmodel.cpp')
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index 3d9263e..cd17076 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -467,6 +467,21 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel()
return qEmptyModel();
}
+const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames()
+{
+ static QHash<int,QByteArray> roleNames;
+ if (roleNames.isEmpty()) {
+ roleNames[Qt::DisplayRole] = "display";
+ roleNames[Qt::DecorationRole] = "decoration";
+ roleNames[Qt::EditRole] = "edit";
+ roleNames[Qt::ToolTipRole] = "toolTip";
+ roleNames[Qt::StatusTipRole] = "statusTip";
+ roleNames[Qt::WhatsThisRole] = "whatsThis";
+ }
+
+ return roleNames;
+}
+
/*!
\internal
return true if \a value contains a numerical type
@@ -1863,6 +1878,33 @@ 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<int,QByteArray> &roleNames)
+{
+ Q_D(QAbstractItemModel);
+ d->roleNames = roleNames;
+}
+
+/*!
+ Returns the model's role names.
+
+ \sa setRoleNames
+*/
+const QHash<int,QByteArray> &QAbstractItemModel::roleNames() const
+{
+ Q_D(const QAbstractItemModel);
+ return d->roleNames;
+}
+
+/*!
Called to let the model know that it should submit whatever it has cached
to the permanent storage. Typically used for row editing.