mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
Switch to clang-format for code formatting, include Mac client
This commit is contained in:
@@ -28,17 +28,17 @@
|
||||
|
||||
@interface InfoFileViewController (Private)
|
||||
|
||||
- (void) setupInfo;
|
||||
- (void)setupInfo;
|
||||
|
||||
- (BOOL) canQuickLookFile: (FileListNode *) item;
|
||||
- (BOOL)canQuickLookFile:(FileListNode*)item;
|
||||
|
||||
@end
|
||||
|
||||
@implementation InfoFileViewController
|
||||
|
||||
- (instancetype) init
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super initWithNibName: @"InfoFileView" bundle: nil]))
|
||||
if ((self = [super initWithNibName:@"InfoFileView" bundle:nil]))
|
||||
{
|
||||
self.title = NSLocalizedString(@"Files", "Inspector view -> title");
|
||||
}
|
||||
@@ -46,9 +46,9 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
const CGFloat height = [NSUserDefaults.standardUserDefaults floatForKey: @"InspectorContentHeightFiles"];
|
||||
CGFloat const height = [NSUserDefaults.standardUserDefaults floatForKey:@"InspectorContentHeightFiles"];
|
||||
if (height != 0.0)
|
||||
{
|
||||
NSRect viewRect = self.view.frame;
|
||||
@@ -56,7 +56,7 @@
|
||||
self.view.frame = viewRect;
|
||||
}
|
||||
|
||||
[fFileFilterField.cell setPlaceholderString: NSLocalizedString(@"Filter", "inspector -> file filter")];
|
||||
[fFileFilterField.cell setPlaceholderString:NSLocalizedString(@"Filter", "inspector -> file filter")];
|
||||
|
||||
//localize and place all and none buttons
|
||||
fCheckAllButton.title = NSLocalizedString(@"All", "inspector -> check all");
|
||||
@@ -64,26 +64,25 @@
|
||||
|
||||
NSRect checkAllFrame = fCheckAllButton.frame;
|
||||
NSRect uncheckAllFrame = fUncheckAllButton.frame;
|
||||
const CGFloat oldAllWidth = checkAllFrame.size.width;
|
||||
const CGFloat oldNoneWidth = uncheckAllFrame.size.width;
|
||||
CGFloat const oldAllWidth = checkAllFrame.size.width;
|
||||
CGFloat const oldNoneWidth = uncheckAllFrame.size.width;
|
||||
|
||||
[fCheckAllButton sizeToFit];
|
||||
[fUncheckAllButton sizeToFit];
|
||||
const CGFloat newWidth = MAX(fCheckAllButton.bounds.size.width, fUncheckAllButton.bounds.size.width);
|
||||
CGFloat const newWidth = MAX(fCheckAllButton.bounds.size.width, fUncheckAllButton.bounds.size.width);
|
||||
|
||||
const CGFloat uncheckAllChange = newWidth - oldNoneWidth;
|
||||
CGFloat const uncheckAllChange = newWidth - oldNoneWidth;
|
||||
uncheckAllFrame.size.width = newWidth;
|
||||
uncheckAllFrame.origin.x -= uncheckAllChange;
|
||||
fUncheckAllButton.frame = uncheckAllFrame;
|
||||
|
||||
const CGFloat checkAllChange = newWidth - oldAllWidth;
|
||||
CGFloat const checkAllChange = newWidth - oldAllWidth;
|
||||
checkAllFrame.size.width = newWidth;
|
||||
checkAllFrame.origin.x -= (checkAllChange + uncheckAllChange);
|
||||
fCheckAllButton.frame = checkAllFrame;
|
||||
}
|
||||
|
||||
|
||||
- (void) setInfoForTorrents: (NSArray *) torrents
|
||||
- (void)setInfoForTorrents:(NSArray*)torrents
|
||||
{
|
||||
//don't check if it's the same in case the metadata changed
|
||||
fTorrents = torrents;
|
||||
@@ -91,102 +90,117 @@
|
||||
fSet = NO;
|
||||
}
|
||||
|
||||
- (void) updateInfo
|
||||
- (void)updateInfo
|
||||
{
|
||||
if (!fSet)
|
||||
{
|
||||
[self setupInfo];
|
||||
}
|
||||
|
||||
if (fTorrents.count == 1)
|
||||
{
|
||||
[fFileController refresh];
|
||||
|
||||
#warning use TorrentFileCheckChange notification as well
|
||||
Torrent * torrent = fTorrents[0];
|
||||
#warning use TorrentFileCheckChange notification as well
|
||||
Torrent* torrent = fTorrents[0];
|
||||
if (torrent.folder)
|
||||
{
|
||||
const NSInteger filesCheckState = [torrent checkForFiles: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, torrent.fileCount)]];
|
||||
NSInteger const filesCheckState = [torrent
|
||||
checkForFiles:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, torrent.fileCount)]];
|
||||
fCheckAllButton.enabled = filesCheckState != NSOnState; //if anything is unchecked
|
||||
fUncheckAllButton.enabled = !torrent.allDownloaded; //if there are any checked files that aren't finished
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) saveViewSize
|
||||
- (void)saveViewSize
|
||||
{
|
||||
[NSUserDefaults.standardUserDefaults setFloat: NSHeight(self.view.frame) forKey: @"InspectorContentHeightFiles"];
|
||||
[NSUserDefaults.standardUserDefaults setFloat:NSHeight(self.view.frame) forKey:@"InspectorContentHeightFiles"];
|
||||
}
|
||||
|
||||
- (void) setFileFilterText: (id) sender
|
||||
- (void)setFileFilterText:(id)sender
|
||||
{
|
||||
[fFileController setFilterText: [sender stringValue]];
|
||||
[fFileController setFilterText:[sender stringValue]];
|
||||
}
|
||||
|
||||
- (IBAction) checkAll: (id) sender
|
||||
- (IBAction)checkAll:(id)sender
|
||||
{
|
||||
[fFileController checkAll];
|
||||
}
|
||||
|
||||
- (IBAction) uncheckAll: (id) sender
|
||||
- (IBAction)uncheckAll:(id)sender
|
||||
{
|
||||
[fFileController uncheckAll];
|
||||
}
|
||||
|
||||
- (NSArray *) quickLookURLs
|
||||
- (NSArray*)quickLookURLs
|
||||
{
|
||||
FileOutlineView * fileOutlineView = fFileController.outlineView;
|
||||
Torrent * torrent = fTorrents[0];
|
||||
NSIndexSet * indexes = fileOutlineView.selectedRowIndexes;
|
||||
NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: indexes.count];
|
||||
FileOutlineView* fileOutlineView = fFileController.outlineView;
|
||||
Torrent* torrent = fTorrents[0];
|
||||
NSIndexSet* indexes = fileOutlineView.selectedRowIndexes;
|
||||
NSMutableArray* urlArray = [NSMutableArray arrayWithCapacity:indexes.count];
|
||||
|
||||
for (NSUInteger i = indexes.firstIndex; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
for (NSUInteger i = indexes.firstIndex; i != NSNotFound; i = [indexes indexGreaterThanIndex:i])
|
||||
{
|
||||
FileListNode * item = [fileOutlineView itemAtRow: i];
|
||||
if ([self canQuickLookFile: item])
|
||||
[urlArray addObject: [NSURL fileURLWithPath: [torrent fileLocation: item]]];
|
||||
FileListNode* item = [fileOutlineView itemAtRow:i];
|
||||
if ([self canQuickLookFile:item])
|
||||
{
|
||||
[urlArray addObject:[NSURL fileURLWithPath:[torrent fileLocation:item]]];
|
||||
}
|
||||
}
|
||||
|
||||
return urlArray;
|
||||
}
|
||||
|
||||
- (BOOL) canQuickLook
|
||||
- (BOOL)canQuickLook
|
||||
{
|
||||
if (fTorrents.count != 1)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
Torrent * torrent = fTorrents[0];
|
||||
Torrent* torrent = fTorrents[0];
|
||||
if (!torrent.folder)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
FileOutlineView * fileOutlineView = fFileController.outlineView;
|
||||
NSIndexSet * indexes = fileOutlineView.selectedRowIndexes;
|
||||
FileOutlineView* fileOutlineView = fFileController.outlineView;
|
||||
NSIndexSet* indexes = fileOutlineView.selectedRowIndexes;
|
||||
|
||||
for (NSUInteger i = indexes.firstIndex; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
|
||||
if ([self canQuickLookFile: [fileOutlineView itemAtRow: i]])
|
||||
for (NSUInteger i = indexes.firstIndex; i != NSNotFound; i = [indexes indexGreaterThanIndex:i])
|
||||
{
|
||||
if ([self canQuickLookFile:[fileOutlineView itemAtRow:i]])
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSRect) quickLookSourceFrameForPreviewItem: (id <QLPreviewItem>) item
|
||||
- (NSRect)quickLookSourceFrameForPreviewItem:(id<QLPreviewItem>)item
|
||||
{
|
||||
FileOutlineView * fileOutlineView = fFileController.outlineView;
|
||||
FileOutlineView* fileOutlineView = fFileController.outlineView;
|
||||
|
||||
NSString * fullPath = ((NSURL *)item).path;
|
||||
Torrent * torrent = fTorrents[0];
|
||||
NSRange visibleRows = [fileOutlineView rowsInRect: fileOutlineView.bounds];
|
||||
NSString* fullPath = ((NSURL*)item).path;
|
||||
Torrent* torrent = fTorrents[0];
|
||||
NSRange visibleRows = [fileOutlineView rowsInRect:fileOutlineView.bounds];
|
||||
|
||||
for (NSUInteger row = visibleRows.location; row < NSMaxRange(visibleRows); row++)
|
||||
{
|
||||
FileListNode * rowItem = [fileOutlineView itemAtRow: row];
|
||||
if ([[torrent fileLocation: rowItem] isEqualToString: fullPath])
|
||||
FileListNode* rowItem = [fileOutlineView itemAtRow:row];
|
||||
if ([[torrent fileLocation:rowItem] isEqualToString:fullPath])
|
||||
{
|
||||
NSRect frame = [fileOutlineView iconRectForRow: row];
|
||||
NSRect frame = [fileOutlineView iconRectForRow:row];
|
||||
|
||||
if (!NSIntersectsRect(fileOutlineView.visibleRect, frame))
|
||||
{
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
frame.origin = [fileOutlineView convertPoint: frame.origin toView: nil];
|
||||
frame = [self.view.window convertRectToScreen: frame];
|
||||
frame.origin = [fileOutlineView convertPoint:frame.origin toView:nil];
|
||||
frame = [self.view.window convertRectToScreen:frame];
|
||||
frame.origin.y -= frame.size.height;
|
||||
return frame;
|
||||
}
|
||||
@@ -199,17 +213,17 @@
|
||||
|
||||
@implementation InfoFileViewController (Private)
|
||||
|
||||
- (void) setupInfo
|
||||
- (void)setupInfo
|
||||
{
|
||||
fFileFilterField.stringValue = @"";
|
||||
|
||||
if (fTorrents.count == 1)
|
||||
{
|
||||
Torrent * torrent = fTorrents[0];
|
||||
Torrent* torrent = fTorrents[0];
|
||||
|
||||
[fFileController setTorrent: torrent];
|
||||
[fFileController setTorrent:torrent];
|
||||
|
||||
const BOOL isFolder = torrent.folder;
|
||||
BOOL const isFolder = torrent.folder;
|
||||
fFileFilterField.enabled = isFolder;
|
||||
|
||||
if (!isFolder)
|
||||
@@ -220,7 +234,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
[fFileController setTorrent: nil];
|
||||
[fFileController setTorrent:nil];
|
||||
|
||||
fFileFilterField.enabled = NO;
|
||||
|
||||
@@ -231,10 +245,10 @@
|
||||
fSet = YES;
|
||||
}
|
||||
|
||||
- (BOOL) canQuickLookFile: (FileListNode *) item
|
||||
- (BOOL)canQuickLookFile:(FileListNode*)item
|
||||
{
|
||||
Torrent * torrent = fTorrents[0];
|
||||
return (item.isFolder || [torrent fileProgress: item] >= 1.0) && [torrent fileLocation: item];
|
||||
Torrent* torrent = fTorrents[0];
|
||||
return (item.isFolder || [torrent fileProgress:item] >= 1.0) && [torrent fileLocation:item];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user