mirror of
https://github.com/transmission/transmission
synced 2025-01-03 13:35:36 +00:00
#2458 Tracker pane - copy addresses
This commit is contained in:
parent
d08ab9e510
commit
8296112fae
2 changed files with 46 additions and 0 deletions
|
@ -31,4 +31,6 @@
|
||||||
|
|
||||||
- (void) setTrackers: (NSArray *) trackers;
|
- (void) setTrackers: (NSArray *) trackers;
|
||||||
|
|
||||||
|
- (IBAction) copy: (id) sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#import "TrackerTableView.h"
|
#import "TrackerTableView.h"
|
||||||
|
#import "NSApplicationAdditions.h"
|
||||||
|
#import "TrackerNode.h"
|
||||||
|
|
||||||
@implementation TrackerTableView
|
@implementation TrackerTableView
|
||||||
|
|
||||||
|
@ -37,6 +39,48 @@
|
||||||
fTrackers = trackers;
|
fTrackers = trackers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction) copy: (id) sender
|
||||||
|
{
|
||||||
|
NSMutableArray * addresses = [NSMutableArray arrayWithCapacity: [fTrackers count]];
|
||||||
|
NSIndexSet * indexes = [self selectedRowIndexes];
|
||||||
|
for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||||
|
{
|
||||||
|
id item = [fTrackers objectAtIndex: i];
|
||||||
|
if ([item isKindOfClass: [NSNumber class]])
|
||||||
|
{
|
||||||
|
for (++i; i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; ++i)
|
||||||
|
[addresses addObject: [(TrackerNode *)[fTrackers objectAtIndex: i] fullAnnounceAddress]];
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[addresses addObject: [(TrackerNode *)item fullAnnounceAddress]];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString * text = [addresses componentsJoinedByString: @"\n"];;
|
||||||
|
|
||||||
|
NSPasteboard * pb = [NSPasteboard generalPasteboard];
|
||||||
|
if ([NSApp isOnSnowLeopardOrBetter])
|
||||||
|
{
|
||||||
|
[pb clearContents];
|
||||||
|
[pb writeObjects: [NSArray arrayWithObject: text]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner: nil];
|
||||||
|
[pb setString: text forType: NSStringPboardType];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
|
||||||
|
{
|
||||||
|
SEL action = [menuItem action];
|
||||||
|
|
||||||
|
if (action == @selector(copy:))
|
||||||
|
return [self numberOfSelectedRows] > 0;
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
//alternating rows - first row after group row is white
|
//alternating rows - first row after group row is white
|
||||||
- (void) highlightSelectionInClipRect: (NSRect) clipRect
|
- (void) highlightSelectionInClipRect: (NSRect) clipRect
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue