Changeset 13137


Ignore:
Timestamp:
Jan 7, 2012, 6:46:03 PM (10 years ago)
Author:
livings124
Message:

move tinkering with the main table's animations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r13136 r13137  
    21112111                    for (NSString * tracker in trackers)
    21122112                    {
    2113                         if ([tracker rangeOfString: searchString options:
    2114                              (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location != NSNotFound)
     2113                        if ([tracker rangeOfString: searchString options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location != NSNotFound)
    21152114                        {
    21162115                            found = YES;
     
    21582157            }];
    21592158           
    2160             if (index == NSNotFound){NSLog(@"%@",objDisplay);
     2159            if (index == NSNotFound){
    21612160                [(Torrent *)objDisplay setPreviousFinishedPieces: nil];}
    21622161            else
     
    21802179    if (!groupRows && !wasGroupRows)
    21812180    {
    2182         const NSRange existingTorrentRange = NSMakeRange(0, [fDisplayedTorrents count]);
    21832181        NSMutableIndexSet * addIndexes = [NSMutableIndexSet indexSet],
    2184                         * remainingPreviousIndexes = [NSMutableIndexSet indexSetWithIndexesInRange: existingTorrentRange];
    2185        
    2186         for (NSUInteger previousIndex = 0; previousIndex < [allTorrents count]; ++previousIndex)
    2187         {
    2188             Torrent * torrent = [allTorrents objectAtIndex: previousIndex];
    2189             const NSUInteger currentIndex = [fDisplayedTorrents indexOfObjectAtIndexes: remainingPreviousIndexes options: NSEnumerationConcurrent passingTest: ^(id obj, NSUInteger idx, BOOL *stop) {
    2190                 return (BOOL)(obj == torrent);
     2182                        * removePreviousIndexes = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedTorrents count])];
     2183       
     2184        //for each of the torrents to add, find if it already exists (and keep track of those we've already added & those we need to remove)
     2185        [allTorrents enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock:^(id objAll, NSUInteger previousIndex, BOOL * stop) {
     2186            const NSUInteger currentIndex = [fDisplayedTorrents indexOfObjectAtIndexes: removePreviousIndexes options: NSEnumerationConcurrent passingTest: ^(id objDisplay, NSUInteger idx, BOOL *stop) {
     2187                return (BOOL)(objAll == objDisplay);
    21912188            }];
    21922189            if (currentIndex == NSNotFound)
    21932190                [addIndexes addIndex: previousIndex];
    21942191            else
    2195                 [remainingPreviousIndexes removeIndex: currentIndex];
    2196         }
    2197        
    2198         if ([addIndexes count] > 0 || [remainingPreviousIndexes count] > 0)
     2192                [removePreviousIndexes removeIndex: currentIndex];
     2193        }];
     2194       
     2195        if ([addIndexes count] > 0 || [removePreviousIndexes count] > 0)
    21992196        {
    22002197            beganUpdates = YES;
     
    22032200           
    22042201            //remove torrents we didn't find
    2205             if ([remainingPreviousIndexes count] > 0)
     2202            if ([removePreviousIndexes count] > 0)
    22062203            {
    2207                 [fDisplayedTorrents removeObjectsAtIndexes: remainingPreviousIndexes];
     2204                [fDisplayedTorrents removeObjectsAtIndexes: removePreviousIndexes];
    22082205                if (onLion)
    2209                     [fTableView removeItemsAtIndexes: remainingPreviousIndexes inParent: nil withAnimation: NSTableViewAnimationSlideDown];
     2206                    [fTableView removeItemsAtIndexes: removePreviousIndexes inParent: nil withAnimation: NSTableViewAnimationSlideDown];
    22102207            }
    22112208           
     
    22212218    else if (!groupRows && wasGroupRows)
    22222219    {
    2223         //since we're not doing this the right way (boo buggy animation), we need to remember selected group
    2224         NSArray * selectedValues = [fTableView selectedValues];
    2225        
    22262220        beganUpdates = YES;
    22272221        if (onLion)
     
    22292223       
    22302224#if 1
     2225        //since we're not doing this the right way (boo buggy animation), we need to remember selected group
     2226        NSArray * selectedValues = [fTableView selectedValues];
     2227       
    22312228        if (onLion)
    22322229            [fTableView removeItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedTorrents count])] inParent: nil withAnimation: NSTableViewAnimationSlideDown];
     
    22842281        selectedValues = [fTableView selectedValues];
    22852282       
    2286         beganUpdates = YES;
    2287         if (onLion)
    2288             [fTableView beginUpdates];
    2289        
    22902283        //a map for quickly finding groups
    22912284        NSMutableDictionary * groupsByIndex = [NSMutableDictionary dictionaryWithCapacity: [[GroupsController groups] numberOfGroups]];
     
    23022295            [[group torrents] addObject: torrent];
    23032296        }
     2297       
     2298        beganUpdates = YES;
     2299        if (onLion)
     2300            [fTableView beginUpdates];
    23042301       
    23052302        #warning duplicate from above
     
    23942391                [[group torrents] removeObjectsAtIndexes: removeIndexes];
    23952392                if (onLion)
    2396                     [fTableView removeItemsAtIndexes: removeIndexes inParent: group withAnimation: NSTableViewAnimationSlideDown];
     2393                    [fTableView removeItemsAtIndexes: removeIndexes inParent: group withAnimation: NSTableViewAnimationEffectFade];
    23972394            }
    23982395        }
     
    24202417        //remove empty groups
    24212418        NSMutableIndexSet * removeIndexes = [NSMutableIndexSet indexSet];
    2422         for (NSUInteger index = 0; index < originalGroupCount; ++index)
    2423         {
    2424             TorrentGroup * group = [fDisplayedTorrents objectAtIndex: index];
    2425             if ([[group torrents] count] == 0)
    2426                 [removeIndexes addIndex: index];
    2427         }
     2419        [fDisplayedTorrents enumerateObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, originalGroupCount)] options: NSEnumerationConcurrent usingBlock: ^(id obj, NSUInteger idx, BOOL * stop) {
     2420            if ([[(TorrentGroup *)obj torrents] count] == 0)
     2421                [removeIndexes addIndex: idx];
     2422        }];
    24282423       
    24292424        if ([removeIndexes count] > 0)
Note: See TracChangeset for help on using the changeset viewer.