summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-07-08 07:57:45 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-07-08 07:57:45 (GMT)
commit978e22d6529d7cbe9472749352d632eefd22cd07 (patch)
treeac92a4f489c0a93a48eb502457c679659e472ac0 /doc/src/snippets/code
parentcb11bb0df08f134bbded52fd4140197a01570a0e (diff)
parent1dd26ea2486db87b61e8e9f70a1e04f7386405ef (diff)
downloadQt-978e22d6529d7cbe9472749352d632eefd22cd07.zip
Qt-978e22d6529d7cbe9472749352d632eefd22cd07.tar.gz
Qt-978e22d6529d7cbe9472749352d632eefd22cd07.tar.bz2
Merge remote branch 'mainline/4.8' into staging
Conflicts: dist/changes-4.8.0
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]
+