1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-09 13:50:00 +00:00

don't allow quick look of folders that don't exist

This commit is contained in:
Mitchell Livingston 2008-06-22 01:31:50 +00:00
parent 14e5ab6334
commit 8a0b2ed988
4 changed files with 27 additions and 14 deletions

View file

@ -260,6 +260,7 @@ typedef enum
- (NSArray *) quickLookURLs;
- (BOOL) canQuickLook;
- (BOOL) canQuickLookTorrent: (Torrent *) torrent;
- (NSRect) quickLookFrameWithURL: (NSURL*) url;
- (void) toggleQuickLook: (id) sender;

View file

@ -473,7 +473,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
//timer to update the interface every second
[self updateUI];
fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_UI_SECONDS target: self
selector: @selector(updateUI) userInfo: nil repeats: YES];
selector: @selector(updateUI) userInfo: nil repeats: YES];
[[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSModalPanelRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSEventTrackingRunLoopMode];
@ -4103,10 +4103,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{
if ([torrent isFolder] || [torrent isComplete])
if ([self canQuickLookTorrent: torrent])
[urlArray addObject: [NSURL fileURLWithPath: [torrent dataLocation]]];
}
return urlArray;
}
@ -4118,14 +4116,20 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{
if ([torrent isFolder] || [torrent isComplete])
if ([self canQuickLookTorrent: torrent])
return YES;
}
return NO;
}
- (BOOL) canQuickLookTorrent: (Torrent *) torrent
{
if (![[NSFileManager defaultManager] fileExistsAtPath: [torrent dataLocation]])
return NO;
return [torrent isFolder] || [torrent isComplete];
}
- (NSRect) quickLookFrameWithURL: (NSURL *) url
{
if ([fWindow isVisible])

View file

@ -71,8 +71,10 @@ typedef enum
- (void) updateInfoFiles;
- (NSView *) tabViewForTag: (int) tag;
- (NSArray *) peerSortDescriptors;
- (void) setWebSeedTableHidden: (BOOL) hide animate: (BOOL) animate;
- (NSArray *) peerSortDescriptors;
- (BOOL) canQuickLookFile: (FileListNode *) item;
- (void) addTrackers;
- (void) removeTrackers;
@ -1088,7 +1090,7 @@ typedef enum
for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
{
FileListNode * item = [fileOutlineView itemAtRow: i];
if ([item isFolder] || [torrent fileProgress: [[item indexes] firstIndex]] == 1.0)
if ([self canQuickLookFile: item])
[urlArray addObject: [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [item fullPath]]]];
}
@ -1103,11 +1105,8 @@ typedef enum
int i;
for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
{
FileListNode * item = [fileOutlineView itemAtRow: i];
if ([item isFolder] || [torrent fileProgress: [[item indexes] firstIndex]] == 1.0)
if ([self canQuickLookFile: [fileOutlineView itemAtRow: i]])
return YES;
}
return NO;
}
@ -1600,6 +1599,16 @@ typedef enum
return descriptors;
}
- (BOOL) canQuickLookFile: (FileListNode *) item
{
Torrent * torrent = [fTorrents objectAtIndex: 0];
if (![[NSFileManager defaultManager] fileExistsAtPath: [[torrent downloadFolder] stringByAppendingPathComponent: [item fullPath]]])
return NO;
return [item isFolder] || [torrent fileProgress: [[item indexes] firstIndex]] == 1.0;
}
- (void) addTrackers
{
[[self window] makeKeyWindow];

View file

@ -257,7 +257,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
fPreviousFinishedIndexesDate = indexes != nil ? [[NSDate alloc] init] : nil;
}
#warning when queue and seeding options are folded into libt, no need to call this on all torrents - use tr_torrentGetStatus
- (void) update
{
//get previous status values before update