From af76c33bb0a89f3ff382b514e924f2bbb3253193 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sat, 12 Oct 2013 14:31:28 -0700 Subject: [PATCH] mamburu: Happy New Year commit (which accidentally fixes #83 - enqueueing from FileTree now respects playlist settings while FileTree context menu items still do what they say and don't depend on playlist settings). Also, the code should be cleaned up a bit, but i'm too sleepy to do it now. --- FileTree/FileTreeController.h | 1 + FileTree/FileTreeController.m | 32 ++++++++++++++++++++----------- FileTree/FileTreeOutlineView.m | 4 ++-- FileTree/FileTreeViewController.m | 16 +++++++++++++--- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/FileTree/FileTreeController.h b/FileTree/FileTreeController.h index 79546d6de..474acfdb3 100644 --- a/FileTree/FileTreeController.h +++ b/FileTree/FileTreeController.h @@ -17,6 +17,7 @@ } - (IBAction)addToPlaylist:(id)sender; +- (IBAction)addToPlaylistExternal:(id)sender; - (IBAction)setAsPlaylist:(id)sender; - (IBAction)playPauseResume:(NSObject *)id; - (IBAction)showEntryInFinder:(id)sender; diff --git a/FileTree/FileTreeController.m b/FileTree/FileTreeController.m index d4c3005e7..c1e71df10 100644 --- a/FileTree/FileTreeController.m +++ b/FileTree/FileTreeController.m @@ -14,18 +14,28 @@ - (IBAction)addToPlaylist:(id)sender { - NSUInteger index; - NSIndexSet *selectedIndexes = [outlineView selectedRowIndexes]; - NSMutableArray *urls = [[NSMutableArray alloc] init]; + [self doAddToPlaylist:sender origin:URLOriginInternal]; +} - for (index = [selectedIndexes firstIndex]; - index != NSNotFound; index = [selectedIndexes indexGreaterThanIndex: index]) - { - [urls addObject:[[outlineView itemAtRow:index] URL]]; - } - - [controller addToPlaylist:urls]; - [urls release]; +- (void)doAddToPlaylist:(id)sender origin:(URLOrigin)origin +{ + NSUInteger index; + NSIndexSet *selectedIndexes = [outlineView selectedRowIndexes]; + NSMutableArray *urls = [[NSMutableArray alloc] init]; + + for (index = [selectedIndexes firstIndex]; + index != NSNotFound; index = [selectedIndexes indexGreaterThanIndex: index]) + { + [urls addObject:[[outlineView itemAtRow:index] URL]]; + } + + [controller doAddToPlaylist:urls origin:origin]; + [urls release]; +} + +- (void)addToPlaylistExternal:(id)sender +{ + [self doAddToPlaylist:sender origin:URLOriginExternal]; } - (IBAction)setAsPlaylist:(id)sender diff --git a/FileTree/FileTreeOutlineView.m b/FileTree/FileTreeOutlineView.m index ca6cf3fb3..6a21949ab 100644 --- a/FileTree/FileTreeOutlineView.m +++ b/FileTree/FileTreeOutlineView.m @@ -15,7 +15,7 @@ - (void)awakeFromNib { - [self setDoubleAction:@selector(addToPlaylist:)]; + [self setDoubleAction:@selector(addToPlaylistExternal:)]; [self setTarget:[self delegate]]; } @@ -31,7 +31,7 @@ if (modifiers == 0 && (c == NSEnterCharacter || c == NSCarriageReturnCharacter)) { - [(FileTreeController *)[self delegate] addToPlaylist:self]; + [(FileTreeController *)[self delegate] addToPlaylistExternal:self]; return; } diff --git a/FileTree/FileTreeViewController.m b/FileTree/FileTreeViewController.m index a4b35be24..2367c114c 100644 --- a/FileTree/FileTreeViewController.m +++ b/FileTree/FileTreeViewController.m @@ -16,10 +16,20 @@ return [super initWithNibName:@"FileTree" bundle:[NSBundle mainBundle]]; } -- (void)addToPlaylist:(NSArray *)urls +- (void)addToPlaylistInternal:(NSArray *)urls { - [playlistLoader willInsertURLs:urls origin:URLOriginInternal]; - [playlistLoader didInsertURLs:[playlistLoader addURLs:urls sort:YES] origin:URLOriginInternal]; + [self doAddToPlaylist:urls origin:URLOriginInternal]; +} + +- (void)addToPlaylistExternal:(NSArray *)urls +{ + [self doAddToPlaylist:urls origin:URLOriginExternal]; +} + +- (void)doAddToPlaylist:(NSArray *)urls origin:(URLOrigin)origin +{ + [playlistLoader willInsertURLs:urls origin:origin]; + [playlistLoader didInsertURLs:[playlistLoader addURLs:urls sort:YES] origin:origin]; } - (void)clear:(id)sender