Browse Source

macosx: Use correct table views in abstract master/detail view classes

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
pull/201/head
Claudio Cambra 5 months ago
committed by Felix Paul Kühne
parent
commit
57979cb89b
  1. 10
      modules/gui/macosx/library/VLCLibraryAbstractGroupingDataSource.m
  2. 2
      modules/gui/macosx/library/VLCLibraryMasterDetailViewTableViewDataSource.h
  3. 2
      modules/gui/macosx/library/VLCLibraryMasterDetailViewTableViewDelegate.m
  4. 10
      modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistDataSource.m

10
modules/gui/macosx/library/VLCLibraryAbstractGroupingDataSource.m

@ -51,7 +51,7 @@
[self.masterTableView reloadData];
[self.detailTableView reloadData];
[self.collectionView reloadData];
[self updateHeaderForMasterSelection:self.masterTableView];
[self updateHeaderInTableView:self.detailTableView forMasterSelection:self.masterTableView];
}
- (NSUInteger)indexOfMediaItem:(const int64_t)libraryId inArray:(NSArray const *)array
@ -106,7 +106,7 @@
return nil;
}
- (void)updateHeaderForMasterSelection:(NSTableView *)tableView
- (void)updateHeaderInTableView:(NSTableView *)detailTableView forMasterSelection:(NSTableView *)masterTableView
{
if (self.headerDelegate == nil) {
return;
@ -116,15 +116,15 @@
NSString *fallbackTitle = nil;
NSString *fallbackDetail = nil;
const NSInteger selectedRow = tableView.selectedRow;
const NSInteger selectedRow = masterTableView.selectedRow;
if (selectedRow != -1) {
const id<VLCMediaLibraryItemProtocol> selectedItem = [self libraryItemAtRow:selectedRow forTableView:tableView];
const id<VLCMediaLibraryItemProtocol> selectedItem = [self libraryItemAtRow:selectedRow forTableView:masterTableView];
representedItem = [[VLCLibraryRepresentedItem alloc] initWithItem:selectedItem parentType:self.currentParentType];
fallbackTitle = selectedItem.displayString;
fallbackDetail = selectedItem.primaryDetailString;
}
[self.headerDelegate updateHeaderForTableView:tableView
[self.headerDelegate updateHeaderForTableView:detailTableView
withRepresentedItem:representedItem
fallbackTitle:fallbackTitle
fallbackDetail:fallbackDetail];

2
modules/gui/macosx/library/VLCLibraryMasterDetailViewTableViewDataSource.h

@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (readwrite, weak, nullable) id<VLCLibraryGroupHeaderDelegate> headerDelegate;
- (void)updateHeaderForMasterSelection:(NSTableView *)tableView;
- (void)updateHeaderInTableView:(NSTableView *)detailTableView forMasterSelection:(NSTableView *)masterTableView;
@end

2
modules/gui/macosx/library/VLCLibraryMasterDetailViewTableViewDelegate.m

@ -44,7 +44,7 @@
if (tableView == masterDetailViewDataSource.masterTableView) {
[masterDetailViewDataSource.detailTableView reloadData];
[masterDetailViewDataSource updateHeaderForMasterSelection:tableView];
[masterDetailViewDataSource updateHeaderInTableView:masterDetailViewDataSource.detailTableView forMasterSelection:tableView];
}
}

10
modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistDataSource.m

@ -125,7 +125,7 @@ typedef NS_ENUM(NSInteger, VLCLibraryDataSourceCacheAction) {
{
self.playlists = [[self.libraryModel listOfPlaylistsOfType:self.playlistType] mutableCopy];
[self reloadViews];
[self updateHeaderForMasterSelection:self.detailTableView];
[self updateHeaderInTableView:self.detailTableView forMasterSelection:self.masterTableView];
}
- (void)reloadViews
@ -383,15 +383,15 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
[self reloadData];
}
- (void)updateHeaderForMasterSelection:(NSTableView *)tableView
- (void)updateHeaderInTableView:(NSTableView *)detailTableView forMasterSelection:(NSTableView *)masterTableView
{
if (self.headerDelegate == nil) {
return;
}
const NSInteger selectedRow = tableView.selectedRow;
const NSInteger selectedRow = masterTableView.selectedRow;
if (selectedRow < 0 || selectedRow >= self.playlists.count) {
[self.headerDelegate updateHeaderForTableView:tableView
[self.headerDelegate updateHeaderForTableView:detailTableView
withRepresentedItem:nil
fallbackTitle:_NS("Playlists")
fallbackDetail:_NS("Select a playlist")];
@ -403,7 +403,7 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
[[VLCLibraryRepresentedItem alloc] initWithItem:playlist
parentType:self.currentParentType];
[self.headerDelegate updateHeaderForTableView:tableView
[self.headerDelegate updateHeaderForTableView:detailTableView
withRepresentedItem:representedItem
fallbackTitle:playlist.primaryDetailString
fallbackDetail:playlist.secondaryDetailString];

Loading…
Cancel
Save