Commit 69731466 authored by David Fuhrmann's avatar David Fuhrmann

macosx: select currently played item

And expand outline view tree if necessary.
parent e11d1337
......@@ -80,6 +80,8 @@ typedef enum {
- (void)addItem:(int)i_item withParentNode:(int)i_node;
- (void)removeItem:(int)i_item;
- (PLItem *)currentlyPlayingItem;
- (void)sortForColumn:(NSString *)o_column withMode:(int)i_mode;
- (void)searchUpdate:(NSString *)o_search;
......
......@@ -199,6 +199,18 @@
[_outlineView reloadItem:o_parent reloadChildren:YES];
}
- (PLItem *)currentlyPlayingItem
{
PLItem *item = nil;
PL_LOCK;
playlist_item_t *p_current = playlist_CurrentPlayingItem(p_playlist);
if (p_current)
item = [self findItemByPlaylistId:p_current->i_id];
PL_UNLOCK;
return item;
}
- (void)sortForColumn:(NSString *)o_column withMode:(int)i_mode
{
int i_column = 0;
......
......@@ -1356,6 +1356,8 @@ static bool f_appExit = false;
p_input_changed = vlc_object_hold(p_current_input);
[[self playlist] currentlyPlayingItemChanged];
[[self playlist] continuePlaybackWhereYouLeftOff:p_current_input];
[[NSNotificationCenter defaultCenter] postNotificationName:VLCInputChangedNotification
......@@ -1363,7 +1365,6 @@ static bool f_appExit = false;
}
}
[o_playlist updateRowSelection];
[o_mainwindow updateWindow];
[self updateDelays];
[self updateMainMenu];
......
......@@ -91,7 +91,8 @@
- (void)playlistUpdated;
- (void)outlineViewSelectionDidChange:(NSNotification *)notification;
- (void)sortNode:(int)i_mode;
- (void)updateRowSelection;
- (void)currentlyPlayingItemChanged;
- (BOOL)isSelectionEmpty;
......
......@@ -354,42 +354,36 @@
return [o_outline_view selectedRow] == -1;
}
- (void)updateRowSelection
- (void)currentlyPlayingItemChanged
{
// FIXME: unsafe
playlist_t *p_playlist = pl_Get(VLCIntf);
playlist_item_t *p_item, *p_temp_item;
NSMutableArray *o_array = [NSMutableArray array];
PLItem *item = [[self model] currentlyPlayingItem];
if (!item)
return;
// TODO Rework
// PL_LOCK;
// p_item = playlist_CurrentPlayingItem(p_playlist);
// if (p_item == NULL) {
// PL_UNLOCK;
// return;
// }
//
// p_temp_item = p_item;
// while(p_temp_item->p_parent) {
// [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
// p_temp_item = p_temp_item->p_parent;
// }
// PL_UNLOCK;
//
// NSUInteger count = [o_array count];
// for (NSUInteger j = 0; j < count - 1; j++) {
// id o_item;
// if ((o_item = [o_outline_dict objectForKey:
// [NSString stringWithFormat: @"%p",
// [[o_array objectAtIndex:j] pointerValue]]]) != nil) {
// [o_outline_view expandItem: o_item];
// }
// }
//
// id o_item = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_item]];
// NSInteger i_index = [o_outline_view rowForItem:o_item];
// [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_index] byExtendingSelection:NO];
// [o_outline_view setNeedsDisplay:YES];
[[[VLCMain sharedInstance] info] updatePanelWithItem: [item input]];
// select item
NSInteger itemIndex = [o_outline_view rowForItem:item];
if (itemIndex < 0) {
// expand if needed
while (item != nil) {
PLItem *parent = [item parent];
if (![o_outline_view isExpandable: parent])
break;
if (![o_outline_view isItemExpanded: parent])
[o_outline_view expandItem: parent];
item = parent;
}
// search for row again
itemIndex = [o_outline_view rowForItem:item];
if (itemIndex < 0) {
return;
}
}
[o_outline_view selectRowIndexes: [NSIndexSet indexSetWithIndex: itemIndex] byExtendingSelection: NO];
}
- (IBAction)savePlaylist:(id)sender
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment