diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-12-04 12:44:45 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2020-01-02 17:48:07 +0100 |
commit | 2ced01cbdd10a9959db03406f74529cdcce544ca (patch) | |
tree | 48eb1aafb75a448af75250f9e3edf8566f58dbf7 /src | |
parent | cf033b32b56f82cbace1525394f32199cd3a32f7 (diff) |
QIdentityProxyModel: implement moveRows / moveColumns
It makes sense for it (instead of triggering the QAbstractItemModel
base class implementation, which doesn't do anything). Safe to override
virtuals in this case -- code calling the old version could not do
anything useful, so at least new code gets those functions properly
implemented for free.
Change-Id: Iefe1ff25e15d877435e93ab28289ad2579616f72
Task-number: QTBUG-48076
Reviewed-by: Luca Beldi <v.ronin@yahoo.it>
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/itemmodels/qidentityproxymodel.cpp | 24 | ||||
-rw-r--r-- | src/corelib/itemmodels/qidentityproxymodel.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index 39992eccd3..f5684c6eda 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -313,6 +313,30 @@ bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex& pare /*! \reimp + \since 5.15 + */ +bool QIdentityProxyModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) +{ + Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == this : true); + Q_ASSERT(destinationParent.isValid() ? destinationParent.model() == this : true); + Q_D(QIdentityProxyModel); + return d->model->moveRows(mapToSource(sourceParent), sourceRow, count, mapToSource(destinationParent), destinationChild); +} + +/*! + \reimp + \since 5.15 + */ +bool QIdentityProxyModel::moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) +{ + Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == this : true); + Q_ASSERT(destinationParent.isValid() ? destinationParent.model() == this : true); + Q_D(QIdentityProxyModel); + return d->model->moveColumns(mapToSource(sourceParent), sourceColumn, count, mapToSource(destinationParent), destinationChild); +} + +/*! + \reimp */ int QIdentityProxyModel::rowCount(const QModelIndex& parent) const { diff --git a/src/corelib/itemmodels/qidentityproxymodel.h b/src/corelib/itemmodels/qidentityproxymodel.h index 89ac89cdba..4c14e6176a 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.h +++ b/src/corelib/itemmodels/qidentityproxymodel.h @@ -77,6 +77,8 @@ public: bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override; bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; + bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override; + bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override; protected: QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent); |