Changeset 13138 for trunk/macosx/Controller.m
- Timestamp:
- Jan 7, 2012, 9:05:02 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r13137 r13138 2911 2911 NSMutableArray * movingTorrents = [NSMutableArray arrayWithCapacity: [indexes count]]; 2912 2912 for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i]) 2913 [movingTorrents addObject: [fTableView itemAtRow: i]]; 2914 2915 //reset groups 2916 if (item) 2917 { 2913 { 2914 Torrent * torrent = [fTableView itemAtRow: i]; 2915 [movingTorrents addObject: torrent]; 2916 2918 2917 //change groups 2919 const NSInteger groupValue = [item groupIndex]; 2920 [movingTorrents enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { 2921 [(Torrent *)obj setGroupValue: groupValue]; 2922 }]; 2918 if (item) 2919 [torrent setGroupValue: [item groupIndex]]; 2923 2920 } 2924 2921 … … 2943 2940 2944 2941 //insert objects at new location 2945 NSUInteger insertIndex = topTorrent ? [fTorrents indexOfObject: topTorrent] + 1 : 0;2942 const NSUInteger insertIndex = topTorrent ? [fTorrents indexOfObject: topTorrent] + 1 : 0; 2946 2943 NSIndexSet * insertIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(insertIndex, [movingTorrents count])]; 2947 2944 [fTorrents insertObjects: movingTorrents atIndexes: insertIndexes]; … … 2954 2951 [torrent update]; 2955 2952 } 2953 2954 //do the drag animation here so that the dragged torrents are the ones that are animated as moving, and not the torrents around them 2955 const BOOL onLion = [NSApp isOnLionOrBetter]; 2956 if (onLion) 2957 [fTableView beginUpdates]; 2958 2959 NSUInteger insertDisplayIndex = topTorrent ? [groupTorrents indexOfObject: topTorrent] + 1 : 0; 2960 2961 for (Torrent * torrent in movingTorrents) 2962 { 2963 TorrentGroup * oldParent = item ? [fTableView parentForItem: torrent] : nil; 2964 NSMutableArray * oldTorrents = oldParent ? [oldParent torrents] : fDisplayedTorrents; 2965 const NSUInteger oldIndex = [oldTorrents indexOfObject: torrent]; 2966 2967 if (item == oldParent) 2968 { 2969 if (oldIndex < insertDisplayIndex) 2970 --insertDisplayIndex; 2971 [oldTorrents moveObjectAtIndex: oldIndex toIndex: insertDisplayIndex]; 2972 } 2973 else 2974 { 2975 NSMutableArray * newTorrents = [(TorrentGroup *)item torrents]; 2976 [newTorrents insertObject: torrent atIndex: insertDisplayIndex]; 2977 [oldTorrents removeObjectAtIndex: oldIndex]; 2978 } 2979 2980 if (onLion) 2981 [fTableView moveItemAtIndex: oldIndex inParent: oldParent toIndex: insertDisplayIndex inParent: item]; 2982 2983 ++insertDisplayIndex; 2984 } 2985 2986 if (onLion) 2987 [fTableView endUpdates]; 2956 2988 } 2957 2989
Note: See TracChangeset
for help on using the changeset viewer.