src/corelib/kernel/qabstractitemmodel.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
--- a/src/corelib/kernel/qabstractitemmodel.cpp	Tue Jan 26 12:42:25 2010 +0200
+++ b/src/corelib/kernel/qabstractitemmodel.cpp	Tue Feb 02 00:43:10 2010 +0200
@@ -2475,10 +2475,8 @@
 bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int start, int end, const QModelIndex &destinationParent, int destinationStart, Qt::Orientation orientation)
 {
     // Don't move the range within itself.
-    if ( ( destinationParent == srcParent )
-            && ( destinationStart >= start )
-            && ( destinationStart <= end + 1) )
-        return false;
+    if (destinationParent == srcParent)
+        return !(destinationStart >= start && destinationStart <= end + 1);
 
     QModelIndex destinationAncestor = destinationParent;
     int pos = (Qt::Vertical == orientation) ? destinationAncestor.row() : destinationAncestor.column();
@@ -2548,9 +2546,9 @@
     int destinationLast = destinationChild + (sourceLast - sourceFirst);
     d->changes.push(QAbstractItemModelPrivate::Change(destinationParent, destinationChild, destinationLast));
 
-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical);
     emit rowsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild);
     emit layoutAboutToBeChanged();
+    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical);
     return true;
 }