src/corelib/kernel/qabstractitemmodel.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
  2473     \internal
  2473     \internal
  2474 */
  2474 */
  2475 bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int start, int end, const QModelIndex &destinationParent, int destinationStart, Qt::Orientation orientation)
  2475 bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int start, int end, const QModelIndex &destinationParent, int destinationStart, Qt::Orientation orientation)
  2476 {
  2476 {
  2477     // Don't move the range within itself.
  2477     // Don't move the range within itself.
  2478     if ( ( destinationParent == srcParent )
  2478     if (destinationParent == srcParent)
  2479             && ( destinationStart >= start )
  2479         return !(destinationStart >= start && destinationStart <= end + 1);
  2480             && ( destinationStart <= end + 1) )
       
  2481         return false;
       
  2482 
  2480 
  2483     QModelIndex destinationAncestor = destinationParent;
  2481     QModelIndex destinationAncestor = destinationParent;
  2484     int pos = (Qt::Vertical == orientation) ? destinationAncestor.row() : destinationAncestor.column();
  2482     int pos = (Qt::Vertical == orientation) ? destinationAncestor.row() : destinationAncestor.column();
  2485     forever {
  2483     forever {
  2486         if (destinationAncestor == srcParent) {
  2484         if (destinationAncestor == srcParent) {
  2546 
  2544 
  2547     d->changes.push(QAbstractItemModelPrivate::Change(sourceParent, sourceFirst, sourceLast));
  2545     d->changes.push(QAbstractItemModelPrivate::Change(sourceParent, sourceFirst, sourceLast));
  2548     int destinationLast = destinationChild + (sourceLast - sourceFirst);
  2546     int destinationLast = destinationChild + (sourceLast - sourceFirst);
  2549     d->changes.push(QAbstractItemModelPrivate::Change(destinationParent, destinationChild, destinationLast));
  2547     d->changes.push(QAbstractItemModelPrivate::Change(destinationParent, destinationChild, destinationLast));
  2550 
  2548 
  2551     d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical);
       
  2552     emit rowsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild);
  2549     emit rowsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild);
  2553     emit layoutAboutToBeChanged();
  2550     emit layoutAboutToBeChanged();
       
  2551     d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical);
  2554     return true;
  2552     return true;
  2555 }
  2553 }
  2556 
  2554 
  2557 /*!
  2555 /*!
  2558     Ends a row move operation.
  2556     Ends a row move operation.