5#include <private/qtransposeproxymodel_p.h>
6#include <QtCore/qlist.h>
7#include <QtCore/qmetaobject.h>
8#include <QtCore/qsize.h>
9#include <QtCore/qmap.h>
15 if (!
model || !proxyIndex.isValid())
18 return q->createSourceIndex(proxyIndex.column(), proxyIndex.row(), proxyIndex.internalPointer());
23 if (!
model || !sourceIndex.isValid())
26 return q->createIndex(sourceIndex.column(), sourceIndex.row(), sourceIndex.internalPointer());
32 Q_ASSERT(layoutChangeProxyIndexes.
size() == layoutChangePersistentIndexes.
size());
34 toList.reserve(layoutChangePersistentIndexes.
size());
36 toList <<
q->mapFromSource(persistIdx);
37 q->changePersistentIndexList(layoutChangeProxyIndexes,
toList);
38 layoutChangeProxyIndexes.
clear();
39 layoutChangePersistentIndexes.
clear();
40 QList<QPersistentModelIndex> proxyParents;
41 proxyParents.reserve(parents.size());
43 proxyParents <<
q->mapFromSource(srcParent);
49 emit q->layoutChanged(proxyParents, proxyHint);
55 QList<QPersistentModelIndex> proxyParents;
56 proxyParents.reserve(sourceParents.size());
64 proxyParents << mappedParent;
71 emit q->layoutAboutToBeChanged(proxyParents, proxyHint);
73 layoutChangeProxyIndexes.
clear();
74 layoutChangePersistentIndexes.
clear();
75 layoutChangeProxyIndexes.
reserve(proxyPersistentIndexes.size());
76 layoutChangePersistentIndexes.
reserve(proxyPersistentIndexes.size());
77 for (
const QModelIndex &proxyPersistentIndex : proxyPersistentIndexes) {
78 layoutChangeProxyIndexes << proxyPersistentIndex;
79 Q_ASSERT(proxyPersistentIndex.isValid());
81 Q_ASSERT(srcPersistentIndex.isValid());
82 layoutChangePersistentIndexes << srcPersistentIndex;
87 const QList<int> &roles)
90 emit q->dataChanged(
q->mapFromSource(topLeft),
q->mapFromSource(bottomRight), roles);
93void QTransposeProxyModelPrivate::onHeaderDataChanged(
Qt::Orientation orientation,
int first,
int last)
99void QTransposeProxyModelPrivate::onColumnsAboutToBeInserted(
const QModelIndex &parent,
int first,
int last)
105void QTransposeProxyModelPrivate::onColumnsAboutToBeRemoved(
const QModelIndex &parent,
int first,
int last)
111void QTransposeProxyModelPrivate::onColumnsAboutToBeMoved(
const QModelIndex &sourceParent,
int sourceStart,
int sourceEnd,
const QModelIndex &destinationParent,
int destinationColumn)
114 q->beginMoveRows(
q->mapFromSource(sourceParent), sourceStart, sourceEnd,
q->mapFromSource(destinationParent), destinationColumn);
117void QTransposeProxyModelPrivate::onRowsAboutToBeInserted(
const QModelIndex &parent,
int first,
int last)
120 q->beginInsertColumns(
q->mapFromSource(
parent),
first, last);
123void QTransposeProxyModelPrivate::onRowsAboutToBeRemoved(
const QModelIndex &parent,
int first,
int last)
126 q->beginRemoveColumns(
q->mapFromSource(
parent),
first, last);
129void QTransposeProxyModelPrivate::onRowsAboutToBeMoved(
const QModelIndex &sourceParent,
int sourceStart,
int sourceEnd,
const QModelIndex &destinationParent,
int destinationRow)
132 q->beginMoveColumns(
q->mapFromSource(sourceParent), sourceStart, sourceEnd,
q->mapFromSource(destinationParent), destinationRow);
171 if (newSourceModel ==
d->model)
178 d->sourceConnections.clear();
181 using namespace std::placeholders;
182 d->sourceConnections = QList<QMetaObject::Connection>{
188 connect(
d->model, &
QAbstractItemModel::columnsAboutToBeMoved,
this, std::bind(&QTransposeProxyModelPrivate::onColumnsAboutToBeMoved,
d, _1, _2, _3, _4, _5)),
194 connect(
d->model, &
QAbstractItemModel::rowsAboutToBeMoved,
this, std::bind(&QTransposeProxyModelPrivate::onRowsAboutToBeMoved,
d, _1, _2, _3, _4, _5)),
259 if (!
d->model || !
index.isValid())
271 if (!
d->model || !
index.isValid())
283 return QMap<int, QVariant>();
294 if (!
d->model || !sourceIndex.isValid())
296 Q_ASSERT(
d->model->checkIndex(sourceIndex));
297 return d->uncheckedMapFromSource(sourceIndex);
307 if (!
d->model || !proxyIndex.isValid())
309 return d->uncheckedMapToSource(proxyIndex);
319 if (!
d->model || !
index.isValid())
321 return d->uncheckedMapFromSource(
d->uncheckedMapToSource(
index).parent());
423#include "moc_qtransposeproxymodel.cpp"
void rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow, QPrivateSignal)
Q_INVOKABLE int const QModelIndex & parent
Returns the parent of the model item with the given index.
void endResetModel()
Completes a model reset operation.
void modelAboutToBeReset(QPrivateSignal)
void endMoveColumns()
Ends a column move operation.
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.
void modelReset(QPrivateSignal)
void endRemoveRows()
Ends a row removal operation.
void endMoveRows()
Ends a row move operation.
Q_INVOKABLE int int const QModelIndex & destinationParent
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.
void columnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn, QPrivateSignal)
void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted just before columns are removed from the model.
Q_INVOKABLE int int const QModelIndex int destinationChild
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
void headerDataChanged(Qt::Orientation orientation, int first, int last)
This signal is emitted whenever a header is changed.
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.
void beginResetModel()
Begins a model reset operation.
void endRemoveColumns()
Ends a column removal operation.
void rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow, QPrivateSignal)
void rowsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been inserted into the model.
void columnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn, QPrivateSignal)
void endInsertColumns()
Ends a column insertion operation.
void columnsInserted(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after columns have been inserted into the model.
void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been removed from the model.
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting,...
virtual void setSourceModel(QAbstractItemModel *sourceModel)
Sets the given sourceModel to be processed by the proxy model.
qsizetype size() const noexcept
void reserve(qsizetype size)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
This proxy transposes the source model.
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) override
\reimp
bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override
\reimp
~QTransposeProxyModel()
Destructs the proxy model.
QMap< int, QVariant > itemData(const QModelIndex &index) const override
\reimp
QSize span(const QModelIndex &index) const override
\reimp
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
\reimp
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
\reimp This method will perform no action.
QTransposeProxyModel(QObject *parent=nullptr)
Constructs a new proxy model with the given parent.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
void setSourceModel(QAbstractItemModel *newSourceModel) override
\reimp
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override
\reimp
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override
\reimp
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
\reimp
bool setItemData(const QModelIndex &index, const QMap< int, QVariant > &roles) override
\reimp
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
\reimp
int columnCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLenum GLsizei count
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
GLfixed GLfixed GLint GLint order
static QList< QVariant > toList(char **buf, int count)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
QSqlQueryModel * model
[16]
myObject disconnect()
[26]