diff options
author | Mark Brand <mabrand@mabrand.nl> | 2011-04-10 21:48:36 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-24 19:12:23 +0100 |
commit | 764840ec0e189b4a9f76cdd659d82a2a50324190 (patch) | |
tree | 42b40caa1892cd1c219b2865b2e7e3bcb529234e /src/corelib/itemmodels/qabstractitemmodel.h | |
parent | af48e0ba36aed330e8b262687e3192d7e09796f7 (diff) |
add missing move* methods to QAbstractItemModel
The existence of QAbstractItemModel virtual methods
moveRow, moveColumn, moveRows, and moveColumns
is implied by the existence of
beginMoveRows, endMoveRows, beginMoveColumns and endMoveColumns.
However, these were not actually provided by QAbstractItemModel.
With this change, subclasses can implement support for moving rows
and columns following the same pattern as for insert* and remove*.
Change-Id: Iad8b2223d4b9303abb6459c174a82ffed71a0fdf
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.h')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 15669a0937..e5e6d26e93 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -210,11 +210,19 @@ public: virtual bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()); virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); virtual bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()); + virtual bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, + const QModelIndex &destinationParent, int destinationChild); + virtual bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, + const QModelIndex &destinationParent, int destinationChild); inline bool insertRow(int row, const QModelIndex &parent = QModelIndex()); inline bool insertColumn(int column, const QModelIndex &parent = QModelIndex()); inline bool removeRow(int row, const QModelIndex &parent = QModelIndex()); inline bool removeColumn(int column, const QModelIndex &parent = QModelIndex()); + inline bool moveRow(const QModelIndex &sourceParent, int sourceRow, + const QModelIndex &destinationParent, int destinationChild); + inline bool moveColumn(const QModelIndex &sourceParent, int sourceColumn, + const QModelIndex &destinationParent, int destinationChild); virtual void fetchMore(const QModelIndex &parent); virtual bool canFetchMore(const QModelIndex &parent) const; @@ -330,7 +338,12 @@ inline bool QAbstractItemModel::removeRow(int arow, const QModelIndex &aparent) { return removeRows(arow, 1, aparent); } inline bool QAbstractItemModel::removeColumn(int acolumn, const QModelIndex &aparent) { return removeColumns(acolumn, 1, aparent); } - +inline bool QAbstractItemModel::moveRow(const QModelIndex &sourceParent, int sourceRow, + const QModelIndex &destinationParent, int destinationChild) +{ return moveRows(sourceParent, sourceRow, 1, destinationParent, destinationChild); } +inline bool QAbstractItemModel::moveColumn(const QModelIndex &sourceParent, int sourceColumn, + const QModelIndex &destinationParent, int destinationChild) +{ return moveRows(sourceParent, sourceColumn, 1, destinationParent, destinationChild); } inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, void *adata) const { return QModelIndex(arow, acolumn, adata, this); } inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, int aid) const |