Browse Source

macosx: Replace table view delegation for video view tables using VLCLibraryVideoTableViewDataSource with VLCLibraryVideoTableViewDelegate

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
pull/162/head
Claudio Cambra 3 years ago
committed by Steve Lhomme
parent
commit
80da84b076
  1. 3
      modules/gui/macosx/library/video-library/VLCLibraryVideoTableViewDataSource.h
  2. 51
      modules/gui/macosx/library/video-library/VLCLibraryVideoTableViewDataSource.m
  3. 21
      modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m

3
modules/gui/macosx/library/video-library/VLCLibraryVideoTableViewDataSource.h

@ -28,13 +28,12 @@ NS_ASSUME_NONNULL_BEGIN
@class VLCLibraryModel;
@interface VLCLibraryVideoTableViewDataSource : NSObject <VLCLibraryTableViewDataSource, NSTableViewDelegate>
@interface VLCLibraryVideoTableViewDataSource : NSObject <VLCLibraryTableViewDataSource>
@property (readwrite, assign) VLCLibraryModel *libraryModel;
@property (readwrite, assign) NSTableView *groupsTableView;
@property (readwrite, assign) NSTableView *groupSelectionTableView;
- (void)setup;
- (void)reloadData;
@end

51
modules/gui/macosx/library/video-library/VLCLibraryVideoTableViewDataSource.m

@ -84,22 +84,6 @@
});
}
- (void)setup
{
[self setupTableViews];
}
- (void)setupTableViews
{
_groupsTableView.dataSource = self;
_groupsTableView.delegate = self;
_groupsTableView.target = self;
_groupSelectionTableView.dataSource = self;
_groupSelectionTableView.delegate = self;
_groupSelectionTableView.target = self;
}
#pragma mark - table view data source and delegation
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
@ -121,41 +105,6 @@
return 0;
}
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
VLCLibraryTableCellView *cellView = [tableView makeViewWithIdentifier:@"VLCVideoLibraryTableViewCellIdentifier" owner:self];
if (!cellView) {
cellView = [VLCLibraryTableCellView fromNibWithOwner:self];
cellView.identifier = @"VLCVideoLibraryTableViewCellIdentifier";
}
if (tableView == _groupsTableView) {
cellView.representedVideoLibrarySection = row;
} else if (tableView == _groupSelectionTableView && _groupsTableView.selectedRow > -1) {
switch(_groupsTableView.selectedRow + 1) { // Group 0 is invalid so add one
case VLCLibraryVideoRecentsGroup:
cellView.representedItem = _recentsArray[row];
break;
case VLCLibraryVideoLibraryGroup:
cellView.representedItem = _libraryArray[row];
break;
default:
NSAssert(1, @"Reached unreachable case for video library section");
break;
}
}
return cellView;
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
if(notification.object == _groupsTableView) {
[_groupSelectionTableView reloadData];
}
}
- (id<VLCMediaLibraryItemProtocol>)libraryItemAtRow:(NSInteger)row
forTableView:(NSTableView *)tableView
{

21
modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m

@ -33,12 +33,19 @@
#import "library/video-library/VLCLibraryVideoCollectionViewsStackViewController.h"
#import "library/video-library/VLCLibraryVideoTableViewDataSource.h"
#import "library/video-library/VLCLibraryVideoTableViewDelegate.h"
#import "main/VLCMain.h"
#import "windows/video/VLCVoutView.h"
#import "windows/video/VLCMainVideoViewController.h"
@interface VLCLibraryVideoViewController ()
{
VLCLibraryVideoTableViewDelegate *_videoLibraryTableViewDelegate;
}
@end
@implementation VLCLibraryVideoViewController
- (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow
@ -46,8 +53,11 @@
self = [super init];
if(self) {
_videoLibraryTableViewDelegate = [[VLCLibraryVideoTableViewDelegate alloc] init];
[self setupPropertiesFromLibraryWindow:libraryWindow];
[self setupTableViewDataSource];
[self setupTableViews];
[self setupGridViewController];
[self setupVideoPlaceholderView];
[self setupVideoLibraryViews];
@ -89,8 +99,17 @@
_libraryVideoTableViewDataSource.libraryModel = VLCMain.sharedInstance.libraryController.libraryModel;
_libraryVideoTableViewDataSource.groupsTableView = _videoLibraryGroupsTableView;
_libraryVideoTableViewDataSource.groupSelectionTableView = _videoLibraryGroupSelectionTableView;
}
- (void)setupTableViews
{
_videoLibraryGroupsTableView.dataSource = _libraryVideoTableViewDataSource;
_videoLibraryGroupsTableView.target = _libraryVideoTableViewDataSource;
_videoLibraryGroupsTableView.delegate = _videoLibraryTableViewDelegate;
[_libraryVideoTableViewDataSource setup];
_videoLibraryGroupSelectionTableView.dataSource = _libraryVideoTableViewDataSource;
_videoLibraryGroupSelectionTableView.target = _libraryVideoTableViewDataSource;
_videoLibraryGroupSelectionTableView.delegate = _videoLibraryTableViewDelegate;
}
- (void)setupGridViewController

Loading…
Cancel
Save