summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code
diff options
context:
space:
mode:
authorSami Lempinen <sami.lempinen@nokia.com>2011-07-05 07:10:56 (GMT)
committerSami Lempinen <sami.lempinen@nokia.com>2011-07-05 07:10:56 (GMT)
commit89260bad8fddcbbfe54b3c5238ef370a620ab9e6 (patch)
tree31aac7993c1b06634e83e802a16fb1be87615c10 /doc/src/snippets/code
parentbad513727833e207f7f8ca0d7c07c44c1addfb57 (diff)
parent601b12b7879e9a743ef9e516470219aae73e611d (diff)
downloadQt-89260bad8fddcbbfe54b3c5238ef370a620ab9e6.zip
Qt-89260bad8fddcbbfe54b3c5238ef370a620ab9e6.tar.gz
Qt-89260bad8fddcbbfe54b3c5238ef370a620ab9e6.tar.bz2
Merge remote-tracking branch 'qt/4.8'
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]
+