2023-02-11 20:49:42 +00:00
|
|
|
// This file Copyright © 2012-2023 Transmission authors and contributors.
|
2022-01-20 18:27:56 +00:00
|
|
|
// 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)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];
|
2022-12-21 20:21:16 +00:00
|
|
|
[self.webSeeds enumerateObjectsAtIndexes:indexes options:0
|
|
|
|
usingBlock:^(NSDictionary* webSeed, NSUInteger /*idx*/, BOOL* /*stop*/) {
|
|
|
|
[addresses addObject:webSeed[@"Address"]];
|
|
|
|
}];
|
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
|