|
|
|
@ -30,6 +30,7 @@ |
|
|
|
#import "library/VLCLibraryCollectionViewSupplementaryElementView.h" |
|
|
|
#import "library/VLCLibraryController.h" |
|
|
|
#import "library/VLCLibraryDataTypes.h" |
|
|
|
#import "library/VLCLibraryMasterDetailViewTableViewDelegate.h" |
|
|
|
#import "library/VLCLibraryModel.h" |
|
|
|
#import "library/VLCLibraryRepresentedItem.h" |
|
|
|
|
|
|
|
@ -48,6 +49,8 @@ typedef NS_ENUM(NSInteger, VLCLibraryDataSourceCacheAction) { |
|
|
|
|
|
|
|
@implementation VLCLibraryPlaylistDataSource |
|
|
|
|
|
|
|
@synthesize headerDelegate; |
|
|
|
|
|
|
|
- (instancetype)init |
|
|
|
{ |
|
|
|
self = [super init]; |
|
|
|
@ -122,6 +125,7 @@ typedef NS_ENUM(NSInteger, VLCLibraryDataSourceCacheAction) { |
|
|
|
{ |
|
|
|
self.playlists = [[self.libraryModel listOfPlaylistsOfType:self.playlistType] mutableCopy]; |
|
|
|
[self reloadViews]; |
|
|
|
[self updateHeaderForMasterSelection:self.detailTableView]; |
|
|
|
} |
|
|
|
|
|
|
|
- (void)reloadViews |
|
|
|
@ -379,4 +383,30 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind |
|
|
|
[self reloadData]; |
|
|
|
} |
|
|
|
|
|
|
|
- (void)updateHeaderForMasterSelection:(NSTableView *)tableView |
|
|
|
{ |
|
|
|
if (self.headerDelegate == nil) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const NSInteger selectedRow = tableView.selectedRow; |
|
|
|
if (selectedRow < 0 || selectedRow >= self.playlists.count) { |
|
|
|
[self.headerDelegate updateHeaderForTableView:tableView |
|
|
|
withRepresentedItem:nil |
|
|
|
fallbackTitle:_NS("Playlists") |
|
|
|
fallbackDetail:_NS("Select a playlist")]; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const VLCMediaLibraryPlaylist * const playlist = self.playlists[selectedRow]; |
|
|
|
VLCLibraryRepresentedItem * const representedItem = |
|
|
|
[[VLCLibraryRepresentedItem alloc] initWithItem:playlist |
|
|
|
parentType:self.currentParentType]; |
|
|
|
|
|
|
|
[self.headerDelegate updateHeaderForTableView:tableView |
|
|
|
withRepresentedItem:representedItem |
|
|
|
fallbackTitle:playlist.primaryDetailString |
|
|
|
fallbackDetail:playlist.secondaryDetailString]; |
|
|
|
} |
|
|
|
|
|
|
|
@end |
|
|
|
|