summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@nokia.com>2011-07-08 11:56:47 (GMT)
committerJerome Pasion <jerome.pasion@nokia.com>2011-07-08 11:56:47 (GMT)
commit93ae002230888e98b4e95834f5e5eb9600f05f18 (patch)
tree9449cc65b856b4743e933cf2b8ae1cb2f85ba9fd /doc/src/snippets/code
parent8b89d0aa973c52b44112f10c9fbd9701b17bb333 (diff)
parent1dd26ea2486db87b61e8e9f70a1e04f7386405ef (diff)
downloadQt-93ae002230888e98b4e95834f5e5eb9600f05f18.zip
Qt-93ae002230888e98b4e95834f5e5eb9600f05f18.tar.gz
Qt-93ae002230888e98b4e95834f5e5eb9600f05f18.tar.bz2
Merge branch '4.8' of scm.dev.nokia.troll.no:qt/qt
Conflicts: doc/src/external-resources.qdoc
Diffstat (limited to 'doc/src/snippets/code')
-rw-r--r--doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp b/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
index 5919c01..cf40f9a 100644
--- a/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
+++ b/doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp
@@ -86,3 +86,38 @@ beginMoveRows(parent, 2, 2, parent, 0);
//! [9]
beginMoveRows(parent, 2, 2, parent, 4);
//! [9]
+
+
+//! [10]
+class CustomDataProxy : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ CustomDataProxy(QObject *parent)
+ : QSortFilterProxyModel(parent)
+ {
+ }
+
+ ...
+
+ QVariant data(const QModelIndex &index, int role)
+ {
+ if (role != Qt::BackgroundRole)
+ return QSortFilterProxyModel::data(index, role);
+
+ if (m_customData.contains(index.row()))
+ return m_customData.value(index.row());
+ return QSortFilterProxyModel::data(index, role);
+ }
+
+private slots:
+ void resetInternalData()
+ {
+ m_customData.clear();
+ }
+
+private:
+ QHash<int, QVariant> m_customData;
+};
+//! [10]
+