
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQIdentityProxyModel class proxies its source model unmodifiedMore...
| Header: | #include <QIdentityProxyModel> |
| Since: | Qt 4.8 |
| Inherits: | QAbstractProxyModel |
| QIdentityProxyModel(QObject * parent = 0) | |
| ~QIdentityProxyModel() |
| virtual int | columnCount(const QModelIndex & parent = QModelIndex()) const |
| virtual bool | dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) |
| virtual QModelIndex | index(int row, int column, const QModelIndex & parent = QModelIndex()) const |
| virtual bool | insertColumns(int column, int count, const QModelIndex & parent = QModelIndex()) |
| virtual bool | insertRows(int row, int count, const QModelIndex & parent = QModelIndex()) |
| virtual QModelIndex | mapFromSource(const QModelIndex & sourceIndex) const |
| virtual QItemSelection | mapSelectionFromSource(const QItemSelection & selection) const |
| virtual QItemSelection | mapSelectionToSource(const QItemSelection & selection) const |
| virtual QModelIndex | mapToSource(const QModelIndex & proxyIndex) const |
| virtual QModelIndexList | match(const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap )) const |
| virtual QModelIndex | parent(const QModelIndex & child) const |
| virtual bool | removeColumns(int column, int count, const QModelIndex & parent = QModelIndex()) |
| virtual bool | removeRows(int row, int count, const QModelIndex & parent = QModelIndex()) |
| virtual int | rowCount(const QModelIndex & parent = QModelIndex()) const |
| virtual void | setSourceModel(QAbstractItemModel * newSourceModel) |
TheQIdentityProxyModel class proxies its source model unmodified
QIdentityProxyModel can be used to forward the structure of a source model exactly, with no sorting, filtering or other transformation. This is similar in concept to an identity matrix where A.I = A.
Because it does no sorting or filtering, this class is most suitable to proxy models which transform thedata() of the source model. For example, a proxy model could be created to define the font used, or the background colour, or the tooltip etc. This removes the need to implement all data handling in the same class that creates the structure of the model, and can also be used to create re-usable components.
This also provides a way to change the data in the case where a source model is supplied by a third party which can not be modified.
class DateFormatProxyModel :publicQIdentityProxyModel{// ...void setDateFormatString(constQString&formatString) { m_formatString= formatString; }QVariant data(constQModelIndex&index,int role) {if (role!=Qt::DisplayRole)returnQIdentityProxyModel::data(index, role);constQDateTime dateTime= sourceModel()->data(SourceClass::DateRole).toDateTime();return dateTime.toString(m_formatString); }private:QString m_formatString;};
See alsoQAbstractProxyModel,Model/View Programming, andQAbstractItemModel.
Constructs an identity model with the givenparent.
Destroys this identity model.
[virtual]int QIdentityProxyModel::columnCount(constQModelIndex & parent = QModelIndex()) constReimplemented fromQAbstractItemModel::columnCount().
[virtual]bool QIdentityProxyModel::dropMimeData(constQMimeData * data,Qt::DropAction action,int row,int column, constQModelIndex & parent)Reimplemented fromQAbstractItemModel::dropMimeData().
[virtual]QModelIndex QIdentityProxyModel::index(int row,int column, constQModelIndex & parent = QModelIndex()) constReimplemented fromQAbstractItemModel::index().
[virtual]bool QIdentityProxyModel::insertColumns(int column,int count, constQModelIndex & parent = QModelIndex())Reimplemented fromQAbstractItemModel::insertColumns().
[virtual]bool QIdentityProxyModel::insertRows(int row,int count, constQModelIndex & parent = QModelIndex())Reimplemented fromQAbstractItemModel::insertRows().
[virtual]QModelIndex QIdentityProxyModel::mapFromSource(constQModelIndex & sourceIndex) constReimplemented fromQAbstractProxyModel::mapFromSource().
[virtual]QItemSelection QIdentityProxyModel::mapSelectionFromSource(constQItemSelection & selection) constReimplemented fromQAbstractProxyModel::mapSelectionFromSource().
[virtual]QItemSelection QIdentityProxyModel::mapSelectionToSource(constQItemSelection & selection) constReimplemented fromQAbstractProxyModel::mapSelectionToSource().
[virtual]QModelIndex QIdentityProxyModel::mapToSource(constQModelIndex & proxyIndex) constReimplemented fromQAbstractProxyModel::mapToSource().
[virtual]QModelIndexList QIdentityProxyModel::match(constQModelIndex & start,int role, constQVariant & value,int hits = 1,Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap )) constReimplemented fromQAbstractItemModel::match().
[virtual]QModelIndex QIdentityProxyModel::parent(constQModelIndex & child) constReimplemented fromQAbstractItemModel::parent().
[virtual]bool QIdentityProxyModel::removeColumns(int column,int count, constQModelIndex & parent = QModelIndex())Reimplemented fromQAbstractItemModel::removeColumns().
[virtual]bool QIdentityProxyModel::removeRows(int row,int count, constQModelIndex & parent = QModelIndex())Reimplemented fromQAbstractItemModel::removeRows().
[virtual]int QIdentityProxyModel::rowCount(constQModelIndex & parent = QModelIndex()) constReimplemented fromQAbstractItemModel::rowCount().
[virtual]void QIdentityProxyModel::setSourceModel(QAbstractItemModel * newSourceModel)Reimplemented fromQAbstractProxyModel::setSourceModel().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.