5#include <private/qabstractitemmodel_p.h>
120 qWarning(
"QConcatenateTablesProxyModel: index from wrong model passed to mapFromSource");
121 Q_ASSERT(!
"QConcatenateTablesProxyModel: index from wrong model passed to mapFromSource");
124 if (sourceIndex.
column() >=
d->m_columnCount)
126 int rowsPrior = d_func()->computeRowsPrior(sourceModel);
139 if (proxyIndex.
model() !=
this) {
140 qWarning(
"QConcatenateTablesProxyModel: index from wrong model passed to mapToSource");
141 Q_ASSERT(!
"QConcatenateTablesProxyModel: index from wrong model passed to mapToSource");
144 const int row = proxyIndex.
row();
145 const auto result =
d->sourceModelForRow(
row);
160 return sourceIndex.
data(role);
195 return sourceModel->
setItemData(sourceIndex, roles);
207 if (
d->m_models.isEmpty())
210 if (!
index.isValid())
211 return d->m_models.at(0)->flags(
index);
214 return sourceIndex.
model()->
flags(sourceIndex);
225 if (
d->m_models.isEmpty())
227 switch (orientation) {
229 return d->m_models.at(0)->headerData(section, orientation, role);
231 const auto result =
d->sourceModelForRow(section);
233 return result.sourceModel->headerData(
result.sourceRow, orientation, role);
248 return d->m_columnCount;
261 const auto result =
d->sourceModelForRow(
row);
283 return d->m_rowCount;
293 if (
d->m_models.isEmpty())
295 return d->m_models.at(0)->mimeTypes();
316 const auto result =
d->sourceModelForRow(firstIndex.
row());
322 sourceIndexes.
append(sourceIndex);
324 return result.sourceModel->mimeData(sourceIndexes);
343 *sourceRow =
result.sourceRow;
344 *sourceModel =
result.sourceModel;
350 const int targetRow =
parent.row();
355 *sourceParent = sourceIndex;
356 *sourceModel =
result.sourceModel;
367 if (
d->m_models.isEmpty())
390 if (
d->m_models.isEmpty())
408 if (
d->m_models.isEmpty() || !
index.isValid())
412 return sourceIndex.
model()->
span(sourceIndex);
423 return d->m_models.toList();
437 Q_ASSERT(!
d->m_models.contains(sourceModel));
456 const int newRows = sourceModel->
rowCount();
459 d->m_rowCount += newRows;
460 d->m_models.append(sourceModel);
464 d->updateColumnCount();
475 Q_ASSERT(
d->m_models.contains(sourceModel));
476 disconnect(sourceModel,
nullptr,
this,
nullptr);
479 const int rowsPrior =
d->computeRowsPrior(sourceModel);
483 d->m_models.removeOne(sourceModel);
488 d->updateColumnCount();
537 Q_ASSERT(newColCount >= oldColCount);
538 if (newColCount > oldColCount)
554 q->endInsertColumns();
566 Q_ASSERT(newColCount <= oldColCount);
567 if (newColCount < oldColCount)
581 q->endRemoveColumns();
599 emit q->dataChanged(myFrom, myTo, roles);
609 emit q->layoutAboutToBeChanged({},
hint);
615 for (
const QModelIndex &proxyPersistentIndex : persistentIndexList) {
617 Q_ASSERT(proxyPersistentIndex.isValid());
632 q->changePersistentIndex(proxyIdx, newProxyIdx);
645 q->beginResetModel();
666 return model1->columnCount() < model2->columnCount();
668 return (*it)->columnCount();
676 if (columnDiff > 0) {
679 q->endInsertColumns();
680 }
else if (columnDiff < 0) {
682 q->beginRemoveColumns(
QModelIndex(), lastColumn + columnDiff + 1, lastColumn);
684 q->endRemoveColumns();
690 int newColumnCount = 0;
695 newColumnCount = colCount;
697 newColumnCount =
qMin(colCount, newColumnCount);
699 return newColumnCount;
706 if (
model == sourceModel)
719 if (rowCount + subRowCount >
row) {
723 rowCount += subRowCount;
731#include "moc_qconcatenatetablesproxymodel.cpp"
Q_INVOKABLE int const QModelIndex & parent
Returns the parent of the model item with the given index.
void modelAboutToBeReset(QPrivateSignal)
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
Returns {true} if a model can accept a drop of the data.
void columnsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been removed from the model.
LayoutChangeHint
This enum describes the way the model changes layout.
void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before rows are inserted into the model.
void columnsAboutToBeInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before columns are inserted into the model.
Q_INVOKABLE bool hasIndex(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns {true} if the model returns a valid QModelIndex for row and column with parent,...
virtual Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const
Returns the item flags for the given index.
void modelReset(QPrivateSignal)
void endRemoveRows()
Ends a row removal operation.
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Handles the data supplied by a drag and drop operation that ended with the given action.
void layoutAboutToBeChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
This signal is emitted whenever the data in an existing item changes.
virtual Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before columns are removed from the model.
void layoutChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
bool checkIndex(const QModelIndex &index, CheckIndexOptions options=CheckIndexOption::NoOption) const
Q_INVOKABLE int sourceRow
virtual Q_INVOKABLE bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets the role data for the item at index to value.
void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before rows are removed from the model.
void endInsertRows()
Ends a row insertion operation.
virtual QMap< int, QVariant > itemData(const QModelIndex &index) const
Returns a map with values for all predefined roles in the model for the item at the given index.
virtual bool setItemData(const QModelIndex &index, const QMap< int, QVariant > &roles)
Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole...
virtual Q_INVOKABLE int columnCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of columns for the children of the given parent.
void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been inserted into the model.
Q_INVOKABLE int sourceColumn
QModelIndex createIndex(int row, int column, const void *data=nullptr) const
Creates a model index for the given row and column with the internal pointer ptr.
void columnsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been inserted into the model.
virtual QSize span(const QModelIndex &index) const
Returns the row and column span of the item represented by index.
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.
void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been removed from the model.
QList< QPersistentModelIndex > layoutChangePersistentIndexes
QList< QAbstractItemModel * > m_models
void _q_slotModelAboutToBeReset()
QConcatenateTablesProxyModelPrivate()
void _q_slotSourceLayoutAboutToBeChanged(const QList< QPersistentModelIndex > &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
SourceModelForRowResult sourceModelForRow(int row) const
QList< QModelIndex > layoutChangeProxyIndexes
void _q_slotColumnsRemoved(const QModelIndex &parent, int, int)
void _q_slotDataChanged(const QModelIndex &from, const QModelIndex &to, const QList< int > &roles)
int columnCountAfterChange(const QAbstractItemModel *model, int newCount) const
bool mapDropCoordinatesToSource(int row, int column, const QModelIndex &parent, int *sourceRow, int *sourceColumn, QModelIndex *sourceParent, QAbstractItemModel **sourceModel) const
void _q_slotColumnsInserted(const QModelIndex &parent, int, int)
void _q_slotSourceLayoutChanged(const QList< QPersistentModelIndex > &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
void _q_slotRowsInserted(const QModelIndex &, int start, int end)
void _q_slotColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end)
void _q_slotRowsAboutToBeRemoved(const QModelIndex &, int start, int end)
int computeRowsPrior(const QAbstractItemModel *sourceModel) const
int calculatedColumnCount() const
void _q_slotColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
void _q_slotRowsAboutToBeInserted(const QModelIndex &, int start, int end)
void _q_slotRowsRemoved(const QModelIndex &, int start, int end)
The QConcatenateTablesProxyModel class proxies multiple source models, concatenating their rows.
QStringList mimeTypes() const override
This method returns the mime types for the first source model.
QMap< int, QVariant > itemData(const QModelIndex &proxyIndex) const override
\reimp
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
\reimp
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
\reimp
Q_SCRIPTABLE void addSourceModel(QAbstractItemModel *sourceModel)
Adds a source model sourceModel, below all previously added source models.
QList< QAbstractItemModel * > sourceModels() const
Returns a list of models that were added as source models for this proxy model.
QModelIndex mapToSource(const QModelIndex &proxyIndex) const
Returns the source index for a given proxyIndex.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
\reimp
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
Returns the proxy index for a given sourceIndex, which can be from any of the source models.
QConcatenateTablesProxyModel(QObject *parent=nullptr)
Constructs a concatenate-rows proxy model with the given parent.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
This method returns the horizontal header data for the first source model, and the vertical header da...
bool setItemData(const QModelIndex &index, const QMap< int, QVariant > &roles) override
\reimp
~QConcatenateTablesProxyModel()
Destroys this proxy model.
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the flags for the given index.
QMimeData * mimeData(const QModelIndexList &indexes) const override
The call is forwarded to the source model of the first index in the list of indexes.
Q_SCRIPTABLE void removeSourceModel(QAbstractItemModel *sourceModel)
Removes the source model sourceModel, which was previously added to this proxy.
QSize span(const QModelIndex &index) const override
\reimp
int columnCount(const QModelIndex &parent=QModelIndex()) const override
This method returns the column count of the source model with the smallest number of columns.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
QConcatenateTablesProxyModel handles dropping onto an item, between items, and after the last item.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
\reimp
int rowCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
qsizetype size() const noexcept
bool isEmpty() const noexcept
const T & constLast() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
QModelIndex siblingAtColumn(int column) const
Returns the sibling at column for the current row.
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
constexpr int row() const noexcept
Returns the row this model index refers to.
constexpr const QAbstractItemModel * model() const noexcept
Returns a pointer to the model containing the item that this index refers to.
constexpr int column() const noexcept
Returns the column this model index refers to.
void * internalPointer() const noexcept
Returns a {void} {*} pointer used by the model to associate the index with the internal data structur...
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
bool isValid() const
Returns {true} if this persistent model index is valid; otherwise returns {false}.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
QSet< QString >::iterator it
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
QSqlQueryModel * model
[16]
myObject disconnect()
[26]
SourceModelForRowResult()
QAbstractItemModel * sourceModel
bool contains(const AT &t) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent