2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2012-2022 Transmission authors and contributors.
|
|
|
|
// It may be used under the MIT (SPDX: MIT) license.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2012-04-29 00:53:34 +00:00
|
|
|
|
|
|
|
#import "WebSeedTableView.h"
|
|
|
|
|
|
|
|
@implementation WebSeedTableView
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)mouseDown:(NSEvent*)event
|
2012-04-29 00:53:34 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
[self.window makeKeyWindow];
|
2021-08-15 09:41:48 +00:00
|
|
|
[super mouseDown:event];
|
2012-04-29 00:53:34 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)setWebSeeds:(NSArray*)webSeeds
|
2012-04-29 00:53:34 +00:00
|
|
|
{
|
|
|
|
fWebSeeds = webSeeds;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)copy:(id)sender
|
2012-04-29 00:53:34 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSIndexSet* indexes = self.selectedRowIndexes;
|
|
|
|
NSMutableArray* addresses = [NSMutableArray arrayWithCapacity:indexes.count];
|
|
|
|
[fWebSeeds enumerateObjectsAtIndexes:indexes options:0 usingBlock:^(NSDictionary* webSeed, NSUInteger idx, BOOL* stop) {
|
|
|
|
[addresses addObject:webSeed[@"Address"]];
|
2012-04-29 00:53:34 +00:00
|
|
|
}];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* text = [addresses componentsJoinedByString:@"\n"];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSPasteboard* pb = NSPasteboard.generalPasteboard;
|
2012-04-29 00:53:34 +00:00
|
|
|
[pb clearContents];
|
2021-08-15 09:41:48 +00:00
|
|
|
[pb writeObjects:@[ text ]];
|
2012-04-29 00:53:34 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (BOOL)validateMenuItem:(NSMenuItem*)menuItem
|
2012-04-29 00:53:34 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
SEL const action = menuItem.action;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-04-29 00:53:34 +00:00
|
|
|
if (action == @selector(copy:))
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
return self.numberOfSelectedRows > 0;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-04-29 00:53:34 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|