]> git.sesse.net Git - vlc/commitdiff
macosx: select currently played item
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Sat, 7 Mar 2015 10:05:46 +0000 (11:05 +0100)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Sun, 8 Mar 2015 16:28:48 +0000 (17:28 +0100)
And expand outline view tree if necessary.

modules/gui/macosx/PLModel.h
modules/gui/macosx/PLModel.m
modules/gui/macosx/intf.m
modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m

index 01a1bd36750ec3f0f35e84ec3b10cb8d98202c76..d6584ae7ceb62f00f425201e1b3f8ed798ab8e66 100644 (file)
@@ -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;
index 27bce4bd0c852e9aa546df5b10d518fe59949e1d..3aec7d8fbdc90f7f5a63ee423ab6b45c94958dfb 100644 (file)
         [_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;
index 2df03a81d63d9bfadb995a25ff3c697350f2d87b..70a51e5f59a767d5ad1f1e681fc9ab337e1c89a6 100644 (file)
@@ -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];
index 29d1a26a726e180bb0501c9005cf966c1fdb1742..1eb3d445d66bb9c041a034e19dc0ba2176a7237a 100644 (file)
@@ -91,7 +91,8 @@
 - (void)playlistUpdated;
 - (void)outlineViewSelectionDidChange:(NSNotification *)notification;
 - (void)sortNode:(int)i_mode;
-- (void)updateRowSelection;
+
+- (void)currentlyPlayingItemChanged;
 
 - (BOOL)isSelectionEmpty;
 
index 63069e0f85eacd2e84bc14db7582c6e453b247db..2de60b7e84697305b2b70d7dbdb85bd38d620ad7 100644 (file)
     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