mirror of https://code.videolan.org/videolan/vlc
macosx: Move delegate methods in VLCLibraryVideoCollectionViewContainerViewDataSource to general VLCLibraryCollectionViewDelegate
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
This commit is contained in:
parent
623d1226fc
commit
b069be4532
|
@ -22,7 +22,9 @@
|
|||
|
||||
#import "VLCLibraryCollectionViewDelegate.h"
|
||||
|
||||
#import "VLCLibraryCollectionViewDataSource.h"
|
||||
#import "VLCLibraryCollectionViewFlowLayout.h"
|
||||
#import "VLCLibraryDataTypes.h"
|
||||
|
||||
@implementation VLCLibraryCollectionViewDelegate
|
||||
|
||||
|
@ -115,4 +117,48 @@
|
|||
return NSMakeSize(itemWidth, itemWidth + 46); // Text fields height needed
|
||||
}
|
||||
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
canDragItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
|
||||
withEvent:(NSEvent *)event
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
writeItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
|
||||
toPasteboard:(NSPasteboard *)pasteboard
|
||||
{
|
||||
if (![collectionView.dataSource conformsToProtocol:@protocol(VLCLibraryCollectionViewDataSource)]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSObject<VLCLibraryCollectionViewDataSource> *vlcDataSource = (NSObject<VLCLibraryCollectionViewDataSource>*)collectionView.dataSource;
|
||||
|
||||
NSUInteger numberOfIndexPaths = indexPaths.count;
|
||||
NSMutableArray *encodedLibraryItemsArray = [NSMutableArray arrayWithCapacity:numberOfIndexPaths];
|
||||
NSMutableArray *filePathsArray = [NSMutableArray arrayWithCapacity:numberOfIndexPaths];
|
||||
|
||||
for (NSIndexPath *indexPath in indexPaths) {
|
||||
|
||||
id<VLCMediaLibraryItemProtocol> libraryItem = [vlcDataSource libraryItemAtIndexPath:indexPath
|
||||
forCollectionView:collectionView];
|
||||
|
||||
VLCMediaLibraryMediaItem *mediaItem = libraryItem.firstMediaItem;
|
||||
[encodedLibraryItemsArray addObject:mediaItem];
|
||||
|
||||
VLCMediaLibraryFile *file = mediaItem.files.firstObject;
|
||||
if (file) {
|
||||
NSURL *url = [NSURL URLWithString:file.MRL];
|
||||
[filePathsArray addObject:url.path];
|
||||
}
|
||||
}
|
||||
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:encodedLibraryItemsArray];
|
||||
[pasteboard declareTypes:@[VLCMediaLibraryMediaItemPasteboardType, NSFilenamesPboardType] owner:self];
|
||||
[pasteboard setPropertyList:filePathsArray forType:NSFilenamesPboardType];
|
||||
[pasteboard setData:data forType:VLCMediaLibraryMediaItemPasteboardType];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface VLCLibraryVideoCollectionViewContainerViewDataSource : NSObject <VLCLibraryCollectionViewDataSource, NSCollectionViewDelegate>
|
||||
@interface VLCLibraryVideoCollectionViewContainerViewDataSource : NSObject <VLCLibraryCollectionViewDataSource>
|
||||
|
||||
@property (readwrite, assign) NSCollectionView *collectionView;
|
||||
@property (readwrite, assign, nonatomic) VLCLibraryVideoCollectionViewGroupDescriptor *groupDescriptor;
|
||||
|
|
|
@ -104,7 +104,6 @@
|
|||
|
||||
_collectionViewFlowLayout = collectionViewLayout;
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.delegate = self;
|
||||
|
||||
[_collectionView registerClass:[VLCLibraryCollectionViewItem class]
|
||||
forItemWithIdentifier:VLCLibraryCellIdentifier];
|
||||
|
@ -165,62 +164,6 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (void)collectionView:(NSCollectionView *)collectionView didSelectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
|
||||
{
|
||||
NSIndexPath *indexPath = indexPaths.anyObject;
|
||||
if (!indexPath) {
|
||||
NSLog(@"Bad index path on item selection");
|
||||
return;
|
||||
}
|
||||
|
||||
[_collectionViewFlowLayout expandDetailSectionAtIndex:indexPath];
|
||||
}
|
||||
|
||||
- (void)collectionView:(NSCollectionView *)collectionView didDeselectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
|
||||
{
|
||||
NSIndexPath *indexPath = indexPaths.anyObject;
|
||||
if (!indexPath) {
|
||||
NSLog(@"Bad index path on item deselection");
|
||||
return;
|
||||
}
|
||||
|
||||
[_collectionViewFlowLayout collapseDetailSectionAtIndex:indexPath];
|
||||
}
|
||||
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
canDragItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
|
||||
withEvent:(NSEvent *)event
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
writeItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
|
||||
toPasteboard:(NSPasteboard *)pasteboard
|
||||
{
|
||||
NSUInteger numberOfIndexPaths = indexPaths.count;
|
||||
NSMutableArray *encodedLibraryItemsArray = [NSMutableArray arrayWithCapacity:numberOfIndexPaths];
|
||||
NSMutableArray *filePathsArray = [NSMutableArray arrayWithCapacity:numberOfIndexPaths];
|
||||
|
||||
for (NSIndexPath *indexPath in indexPaths) {
|
||||
VLCMediaLibraryMediaItem *mediaItem = _collectionArray[indexPath.item];
|
||||
[encodedLibraryItemsArray addObject:mediaItem];
|
||||
|
||||
VLCMediaLibraryFile *file = mediaItem.files.firstObject;
|
||||
if (file) {
|
||||
NSURL *url = [NSURL URLWithString:file.MRL];
|
||||
[filePathsArray addObject:url.path];
|
||||
}
|
||||
}
|
||||
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:encodedLibraryItemsArray];
|
||||
[pasteboard declareTypes:@[VLCMediaLibraryMediaItemPasteboardType, NSFilenamesPboardType] owner:self];
|
||||
[pasteboard setPropertyList:filePathsArray forType:NSFilenamesPboardType];
|
||||
[pasteboard setData:data forType:VLCMediaLibraryMediaItemPasteboardType];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id<VLCMediaLibraryItemProtocol>)libraryItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
forCollectionView:(NSCollectionView *)collectionView
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue