]> granicus.if.org Git - transmission/commitdiff
merge some code for removing trackers
authorMitchell Livingston <livings124@transmissionbt.com>
Mon, 2 Jun 2008 18:47:54 +0000 (18:47 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Mon, 2 Jun 2008 18:47:54 +0000 (18:47 +0000)
macosx/InfoWindowController.m

index a1023c8af3994e46ce9432c913deab103863ae14..832b0271e5f2d3f7d0bfa9306f1a68964bc5ed1c 100644 (file)
@@ -1452,22 +1452,18 @@ typedef enum
 {
     NSMutableIndexSet * indexes = [[[fTrackerTable selectedRowIndexes] mutableCopy] autorelease];
     
-    #warning merge?
-    //if a group is selected, remove all trackers in the group
-    NSUInteger i;
-    for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
+    
+    NSUInteger i = 0;
+    while (i < [fTrackers count])
     {
-        if ([[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]])
+        //if a group is selected, remove all trackers in the group
+        if ([indexes containsIndex: i])
         {
             for (i = i+1; i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; i++)
                 [indexes addIndex: i];
-            i--;
         }
-    }
-    
-    //remove empty groups
-    for (i = 0; i < [fTrackers count]; i++)
-        if (![indexes containsIndex: i] && [[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]])
+        //remove empty groups
+        else
         {
             BOOL allSelected = YES;
             NSUInteger j;
@@ -1481,7 +1477,12 @@ typedef enum
             if (allSelected)
                 [indexes addIndex: i];
             i = j;
+            
+            //get to next group
+            while (i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]])
+                i++;
         }
+    }
     
     if ([fTrackers count] == [indexes count])
     {