[vlc-commits] macosx: simplify library model code

Felix Paul Kühne git at videolan.org
Wed May 15 20:08:50 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed May 15 20:07:33 2019 +0200| [1fc2ab02f8f0a3f94b6a8165941da494225fb880] | committer: Felix Paul Kühne

macosx: simplify library model code

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

 modules/gui/macosx/library/VLCLibraryModel.h       |  7 ------
 modules/gui/macosx/library/VLCLibraryModel.m       | 19 +++-----------
 .../gui/macosx/library/VLCLibraryVideoDataSource.m | 29 ++--------------------
 modules/gui/macosx/library/VLCLibraryWindow.m      |  3 ---
 4 files changed, 5 insertions(+), 53 deletions(-)

diff --git a/modules/gui/macosx/library/VLCLibraryModel.h b/modules/gui/macosx/library/VLCLibraryModel.h
index aa58e17fd9..80e04dd06c 100644
--- a/modules/gui/macosx/library/VLCLibraryModel.h
+++ b/modules/gui/macosx/library/VLCLibraryModel.h
@@ -26,11 +26,6 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-typedef NS_ENUM(NSInteger, VLCLibraryMode) {
-    VLCLibraryModeAudio,
-    VLCLibraryModeVideo,
-};
-
 @class VLCMediaLibraryMediaItem;
 @class VLCMediaLibraryArtist;
 @class VLCMediaLibraryAlbum;
@@ -50,8 +45,6 @@ extern NSString *VLCLibraryModelMediaItemUpdated;
 
 - (instancetype)initWithLibrary:(vlc_medialibrary_t *)library;
 
- at property (readwrite) VLCLibraryMode libraryMode;
-
 @property (readonly) size_t numberOfAudioMedia;
 @property (readonly) NSArray <VLCMediaLibraryMediaItem *> *listOfAudioMedia;
 
diff --git a/modules/gui/macosx/library/VLCLibraryModel.m b/modules/gui/macosx/library/VLCLibraryModel.m
index 2417ef8576..09ae2c3532 100644
--- a/modules/gui/macosx/library/VLCLibraryModel.m
+++ b/modules/gui/macosx/library/VLCLibraryModel.m
@@ -63,22 +63,9 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
         case VLC_ML_EVENT_MEDIA_DELETED:
             dispatch_async(dispatch_get_main_queue(), ^{
                 VLCLibraryModel *libraryModel = (__bridge VLCLibraryModel *)p_data;
-                switch (libraryModel.libraryMode) {
-                    case VLCLibraryModeAudio:
-                        [libraryModel updateCachedListOfRecentMedia];
-                        [libraryModel updateCachedListOfAudioMedia];
-                        break;
-
-                    case VLCLibraryModeVideo:
-                        [libraryModel updateCachedListOfRecentMedia];
-                        [libraryModel updateCachedListOfVideoMedia];
-                        break;
-
-                    default:
-                        [libraryModel updateCachedListOfRecentMedia];
-                        break;
-                }
-
+                [libraryModel updateCachedListOfRecentMedia];
+                [libraryModel updateCachedListOfAudioMedia];
+                [libraryModel updateCachedListOfVideoMedia];
             });
             break;
         case VLC_ML_EVENT_MEDIA_THUMBNAIL_GENERATED:
diff --git a/modules/gui/macosx/library/VLCLibraryVideoDataSource.m b/modules/gui/macosx/library/VLCLibraryVideoDataSource.m
index 68dfa78e3b..f99d37ffd9 100644
--- a/modules/gui/macosx/library/VLCLibraryVideoDataSource.m
+++ b/modules/gui/macosx/library/VLCLibraryVideoDataSource.m
@@ -38,19 +38,7 @@
         return [_libraryModel numberOfRecentMedia];
     }
 
-    switch (_libraryModel.libraryMode) {
-        case VLCLibraryModeAudio:
-            return [_libraryModel numberOfAudioMedia];
-            break;
-
-        case VLCLibraryModeVideo:
-            return [_libraryModel numberOfVideoMedia];
-            break;
-
-        default:
-            return 0;
-            break;
-    }
+    return [_libraryModel numberOfVideoMedia];
 }
 
 - (NSInteger)numberOfSectionsInCollectionView:(NSCollectionView *)collectionView
@@ -67,20 +55,7 @@
     if (collectionView == self.recentMediaCollectionView) {
         mediaArray = [_libraryModel listOfRecentMedia];
     } else {
-        switch (_libraryModel.libraryMode) {
-            case VLCLibraryModeAudio:
-                mediaArray = [_libraryModel listOfAudioMedia];
-                break;
-
-            case VLCLibraryModeVideo:
-                mediaArray = [_libraryModel listOfVideoMedia];
-                break;
-
-            default:
-                NSAssert(1, @"no representation for selected library mode");
-                mediaArray = @[];
-                break;
-        }
+        mediaArray = [_libraryModel listOfVideoMedia];
     }
 
     viewItem.representedMediaItem = mediaArray[indexPath.item];
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index 5eabfbad89..e0d9020783 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -288,7 +288,6 @@ const CGFloat VLCLibraryWindowLargeRowHeight = 50.;
 {
     switch (_segmentedTitleControl.selectedSegment) {
         case 0:
-            _libraryVideoDataSource.libraryModel.libraryMode = VLCLibraryModeVideo;
             if (_mediaSourceScrollView.superview != nil) {
                 [_mediaSourceScrollView removeFromSuperview];
             }
@@ -310,7 +309,6 @@ const CGFloat VLCLibraryWindowLargeRowHeight = 50.;
             break;
 
         case 1:
-            _libraryVideoDataSource.libraryModel.libraryMode = VLCLibraryModeAudio;
             if (_mediaSourceScrollView.superview != nil) {
                 [_mediaSourceScrollView removeFromSuperview];
             }
@@ -332,7 +330,6 @@ const CGFloat VLCLibraryWindowLargeRowHeight = 50.;
             break;
 
         case 2:
-            _libraryVideoDataSource.libraryModel.libraryMode = VLCLibraryModeAudio;
             if (_mediaSourceScrollView.superview != nil) {
                 [_mediaSourceScrollView removeFromSuperview];
             }



More information about the vlc-commits mailing list