6.0.0-rc4Source

QIdentityProxyModel Class

The QIdentityProxyModel class proxies its source model unmodified. More…

Header#include <QIdentityProxyModel>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes
Since4.8
InheritsQAbstractProxyModel

List of all members, including inherited members

Public Functions

Reimplemented Public Functions

intcolumnCount(const QModelIndex &parent = QModelIndex()) const
QModelIndexindex(int row, int column, const QModelIndex &parent = QModelIndex()) const
QModelIndexmapFromSource(const QModelIndex &sourceIndex) const
QModelIndexmapToSource(const QModelIndex &proxyIndex) const
QModelIndexparent(const QModelIndex &child) const
introwCount(const QModelIndex &parent = QModelIndex()) const
QVariantheaderData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
QModelIndexsibling(int row, int column, const QModelIndex &idx) const
QItemSelectionmapSelectionFromSource(const QItemSelection &selection) const
QItemSelectionmapSelectionToSource(const QItemSelection &selection) const
QModelIndexListmatch(const QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap)) const
voidsetSourceModel(QAbstractItemModel *sourceModel)
boolinsertColumns(int column, int count, const QModelIndex &parent = QModelIndex())
boolinsertRows(int row, int count, const QModelIndex &parent = QModelIndex())
boolremoveColumns(int column, int count, const QModelIndex &parent = QModelIndex())
boolremoveRows(int row, int count, const QModelIndex &parent = QModelIndex())
boolmoveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
boolmoveColumns(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

[explicit] QIdentityProxyModel::QIdentityProxyModel(QObject *parent = nullptr)

Constructs an identity proxy with the given parent.

[override] QIdentityProxyModel::~QIdentityProxyModel()

Destroys the proxy.

[override] int QIdentityProxyModel::columnCount(const QModelIndex &parent = QModelIndex()) const

Reimplements QAbstractProxyModel::columnCount().

Returns the number of columns of the source under parent.

[override] 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.

[override] 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.

[override] bool QIdentityProxyModel::insertColumns(int column, int count, const QModelIndex &parent = QModelIndex())

Reimplements QAbstractProxyModel::insertColumns().

Inserts count columns before column under parent in the source.

[override] bool QIdentityProxyModel::insertRows(int row, int count, const QModelIndex &parent = QModelIndex())

Reimplements QAbstractProxyModel::insertRows().

Inserts count rows before row under parent in the source.

[override] QModelIndex QIdentityProxyModel::mapFromSource(const QModelIndex &sourceIndex) const

Reimplements QAbstractProxyModel::mapFromSource().

Returns the proxy index at the same position as sourceIndex.

[override] QItemSelection QIdentityProxyModel::mapSelectionFromSource(const QItemSelection &selection) const

Reimplements QAbstractProxyModel::mapSelectionFromSource().

Returns selection mapped from the source, range by range.

[override] QItemSelection QIdentityProxyModel::mapSelectionToSource(const QItemSelection &selection) const

Reimplements QAbstractProxyModel::mapSelectionToSource().

Returns selection mapped to the source, range by range.

[override] QModelIndex QIdentityProxyModel::mapToSource(const QModelIndex &proxyIndex) const

Reimplements QAbstractProxyModel::mapToSource().

Returns the source index at the same position as proxyIndex.

[override] 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.

[override] 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.

[override] 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.

[override] QModelIndex QIdentityProxyModel::parent(const QModelIndex &child) const

Reimplements QAbstractProxyModel::parent().

Returns the parent of child.

[override] bool QIdentityProxyModel::removeColumns(int column, int count, const QModelIndex &parent = QModelIndex())

Reimplements QAbstractProxyModel::removeColumns().

Removes count columns from column under parent in the source.

[override] bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex())

Reimplements QAbstractProxyModel::removeRows().

Removes count rows from row under parent in the source.

[override] int QIdentityProxyModel::rowCount(const QModelIndex &parent = QModelIndex()) const

Reimplements QAbstractProxyModel::rowCount().

Returns the number of rows of the source under parent.

[override] 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.

[override] QModelIndex QIdentityProxyModel::sibling(int row, int column, const QModelIndex &idx) const

Reimplements QAbstractProxyModel::sibling().

Returns the index at row and column next to idx.