diff options
| author | Jiang Jiang <jiang.jiang@nokia.com> | 2011-07-07 06:59:55 (GMT) |
|---|---|---|
| committer | Jiang Jiang <jiang.jiang@nokia.com> | 2011-07-07 06:59:55 (GMT) |
| commit | b2799a705b6d7655bb23ec4121fd76ce8a94b344 (patch) | |
| tree | db7e2a482ca35a40ca7cfb4f4999ec15396a8b55 /doc/src/snippets/code | |
| parent | 6415e22649dd8620728c8c32b918c7afb8efc4dc (diff) | |
| parent | e6843c5a9cf4949e7521c1304bb5dc5d48fbc9be (diff) | |
| download | Qt-b2799a705b6d7655bb23ec4121fd76ce8a94b344.zip Qt-b2799a705b6d7655bb23ec4121fd76ce8a94b344.tar.gz Qt-b2799a705b6d7655bb23ec4121fd76ce8a94b344.tar.bz2 | |
Merge remote branch 'mainline/4.8'
Conflicts:
dist/changes-4.8.0
Diffstat (limited to 'doc/src/snippets/code')
| -rw-r--r-- | doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp | 35 |
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] + |
