The QConcatenateTablesProxyModel class proxies multiple source models, concatenating their rows. 更多...
头: | #include <QConcatenateTablesProxyModel> |
qmake: | QT += core |
Since: | Qt 5.13 |
继承: | QAbstractItemModel |
该类在 Qt 5.13 引入。
QConcatenateTablesProxyModel (QObject * parent = nullptr) | |
virtual | ~QConcatenateTablesProxyModel () |
void | addSourceModel (QAbstractItemModel * sourceModel ) |
QModelIndex | mapFromSource (const QModelIndex & sourceIndex ) const |
QModelIndex | mapToSource (const QModelIndex & proxyIndex ) const |
void | removeSourceModel (QAbstractItemModel * sourceModel ) |
QList<QAbstractItemModel *> | sourceModels () const |
virtual bool | canDropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent ) const override |
virtual int | columnCount (const QModelIndex & parent = QModelIndex()) const override |
virtual QVariant | data (const QModelIndex & index , int role = Qt::DisplayRole) const override |
virtual bool | dropMimeData (const QMimeData * data , Qt::DropAction action , int row , int column , const QModelIndex & parent ) override |
virtual Qt::ItemFlags | flags (const QModelIndex & index ) const 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 QMap<int, QVariant> | itemData (const QModelIndex & proxyIndex ) const override |
virtual QMimeData * | mimeData (const QModelIndexList & indexes ) const override |
virtual QStringList | mimeTypes () const override |
virtual QModelIndex | parent (const QModelIndex & index ) const override |
virtual int | rowCount (const QModelIndex & parent = QModelIndex()) const override |
virtual bool | setData (const QModelIndex & index , const QVariant & value , int role = Qt::EditRole) override |
virtual bool | setItemData (const QModelIndex & proxyIndex , const QMap<int, QVariant> & roles ) override |
virtual QSize | span (const QModelIndex & index ) const override |
QConcatenateTablesProxyModel takes multiple source models and concatenates their rows.
In other words, the proxy will have all rows of the first source model, followed by all rows of the second source model, and so on.
If the source models don't have the same number of columns, the proxy will only have as many columns as the source model with the smallest number of columns. Additional columns in other source models will simply be ignored.
Source models can be added and removed at runtime, and the column count is adjusted accordingly.
This proxy does not inherit from QAbstractProxyModel because it uses multiple source models, rather than a single one.
Only flat models (lists and tables) are supported, tree models are not.
另请参阅 QAbstractProxyModel , 模型/视图编程 , QIdentityProxyModel ,和 QAbstractItemModel .
Constructs a concatenate-rows proxy model with the given parent .
[虚拟]
QConcatenateTablesProxyModel::
~QConcatenateTablesProxyModel
()
Destroys this proxy model.
Adds a source model sourceModel , below all previously added source models.
所有权对于 sourceModel is not affected by this.
The same source model cannot be added more than once.
[override virtual]
bool
QConcatenateTablesProxyModel::
canDropMimeData
(const
QMimeData
*
data
,
Qt::DropAction
action
,
int
row
,
int
column
, const
QModelIndex
&
parent
) const
重实现: QAbstractItemModel::canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const.
[override virtual]
int
QConcatenateTablesProxyModel::
columnCount
(const
QModelIndex
&
parent
= QModelIndex()) const
重实现: QAbstractItemModel::columnCount (const QModelIndex &parent) const.
This method returns the column count of the source model with the smallest number of columns.
[override virtual]
QVariant
QConcatenateTablesProxyModel::
data
(const
QModelIndex
&
index
,
int
role
= Qt::DisplayRole) const
重实现: QAbstractItemModel::data (const QModelIndex &index, int role) const.
另请参阅 setData ().
[override virtual]
bool
QConcatenateTablesProxyModel::
dropMimeData
(const
QMimeData
*
data
,
Qt::DropAction
action
,
int
row
,
int
column
, const
QModelIndex
&
parent
)
重实现: QAbstractItemModel::dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent).
QConcatenateTablesProxyModel handles dropping onto an item, between items, and after the last item. In all cases the call is forwarded to the underlying source model. When dropping onto an item, the source model for this item is called. When dropping between items, the source model immediately below the drop position is called. When dropping after the last item, the last source model is called.
[override virtual]
Qt::ItemFlags
QConcatenateTablesProxyModel::
flags
(const
QModelIndex
&
index
) const
重实现: QAbstractItemModel::flags (const QModelIndex &index) const.
Returns the flags for the given index. If the index is valid, the flags come from the source model for this index 。若 index is invalid (as used to determine if dropping onto an empty area in the view is allowed, for instance), the flags from the first model are returned.
[override virtual]
QVariant
QConcatenateTablesProxyModel::
headerData
(
int
section
,
Qt::Orientation
orientation
,
int
role
= Qt::DisplayRole) const
重实现: QAbstractItemModel::headerData (int section, Qt::Orientation orientation, int role) const.
This method returns the horizontal header data for the first source model, and the vertical header data for the source model corresponding to each row.
[override virtual]
QModelIndex
QConcatenateTablesProxyModel::
index
(
int
row
,
int
column
, const
QModelIndex
&
parent
= QModelIndex()) const
重实现: QAbstractItemModel::index (int row, int column, const QModelIndex &parent) const.
[override virtual]
QMap
<
int
,
QVariant
> QConcatenateTablesProxyModel::
itemData
(const
QModelIndex
&
proxyIndex
) const
重实现: QAbstractItemModel::itemData (const QModelIndex &index) const.
另请参阅 setItemData ().
Returns the proxy index for a given sourceIndex , which can be from any of the source models.
Returns the source index for a given proxyIndex .
[override virtual]
QMimeData
*QConcatenateTablesProxyModel::
mimeData
(const
QModelIndexList
&
indexes
) const
重实现: QAbstractItemModel::mimeData (const QModelIndexList &indexes) const.
The call is forwarded to the source model of the first index in the list of indexes .
Important: please note that this proxy only supports dragging a single row. It will assert if called with indexes from multiple rows, because dragging rows that might come from different source models cannot be implemented generically by this proxy model. Each piece of data in the QMimeData needs to be merged, which is data-type-specific. Reimplement this method in a subclass if you want to support dragging multiple rows.
[override virtual]
QStringList
QConcatenateTablesProxyModel::
mimeTypes
() const
重实现: QAbstractItemModel::mimeTypes () const.
This method returns the mime types for the first source model.
[override virtual]
QModelIndex
QConcatenateTablesProxyModel::
parent
(const
QModelIndex
&
index
) const
重实现: QAbstractItemModel::parent (const QModelIndex &index) const.
Removes the source model sourceModel , which was previously added to this proxy.
所有权对于 sourceModel is not affected by this.
[override virtual]
int
QConcatenateTablesProxyModel::
rowCount
(const
QModelIndex
&
parent
= QModelIndex()) const
重实现: QAbstractItemModel::rowCount (const QModelIndex &parent) const.
[override virtual]
bool
QConcatenateTablesProxyModel::
setData
(const
QModelIndex
&
index
, const
QVariant
&
value
,
int
role
= Qt::EditRole)
重实现: QAbstractItemModel::setData (const QModelIndex &index, const QVariant &value, int role).
另请参阅 data ().
[override virtual]
bool
QConcatenateTablesProxyModel::
setItemData
(const
QModelIndex
&
proxyIndex
, const
QMap
<
int
,
QVariant
> &
roles
)
重实现: QAbstractItemModel::setItemData (const QModelIndex &index, const QMap<int, QVariant> &roles).
另请参阅 itemData ().
Returns a list of models that were added as source models for this proxy model.
该函数在 Qt 5.15 引入。
[override virtual]
QSize
QConcatenateTablesProxyModel::
span
(const
QModelIndex
&
index
) const
重实现: QAbstractItemModel::span (const QModelIndex &index) const.