Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qconcatenatetablesproxymodel.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <private/qabstractitemmodel_p.h>
6#include "qsize.h"
7#include "qmap.h"
8#include "qdebug.h"
9
11
13{
14 Q_DECLARE_PUBLIC(QConcatenateTablesProxyModel);
15
16public:
18
19 int computeRowsPrior(const QAbstractItemModel *sourceModel) const;
20
22 {
26 };
28
29 void _q_slotRowsAboutToBeInserted(const QModelIndex &, int start, int end);
30 void _q_slotRowsInserted(const QModelIndex &, int start, int end);
31 void _q_slotRowsAboutToBeRemoved(const QModelIndex &, int start, int end);
32 void _q_slotRowsRemoved(const QModelIndex &, int start, int end);
34 void _q_slotColumnsInserted(const QModelIndex &parent, int, int);
36 void _q_slotColumnsRemoved(const QModelIndex &parent, int, int);
37 void _q_slotDataChanged(const QModelIndex &from, const QModelIndex &to, const QList<int> &roles);
41 void _q_slotModelReset();
42 int columnCountAfterChange(const QAbstractItemModel *model, int newCount) const;
43 int calculatedColumnCount() const;
44 void updateColumnCount();
46 int *sourceRow, int *sourceColumn, QModelIndex *sourceParent, QAbstractItemModel **sourceModel) const;
47
49 int m_rowCount; // have to maintain it here since we can't compute during model destruction
51
52 // for columns{AboutToBe,}{Inserted,Removed}
54
55 // for layoutAboutToBeChanged/layoutChanged
58};
59
61 : m_rowCount(0),
62 m_columnCount(0),
63 m_newColumnCount(0)
64{
65}
66
100{
101}
102
107{
108}
109
114{
116 if (!sourceIndex.isValid())
117 return QModelIndex();
118 const QAbstractItemModel *sourceModel = sourceIndex.model();
119 if (!d->m_models.contains(const_cast<QAbstractItemModel *>(sourceModel))) {
120 qWarning("QConcatenateTablesProxyModel: index from wrong model passed to mapFromSource");
121 Q_ASSERT(!"QConcatenateTablesProxyModel: index from wrong model passed to mapFromSource");
122 return QModelIndex();
123 }
124 if (sourceIndex.column() >= d->m_columnCount)
125 return QModelIndex();
126 int rowsPrior = d_func()->computeRowsPrior(sourceModel);
127 return createIndex(rowsPrior + sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer());
128}
129
134{
136 Q_ASSERT(checkIndex(proxyIndex));
137 if (!proxyIndex.isValid())
138 return QModelIndex();
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");
142 return QModelIndex();
143 }
144 const int row = proxyIndex.row();
145 const auto result = d->sourceModelForRow(row);
146 if (!result.sourceModel)
147 return QModelIndex();
148 return result.sourceModel->index(result.sourceRow, proxyIndex.column());
149}
150
155{
156 const QModelIndex sourceIndex = mapToSource(index);
158 if (!sourceIndex.isValid())
159 return QVariant();
160 return sourceIndex.data(role);
161}
162
167{
169 const QModelIndex sourceIndex = mapToSource(index);
170 Q_ASSERT(sourceIndex.isValid());
171 const auto sourceModel = const_cast<QAbstractItemModel *>(sourceIndex.model());
172 return sourceModel->setData(sourceIndex, value, role);
173}
174
179{
180 Q_ASSERT(checkIndex(proxyIndex));
181 const QModelIndex sourceIndex = mapToSource(proxyIndex);
182 Q_ASSERT(sourceIndex.isValid());
183 return sourceIndex.model()->itemData(sourceIndex);
184}
185
190{
191 Q_ASSERT(checkIndex(proxyIndex));
192 const QModelIndex sourceIndex = mapToSource(proxyIndex);
193 Q_ASSERT(sourceIndex.isValid());
194 const auto sourceModel = const_cast<QAbstractItemModel *>(sourceIndex.model());
195 return sourceModel->setItemData(sourceIndex, roles);
196}
197
205{
207 if (d->m_models.isEmpty())
208 return Qt::NoItemFlags;
210 if (!index.isValid())
211 return d->m_models.at(0)->flags(index);
212 const QModelIndex sourceIndex = mapToSource(index);
213 Q_ASSERT(sourceIndex.isValid());
214 return sourceIndex.model()->flags(sourceIndex);
215}
216
223{
225 if (d->m_models.isEmpty())
226 return QVariant();
227 switch (orientation) {
228 case Qt::Horizontal:
229 return d->m_models.at(0)->headerData(section, orientation, role);
230 case Qt::Vertical: {
231 const auto result = d->sourceModelForRow(section);
232 Q_ASSERT(result.sourceModel);
233 return result.sourceModel->headerData(result.sourceRow, orientation, role);
234 }
235 }
236 return QVariant();
237}
238
244{
246 if (parent.isValid())
247 return 0; // flat model
248 return d->m_columnCount;
249}
250
255{
258 if (!hasIndex(row, column, parent))
259 return QModelIndex();
261 const auto result = d->sourceModelForRow(row);
262 Q_ASSERT(result.sourceModel);
263 return mapFromSource(result.sourceModel->index(result.sourceRow, column));
264}
265
270{
272 return QModelIndex(); // flat model, no hierarchy
273}
274
279{
281 if (parent.isValid())
282 return 0; // flat model
283 return d->m_rowCount;
284}
285
291{
293 if (d->m_models.isEmpty())
294 return QStringList();
295 return d->m_models.at(0)->mimeTypes();
296}
297
310{
312 if (indexes.isEmpty())
313 return nullptr;
314 const QModelIndex firstIndex = indexes.first();
316 const auto result = d->sourceModelForRow(firstIndex.row());
317 QModelIndexList sourceIndexes;
318 sourceIndexes.reserve(indexes.size());
319 for (const QModelIndex &index : indexes) {
320 const QModelIndex sourceIndex = mapToSource(index);
321 Q_ASSERT(sourceIndex.model() == result.sourceModel); // see documentation above
322 sourceIndexes.append(sourceIndex);
323 }
324 return result.sourceModel->mimeData(sourceIndexes);
325}
326
327
329 int *sourceRow, int *sourceColumn, QModelIndex *sourceParent, QAbstractItemModel **sourceModel) const
330{
332 *sourceColumn = column;
333 if (!parent.isValid()) {
334 // Drop after the last item
335 if (row == -1 || row == m_rowCount) {
336 *sourceRow = -1;
337 *sourceModel = m_models.constLast();
338 return true;
339 }
340 // Drop between toplevel items
341 const auto result = sourceModelForRow(row);
342 Q_ASSERT(result.sourceModel);
343 *sourceRow = result.sourceRow;
344 *sourceModel = result.sourceModel;
345 return true;
346 } else {
347 if (row > -1)
348 return false; // flat model, no dropping as new children of items
349 // Drop onto item
350 const int targetRow = parent.row();
351 const auto result = sourceModelForRow(targetRow);
352 Q_ASSERT(result.sourceModel);
353 const QModelIndex sourceIndex = q->mapToSource(parent);
354 *sourceRow = -1;
355 *sourceParent = sourceIndex;
356 *sourceModel = result.sourceModel;
357 return true;
358 }
359}
360
365{
367 if (d->m_models.isEmpty())
368 return false;
369
371 QModelIndex sourceParent;
372 QAbstractItemModel *sourceModel;
373 if (!d->mapDropCoordinatesToSource(row, column, parent, &sourceRow, &sourceColumn, &sourceParent, &sourceModel))
374 return false;
375 return sourceModel->canDropMimeData(data, action, sourceRow, sourceColumn, sourceParent);
376}
377
388{
390 if (d->m_models.isEmpty())
391 return false;
393 QModelIndex sourceParent;
394 QAbstractItemModel *sourceModel;
395 if (!d->mapDropCoordinatesToSource(row, column, parent, &sourceRow, &sourceColumn, &sourceParent, &sourceModel))
396 return false;
397
398 return sourceModel->dropMimeData(data, action, sourceRow, sourceColumn, sourceParent);
399}
400
405{
408 if (d->m_models.isEmpty() || !index.isValid())
409 return QSize();
410 const QModelIndex sourceIndex = mapToSource(index);
411 Q_ASSERT(sourceIndex.isValid());
412 return sourceIndex.model()->span(sourceIndex);
413}
414
421{
423 return d->m_models.toList();
424}
425
434{
436 Q_ASSERT(sourceModel);
437 Q_ASSERT(!d->m_models.contains(sourceModel));
439 connect(sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(_q_slotRowsInserted(QModelIndex,int,int)));
440 connect(sourceModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(_q_slotRowsRemoved(QModelIndex,int,int)));
441 connect(sourceModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(_q_slotRowsAboutToBeInserted(QModelIndex,int,int)));
442 connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(_q_slotRowsAboutToBeRemoved(QModelIndex,int,int)));
443
444 connect(sourceModel, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(_q_slotColumnsInserted(QModelIndex,int,int)));
445 connect(sourceModel, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(_q_slotColumnsRemoved(QModelIndex,int,int)));
446 connect(sourceModel, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(_q_slotColumnsAboutToBeInserted(QModelIndex,int,int)));
447 connect(sourceModel, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(_q_slotColumnsAboutToBeRemoved(QModelIndex,int,int)));
448
450 this, SLOT(_q_slotSourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>, QAbstractItemModel::LayoutChangeHint)));
453 connect(sourceModel, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_slotModelAboutToBeReset()));
454 connect(sourceModel, SIGNAL(modelReset()), this, SLOT(_q_slotModelReset()));
455
456 const int newRows = sourceModel->rowCount();
457 if (newRows > 0)
458 beginInsertRows(QModelIndex(), d->m_rowCount, d->m_rowCount + newRows - 1);
459 d->m_rowCount += newRows;
460 d->m_models.append(sourceModel);
461 if (newRows > 0)
463
464 d->updateColumnCount();
465}
466
473{
475 Q_ASSERT(d->m_models.contains(sourceModel));
476 disconnect(sourceModel, nullptr, this, nullptr);
477
478 const int rowsRemoved = sourceModel->rowCount();
479 const int rowsPrior = d->computeRowsPrior(sourceModel); // location of removed section
480
481 if (rowsRemoved > 0)
482 beginRemoveRows(QModelIndex(), rowsPrior, rowsPrior + rowsRemoved - 1);
483 d->m_models.removeOne(sourceModel);
484 d->m_rowCount -= rowsRemoved;
485 if (rowsRemoved > 0)
487
488 d->updateColumnCount();
489}
490
492{
494 if (parent.isValid()) // not supported, the proxy is a flat model
495 return;
496 const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
497 const int rowsPrior = computeRowsPrior(model);
498 q->beginInsertRows(QModelIndex(), rowsPrior + start, rowsPrior + end);
499}
500
502{
504 if (parent.isValid()) // flat model
505 return;
506 m_rowCount += end - start + 1;
507 q->endInsertRows();
508}
509
511{
513 if (parent.isValid()) // flat model
514 return;
515 const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
516 const int rowsPrior = computeRowsPrior(model);
517 q->beginRemoveRows(QModelIndex(), rowsPrior + start, rowsPrior + end);
518}
519
521{
523 if (parent.isValid()) // flat model
524 return;
525 m_rowCount -= end - start + 1;
526 q->endRemoveRows();
527}
528
530{
532 if (parent.isValid()) // flat model
533 return;
534 const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
535 const int oldColCount = model->columnCount();
536 const int newColCount = columnCountAfterChange(model, oldColCount + end - start + 1);
537 Q_ASSERT(newColCount >= oldColCount);
538 if (newColCount > oldColCount)
539 // If the underlying models have a different number of columns (example: 2 and 3), inserting 2 columns in
540 // the first model leads to inserting only one column in the proxy, since qMin(2+2,3) == 3.
541 q->beginInsertColumns(QModelIndex(), start, qMin(end, start + newColCount - oldColCount - 1));
542 m_newColumnCount = newColCount;
543}
544
546{
548 Q_UNUSED(end);
550 if (parent.isValid()) // flat model
551 return;
554 q->endInsertColumns();
555 }
556}
557
559{
561 if (parent.isValid()) // flat model
562 return;
563 const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
564 const int oldColCount = model->columnCount();
565 const int newColCount = columnCountAfterChange(model, oldColCount - (end - start + 1));
566 Q_ASSERT(newColCount <= oldColCount);
567 if (newColCount < oldColCount)
568 q->beginRemoveColumns(QModelIndex(), start, qMax(end, start + oldColCount - newColCount - 1));
569 m_newColumnCount = newColCount;
570}
571
573{
576 Q_UNUSED(end);
577 if (parent.isValid()) // flat model
578 return;
581 q->endRemoveColumns();
582 }
583}
584
586{
588 Q_ASSERT(from.isValid());
589 Q_ASSERT(to.isValid());
590 if (from.column() >= m_columnCount)
591 return;
592 QModelIndex adjustedTo = to;
593 if (to.column() >= m_columnCount)
594 adjustedTo = to.siblingAtColumn(m_columnCount - 1);
595 const QModelIndex myFrom = q->mapFromSource(from);
597 const QModelIndex myTo = q->mapFromSource(adjustedTo);
599 emit q->dataChanged(myFrom, myTo, roles);
600}
601
603{
605
606 if (!sourceParents.isEmpty() && !sourceParents.contains(QModelIndex()))
607 return;
608
609 emit q->layoutAboutToBeChanged({}, hint);
610
611 const QModelIndexList persistentIndexList = q->persistentIndexList();
612 layoutChangePersistentIndexes.reserve(persistentIndexList.size());
613 layoutChangeProxyIndexes.reserve(persistentIndexList.size());
614
615 for (const QModelIndex &proxyPersistentIndex : persistentIndexList) {
616 layoutChangeProxyIndexes.append(proxyPersistentIndex);
617 Q_ASSERT(proxyPersistentIndex.isValid());
618 const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
619 Q_ASSERT(srcPersistentIndex.isValid());
620 layoutChangePersistentIndexes << srcPersistentIndex;
621 }
622}
623
625{
627 if (!sourceParents.isEmpty() && !sourceParents.contains(QModelIndex()))
628 return;
629 for (int i = 0; i < layoutChangeProxyIndexes.size(); ++i) {
630 const QModelIndex proxyIdx = layoutChangeProxyIndexes.at(i);
631 const QModelIndex newProxyIdx = q->mapFromSource(layoutChangePersistentIndexes.at(i));
632 q->changePersistentIndex(proxyIdx, newProxyIdx);
633 }
634
637
638 emit q->layoutChanged({}, hint);
639}
640
642{
644 Q_ASSERT(m_models.contains(const_cast<QAbstractItemModel *>(static_cast<const QAbstractItemModel *>(q->sender()))));
645 q->beginResetModel();
646 // A reset might reduce both rowCount and columnCount, and we can't notify of both at the same time,
647 // and notifying of one after the other leaves an intermediary invalid situation.
648 // So the only safe choice is to forward it as a full reset.
649}
650
652{
654 Q_ASSERT(m_models.contains(const_cast<QAbstractItemModel *>(static_cast<const QAbstractItemModel *>(q->sender()))));
656 m_rowCount = computeRowsPrior(nullptr);
657 q->endResetModel();
658}
659
661{
662 if (m_models.isEmpty())
663 return 0;
664
665 const auto it = std::min_element(m_models.begin(), m_models.end(), [](const QAbstractItemModel* model1, const QAbstractItemModel* model2) {
666 return model1->columnCount() < model2->columnCount();
667 });
668 return (*it)->columnCount();
669}
670
672{
674 const int newColumnCount = calculatedColumnCount();
675 const int columnDiff = newColumnCount - m_columnCount;
676 if (columnDiff > 0) {
677 q->beginInsertColumns(QModelIndex(), m_columnCount, m_columnCount + columnDiff - 1);
678 m_columnCount = newColumnCount;
679 q->endInsertColumns();
680 } else if (columnDiff < 0) {
681 const int lastColumn = m_columnCount - 1;
682 q->beginRemoveColumns(QModelIndex(), lastColumn + columnDiff + 1, lastColumn);
683 m_columnCount = newColumnCount;
684 q->endRemoveColumns();
685 }
686}
687
689{
690 int newColumnCount = 0;
691 for (int i = 0; i < m_models.size(); ++i) {
692 const QAbstractItemModel *mod = m_models.at(i);
693 const int colCount = mod == model ? newCount : mod->columnCount();
694 if (i == 0)
695 newColumnCount = colCount;
696 else
697 newColumnCount = qMin(colCount, newColumnCount);
698 }
699 return newColumnCount;
700}
701
703{
704 int rowsPrior = 0;
705 for (const QAbstractItemModel *model : m_models) {
706 if (model == sourceModel)
707 break;
708 rowsPrior += model->rowCount();
709 }
710 return rowsPrior;
711}
712
714{
716 int rowCount = 0;
718 const int subRowCount = model->rowCount();
719 if (rowCount + subRowCount > row) {
720 result.sourceModel = model;
721 break;
722 }
723 rowCount += subRowCount;
724 }
725 result.sourceRow = row - rowCount;
726 return result;
727}
728
730
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
void _q_slotSourceLayoutAboutToBeChanged(const QList< QPersistentModelIndex > &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
SourceModelForRowResult sourceModelForRow(int row) const
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
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
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
bool isEmpty() const noexcept
Definition qlist.h:390
T & first()
Definition qlist.h:628
const T & constLast() const noexcept
Definition qlist.h:633
iterator end()
Definition qlist.h:609
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
iterator begin()
Definition qlist.h:608
void reserve(qsizetype size)
Definition qlist.h:746
void append(parameter_type t)
Definition qlist.h:441
void clear()
Definition qlist.h:417
Definition qmap.h:186
\inmodule QtCore
Definition qmimedata.h:16
\inmodule QtCore
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}.
QObject * parent
Definition qobject.h:61
\inmodule QtCore
Definition qobject.h:90
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
bool isValid() const
Returns {true} if this persistent model index is valid; otherwise returns {false}.
\inmodule QtCore
Definition qsize.h:25
int rowCount(const QModelIndex &parent=QModelIndex()) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
\inmodule QtCore
\inmodule QtCore
Definition qvariant.h:64
QSet< QString >::iterator it
Combined button and popup list for selecting options.
Orientation
Definition qnamespace.h:97
@ Horizontal
Definition qnamespace.h:98
@ Vertical
Definition qnamespace.h:99
DropAction
@ NoItemFlags
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:162
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLuint index
[2]
GLuint GLuint end
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLenum GLenum GLsizei void * row
GLuint64EXT * result
[6]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define emit
#define Q_UNUSED(x)
QSqlQueryModel * model
[16]
QObject::connect nullptr
myObject disconnect()
[26]
bool contains(const AT &t) const noexcept
Definition qlist.h:44
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent