QIdentityProxyModel Class Reference
[QtGui module]
The QIdentityProxyModel class proxies its source model
unmodified More...
Inherits QAbstractProxyModel.
Methods
- __init__ (self, QObject parent = None)
- int columnCount (self, QModelIndex parent = QModelIndex())
- bool dropMimeData (self, QMimeData data, Qt.DropAction action, int row, int column, QModelIndex parent)
- QModelIndex index (self, int row, int column, QModelIndex parent = QModelIndex())
- bool insertColumns (self, int column, int count, QModelIndex parent = QModelIndex())
- bool insertRows (self, int row, int count, QModelIndex parent = QModelIndex())
- QModelIndex mapFromSource (self, QModelIndex sourceIndex)
- QItemSelection mapSelectionFromSource (self, QItemSelection selection)
- QItemSelection mapSelectionToSource (self, QItemSelection selection)
- QModelIndex mapToSource (self, QModelIndex proxyIndex)
- unknown-type match (self, QModelIndex start, int role, QVariant value, int hits = 1, Qt.MatchFlags flags = Qt.MatchStartsWith|Qt.MatchWrap)
- QModelIndex parent (self, QModelIndex child)
- bool removeColumns (self, int column, int count, QModelIndex parent = QModelIndex())
- bool removeRows (self, int row, int count, QModelIndex parent = QModelIndex())
- int rowCount (self, QModelIndex parent = QModelIndex())
- setSourceModel (self, QAbstractItemModel sourceModel)
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)
{
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;
};
Method Documentation
QIdentityProxyModel.__init__ (self, QObject parent = None)
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs an identity model with the given parent.
int QIdentityProxyModel.columnCount (self, QModelIndex parent = QModelIndex())
Reimplemented from QAbstractItemModel.columnCount().
bool QIdentityProxyModel.dropMimeData (self, QMimeData data, Qt.DropAction action, int row, int column, QModelIndex parent)
Reimplemented from QAbstractItemModel.dropMimeData().
QModelIndex QIdentityProxyModel.index (self, int row, int column, QModelIndex parent = QModelIndex())
Reimplemented from QAbstractItemModel.index().
bool QIdentityProxyModel.insertColumns (self, int column, int count, QModelIndex parent = QModelIndex())
Reimplemented from QAbstractItemModel.insertColumns().
bool QIdentityProxyModel.insertRows (self, int row, int count, QModelIndex parent = QModelIndex())
Reimplemented from QAbstractItemModel.insertRows().
QModelIndex QIdentityProxyModel.mapFromSource (self, QModelIndex sourceIndex)
Reimplemented from QAbstractProxyModel.mapFromSource().
QItemSelection QIdentityProxyModel.mapSelectionFromSource (self, QItemSelection selection)
Reimplemented from QAbstractProxyModel.mapSelectionFromSource().
QItemSelection QIdentityProxyModel.mapSelectionToSource (self, QItemSelection selection)
Reimplemented from QAbstractProxyModel.mapSelectionToSource().
QModelIndex QIdentityProxyModel.mapToSource (self, QModelIndex proxyIndex)
Reimplemented from QAbstractProxyModel.mapToSource().
unknown-type QIdentityProxyModel.match (self, QModelIndex start, int role, QVariant value, int hits = 1, Qt.MatchFlags flags = Qt.MatchStartsWith|Qt.MatchWrap)
Reimplemented from QAbstractItemModel.match().
Reimplemented from QAbstractItemModel.parent().
bool QIdentityProxyModel.removeColumns (self, int column, int count, QModelIndex parent = QModelIndex())
Reimplemented from QAbstractItemModel.removeColumns().
bool QIdentityProxyModel.removeRows (self, int row, int count, QModelIndex parent = QModelIndex())
Reimplemented from QAbstractItemModel.removeRows().
int QIdentityProxyModel.rowCount (self, QModelIndex parent = QModelIndex())
Reimplemented from QAbstractItemModel.rowCount().
QIdentityProxyModel.setSourceModel (self, QAbstractItemModel sourceModel)
Reimplemented from QAbstractProxyModel.setSourceModel().