]> granicus.if.org Git - transmission/commitdiff
allow changing groups by dragging (regardless of sort)
authorMitchell Livingston <livings124@transmissionbt.com>
Mon, 12 May 2008 21:57:37 +0000 (21:57 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Mon, 12 May 2008 21:57:37 +0000 (21:57 +0000)
NEWS
macosx/Controller.m

diff --git a/NEWS b/NEWS
index 210ffa28620097fb249b6fbe5e235269df29c46f..70517881c8deaa29ca49a04039299b19b27a52af 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ NEWS file for Transmission <http://www.transmissionbt.com/>
 1.30 (2008/mm/dd)
 http://trac.transmissionbt.com/query?group=component&milestone=1.30
 - Mac
+   + Torrents can be dragged to different groups
    + Status strings are toggled from the action button (they are no longer clickable)
 
 1.20 (2008/05/09)
index 49ba7f2381bd1d109952bb14db0fd65d6e398969..c68edd95bc876a3ea014829a000af8d5307ebea4 100644 (file)
@@ -2578,7 +2578,8 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
 - (BOOL) outlineView: (NSOutlineView *) outlineView writeItems: (NSArray *) items toPasteboard: (NSPasteboard *) pasteboard
 {
     //only allow reordering of rows if sorting by order
-    if ([[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER])
+    if (([fDefaults boolForKey: @"SortByGroup"] && [NSApp isOnLeopardOrBetter])
+        || [[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER])
     {
         NSMutableIndexSet * indexSet = [NSMutableIndexSet indexSet];
         NSEnumerator * enumerator = [items objectEnumerator];
@@ -2611,10 +2612,17 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
             else if ([item isKindOfClass: [Torrent class]])
             {
                 NSDictionary * group = [fTableView parentForItem: item];
-                index = [[group objectForKey: @"Torrents"] indexOfObject: item] + 1;
+                if ([[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER])
+                    index = [[group objectForKey: @"Torrents"] indexOfObject: item] + 1;
+                else
+                    index = NSOutlineViewDropOnItemIndex;
                 item = group;
             }
-            else;
+            else
+            {
+                if (![[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER])
+                    index = NSOutlineViewDropOnItemIndex;
+            }
         }
         else
         {
@@ -2649,19 +2657,6 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
         for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
             [movingTorrents addObject: [fTableView itemAtRow: i]];
         
-        //find torrent to place under
-        NSArray * groupTorrents = item ? [item objectForKey: @"Torrents"] : fDisplayedTorrents;
-        Torrent * topTorrent = nil;
-        for (i = newRow-1; i >= 0; i--)
-        {
-            Torrent * tempTorrent = [groupTorrents objectAtIndex: i];
-            if (![movingTorrents containsObject: tempTorrent])
-            {
-                topTorrent = tempTorrent;
-                break;
-            }
-        }
-        
         //reset groups
         if (item)
         {
@@ -2677,25 +2672,42 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
                 
                 [torrent setGroupValue: groupValue];
             }
-            //part 1 of avoiding weird crash
+            //part 2 of avoiding weird crash
             [fTableView reloadItem: nil reloadChildren: YES];
         }
         
-        //remove objects to reinsert
-        [fTorrents removeObjectsInArray: movingTorrents];
-        
-        //get all torrents to reorder
-        NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"orderValue" ascending: YES] autorelease];
-        [fTorrents sortUsingDescriptors: [NSArray arrayWithObject: orderDescriptor]];
-        
-        //insert objects at new location
-        int insertIndex = topTorrent ? [fTorrents indexOfObject: topTorrent] + 1 : 0;
-        for (i = 0; i < [movingTorrents count]; i++)
-            [fTorrents insertObject: [movingTorrents objectAtIndex: i] atIndex: insertIndex + i];
-        
-        //redo order values
-        for (i = 0; i < [fTorrents count]; i++)
-            [[fTorrents objectAtIndex: i] setOrderValue: i];
+        //reorder queue order
+        if ([[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER])
+        {
+            //find torrent to place under
+            NSArray * groupTorrents = item ? [item objectForKey: @"Torrents"] : fDisplayedTorrents;
+            Torrent * topTorrent = nil;
+            for (i = newRow-1; i >= 0; i--)
+            {
+                Torrent * tempTorrent = [groupTorrents objectAtIndex: i];
+                if (![movingTorrents containsObject: tempTorrent])
+                {
+                    topTorrent = tempTorrent;
+                    break;
+                }
+            }
+            
+            //remove objects to reinsert
+            [fTorrents removeObjectsInArray: movingTorrents];
+            
+            //get all torrents to reorder
+            NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"orderValue" ascending: YES] autorelease];
+            [fTorrents sortUsingDescriptors: [NSArray arrayWithObject: orderDescriptor]];
+            
+            //insert objects at new location
+            int insertIndex = topTorrent ? [fTorrents indexOfObject: topTorrent] + 1 : 0;
+            for (i = 0; i < [movingTorrents count]; i++)
+                [fTorrents insertObject: [movingTorrents objectAtIndex: i] atIndex: insertIndex + i];
+            
+            //redo order values
+            for (i = 0; i < [fTorrents count]; i++)
+                [[fTorrents objectAtIndex: i] setOrderValue: i];
+        }
         
         [self applyFilter: nil];