[vlc-commits] [Git][videolan/vlc][master] 3 commits: macosx: Add rating sorting to sorting menu controller

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sat Nov 7 11:25:03 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
bad0aeac by Claudio Cambra at 2026-11-07T11:50:06+01:00
macosx: Add rating sorting to sorting menu controller

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
72886930 by Claudio Cambra at 2026-11-07T11:50:06+01:00
macosx: Add rating sorting to audio data source

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
5e2c7454 by Claudio Cambra at 2026-11-07T11:50:06+01:00
macosx: Add test for rating sorting in library model

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


4 changed files:

- modules/gui/macosx/library/VLCLibrarySortingMenuController.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.h
- modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
- modules/gui/macosx/tests/VLCLibraryModelIntegrationTest.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibrarySortingMenuController.m
=====================================
@@ -62,7 +62,8 @@
                         _NS("Play Count"),
                         _NS("Album"),
                         _NS("Filename"),
-                        _NS("Track Number")];
+                        _NS("Track Number"),
+                        _NS("Rating")];
     NSUInteger count = titles.count;
     for (NSUInteger x = 0; x < count; x++) {
         NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:titles[x] action:@selector(selectSortKey:) keyEquivalent:@""];


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.h
=====================================
@@ -56,6 +56,7 @@ extern NSString * const VLCLibraryArtistSortDescriptorKey;
 extern NSString * const VLCLibraryAlbumSortDescriptorKey;
 extern NSString * const VLCLibraryPlayCountSortDescriptorKey;
 extern NSString * const VLCLibraryYearSortDescriptorKey;
+extern NSString * const VLCLibraryRatingSortDescriptorKey;
 
 extern NSString * const VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification;
 


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
=====================================
@@ -72,6 +72,7 @@ NSString * const VLCLibraryArtistSortDescriptorKey = @"VLCLibraryArtistSortDescr
 NSString * const VLCLibraryAlbumSortDescriptorKey = @"VLCLibraryAlbumSortDescriptorKey";
 NSString * const VLCLibraryPlayCountSortDescriptorKey = @"VLCLibraryPlayCountSortDescriptorKey";
 NSString * const VLCLibraryYearSortDescriptorKey = @"VLCLibraryYearSortDescriptorKey";
+NSString * const VLCLibraryRatingSortDescriptorKey = @"VLCLibraryRatingSortDescriptorKey";
 // TODO: Add sorting by genre
 
 NSString * const VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification = @"VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification";
@@ -548,6 +549,9 @@ NSString * const VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
     } else if (existingSortCriteria == VLC_ML_SORTING_RELEASEDATE) {
         return VLCLibraryYearSortDescriptorKey;
 
+    } else if (existingSortCriteria == VLC_ML_SORTING_RATING) {
+        return VLCLibraryRatingSortDescriptorKey;
+
     }
 
     return VLCLibraryTitleSortDescriptorKey;
@@ -959,6 +963,9 @@ NSString * const VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
     } else if ([sortDescriptorKey isEqualToString:VLCLibraryYearSortDescriptorKey]) {
         return VLC_ML_SORTING_RELEASEDATE;
 
+    } else if ([sortDescriptorKey isEqualToString:VLCLibraryRatingSortDescriptorKey]) {
+        return VLC_ML_SORTING_RATING;
+
     }
 
     return VLC_ML_SORTING_DEFAULT;


=====================================
modules/gui/macosx/tests/VLCLibraryModelIntegrationTest.m
=====================================
@@ -412,6 +412,38 @@
                    VLCLibraryDataTypesIntegrationSortingAudioAlphaMediaID());
 }
 
+- (void)testAudioMediaQuerySortsByRatingInBothDirectionsWithUnratedLast
+{
+    vlc_medialibrary_t * const library = VLCLibraryDataTypesIntegrationMediaLibrary();
+    const int64_t highestRatedID =
+        VLCLibraryDataTypesIntegrationSortingAudioAlphaMediaID();
+    const int64_t lowestRatedID =
+        VLCLibraryDataTypesIntegrationSortingAudioZuluMediaID();
+    const int64_t unratedID = VLCLibraryDataTypesIntegrationFactoryAudioMediaID();
+    XCTAssertEqual(vlc_ml_media_set_playback_state(library, highestRatedID,
+                                                   VLC_ML_PLAYBACK_STATE_RATING, "5"),
+                   VLC_SUCCESS);
+    XCTAssertEqual(vlc_ml_media_set_playback_state(library, lowestRatedID,
+                                                   VLC_ML_PLAYBACK_STATE_RATING, "1"),
+                   VLC_SUCCESS);
+
+    [self.model sortByCriteria:VLC_ML_SORTING_RATING andDescending:NO];
+    NSArray<VLCMediaLibraryMediaItem *> *media = [self audioMediaAfterFilter:@""];
+
+    XCTAssertEqual(media.count, (NSUInteger)3);
+    XCTAssertEqual(media[0].libraryID, lowestRatedID);
+    XCTAssertEqual(media[1].libraryID, highestRatedID);
+    XCTAssertEqual(media[2].libraryID, unratedID);
+
+    [self.model sortByCriteria:VLC_ML_SORTING_RATING andDescending:YES];
+    media = [self audioMediaAfterFilter:@""];
+
+    XCTAssertEqual(media.count, (NSUInteger)3);
+    XCTAssertEqual(media[0].libraryID, highestRatedID);
+    XCTAssertEqual(media[1].libraryID, lowestRatedID);
+    XCTAssertEqual(media[2].libraryID, unratedID);
+}
+
 - (void)testVideoMediaQuerySortsMatchingItemsInAscendingOrder
 {
     [self.model sortByCriteria:VLC_ML_SORTING_ALPHA andDescending:NO];



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c0ca284385fb62c6150c0f1b3cc432f92d936865...5e2c7454ecd71b69369ec5d2b06a5d87eb981ffb

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c0ca284385fb62c6150c0f1b3cc432f92d936865...5e2c7454ecd71b69369ec5d2b06a5d87eb981ffb
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list