]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Yet more corner cases in commitToggleIndexRange - include them, and refactor to make...
authorSimon Paul St James <kdedevel@etotheipiplusone.com>
Tue, 28 Oct 2008 19:47:31 +0000 (19:47 +0000)
committerSimon Paul St James <kdedevel@etotheipiplusone.com>
Tue, 28 Oct 2008 19:47:31 +0000 (19:47 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=877164

src/dolphindetailsview.cpp

index f21f6ed66d3410ec78c0575c30fa5072f8abfe31..6d9038b46e026744f00282850ef7e89beb03108e 100644 (file)
@@ -786,22 +786,21 @@ void DolphinDetailsView::updateElasticBandSelection()
                                             allItemsInBoundDone ||
                                             currIndex.parent() != toggleIndexRangeBegin.parent());
        if (commitToggleIndexRange) {
                                             allItemsInBoundDone ||
                                             currIndex.parent() != toggleIndexRangeBegin.parent());
        if (commitToggleIndexRange) {
-           if (!allItemsInBoundDone) {
+           formingToggleIndexRange = false;
+            // If this is the last item in the bounds and it is also the beginning of a range,
+            // don't toggle lastIndex - it will already have been dealt with.
+           if (!allItemsInBoundDone || toggleIndexRangeBegin != currIndex) { 
                itemsToToggle.select(toggleIndexRangeBegin, lastIndex);
                itemsToToggle.select(toggleIndexRangeBegin, lastIndex);
-               // Need to start a new range immediately with currIndex?
-               if (needToToggleItem)
-                   toggleIndexRangeBegin = currIndex;
            }
            }
-           else  {
-                // Final item in the bounds.  Is it also the beginning of a range?
-               if (toggleIndexRangeBegin == currIndex) {
-                   itemsToToggle.select(currIndex, currIndex);
-               }
-               else {
-                   itemsToToggle.select(toggleIndexRangeBegin, lastIndex);
-               }
+            // Need to start a new range immediately with currIndex?
+           if (needToToggleItem) {
+               toggleIndexRangeBegin = currIndex;
+               formingToggleIndexRange = true;
+           }
+           if (allItemsInBoundDone && needToToggleItem) {
+                // Toggle the very last item in the bounds.
+               itemsToToggle.select(currIndex, currIndex);
            }
            }
-           formingToggleIndexRange = needToToggleItem;
        }
 
        // next item
        }
 
        // next item