QIdentityProxyModel Class
The QIdentityProxyModel class proxies its source model unmodified. More…
| Header | #include <QIdentityProxyModel> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
| Since | 4.8 |
| Inherits | QAbstractProxyModel |
List of all members, including inherited members
Public Functions
| QIdentityProxyModel(QObject *parent = nullptr) | |
| ~QIdentityProxyModel() |
Reimplemented Public Functions
| int | columnCount(const QModelIndex &parent = QModelIndex()) const |
| QModelIndex | index(int row, int column, const QModelIndex &parent = QModelIndex()) const |
| QModelIndex | mapFromSource(const QModelIndex &sourceIndex) const |
| QModelIndex | mapToSource(const QModelIndex &proxyIndex) const |
| QModelIndex | parent(const QModelIndex &child) const |
| int | rowCount(const QModelIndex &parent = QModelIndex()) const |
| QVariant | headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const |
| QModelIndex | sibling(int row, int column, const QModelIndex &idx) const |
| QItemSelection | mapSelectionFromSource(const QItemSelection &selection) const |
| QItemSelection | mapSelectionToSource(const QItemSelection &selection) const |
| QModelIndexList | match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap)) const |
| void | setSourceModel(QAbstractItemModel *sourceModel) |
| bool | insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) |
| bool | insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) |
| bool | removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) |
| bool | removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) |
| bool | moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) |
| bool | moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) |
Detailed Description
A QIdentityProxyModel presents the source model's structure unchanged: each proxy index corresponds to the source index at the same row and column. It is the base for proxies that change only the data, by reimplementing data():
class UpperCase : public QIdentityProxyModel
{
public:
QVariant data(const QModelIndex &index, int role) const override
{
const QVariant v = QIdentityProxyModel::data(index, role);
return role == Qt::DisplayRole ? QVariant(v.toString().toUpper()) : v;
}
};
See also QAbstractProxyModel and QSortFilterProxyModel.
Differences from Qt
There are no handleSourceLayoutChanges() and handleSourceDataChanges() settings; changes are always forwarded.
Member Function Documentation
QIdentityProxyModel::QIdentityProxyModel(QObject *parent = nullptr)
Constructs an identity proxy with the given parent.
QIdentityProxyModel::~QIdentityProxyModel()
Destroys the proxy.
int QIdentityProxyModel::columnCount(const QModelIndex &parent = QModelIndex()) const
Reimplements QAbstractProxyModel::columnCount().
Returns the number of columns of the source under parent.
QVariant QIdentityProxyModel::headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
Reimplements QAbstractProxyModel::headerData().
Returns the source header data of section in orientation for role.
QModelIndex QIdentityProxyModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const
Reimplements QAbstractProxyModel::index().
Returns the proxy index for row and column under parent.
bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex &parent = QModelIndex())
Reimplements QAbstractProxyModel::insertColumns().
Inserts count columns before column under parent in the source.
bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex &parent = QModelIndex())
Reimplements QAbstractProxyModel::insertRows().
Inserts count rows before row under parent in the source.
QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
Reimplements QAbstractProxyModel::mapFromSource().
Returns the proxy index at the same position as sourceIndex.
QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection &selection) const
Reimplements QAbstractProxyModel::mapSelectionFromSource().
Returns selection mapped from the source, range by range.
QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection &selection) const
Reimplements QAbstractProxyModel::mapSelectionToSource().
Returns selection mapped to the source, range by range.
QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex &proxyIndex) const
Reimplements QAbstractProxyModel::mapToSource().
Returns the source index at the same position as proxyIndex.
QModelIndexList QIdentityProxyModel::match(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap)) const
Reimplements QAbstractProxyModel::match().
Searches the source for items matching value under role from start, with hits and flags as for QAbstractItemModel::match(), and returns the proxy indexes of the matches.
bool QIdentityProxyModel::moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild)
Reimplements QAbstractProxyModel::moveColumns().
Moves count columns from sourceColumn under sourceParent to before destinationChild under destinationParent in the source.
bool QIdentityProxyModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
Reimplements QAbstractProxyModel::moveRows().
Moves count rows from sourceRow under sourceParent to before destinationChild under destinationParent in the source.
QModelIndex QIdentityProxyModel::parent(const QModelIndex &child) const
Reimplements QAbstractProxyModel::parent().
Returns the parent of child.
bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex &parent = QModelIndex())
Reimplements QAbstractProxyModel::removeColumns().
Removes count columns from column under parent in the source.
bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex())
Reimplements QAbstractProxyModel::removeRows().
Removes count rows from row under parent in the source.
int QIdentityProxyModel::rowCount(const QModelIndex &parent = QModelIndex()) const
Reimplements QAbstractProxyModel::rowCount().
Returns the number of rows of the source under parent.
void QIdentityProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
Reimplements QAbstractProxyModel::setSourceModel().
Sets the source model to sourceModel, resetting the proxy, and forwards the changes of the source from then on.
QModelIndex QIdentityProxyModel::sibling(int row, int column, const QModelIndex &idx) const
Reimplements QAbstractProxyModel::sibling().
Returns the index at row and column next to idx.