Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
28
29 void slotRowsAboutToBeInserted(const QModelIndex &, int start, int end);
30 void slotRowsInserted(const QModelIndex &, int start, int end);
31 void slotRowsAboutToBeRemoved(const QModelIndex &, int start, int end);
32 void slotRowsRemoved(const QModelIndex &, int start, int end);
34 void slotColumnsInserted(const QModelIndex &parent, int, int);
36 void slotColumnsRemoved(const QModelIndex &parent, int, int);
37 void slotDataChanged(const QModelIndex &from, const QModelIndex &to, const QList<int> &roles);
38 void slotSourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint);
39 void slotSourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint);
41 void 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
48 struct ModelInfo {
49 using ConnArray = std::array<QMetaObject::Connection, 13>;
54 };
55 QList<ModelInfo> m_models;
56
58 {
59 auto byModelPtr = [m](const auto &modInfo) { return modInfo.model == m; };
60 return std::find_if(m_models.cbegin(), m_models.cend(), byModelPtr);
61 }
62
64 { return findSourceModel(m) != m_models.cend(); }
65
66 int m_rowCount; // have to maintain it here since we can't compute during model destruction
68
69 // for columns{AboutToBe,}{Inserted,Removed}
71
72 // for layoutAboutToBeChanged/layoutChanged
73 QList<QPersistentModelIndex> layoutChangePersistentIndexes;
74 QList<QModelIndex> layoutChangeProxyIndexes;
75};
76
78 : m_rowCount(0),
79 m_columnCount(0),
80 m_newColumnCount(0)
81{
82}
83
119
126
131{
133 if (!sourceIndex.isValid())
134 return QModelIndex();
135 const QAbstractItemModel *sourceModel = sourceIndex.model();
136 if (!d->containsSourceModel(sourceModel)) {
137 qWarning("QConcatenateTablesProxyModel: index from wrong model passed to mapFromSource");
138 Q_ASSERT(!"QConcatenateTablesProxyModel: index from wrong model passed to mapFromSource");
139 return QModelIndex();
140 }
141 if (sourceIndex.column() >= d->m_columnCount)
142 return QModelIndex();
143 int rowsPrior = d_func()->computeRowsPrior(sourceModel);
144 return createIndex(rowsPrior + sourceIndex.row(), sourceIndex.column(), sourceIndex.internalPointer());
145}
146
151{
153 Q_ASSERT(checkIndex(proxyIndex));
154 if (!proxyIndex.isValid())
155 return QModelIndex();
156 if (proxyIndex.model() != this) {
157 qWarning("QConcatenateTablesProxyModel: index from wrong model passed to mapToSource");
158 Q_ASSERT(!"QConcatenateTablesProxyModel: index from wrong model passed to mapToSource");
159 return QModelIndex();
160 }
161 const int row = proxyIndex.row();
162 const auto result = d->sourceModelForRow(row);
163 if (!result.sourceModel)
164 return QModelIndex();
165 return result.sourceModel->index(result.sourceRow, proxyIndex.column());
166}
167
172{
173 const QModelIndex sourceIndex = mapToSource(index);
175 if (!sourceIndex.isValid())
176 return QVariant();
177 return sourceIndex.data(role);
178}
179
184{
186 const QModelIndex sourceIndex = mapToSource(index);
187 Q_ASSERT(sourceIndex.isValid());
188 const auto sourceModel = const_cast<QAbstractItemModel *>(sourceIndex.model());
189 return sourceModel->setData(sourceIndex, value, role);
190}
191
195QMap<int, QVariant> QConcatenateTablesProxyModel::itemData(const QModelIndex &proxyIndex) const
196{
197 Q_ASSERT(checkIndex(proxyIndex));
198 const QModelIndex sourceIndex = mapToSource(proxyIndex);
199 Q_ASSERT(sourceIndex.isValid());
200 return sourceIndex.model()->itemData(sourceIndex);
201}
202
206bool QConcatenateTablesProxyModel::setItemData(const QModelIndex &proxyIndex, const QMap<int, QVariant> &roles)
207{
208 Q_ASSERT(checkIndex(proxyIndex));
209 const QModelIndex sourceIndex = mapToSource(proxyIndex);
210 Q_ASSERT(sourceIndex.isValid());
211 const auto sourceModel = const_cast<QAbstractItemModel *>(sourceIndex.model());
212 return sourceModel->setItemData(sourceIndex, roles);
213}
214
222{
224 if (d->m_models.isEmpty())
225 return Qt::NoItemFlags;
227 if (!index.isValid())
228 return d->m_models.at(0).model->flags(index);
229 const QModelIndex sourceIndex = mapToSource(index);
230 Q_ASSERT(sourceIndex.isValid());
231 return sourceIndex.model()->flags(sourceIndex);
232}
233
240{
242 if (d->m_models.isEmpty())
243 return QVariant();
244 switch (orientation) {
245 case Qt::Horizontal:
246 return d->m_models.at(0).model->headerData(section, orientation, role);
247 case Qt::Vertical: {
248 const auto result = d->sourceModelForRow(section);
249 Q_ASSERT(result.sourceModel);
250 return result.sourceModel->headerData(result.sourceRow, orientation, role);
251 }
252 }
253 return QVariant();
254}
255
261{
263 if (parent.isValid())
264 return 0; // flat model
265 return d->m_columnCount;
266}
267
272{
275 if (!hasIndex(row, column, parent))
276 return QModelIndex();
278 const auto result = d->sourceModelForRow(row);
279 Q_ASSERT(result.sourceModel);
280 return mapFromSource(result.sourceModel->index(result.sourceRow, column));
281}
282
287{
289 return QModelIndex(); // flat model, no hierarchy
290}
291
296{
298 if (parent.isValid())
299 return 0; // flat model
300 return d->m_rowCount;
301}
302
308{
310 if (d->m_models.isEmpty())
311 return QStringList();
312 return d->m_models.at(0).model->mimeTypes();
313}
314
327{
329 if (indexes.isEmpty())
330 return nullptr;
331 const QModelIndex firstIndex = indexes.first();
333 const auto result = d->sourceModelForRow(firstIndex.row());
334 QModelIndexList sourceIndexes;
335 sourceIndexes.reserve(indexes.size());
336 for (const QModelIndex &index : indexes) {
337 const QModelIndex sourceIndex = mapToSource(index);
338 Q_ASSERT(sourceIndex.model() == result.sourceModel); // see documentation above
339 sourceIndexes.append(sourceIndex);
340 }
341 return result.sourceModel->mimeData(sourceIndexes);
342}
343
344
346 int *sourceRow, int *sourceColumn, QModelIndex *sourceParent, QAbstractItemModel **sourceModel) const
347{
349 *sourceColumn = column;
350 if (!parent.isValid()) {
351 // Drop after the last item
352 if (row == -1 || row == m_rowCount) {
353 *sourceRow = -1;
354 *sourceModel = m_models.constLast().model;
355 return true;
356 }
357 // Drop between toplevel items
358 const auto result = sourceModelForRow(row);
359 Q_ASSERT(result.sourceModel);
360 *sourceRow = result.sourceRow;
361 *sourceModel = result.sourceModel;
362 return true;
363 } else {
364 if (row > -1)
365 return false; // flat model, no dropping as new children of items
366 // Drop onto item
367 const int targetRow = parent.row();
368 const auto result = sourceModelForRow(targetRow);
369 Q_ASSERT(result.sourceModel);
370 const QModelIndex sourceIndex = q->mapToSource(parent);
371 *sourceRow = -1;
372 *sourceParent = sourceIndex;
373 *sourceModel = result.sourceModel;
374 return true;
375 }
376}
377
382{
384 if (d->m_models.isEmpty())
385 return false;
386
388 QModelIndex sourceParent;
389 QAbstractItemModel *sourceModel;
390 if (!d->mapDropCoordinatesToSource(row, column, parent, &sourceRow, &sourceColumn, &sourceParent, &sourceModel))
391 return false;
392 return sourceModel->canDropMimeData(data, action, sourceRow, sourceColumn, sourceParent);
393}
394
405{
407 if (d->m_models.isEmpty())
408 return false;
410 QModelIndex sourceParent;
411 QAbstractItemModel *sourceModel;
412 if (!d->mapDropCoordinatesToSource(row, column, parent, &sourceRow, &sourceColumn, &sourceParent, &sourceModel))
413 return false;
414
415 return sourceModel->dropMimeData(data, action, sourceRow, sourceColumn, sourceParent);
416}
417
422{
425 if (d->m_models.isEmpty() || !index.isValid())
426 return QSize();
427 const QModelIndex sourceIndex = mapToSource(index);
428 Q_ASSERT(sourceIndex.isValid());
429 return sourceIndex.model()->span(sourceIndex);
430}
431
437QList<QAbstractItemModel *> QConcatenateTablesProxyModel::sourceModels() const
438{
440 QList<QAbstractItemModel *> ret;
441 ret.reserve(d->m_models.size());
442 for (const auto &info : d->m_models)
443 ret.push_back(info.model);
444 return ret;
445}
446
455{
457 Q_ASSERT(sourceModel);
458 Q_ASSERT(!d->containsSourceModel(sourceModel));
459
460 const int newRows = sourceModel->rowCount();
461 if (newRows > 0)
462 beginInsertRows(QModelIndex(), d->m_rowCount, d->m_rowCount + newRows - 1);
463 d->m_rowCount += newRows;
464 d->m_models.emplace_back(sourceModel, std::array{
475
484
493 });
494 if (newRows > 0)
496
497 d->updateColumnCount();
498}
499
506{
508
509 auto it = d->findSourceModel(sourceModel);
510 Q_ASSERT(it != d->m_models.cend());
511 for (auto &c : it->connections)
512 disconnect(c);
513
514 const int rowsRemoved = sourceModel->rowCount();
515 const int rowsPrior = d->computeRowsPrior(sourceModel); // location of removed section
516
517 if (rowsRemoved > 0)
518 beginRemoveRows(QModelIndex(), rowsPrior, rowsPrior + rowsRemoved - 1);
519 d->m_models.erase(it);
520 d->m_rowCount -= rowsRemoved;
521 if (rowsRemoved > 0)
523
524 d->updateColumnCount();
525}
526
528 int start, int end)
529{
531 if (parent.isValid()) // not supported, the proxy is a flat model
532 return;
533 const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
534 const int rowsPrior = computeRowsPrior(model);
535 q->beginInsertRows(QModelIndex(), rowsPrior + start, rowsPrior + end);
536}
537
539 int end)
540{
542 if (parent.isValid()) // flat model
543 return;
544 m_rowCount += end - start + 1;
545 q->endInsertRows();
546}
547
549 int start, int end)
550{
552 if (parent.isValid()) // flat model
553 return;
554 const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
555 const int rowsPrior = computeRowsPrior(model);
556 q->beginRemoveRows(QModelIndex(), rowsPrior + start, rowsPrior + end);
557}
558
560{
562 if (parent.isValid()) // flat model
563 return;
564 m_rowCount -= end - start + 1;
565 q->endRemoveRows();
566}
567
569 int start, int end)
570{
572 if (parent.isValid()) // flat model
573 return;
574 const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
575 const int oldColCount = model->columnCount();
576 const int newColCount = columnCountAfterChange(model, oldColCount + end - start + 1);
577 Q_ASSERT(newColCount >= oldColCount);
578 if (newColCount > oldColCount)
579 // If the underlying models have a different number of columns (example: 2 and 3), inserting 2 columns in
580 // the first model leads to inserting only one column in the proxy, since qMin(2+2,3) == 3.
581 q->beginInsertColumns(QModelIndex(), start, qMin(end, start + newColCount - oldColCount - 1));
582 m_newColumnCount = newColCount;
583}
584
586 int end)
587{
589 Q_UNUSED(end);
591 if (parent.isValid()) // flat model
592 return;
595 q->endInsertColumns();
596 }
597}
598
600 int start, int end)
601{
603 if (parent.isValid()) // flat model
604 return;
605 const QAbstractItemModel * const model = static_cast<QAbstractItemModel *>(q->sender());
606 const int oldColCount = model->columnCount();
607 const int newColCount = columnCountAfterChange(model, oldColCount - (end - start + 1));
608 Q_ASSERT(newColCount <= oldColCount);
609 if (newColCount < oldColCount)
610 q->beginRemoveColumns(QModelIndex(), start, qMax(end, start + oldColCount - newColCount - 1));
611 m_newColumnCount = newColCount;
612}
613
615 int end)
616{
619 Q_UNUSED(end);
620 if (parent.isValid()) // flat model
621 return;
624 q->endRemoveColumns();
625 }
626}
627
629 const QModelIndex &to,
630 const QList<int> &roles)
631{
633 Q_ASSERT(from.isValid());
634 Q_ASSERT(to.isValid());
635 if (from.column() >= m_columnCount)
636 return;
637 QModelIndex adjustedTo = to;
638 if (to.column() >= m_columnCount)
639 adjustedTo = to.siblingAtColumn(m_columnCount - 1);
640 const QModelIndex myFrom = q->mapFromSource(from);
642 const QModelIndex myTo = q->mapFromSource(adjustedTo);
644 emit q->dataChanged(myFrom, myTo, roles);
645}
646
648 const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
649{
651
652 if (!sourceParents.isEmpty() && !sourceParents.contains(QModelIndex()))
653 return;
654
655 emit q->layoutAboutToBeChanged({}, hint);
656
657 const QModelIndexList persistentIndexList = q->persistentIndexList();
658 layoutChangePersistentIndexes.reserve(persistentIndexList.size());
659 layoutChangeProxyIndexes.reserve(persistentIndexList.size());
660
661 for (const QModelIndex &proxyPersistentIndex : persistentIndexList) {
662 layoutChangeProxyIndexes.append(proxyPersistentIndex);
663 Q_ASSERT(proxyPersistentIndex.isValid());
664 const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
665 Q_ASSERT(srcPersistentIndex.isValid());
666 layoutChangePersistentIndexes << srcPersistentIndex;
667 }
668}
669
671 const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
672{
674 if (!sourceParents.isEmpty() && !sourceParents.contains(QModelIndex()))
675 return;
676 for (int i = 0; i < layoutChangeProxyIndexes.size(); ++i) {
677 const QModelIndex proxyIdx = layoutChangeProxyIndexes.at(i);
678 const QModelIndex newProxyIdx = q->mapFromSource(layoutChangePersistentIndexes.at(i));
679 q->changePersistentIndex(proxyIdx, newProxyIdx);
680 }
681
684
685 emit q->layoutChanged({}, hint);
686}
687
689{
691 Q_ASSERT(containsSourceModel(static_cast<QAbstractItemModel *>(q->sender())));
692 q->beginResetModel();
693 // A reset might reduce both rowCount and columnCount, and we can't notify of both at the same time,
694 // and notifying of one after the other leaves an intermediary invalid situation.
695 // So the only safe choice is to forward it as a full reset.
696}
697
706
708{
709 if (m_models.isEmpty())
710 return 0;
711
712 auto byColumnCount = [](const auto &a, const auto &b) {
713 return a.model->columnCount() < b.model->columnCount();
714 };
715 const auto it = std::min_element(m_models.begin(), m_models.end(), byColumnCount);
716 return it->model->columnCount();
717}
718
720{
722 const int newColumnCount = calculatedColumnCount();
723 const int columnDiff = newColumnCount - m_columnCount;
724 if (columnDiff > 0) {
725 q->beginInsertColumns(QModelIndex(), m_columnCount, m_columnCount + columnDiff - 1);
726 m_columnCount = newColumnCount;
727 q->endInsertColumns();
728 } else if (columnDiff < 0) {
729 const int lastColumn = m_columnCount - 1;
730 q->beginRemoveColumns(QModelIndex(), lastColumn + columnDiff + 1, lastColumn);
731 m_columnCount = newColumnCount;
732 q->endRemoveColumns();
733 }
734}
735
737{
738 int newColumnCount = 0;
739 for (qsizetype i = 0; i < m_models.size(); ++i) {
740 const QAbstractItemModel *mod = m_models.at(i).model;
741 const int colCount = mod == model ? newCount : mod->columnCount();
742 if (i == 0)
743 newColumnCount = colCount;
744 else
745 newColumnCount = qMin(colCount, newColumnCount);
746 }
747 return newColumnCount;
748}
749
751{
752 int rowsPrior = 0;
753 for (const auto &[model, _] : m_models) {
754 if (model == sourceModel)
755 break;
756 rowsPrior += model->rowCount();
757 }
758 return rowsPrior;
759}
760
762{
764 int rowCount = 0;
765 for (const auto &[model, _] : m_models) {
766 const int subRowCount = model->rowCount();
767 if (rowCount + subRowCount > row) {
768 result.sourceModel = model;
769 break;
770 }
771 rowCount += subRowCount;
772 }
773 result.sourceRow = row - rowCount;
774 return result;
775}
776
778
779#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,...
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 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...
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.
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 slotSourceLayoutAboutToBeChanged(const QList< QPersistentModelIndex > &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
bool containsSourceModel(const QAbstractItemModel *m) const
void slotRowsAboutToBeRemoved(const QModelIndex &, int start, int end)
void slotDataChanged(const QModelIndex &from, const QModelIndex &to, const QList< int > &roles)
SourceModelForRowResult sourceModelForRow(int row) const
void slotColumnsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
QList< ModelInfo >::const_iterator findSourceModel(const QAbstractItemModel *m) const
void slotColumnsRemoved(const QModelIndex &parent, int, int)
int columnCountAfterChange(const QAbstractItemModel *model, int newCount) const
void slotRowsAboutToBeInserted(const QModelIndex &, int start, int end)
bool mapDropCoordinatesToSource(int row, int column, const QModelIndex &parent, int *sourceRow, int *sourceColumn, QModelIndex *sourceParent, QAbstractItemModel **sourceModel) const
void slotColumnsAboutToBeInserted(const QModelIndex &parent, int start, int end)
void slotRowsInserted(const QModelIndex &, int start, int end)
void slotColumnsInserted(const QModelIndex &parent, int, int)
void slotSourceLayoutChanged(const QList< QPersistentModelIndex > &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
int computeRowsPrior(const QAbstractItemModel *sourceModel) const
void 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
Definition qlist.h:397
bool isEmpty() const noexcept
Definition qlist.h:401
T & first()
Definition qlist.h:645
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
void reserve(qsizetype size)
Definition qlist.h:753
void append(parameter_type t)
Definition qlist.h:458
void clear()
Definition qlist.h:434
\inmodule QtCore
Definition qmimedata.h:16
\inmodule QtCore
QModelIndex siblingAtColumn(int column) const
Returns the sibling at column for the current row.
constexpr int row() const noexcept
Returns the row this model index refers to.
constexpr int column() const noexcept
Returns the column this model index refers to.
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
QObject * parent
Definition qobject.h:73
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
Definition qobject_p.h:299
\inmodule QtCore
Definition qobject.h:103
const_iterator cend() const noexcept
Definition qset.h:142
\inmodule QtCore
Definition qsize.h:25
int rowCount(const QModelIndex &parent=QModelIndex()) const override
If the database supports returning the size of a query (see QSqlDriver::hasFeature()),...
int columnCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
\inmodule QtCore
\inmodule QtCore
Definition qvariant.h:65
QSet< QString >::iterator it
Combined button and popup list for selecting options.
Orientation
Definition qnamespace.h:98
@ Horizontal
Definition qnamespace.h:99
@ Vertical
Definition qnamespace.h:100
DropAction
@ NoItemFlags
QList< QString > QStringList
Constructs a string list that contains the given string, str.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:166
return ret
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
GLboolean GLboolean GLboolean b
const GLfloat * m
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLuint GLuint end
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint start
GLenum GLenum GLsizei void GLsizei void * column
const GLubyte * c
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)
ptrdiff_t qsizetype
Definition qtypes.h:165
QSqlQueryModel * model
[16]
QObject::connect nullptr
myObject disconnect()
[26]
QHostInfo info
[0]
std::array< QMetaObject::Connection, 13 > ConnArray