[vlc-commits] [Git][videolan/vlc][master] 4 commits: macosx: Add VLCMediaLibraryDummyItem type
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Thu Dec 29 17:26:19 UTC 2022
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
d731ad5c by Claudio Cambra at 2022-12-29T17:13:52+00:00
macosx: Add VLCMediaLibraryDummyItem type
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
860e7ab5 by Claudio Cambra at 2022-12-29T17:13:52+00:00
macosx: Display 'all items' entry in VLCAudioDataSource client table views
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
406ab6c1 by Claudio Cambra at 2022-12-29T17:13:52+00:00
macosx: Display all albums when clicking on 'All items' table entry
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1cc3ce63 by Claudio Cambra at 2022-12-29T17:13:52+00:00
macosx: Adapt all items entry text to current audio group type
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3 changed files:
- modules/gui/macosx/library/VLCLibraryDataTypes.h
- modules/gui/macosx/library/VLCLibraryDataTypes.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.h
=====================================
@@ -228,4 +228,11 @@ extern const long long int VLCMediaLibraryMediaItemDurationDenominator;
@end
+ at interface VLCMediaLibraryDummyItem : NSObject<VLCMediaLibraryItemProtocol>
+
+- (instancetype)initWithDisplayString:(NSString*)displayString
+ withDetailString:(NSString*)detailString;
+
+ at end
+
NS_ASSUME_NONNULL_END
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -1102,3 +1102,36 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
}
@end
+
+ at implementation VLCMediaLibraryDummyItem
+
+ at synthesize detailString = _detailString;
+ at synthesize displayString = _displayString;
+ at synthesize durationString = _durationString;
+ at synthesize firstMediaItem = _firstMediaItem;
+ at synthesize libraryID = _libraryId;
+ at synthesize smallArtworkGenerated = _smallArtworkGenerated;
+ at synthesize smallArtworkImage = _smallArtworkImage;
+ at synthesize smallArtworkMRL = _smallArtworkMRL;
+
+
+- (instancetype)initWithDisplayString:(NSString*)displayString
+ withDetailString:(NSString*)detailString
+{
+ self = [super init];
+ if (self) {
+ _displayString = displayString;
+ _detailString = detailString;
+ _durationString = @"";
+ _libraryId = -1;
+ _smallArtworkGenerated = NO;
+ _smallArtworkMRL = @"";
+ }
+ return self;
+}
+
+- (void)iterateMediaItemsWithBlock:(nonnull void (^)(VLCMediaLibraryMediaItem * _Nonnull))mediaItemBlock {
+ return;
+}
+
+ at end
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
=====================================
@@ -474,9 +474,16 @@ static NSString *VLCLibraryYearSortDescriptorKey = @"VLCLibraryYearSortDescripto
#pragma mark - table view data source and delegation
+- (BOOL)displayAllArtistsGenresTableEntry
+{
+ return _currentParentType == VLC_ML_PARENT_GENRE ||
+ _currentParentType == VLC_ML_PARENT_ARTIST;
+}
+
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
- return _displayedCollection.count;
+ NSInteger numItems = _displayedCollection.count;
+ return [self displayAllArtistsGenresTableEntry] ? numItems + 1 : numItems;
}
- (NSView *)tableView:(NSTableView *)tableView
@@ -543,23 +550,42 @@ static NSString *VLCLibraryYearSortDescriptorKey = @"VLCLibraryYearSortDescripto
- (id<VLCMediaLibraryItemProtocol>)libraryItemAtRow:(NSInteger)row
forTableView:(NSTableView *)tableView
{
+ BOOL viewDisplayingAllItemsEntry = [self displayAllArtistsGenresTableEntry];
+ BOOL provideAllItemsEntry = viewDisplayingAllItemsEntry && row == 0;
+
+ if (provideAllItemsEntry && _currentParentType == VLC_ML_PARENT_GENRE) {
+ return [[VLCMediaLibraryDummyItem alloc] initWithDisplayString:_NS("All genres")
+ withDetailString:@""];
+ } else if (provideAllItemsEntry && _currentParentType == VLC_ML_PARENT_ARTIST) {
+ return [[VLCMediaLibraryDummyItem alloc] initWithDisplayString:_NS("All artists")
+ withDetailString:@""];
+ } else if (viewDisplayingAllItemsEntry) {
+ return _displayedCollection[row - 1];
+ }
+
return _displayedCollection[row];
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
- if (notification.object != _collectionSelectionTableView) {
- return;
- }
-
- id<VLCMediaLibraryItemProtocol> libraryItem = _displayedCollection[self.collectionSelectionTableView.selectedRow];
-
- if (_currentParentType == VLC_ML_PARENT_ALBUM) {
- _groupDataSource.representedListOfAlbums = @[(VLCMediaLibraryAlbum *)libraryItem];
- } else if(_currentParentType != VLC_ML_PARENT_UNKNOWN) {
- _groupDataSource.representedListOfAlbums = [_libraryModel listAlbumsOfParentType:_currentParentType forID:libraryItem.libraryID];
- } else { // FIXME: we have nothing to show here
- _groupDataSource.representedListOfAlbums = nil;
+ NSParameterAssert(notification);
+ NSTableView *tableView = (NSTableView *)notification.object;
+ NSInteger selectedRow = tableView.selectedRow;
+ BOOL showingAllItemsEntry = [self displayAllArtistsGenresTableEntry];
+ NSInteger libraryItemIndex = showingAllItemsEntry ? selectedRow - 1 : selectedRow;
+
+ if (libraryItemIndex < 0 && showingAllItemsEntry) {
+ _groupDataSource.representedListOfAlbums = _libraryModel.listOfAlbums;
+ } else {
+ id<VLCMediaLibraryItemProtocol> libraryItem = _displayedCollection[libraryItemIndex];
+
+ if (_currentParentType == VLC_ML_PARENT_ALBUM) {
+ _groupDataSource.representedListOfAlbums = @[(VLCMediaLibraryAlbum *)libraryItem];
+ } else if(_currentParentType != VLC_ML_PARENT_UNKNOWN) {
+ _groupDataSource.representedListOfAlbums = [_libraryModel listAlbumsOfParentType:_currentParentType forID:libraryItem.libraryID];
+ } else { // FIXME: we have nothing to show here
+ _groupDataSource.representedListOfAlbums = nil;
+ }
}
[self.groupSelectionTableView reloadData];
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b8cec147d6c727b34fa20cd5afc4a8240de1879c...1cc3ce63a84b4206b2f757bdae0efb30a13233d6
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b8cec147d6c727b34fa20cd5afc4a8240de1879c...1cc3ce63a84b4206b2f757bdae0efb30a13233d6
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list