Changeset 9227


Ignore:
Timestamp:
Oct 1, 2009, 1:15:37 AM (13 years ago)
Author:
livings124
Message:

#2470 Pasting an address (or list of addresses) into the tracker list should add those trackers

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r9225 r9227  
    379379        [self setWebSeedTableHidden: YES animate: YES];
    380380       
     381        [fTrackerTable setTorrent: nil];
     382       
    381383        [fTrackers release];
    382384        fTrackers = nil;
     
    468470        }
    469471       
     472        [fTrackerTable setTorrent: torrent];
    470473        [fTrackerTable deselectAll: self];
    471474        [fTrackerAddRemoveControl setEnabled: YES forSegment: TRACKER_ADD_TAG];
     
    17201723        if ([item isKindOfClass: [NSNumber class]])
    17211724        {
    1722             ++i;
    1723             for (NSInteger j = i; j < [fTrackers count] && ![[fTrackers objectAtIndex: j] isKindOfClass: [NSNumber class]]; ++j, ++i)
    1724                 [addresses addObject: [[fTrackers objectAtIndex: j] fullAnnounceAddress]];
     1725            for (++i; i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; ++i)
     1726                [addresses addObject: [[fTrackers objectAtIndex: i] fullAnnounceAddress]];
    17251727            --i;
    17261728        }
  • trunk/macosx/Torrent.h

    r9221 r9227  
    2828
    2929@class FileListNode;
    30 
    31 #warning remove!?
    32 #define STAT_TIME_NONE -1
    33 #define STAT_TIME_NOW -2
    3430
    3531@interface Torrent : NSObject <QLPreviewItem>
  • trunk/macosx/Torrent.m

    r9221 r9227  
    706706}
    707707
     708#warning check for duplicates?
    708709- (BOOL) addTrackerToNewTier: (NSString *) tracker
    709710{
  • trunk/macosx/TrackerTableView.h

    r9219 r9227  
    2525#import <Cocoa/Cocoa.h>
    2626
     27@class Torrent;
     28
    2729@interface TrackerTableView : NSTableView
    2830{
     31    //weak references
     32    Torrent * fTorrent;
    2933    NSArray * fTrackers;
    3034}
    3135
     36- (void) setTorrent: (Torrent *) torrent;
    3237- (void) setTrackers: (NSArray *) trackers;
    3338
    34 - (IBAction) copy: (id) sender;
     39- (void) copy: (id) sender;
     40- (void) paste: (id) sender;
    3541
    3642@end
  • trunk/macosx/TrackerTableView.m

    r9220 r9227  
    2525#import "TrackerTableView.h"
    2626#import "NSApplicationAdditions.h"
     27#import "Torrent.h"
    2728#import "TrackerNode.h"
    2829
     
    3536}
    3637
     38- (void) setTorrent: (Torrent *) torrent
     39{
     40    fTorrent = torrent;
     41}
     42
    3743- (void) setTrackers: (NSArray *) trackers
    3844{
     
    4046}
    4147
    42 - (IBAction) copy: (id) sender
     48- (void) copy: (id) sender
    4349{
    4450    NSMutableArray * addresses = [NSMutableArray arrayWithCapacity: [fTrackers count]];
     
    7278}
    7379
     80- (void) paste: (id) sender
     81{
     82    if (!fTorrent)
     83        return;
     84   
     85    if ([NSApp isOnSnowLeopardOrBetter])
     86    {
     87        NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses:
     88                            [NSArray arrayWithObject: [NSString class]] options: nil];
     89        NSAssert(items != nil, @"no string items to paste; should not be able to call this method");
     90       
     91        BOOL added = NO;
     92        for (NSString * pbItem in items)
     93        {
     94            for (NSString * item in [pbItem componentsSeparatedByString: @"\n"])
     95                if ([fTorrent addTrackerToNewTier: item])
     96                    added = YES;
     97        }
     98       
     99        //none added
     100        if (!added)
     101            NSBeep();
     102    }
     103}
     104
    74105- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
    75106{
     
    78109    if (action == @selector(copy:))
    79110        return [self numberOfSelectedRows] > 0;
     111   
     112    if (action == @selector(paste:))
     113        return [[NSPasteboard generalPasteboard] canReadObjectForClasses: [NSArray arrayWithObject: [NSString class]] options: nil];
    80114   
    81115    return YES;
Note: See TracChangeset for help on using the changeset viewer.