diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 42 | ||||
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.h | 15 |
2 files changed, 56 insertions, 1 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index cdc9466a0b..50a63e28da 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -1959,6 +1959,48 @@ bool QAbstractItemModel::removeColumns(int, int, const QModelIndex &) } /*! + On models that support this, moves \a count rows starting with the given + \a sourceRow under parent \a sourceParent to row \a destinationChild under + \a parent \a destinationParent. + + Returns true if the rows were successfully moved; otherwise returns + false. + + The base class implementation does nothing and returns false. + + If you implement your own model, you can reimplement this function if you + want to support moving. Alternatively, you can provide your own API for + altering the data. + + \sa beginMoveRows(), endMoveRows() +*/ +bool QAbstractItemModel::moveRows(const QModelIndex &, int , int , const QModelIndex &, int) +{ + return false; +} + +/*! + On models that support this, moves \a count columns starting with the given + \a sourceColumn under parent \a sourceParent to column \a destinationChild under + \a parent \a destinationParent. + + Returns true if the columns were successfully moved; otherwise returns + false. + + The base class implementation does nothing and returns false. + + If you implement your own model, you can reimplement this function if you + want to support moving. Alternatively, you can provide your own API for + altering the data. + + \sa beginMoveColumns(), endMoveColumns() +*/ +bool QAbstractItemModel::moveColumns(const QModelIndex &, int , int , const QModelIndex &, int) +{ + return false; +} + +/*! Fetches any available data for the items with the parent specified by the \a parent index. 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 |