From 52f8c6f31f33ceddbe1165937bffd40f113be2c4 Mon Sep 17 00:00:00 2001 From: areff Date: Thu, 21 Feb 2008 09:05:06 +0000 Subject: [PATCH] Fixed adding files in File Tree. Now adds when you press enter, and supports multiple selections. --- FileTreeWindow/FileTreeWindowController.m | 37 ++++++++++++++++++++++- Playlist/PlaylistController.m | 21 +++++++------ 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/FileTreeWindow/FileTreeWindowController.m b/FileTreeWindow/FileTreeWindowController.m index 368bde956..39ab1798d 100644 --- a/FileTreeWindow/FileTreeWindowController.m +++ b/FileTreeWindow/FileTreeWindowController.m @@ -24,9 +24,44 @@ - (IBAction)addToPlaylist:(id)sender { - NSArray *urls = [NSArray arrayWithObject:[[outlineView itemAtRow:[outlineView clickedRow]] URL]]; + unsigned int 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]]; + } + [playlistLoader addURLs:urls sort:NO]; + [urls release]; } +- (void)keyDown:(NSEvent *)e +{ + unsigned int modifiers = [e modifierFlags] & (NSCommandKeyMask | NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask); + NSString *characters = [e characters]; + unichar c; + + if ([characters length] != 1) + { + [super keyDown:e]; + + return; + } + + c = [characters characterAtIndex:0]; + + if (modifiers == 0 && (c == NSEnterCharacter || c == NSCarriageReturnCharacter)) + { + [self addToPlaylist:self]; + } + else + { + [super keyDown:e]; + } +} + + @end diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 2dd4ca561..b3fdd6c14 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -569,16 +569,6 @@ [self updateIndexesFromRow:0]; } -- (NSMutableArray *)queueList -{ - return queueList; -} - -- (IBAction)emptyQueueList:(id)sender -{ - [queueList removeAllObjects]; -} - - (IBAction)showEntryInFinder:(id)sender { NSWorkspace* ws = [NSWorkspace sharedWorkspace]; @@ -601,6 +591,17 @@ [spotlightWindowController searchForAlbum:[entry album]]; } +- (NSMutableArray *)queueList +{ + return queueList; +} + +- (IBAction)emptyQueueList:(id)sender +{ + [queueList removeAllObjects]; +} + + - (IBAction)addToQueue:(id)sender { for (PlaylistEntry *queueItem in [self selectedObjects])