You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
4.2 KiB
109 lines
4.2 KiB
/*****************************************************************************
|
|
* VLCLibraryAudioGroupDataSource.m: MacOS X interface module
|
|
*****************************************************************************
|
|
* Copyright (C) 2022 VLC authors and VideoLAN
|
|
*
|
|
* Authors: Claudio Cambra <developer@claudiocambra.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
|
*****************************************************************************/
|
|
|
|
#import "VLCLibraryAudioGroupDataSource.h"
|
|
|
|
#import "extensions/NSPasteboardItem+VLCAdditions.h"
|
|
|
|
#import "main/VLCMain.h"
|
|
|
|
#import "library/VLCLibraryDataTypes.h"
|
|
#import "library/VLCLibraryCollectionViewItem.h"
|
|
#import "library/VLCLibraryCollectionViewFlowLayout.h"
|
|
#import "library/VLCLibraryWindow.h"
|
|
|
|
#import "library/audio-library/VLCLibraryAlbumTableCellView.h"
|
|
#import "library/audio-library/VLCLibraryCollectionViewAlbumSupplementaryDetailView.h"
|
|
|
|
#import "views/VLCSubScrollView.h"
|
|
|
|
@implementation VLCLibraryAudioGroupDataSource
|
|
|
|
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
|
|
{
|
|
if (self.representedListOfAlbums != nil) {
|
|
return self.representedListOfAlbums.count;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
- (id<VLCMediaLibraryItemProtocol>)libraryItemAtRow:(NSInteger)row
|
|
forTableView:(NSTableView *)tableView
|
|
{
|
|
return self.representedListOfAlbums[row];
|
|
}
|
|
|
|
- (NSInteger)collectionView:(NSCollectionView *)collectionView
|
|
numberOfItemsInSection:(NSInteger)section
|
|
{
|
|
return self.representedListOfAlbums.count;
|
|
}
|
|
|
|
- (NSInteger)numberOfSectionsInCollectionView:(NSCollectionView *)collectionView
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
- (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView
|
|
itemForRepresentedObjectAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
VLCLibraryCollectionViewItem *viewItem = [collectionView makeItemWithIdentifier:VLCLibraryCellIdentifier forIndexPath:indexPath];
|
|
viewItem.representedItem = self.representedListOfAlbums[indexPath.item];
|
|
return viewItem;
|
|
}
|
|
|
|
- (NSView *)collectionView:(NSCollectionView *)collectionView
|
|
viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
|
|
atIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
if ([kind isEqualToString:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind]) {
|
|
|
|
VLCLibraryCollectionViewAlbumSupplementaryDetailView* albumSupplementaryDetailView = [collectionView makeSupplementaryViewOfKind:kind withIdentifier:VLCLibraryCollectionViewAlbumSupplementaryDetailViewKind forIndexPath:indexPath];
|
|
|
|
VLCMediaLibraryAlbum * const album = self.representedListOfAlbums[indexPath.item];
|
|
albumSupplementaryDetailView.representedAlbum = album;
|
|
albumSupplementaryDetailView.selectedItem = [collectionView itemAtIndex:indexPath.item];
|
|
albumSupplementaryDetailView.parentScrollView = VLCMain.sharedInstance.libraryWindow.audioCollectionViewScrollView;
|
|
albumSupplementaryDetailView.internalScrollView.scrollParentY = YES;
|
|
|
|
return albumSupplementaryDetailView;
|
|
|
|
}
|
|
|
|
return nil;
|
|
}
|
|
|
|
- (id<NSPasteboardWriting>)tableView:(NSTableView *)tableView pasteboardWriterForRow:(NSInteger)row
|
|
{
|
|
const id<VLCMediaLibraryItemProtocol> libraryItem = [self libraryItemAtRow:row forTableView:tableView];
|
|
|
|
return [NSPasteboardItem pasteboardItemWithLibraryItem:libraryItem];
|
|
}
|
|
|
|
- (id<VLCMediaLibraryItemProtocol>)libraryItemAtIndexPath:(NSIndexPath *)indexPath
|
|
forCollectionView:(NSCollectionView *)collectionView
|
|
{
|
|
return self.representedListOfAlbums[indexPath.item];
|
|
}
|
|
|
|
@end
|
|
|