Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
20639516 by Claudio Cambra at 2026-01-20T06:20:17+00:00
macosx: Add an all favorites section

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
0a5a9096 by Claudio Cambra at 2026-01-20T06:20:17+00:00
macosx: Fix change notification of library model favorites lists

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
dfe83d59 by Claudio Cambra at 2026-01-20T06:20:17+00:00
macosx: Retain selection after master table view reload in favorites view

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
24b8d699 by Claudio Cambra at 2026-01-20T06:20:17+00:00
macosx: Simplify favorites list update handling

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -


5 changed files:

- modules/gui/macosx/library/VLCLibraryDataTypes.h
- modules/gui/macosx/library/VLCLibraryModel.m
- modules/gui/macosx/library/VLCLibraryRepresentedItem.m
- modules/gui/macosx/library/favorites-library/VLCLibraryFavoritesDataSource.h
- modules/gui/macosx/library/favorites-library/VLCLibraryFavoritesDataSource.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.h
=====================================
@@ -57,7 +57,8 @@ typedef NS_ENUM(NSUInteger, VLCMediaLibraryParentGroupType) {
     // Video library-specific entries.
     // Please define these in the order the are expected to be presented
     VLCMediaLibraryParentGroupTypeRecentVideos,
-    VLCMediaLibraryParentGroupTypeVideoLibrary, // This should be last
+    VLCMediaLibraryParentGroupTypeVideoLibrary,
+    VLCMediaLibraryParentGroupTypeAllFavorites, // This should be last
 };
 
 @interface VLCMediaLibraryFile : NSObject


=====================================
modules/gui/macosx/library/VLCLibraryModel.m
=====================================
@@ -963,6 +963,13 @@ static void libraryCallback(void *p_data, const 
vlc_ml_event_t *p_event)
 - (NSArray<id<VLCMediaLibraryItemProtocol>> 
*)listOfLibraryItemsOfParentType:(const 
VLCMediaLibraryParentGroupType)parentType
 {
     switch(parentType) {
+    case VLCMediaLibraryParentGroupTypeAllFavorites:
+    {
+        NSMutableArray<VLCMediaLibraryMediaItem *> *allFavorites = 
[NSMutableArray array];
+        [allFavorites addObjectsFromArray:self.listOfFavoriteVideoMedia];
+        [allFavorites addObjectsFromArray:self.listOfFavoriteAudioMedia];
+        return [self sortMediaItems:allFavorites];
+    }
     case VLCMediaLibraryParentGroupTypeArtist:
         return self.listOfArtists;
     case VLCMediaLibraryParentGroupTypeAlbum:
@@ -993,6 +1000,75 @@ static void libraryCallback(void *p_data, const 
vlc_ml_event_t *p_event)
     return mediaItems.copy;
 }
 
+- (NSArray<VLCMediaLibraryMediaItem *> 
*)sortMediaItems:(NSArray<VLCMediaLibraryMediaItem *> *)items
+{
+    if (items.count == 0) {
+        return items;
+    }
+
+    const BOOL descending = _sortDescending;
+
+    return [items 
sortedArrayUsingComparator:^NSComparisonResult(VLCMediaLibraryMediaItem *item1, 
VLCMediaLibraryMediaItem *item2) {
+        NSComparisonResult result = NSOrderedSame;
+
+        switch (self->_sortCriteria) {
+            case VLC_ML_SORTING_DEFAULT:
+            case VLC_ML_SORTING_ALPHA:
+                result = [item1.title 
localizedCaseInsensitiveCompare:item2.title];
+                break;
+            case VLC_ML_SORTING_DURATION:
+                result = [@(item1.duration) compare:@(item2.duration)];
+                break;
+            case VLC_ML_SORTING_INSERTIONDATE:
+            case VLC_ML_SORTING_LASTMODIFICATIONDATE:
+                result = NSOrderedSame;
+                break;
+            case VLC_ML_SORTING_RELEASEDATE:
+                result = [@(item1.year) compare:@(item2.year)];
+                break;
+            case VLC_ML_SORTING_FILESIZE:
+                result = NSOrderedSame;
+                break;
+            case VLC_ML_SORTING_ARTIST:
+            {
+                VLCMediaLibraryAlbum *album1 = [VLCMediaLibraryAlbum 
albumWithID:item1.albumID];
+                VLCMediaLibraryAlbum *album2 = [VLCMediaLibraryAlbum 
albumWithID:item2.albumID];
+                if (album1 && album2) {
+                    result = [album1.artistName 
localizedCaseInsensitiveCompare:album2.artistName];
+                } else {
+                    result = NSOrderedSame;
+                }
+                break;
+            }
+            case VLC_ML_SORTING_PLAYCOUNT:
+                result = [@(item1.playCount) compare:@(item2.playCount)];
+                break;
+            case VLC_ML_SORTING_ALBUM:
+            {
+                VLCMediaLibraryAlbum *album1 = [VLCMediaLibraryAlbum 
albumWithID:item1.albumID];
+                VLCMediaLibraryAlbum *album2 = [VLCMediaLibraryAlbum 
albumWithID:item2.albumID];
+                if (album1 && album2) {
+                    result = [album1.title 
localizedCaseInsensitiveCompare:album2.title];
+                } else {
+                    result = NSOrderedSame;
+                }
+                break;
+            }
+            case VLC_ML_SORTING_FILENAME:
+                result = [item1.title 
localizedCaseInsensitiveCompare:item2.title];
+                break;
+            case VLC_ML_SORTING_TRACKNUMBER:
+                result = [@(item1.trackNumber) compare:@(item2.trackNumber)];
+                break;
+            default:
+                result = NSOrderedSame;
+                break;
+        }
+
+        return descending ? -result : result;
+    }];
+}
+
 - (void)sortByCriteria:(enum vlc_ml_sorting_criteria_t)sortCriteria 
andDescending:(bool)descending
 {
     if(sortCriteria == _sortCriteria && descending == _sortDescending) {
@@ -1031,6 +1107,11 @@ static void libraryCallback(void *p_data, const 
vlc_ml_event_t *p_event)
     [self.changeDelegate notifyChange:VLCLibraryModelGenreListReset 
withObject:self];
     [self.changeDelegate notifyChange:VLCLibraryModelRecentsMediaListReset 
withObject:self];
     [self.changeDelegate notifyChange:VLCLibraryModelRecentAudioMediaListReset 
withObject:self];
+    [self.changeDelegate 
notifyChange:VLCLibraryModelFavoriteVideoMediaListReset withObject:self];
+    [self.changeDelegate 
notifyChange:VLCLibraryModelFavoriteAudioMediaListReset withObject:self];
+    [self.changeDelegate notifyChange:VLCLibraryModelFavoriteAlbumsListReset 
withObject:self];
+    [self.changeDelegate notifyChange:VLCLibraryModelFavoriteArtistsListReset 
withObject:self];
+    [self.changeDelegate notifyChange:VLCLibraryModelFavoriteGenresListReset 
withObject:self];
 }
 
 - (void)performActionOnMediaItemInCache:(const int64_t)libraryId 


=====================================
modules/gui/macosx/library/VLCLibraryRepresentedItem.m
=====================================
@@ -29,6 +29,7 @@
 #import "library/VLCLibraryModel.h"
 
 #import "library/audio-library/VLCLibraryAllAudioGroupsMediaLibraryItem.h"
+#import "library/favorites-library/VLCLibraryFavoritesDataSource.h"
 
 #import "main/VLCMain.h"
 
@@ -191,6 +192,11 @@
 
 - (NSArray<VLCMediaLibraryMediaItem *> *)parentMediaArrayForItem:(const 
id<VLCMediaLibraryItemProtocol>)item
 {
+    if (self.parentType == VLCMediaLibraryParentGroupTypeAllFavorites) {
+        VLCLibraryModel * const libraryModel = 
VLCMain.sharedInstance.libraryController.libraryModel;
+        return [libraryModel listOfMediaItemsForParentType:self.parentType];
+    }
+
     const BOOL isVideo = self.mediaType == VLC_ML_MEDIA_TYPE_VIDEO;
     if (isVideo) {
         VLCLibraryModel * const libraryModel = 
VLCMain.sharedInstance.libraryController.libraryModel;


=====================================
modules/gui/macosx/library/favorites-library/VLCLibraryFavoritesDataSource.h
=====================================
@@ -32,7 +32,8 @@ NS_ASSUME_NONNULL_BEGIN
 extern NSString * const 
VLCLibraryFavoritesDataSourceDisplayedCollectionChangedNotification;
 
 typedef NS_ENUM(NSUInteger, VLCLibraryFavoritesSection) {
-    VLCLibraryFavoritesSectionVideoMedia = 0,
+    VLCLibraryFavoritesSectionAllFavorites = 0,
+    VLCLibraryFavoritesSectionVideoMedia,
     VLCLibraryFavoritesSectionAudioMedia,
     VLCLibraryFavoritesSectionAlbums,
     VLCLibraryFavoritesSectionArtists,


=====================================
modules/gui/macosx/library/favorites-library/VLCLibraryFavoritesDataSource.m
=====================================
@@ -46,6 +46,7 @@ NSString * const 
VLCLibraryFavoritesDataSourceDisplayedCollectionChangedNotifica
 
 @interface VLCLibraryFavoritesDataSource ()
 {
+    NSArray<VLCMediaLibraryMediaItem *> *_allFavoritesArray;
     NSArray<VLCMediaLibraryMediaItem *> *_favoriteVideoMediaArray;
     NSArray<VLCMediaLibraryMediaItem *> *_favoriteAudioMediaArray;
     NSArray<VLCMediaLibraryAlbum *> *_favoriteAlbumsArray;
@@ -73,6 +74,8 @@ NSString * const 
VLCLibraryFavoritesDataSourceDisplayedCollectionChangedNotifica
 - (NSArray<id<VLCMediaLibraryItemProtocol>> 
*)arrayForSection:(VLCLibraryFavoritesSection)section
 {
     switch (section) {
+        case VLCLibraryFavoritesSectionAllFavorites:
+            return _allFavoritesArray;
         case VLCLibraryFavoritesSectionVideoMedia:
             return _favoriteVideoMediaArray;
         case VLCLibraryFavoritesSectionAudioMedia:
@@ -91,6 +94,8 @@ NSString * const 
VLCLibraryFavoritesDataSourceDisplayedCollectionChangedNotifica
 - (NSString *)titleForSection:(VLCLibraryFavoritesSection)section
 {
     switch (section) {
+        case VLCLibraryFavoritesSectionAllFavorites:
+            return _NS("All Favorites");
         case VLCLibraryFavoritesSectionVideoMedia:
             return _NS("Favorite Videos");
         case VLCLibraryFavoritesSectionAudioMedia:
@@ -109,6 +114,8 @@ NSString * const 
VLCLibraryFavoritesDataSourceDisplayedCollectionChangedNotifica
 - 
(VLCMediaLibraryParentGroupType)parentTypeForSection:(VLCLibraryFavoritesSection)section
 {
     switch (section) {
+        case VLCLibraryFavoritesSectionAllFavorites:
+            return VLCMediaLibraryParentGroupTypeAllFavorites;
         case VLCLibraryFavoritesSectionVideoMedia:
             return VLCMediaLibraryParentGroupTypeVideoLibrary;
         case VLCLibraryFavoritesSectionAudioMedia:
@@ -215,27 +222,7 @@ NSString * const 
VLCLibraryFavoritesDataSourceDisplayedCollectionChangedNotifica
 
 #pragma mark - Notification handlers
 
-- (void)libraryModelFavoriteVideoMediaListReset:(NSNotification * 
const)notification
-{
-    [self reloadData];
-}
-
-- (void)libraryModelFavoriteAudioMediaListReset:(NSNotification * 
const)notification
-{
-    [self reloadData];
-}
-
-- (void)libraryModelFavoriteAlbumsListReset:(NSNotification * 
const)notification
-{
-    [self reloadData];
-}
-
-- (void)libraryModelFavoriteArtistsListReset:(NSNotification * 
const)notification
-{
-    [self reloadData];
-}
-
-- (void)libraryModelFavoriteGenresListReset:(NSNotification * 
const)notification
+- (void)libraryModelFavoriteListReset:(NSNotification * const)notification
 {
     [self reloadData];
 }
@@ -247,23 +234,23 @@ NSString * const 
VLCLibraryFavoritesDataSourceDisplayedCollectionChangedNotifica
     NSNotificationCenter * const notificationCenter = 
NSNotificationCenter.defaultCenter;
 
     [notificationCenter addObserver:self
-                           
selector:@selector(libraryModelFavoriteVideoMediaListReset:)
+                           selector:@selector(libraryModelFavoriteListReset:)
                                name:VLCLibraryModelFavoriteVideoMediaListReset
                              object:nil];
     [notificationCenter addObserver:self
-                           
selector:@selector(libraryModelFavoriteAudioMediaListReset:)
+                           selector:@selector(libraryModelFavoriteListReset:)
                                name:VLCLibraryModelFavoriteAudioMediaListReset
                              object:nil];
     [notificationCenter addObserver:self
-                           
selector:@selector(libraryModelFavoriteAlbumsListReset:)
+                           selector:@selector(libraryModelFavoriteListReset:)
                                name:VLCLibraryModelFavoriteAlbumsListReset
                              object:nil];
     [notificationCenter addObserver:self
-                           
selector:@selector(libraryModelFavoriteArtistsListReset:)
+                           selector:@selector(libraryModelFavoriteListReset:)
                                name:VLCLibraryModelFavoriteArtistsListReset
                              object:nil];
     [notificationCenter addObserver:self
-                           
selector:@selector(libraryModelFavoriteGenresListReset:)
+                           selector:@selector(libraryModelFavoriteListReset:)
                                name:VLCLibraryModelFavoriteGenresListReset
                              object:nil];
 
@@ -288,13 +275,19 @@ NSString * const 
VLCLibraryFavoritesDataSourceDisplayedCollectionChangedNotifica
     _favoriteAlbumsArray = [self.libraryModel listOfFavoriteAlbums];
     _favoriteArtistsArray = [self.libraryModel listOfFavoriteArtists];
     _favoriteGenresArray = [self.libraryModel listOfFavoriteGenres];
+    _allFavoritesArray = [self.libraryModel 
listOfLibraryItemsOfParentType:VLCMediaLibraryParentGroupTypeAllFavorites];
 
     [self updateVisibleSectionMapping];
     
     [_flattenedRowMappings removeAllObjects];
 
+    const NSInteger selectedRow = self.masterTableView.selectedRow;
+
     if (self.masterTableView.dataSource == self) {
         [self.masterTableView reloadData];
+        if (selectedRow != -1 && selectedRow < [self.masterTableView 
numberOfRows]) {
+            [self.masterTableView selectRowIndexes:[NSIndexSet 
indexSetWithIndex:selectedRow] byExtendingSelection:NO];
+        }
     }
     if (self.detailTableView.dataSource == self) {
         [self.detailTableView reloadData];
@@ -578,4 +571,9 @@ 
viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
     return VLCLibraryCollectionViewMediaItemSupplementaryDetailViewKind;
 }
 
+- (NSArray<VLCMediaLibraryMediaItem *> *)allFavoritesArray
+{
+    return _allFavoritesArray;
+}
+
 @end



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/ec9adb00d10fae2d7aa5685020f5c6525e3db642...24b8d69983fbc767f122df640c4fec85cff62dc1

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/ec9adb00d10fae2d7aa5685020f5c6525e3db642...24b8d69983fbc767f122df640c4fec85cff62dc1
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to