QIdentityProxyModel Class
The QIdentityProxyModel class proxies its source model unmodified. More...
Header: | #include <QIdentityProxyModel> |
qmake: | QT += core |
Since: | Qt 4.8 |
Inherits: | QAbstractProxyModel |
Public Functions
QIdentityProxyModel(QObject *parent = nullptr) | |
virtual | ~QIdentityProxyModel() |
Reimplemented Public Functions
virtual int | columnCount(const QModelIndex &parent = QModelIndex()) const override |
virtual bool | dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
virtual QVariant | headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override |
virtual QModelIndex | index(int row, int column, const QModelIndex &parent = QModelIndex()) const override |
virtual bool | insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override |
virtual bool | insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override |
virtual QModelIndex | mapFromSource(const QModelIndex &sourceIndex) const override |
virtual QItemSelection | mapSelectionFromSource(const QItemSelection &selection) const override |
virtual QItemSelection | mapSelectionToSource(const QItemSelection &selection) const override |
virtual QModelIndex | mapToSource(const QModelIndex &proxyIndex) const override |
virtual QModelIndexList | match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const override |
virtual QModelIndex | parent(const QModelIndex &child) const override |
virtual bool | removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override |
virtual bool | removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override |
virtual int | rowCount(const QModelIndex &parent = QModelIndex()) const override |
virtual void | setSourceModel(QAbstractItemModel *newSourceModel) override |
virtual QModelIndex | sibling(int row, int column, const QModelIndex &idx) const override |
- 28 public functions inherited from QAbstractProxyModel
- 40 public functions inherited from QAbstractItemModel
- 32 public functions inherited from QObject
Static Public Members
const QMetaObject | staticMetaObject |
- 10 static public members inherited from QObject
Additional Inherited Members
- 1 property inherited from QAbstractProxyModel
- 1 property inherited from QObject
- 2 public slots inherited from QAbstractItemModel
- 1 public slot inherited from QObject
- 1 signal inherited from QAbstractProxyModel
- 18 signals inherited from QAbstractItemModel
- 2 signals inherited from QObject
- 19 protected functions inherited from QAbstractItemModel
- 9 protected functions inherited from QObject
- 1 protected slot inherited from QAbstractProxyModel
- 1 protected slot inherited from QAbstractItemModel
Detailed Description
The QIdentityProxyModel 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 the data() 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 : public QIdentityProxyModel { // ... void setDateFormatString(const QString &formatString) { m_formatString = formatString; } QVariant data(const QModelIndex &index, int role) const override { if (role != Qt::DisplayRole) return QIdentityProxyModel::data(index, role); const QDateTime dateTime = sourceModel()->data(SourceClass::DateRole).toDateTime(); return dateTime.toString(m_formatString); } private: QString m_formatString; };
See also QAbstractProxyModel, Model/View Programming, and QAbstractItemModel.
Member Function Documentation
QIdentityProxyModel::QIdentityProxyModel(QObject *parent = nullptr)
Constructs an identity model with the given parent.
[virtual]
QIdentityProxyModel::~QIdentityProxyModel()
Destroys this identity model.
[override virtual]
int QIdentityProxyModel::columnCount(const QModelIndex &parent = QModelIndex()) const
Reimplemented from QAbstractItemModel::columnCount().
[override virtual]
bool QIdentityProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplemented from QAbstractProxyModel::dropMimeData().
[override virtual]
QVariant QIdentityProxyModel::headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
Reimplemented from QAbstractProxyModel::headerData().
[override virtual]
QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const
Reimplemented from QAbstractItemModel::index().
[override virtual]
bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex &parent = QModelIndex())
Reimplemented from QAbstractItemModel::insertColumns().
[override virtual]
bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex &parent = QModelIndex())
Reimplemented from QAbstractItemModel::insertRows().
[override virtual]
QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
Reimplemented from QAbstractProxyModel::mapFromSource().
[override virtual]
QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection &selection) const
Reimplemented from QAbstractProxyModel::mapSelectionFromSource().
[override virtual]
QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection &selection) const
Reimplemented from QAbstractProxyModel::mapSelectionToSource().
[override virtual]
QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex &proxyIndex) const
Reimplemented from QAbstractProxyModel::mapToSource().
[override virtual]
QModelIndexList QIdentityProxyModel::match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const
Reimplemented from QAbstractItemModel::match().
[override virtual]
QModelIndex QIdentityProxyModel::parent(const QModelIndex &child) const
Reimplemented from QAbstractItemModel::parent().
[override virtual]
bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex &parent = QModelIndex())
Reimplemented from QAbstractItemModel::removeColumns().
[override virtual]
bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex())
Reimplemented from QAbstractItemModel::removeRows().
[override virtual]
int QIdentityProxyModel::rowCount(const QModelIndex &parent = QModelIndex()) const
Reimplemented from QAbstractItemModel::rowCount().
[override virtual]
void QIdentityProxyModel::setSourceModel(QAbstractItemModel *newSourceModel)
Reimplemented from QAbstractProxyModel::setSourceModel().
[override virtual]
QModelIndex QIdentityProxyModel::sibling(int row, int column, const QModelIndex &idx) const
Reimplemented from QAbstractProxyModel::sibling().
© 2021 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 the GNU 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.