]> granicus.if.org Git - transmission/commitdiff
update moveGroupAtRow:toRow to use NSMutableArrayAdditions's moveObjectAtIndex:toIndex:
authorMitchell Livingston <livings124@transmissionbt.com>
Wed, 4 Jan 2012 00:06:30 +0000 (00:06 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Wed, 4 Jan 2012 00:06:30 +0000 (00:06 +0000)
macosx/GroupsController.m
macosx/GroupsPrefsController.m

index e2e9007db6ae60eabea20c08faf90425070188cd..b49ddaf4ae78eecf64a80a695d26f9e41a97bf2a 100644 (file)
@@ -23,6 +23,7 @@
  *****************************************************************************/
 
 #import "GroupsController.h"
+#import "NSMutableArrayAdditions.h"
 
 #define ICON_WIDTH 16.0
 #define ICON_WIDTH_SMALL 12.0
@@ -281,17 +282,7 @@ GroupsController * fGroupsInstance = nil;
 
 - (void) moveGroupAtRow: (NSInteger) oldRow toRow: (NSInteger) newRow
 {
-    if (oldRow < newRow)
-        newRow--;
-    
-    //remove objects to reinsert
-    id movingGroup = [[fGroups objectAtIndex: oldRow] retain];
-    [fGroups removeObjectAtIndex: oldRow];
-    
-    //insert objects at new location
-    [fGroups insertObject: movingGroup atIndex: newRow];
-    
-    [movingGroup release];
+    [fGroups moveObjectAtIndex: oldRow toIndex: newRow];
     
     [self saveGroups];
     [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self];
index 237e40ee98c58e0359a1713cb5b5bb908ef86852..93b2b2bcc4f22429daf0eaeb895915e66c555299 100644 (file)
         NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData: [pasteboard dataForType: GROUP_TABLE_VIEW_DATA_TYPE]];
         NSInteger oldRow = [indexes firstIndex], selectedRow = [fTableView selectedRow];
         
+        if (oldRow < newRow)
+            newRow--;
         
         if ([NSApp isOnLionOrBetter])
             [fTableView beginUpdates];
         
         [[GroupsController groups] moveGroupAtRow: oldRow toRow: newRow];
         
-        if (oldRow < newRow)
-            newRow--;
-        
         if ([NSApp isOnLionOrBetter])
         {
             [fTableView moveRowAtIndex: oldRow toIndex: newRow];