QConcatenateTablesProxyModel Class
The QConcatenateTablesProxyModel class proxies multiple source models, concatenating their rows. More…
| Header | #include <QConcatenateTablesProxyModel> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
| Since | 5.13 |
| Inherits | QAbstractItemModel |
List of all members, including inherited members
Public Functions
| QConcatenateTablesProxyModel(QObject *parent = nullptr) | |
| ~QConcatenateTablesProxyModel() | |
| QList<QAbstractItemModel *> | sourceModels() const |
| void | addSourceModel(QAbstractItemModel *sourceModel) |
| void | removeSourceModel(QAbstractItemModel *sourceModel) |
| QModelIndex | mapFromSource(const QModelIndex &sourceIndex) const |
| QModelIndex | mapToSource(const QModelIndex &proxyIndex) const |
Reimplemented Public Functions
| QVariant | data(const QModelIndex &index, int role = Qt::DisplayRole) const |
| bool | setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) |
| QMap<int, QVariant> | itemData(const QModelIndex &proxyIndex) const |
| bool | setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) |
| Qt::ItemFlags | flags(const QModelIndex &index) const |
| QModelIndex | index(int row, int column, const QModelIndex &parent = QModelIndex()) const |
| QModelIndex | parent(const QModelIndex &index) const |
| int | rowCount(const QModelIndex &parent = QModelIndex()) const |
| QVariant | headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const |
| int | columnCount(const QModelIndex &parent = QModelIndex()) const |
| QStringList | mimeTypes() const |
| QMimeData * | mimeData(const QModelIndexList &indexes) const |
| bool | canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const |
| bool | dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
| QSize | span(const QModelIndex &index) const |
Detailed Description
The rows of the first source model come first, followed by those of the second, and so on. The proxy has as many columns as the source with the fewest. The source models must be flat: their items have no children.
QConcatenateTablesProxyModel all;
all.addSourceModel(&inbox);
all.addSourceModel(&archive);
See also QAbstractItemModel.
Differences from Qt
A change of the column count of a source resets the proxy.
Member Function Documentation
QConcatenateTablesProxyModel::QConcatenateTablesProxyModel(QObject *parent = nullptr)
Constructs a proxy with the given parent and no source models.
QConcatenateTablesProxyModel::~QConcatenateTablesProxyModel()
Destroys the proxy.
void QConcatenateTablesProxyModel::addSourceModel(QAbstractItemModel *sourceModel)
Appends the rows of sourceModel, which must be a flat model. The proxy follows the changes of the source from then on.
See also removeSourceModel().
bool QConcatenateTablesProxyModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
Reimplements QAbstractItemModel::canDropMimeData().
Returns whether the source model at row accepts data dropped with action at column under parent.
int QConcatenateTablesProxyModel::columnCount(const QModelIndex &parent = QModelIndex()) const
Reimplements QAbstractItemModel::columnCount().
Returns the smallest column count of the source models, or 0 for a valid parent.
QVariant QConcatenateTablesProxyModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const
Reimplements QAbstractItemModel::data().
Returns the data of the source item of index for role.
bool QConcatenateTablesProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Reimplements QAbstractItemModel::dropMimeData().
Drops data with action into the source model at row and column under parent.
Qt::ItemFlags QConcatenateTablesProxyModel::flags(const QModelIndex &index) const
Reimplements QAbstractItemModel::flags().
Returns the flags of the source item of index, or none for an invalid index.
QVariant QConcatenateTablesProxyModel::headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
Reimplements QAbstractItemModel::headerData().
Returns the header data of section in orientation for role: the horizontal headers come from the first source model, and the vertical headers from the source of each row.
QModelIndex QConcatenateTablesProxyModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const
Reimplements QAbstractItemModel::index().
Returns the index at row and column; parent must be invalid.
QMap<int, QVariant> QConcatenateTablesProxyModel::itemData(const QModelIndex &proxyIndex) const
Reimplements QAbstractItemModel::itemData().
Returns the item data of the source item of proxyIndex.
QModelIndex QConcatenateTablesProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
Returns the proxy index of sourceIndex, an index of one of the source models, or an invalid index.
QModelIndex QConcatenateTablesProxyModel::mapToSource(const QModelIndex &proxyIndex) const
Returns the source index of proxyIndex, or an invalid index.
QMimeData * QConcatenateTablesProxyModel::mimeData(const QModelIndexList &indexes) const
Reimplements QAbstractItemModel::mimeData().
Returns the MIME data of the source items of indexes, which must all belong to the same source model; otherwise returns nullptr.
QStringList QConcatenateTablesProxyModel::mimeTypes() const
Reimplements QAbstractItemModel::mimeTypes().
Returns the MIME types that all source models support.
QModelIndex QConcatenateTablesProxyModel::parent(const QModelIndex &index) const
Reimplements QAbstractItemModel::parent().
Returns an invalid index: the proxy is flat. index is not used.
void QConcatenateTablesProxyModel::removeSourceModel(QAbstractItemModel *sourceModel)
Removes the rows of sourceModel from the proxy.
See also addSourceModel().
int QConcatenateTablesProxyModel::rowCount(const QModelIndex &parent = QModelIndex()) const
Reimplements QAbstractItemModel::rowCount().
Returns the total number of rows of the source models, or 0 for a valid parent.
bool QConcatenateTablesProxyModel::setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)
Reimplements QAbstractItemModel::setData().
Sets the data of the source item of index for role to value.
bool QConcatenateTablesProxyModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)
Reimplements QAbstractItemModel::setItemData().
Sets the item data of the source item of index to roles.
QList<QAbstractItemModel *> QConcatenateTablesProxyModel::sourceModels() const
Returns the source models, in the order their rows appear.
QSize QConcatenateTablesProxyModel::span(const QModelIndex &index) const
Reimplements QAbstractItemModel::span().
Returns the span of the source item of index.