]> git.sesse.net Git - vlc/commitdiff
macosx: add new pl items to the end if they are dropped to a node
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Sun, 7 Dec 2014 12:29:12 +0000 (13:29 +0100)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Tue, 30 Dec 2014 15:10:48 +0000 (16:10 +0100)
modules/gui/macosx/PLModel.m

index 6fae2ccbe81055b52fb94e59d5b427d7ea11b822..41055eebba48be0bd1bf76fbc7f82d7d82a3934f 100644 (file)
 #import "playlist.h"
 #import "StringUtility.h"
 
+#ifdef HAVE_CONFIG_H
+# import "config.h"
+#endif
+#include <assert.h>
+
 #include <vlc_playlist.h>
 #include <vlc_input_item.h>
-#import <vlc_input.h>
+#include <vlc_input.h>
 #include <vlc_url.h>
 
 #define TRACKNUM_COLUMN @"tracknumber"
 {
     NSPasteboard *o_pasteboard = [info draggingPasteboard];
 
-    // this is no valid target, sanitize to top of table
-    if (index == NSOutlineViewDropOnItemIndex)
-        index = 0;
-
     if (targetItem == nil) {
         targetItem = _rootItem;
     }
                 pp_items[j++] = p_item;
         }
 
+        // drop on a node itself will append entries at the end
+        if (index == NSOutlineViewDropOnItemIndex)
+            index = p_new_parent->i_children;
+
         if (playlist_TreeMoveMany(p_playlist, j, pp_items, p_new_parent, index) != VLC_SUCCESS) {
             PL_UNLOCK;
             free(pp_items);
             [o_array addObject: o_dic];
         }
 
+        // drop on a node itself will append entries at the end
+        static_assert(NSOutlineViewDropOnItemIndex == -1, "Expect NSOutlineViewDropOnItemIndex to be -1");
+
         [_playlist addPlaylistItems:o_array withParentItemId:[targetItem plItemId] atPos:index startPlayback:NO];
         return YES;
     }