Changeset 3776


Ignore:
Timestamp:
Nov 9, 2007, 11:38:35 PM (14 years ago)
Author:
livings124
Message:

when sorting by queue order, allow torrents to be reordered even if they are filtered (put below the one above it in the total queue)

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r3768 r3776  
    21662166- (BOOL) tableView: (NSTableView *) tableView writeRowsWithIndexes: (NSIndexSet *) indexes toPasteboard: (NSPasteboard *) pasteboard
    21672167{
    2168     //only allow reordering of rows if sorting by order with no filter
    2169     if ([[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER]
    2170         && [[fDefaults stringForKey: @"Filter"] isEqualToString: FILTER_NONE]
    2171         && [[fSearchFilterField stringValue] length] == 0)
     2168    //only allow reordering of rows if sorting by order
     2169    if ([[fDefaults stringForKey: @"Sort"] isEqualToString: SORT_ORDER])
    21722170    {
    21732171        [pasteboard declareTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE] owner: self];
     
    21782176}
    21792177
    2180 - (NSDragOperation) tableView: (NSTableView *) t validateDrop: (id <NSDraggingInfo>) info
     2178- (NSDragOperation) tableView: (NSTableView *) tableView validateDrop: (id <NSDraggingInfo>) info
    21812179    proposedRow: (int) row proposedDropOperation: (NSTableViewDropOperation) operation
    21822180{
     
    22062204                                [pasteboard dataForType: TORRENT_TABLE_VIEW_DATA_TYPE]];
    22072205       
    2208         //move torrent in array
    2209         NSArray * movingTorrents = [[fDisplayedTorrents objectsAtIndexes: indexes] retain];
    2210         [fDisplayedTorrents removeObjectsInArray: movingTorrents];
    2211        
    2212         //determine the insertion index now that transfers to move have been removed
     2206        //determine where to move them
    22132207        int i, decrease = 0;
    22142208        for (i = [indexes firstIndex]; i < newRow && i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
    2215             decrease++;
     2209            newRow--;
     2210       
     2211        //reinsert into array
     2212        int insertIndex = newRow > 0 ? [[[fDisplayedTorrents objectAtIndex: newRow-1] orderValue] intValue] + 1 : 0;
     2213       
     2214        //get all torrents to reorder
     2215        NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
     2216                                                @"orderValue" ascending: YES] autorelease];
     2217        NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
     2218       
     2219        NSMutableArray * sortedTorrents = [[fTorrents sortedArrayUsingDescriptors: descriptors] mutableCopy];
     2220        [descriptors release];
     2221       
     2222        //remove objects to reinsert
     2223        NSArray * movingTorrents = [[fDisplayedTorrents objectsAtIndexes: indexes] retain];
     2224        [sortedTorrents removeObjectsInArray: movingTorrents];
    22162225       
    22172226        //insert objects at new location
    22182227        for (i = 0; i < [movingTorrents count]; i++)
    2219             [fDisplayedTorrents insertObject: [movingTorrents objectAtIndex: i] atIndex: newRow - decrease + i];
     2228            [sortedTorrents insertObject: [movingTorrents objectAtIndex: i] atIndex: insertIndex + i];
    22202229       
    22212230        [movingTorrents release];
    2222        
     2231               
    22232232        //redo order values
    2224         int low = [indexes firstIndex], high = [indexes lastIndex];
    2225         if (newRow < low)
    2226             low = newRow;
    2227         else if (newRow > high + 1)
    2228             high = newRow - 1;
    2229         else;
    2230        
    2231         for (i = low; i <= high; i++)
    2232             [[fDisplayedTorrents objectAtIndex: i] setOrderValue: i];
    2233        
    2234         [fTableView reloadData];
     2233        i = 0;
     2234        for (i = 0; i < [sortedTorrents count]; i++)
     2235            [[sortedTorrents objectAtIndex: i] setOrderValue: i];
     2236       
     2237        [sortedTorrents release];
     2238       
     2239        [self applyFilter: nil];
    22352240       
    22362241        //set selected rows if needed
  • trunk/macosx/FileNameCell.m

    r3700 r3776  
    9090    [[self image] drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
    9191   
    92     #warning factor in selected folder
    9392    //title
    9493    NSColor * specialColor = nil;
  • trunk/macosx/PrefsController.m

    r3768 r3776  
    132132   
    133133    //set port
     134    #warning why no binding?
    134135    [fPortField setIntValue: [fDefaults integerForKey: @"BindPort"]];
    135136    fNatStatus = -1;
Note: See TracChangeset for help on using the changeset viewer.