[vlc-commits] macosx/playlist controller: expose sorting

Felix Paul Kühne git at videolan.org
Fri May 31 19:58:20 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Fri May 31 18:41:00 2019 +0200| [bb1a55aa8012f56a39718c5da3f04849327c0271] | committer: Felix Paul Kühne

macosx/playlist controller: expose sorting

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bb1a55aa8012f56a39718c5da3f04849327c0271
---

 .../gui/macosx/playlist/VLCPlaylistController.h    | 24 ++++++++++++++++++++++
 .../gui/macosx/playlist/VLCPlaylistController.m    | 16 +++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/modules/gui/macosx/playlist/VLCPlaylistController.h b/modules/gui/macosx/playlist/VLCPlaylistController.h
index eba43dd114..4d7e6c2704 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistController.h
+++ b/modules/gui/macosx/playlist/VLCPlaylistController.h
@@ -143,6 +143,30 @@ extern NSString *VLCPlaylistItemsRemoved;
 - (void)clearPlaylist;
 
 /**
+ * Sort the entire playlist listen based on:
+ * @param sortKey the key used for sorting
+ * @param sortOrder sort ascending or descending..
+ * @return Returns VLC_SUCCESS on success.
+ */
+- (int)sortByKey:(enum vlc_playlist_sort_key)sortKey andOrder:(enum vlc_playlist_sort_order)sortOrder;
+
+/**
+ * Initially, the playlist is unsorted until the user decides to do so
+ * Until then, the unsorted state is retained.
+ */
+ at property (readonly) BOOL unsorted;
+
+/**
+ * The last key used for sorting
+ */
+ at property (readonly) enum vlc_playlist_sort_key lastSortKey;
+
+/**
+ * The last order used for sorting
+ */
+ at property (readonly) enum vlc_playlist_sort_order lastSortOrder;
+
+/**
  * Start the playlist
  * @return Returns VLC_SUCCESS on success.
  */
diff --git a/modules/gui/macosx/playlist/VLCPlaylistController.m b/modules/gui/macosx/playlist/VLCPlaylistController.m
index a65c044e83..f09570df32 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistController.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistController.m
@@ -210,6 +210,7 @@ static const struct vlc_playlist_callbacks playlist_callbacks = {
 
         /* set initial values, further updates through callbacks */
         vlc_playlist_Lock(_p_playlist);
+        _unsorted = YES;
         _playbackOrder = vlc_playlist_GetPlaybackOrder(_p_playlist);
         _playbackRepeat = vlc_playlist_GetPlaybackRepeat(_p_playlist);
         _playlistListenerID = vlc_playlist_AddListener(_p_playlist,
@@ -424,6 +425,21 @@ static const struct vlc_playlist_callbacks playlist_callbacks = {
     vlc_playlist_Unlock(_p_playlist);
 }
 
+- (int)sortByKey:(enum vlc_playlist_sort_key)sortKey andOrder:(enum vlc_playlist_sort_order)sortOrder
+{
+    struct vlc_playlist_sort_criterion sortCriterion = { sortKey, sortOrder };
+    int returnValue = VLC_SUCCESS;
+    vlc_playlist_Lock(_p_playlist);
+    returnValue = vlc_playlist_Sort(_p_playlist, &sortCriterion, 1);
+    vlc_playlist_Unlock(_p_playlist);
+    if (returnValue == VLC_SUCCESS) {
+        _lastSortKey = sortKey;
+        _lastSortOrder = sortOrder;
+        _unsorted = NO;
+    }
+    return returnValue;
+}
+
 - (int)startPlaylist
 {
     NSInteger selectedIndex = [_playlistDataSource.tableView selectedRow];



More information about the vlc-commits mailing list