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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.