summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@nokia.com>2011-07-08 11:17:37 (GMT)
committerJerome Pasion <jerome.pasion@nokia.com>2011-07-08 11:17:37 (GMT)
commitf037c0e87d186a01f07cb9aa360dcc496d11145e (patch)
tree9449cc65b856b4743e933cf2b8ae1cb2f85ba9fd /doc/src/snippets/code
parent5016de08d84c4d2887f7424dbf17f31e27c2e8e2 (diff)
parent1dd26ea2486db87b61e8e9f70a1e04f7386405ef (diff)
downloadQt-f037c0e87d186a01f07cb9aa360dcc496d11145e.zip
Qt-f037c0e87d186a01f07cb9aa360dcc496d11145e.tar.gz
Qt-f037c0e87d186a01f07cb9aa360dcc496d11145e.tar.bz2
Merge remote branch 'upstream/4.8'
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]
+