[vlc-commits] [Git][videolan/vlc][master] 3 commits: macosx: Fix the parent type for represented items given out in video data source
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Jul 30 11:34:06 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
07289b29 by Claudio Cambra at 2024-07-30T11:02:45+00:00
macosx: Fix the parent type for represented items given out in video data source
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1d654fab by Claudio Cambra at 2024-07-30T11:02:45+00:00
macosx: Return VLCMediaLibraryParentGroupType directly from rowToVideoGroup rather than an NSInteger
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
d677a00a by Claudio Cambra at 2024-07-30T11:02:45+00:00
macosx: Fix always bad nsasserts in video data source
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1 changed file:
- modules/gui/macosx/library/video-library/VLCLibraryVideoDataSource.m
Changes:
=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoDataSource.m
=====================================
@@ -246,18 +246,15 @@ NSString * const VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
[self.collectionView reloadItemsAtIndexPaths:indexPathSet];
}
- if (self.groupSelectionTableView.dataSource == self) {
- const NSInteger selectedTableViewVideoGroup =
- [self rowToVideoGroup:self.groupsTableView.selectedRow];
- if (selectedTableViewVideoGroup == group) {
- // Don't regenerate the groups by index as these do not change according to the
- // notification, stick to the selection table view
- const NSRange columnRange = NSMakeRange(0, self->_groupsTableView.numberOfColumns);
- NSIndexSet * const columnIndexSet =
- [NSIndexSet indexSetWithIndexesInRange:columnRange];
- [self.groupSelectionTableView reloadDataForRowIndexes:rowIndexSet
- columnIndexes:columnIndexSet];
- }
+ if (self.groupSelectionTableView.dataSource == self &&
+ [self rowToVideoGroup:self.groupsTableView.selectedRow] == group) {
+ // Don't regenerate the groups by index as these do not change according to the
+ // notification, stick to the selection table view
+ const NSRange columnRange = NSMakeRange(0, self->_groupsTableView.numberOfColumns);
+ NSIndexSet * const columnIndexSet =
+ [NSIndexSet indexSetWithIndexesInRange:columnRange];
+ [self.groupSelectionTableView reloadDataForRowIndexes:rowIndexSet
+ columnIndexes:columnIndexSet];
}
// Don't bother with the groups table view as we always show "recents" and "videos" there
@@ -282,15 +279,12 @@ NSString * const VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
[self.collectionView deleteItemsAtIndexPaths:indexPathSet];
}
- if (self.groupSelectionTableView.dataSource == self) {
- const NSInteger selectedTableViewVideoGroup =
- [self rowToVideoGroup:self.groupsTableView.selectedRow];
- if (selectedTableViewVideoGroup == group) {
- // Don't regenerate the groups by index as these do not change according to the
- // notification, stick to the selection table view
- [self.groupSelectionTableView removeRowsAtIndexes:rowIndexSet
- withAnimation:NSTableViewAnimationSlideUp];
- }
+ if (self.groupSelectionTableView.dataSource == self &&
+ [self rowToVideoGroup:self.groupsTableView.selectedRow] == group) {
+ // Don't regenerate the groups by index as these do not change according to the
+ // notification, stick to the selection table view
+ [self.groupSelectionTableView removeRowsAtIndexes:rowIndexSet
+ withAnimation:NSTableViewAnimationSlideUp];
}
}];
}
@@ -317,7 +311,7 @@ NSString * const VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
return anyRecents ? firstEntry : firstEntry + 1;
}
-- (NSUInteger)rowToVideoGroup:(NSInteger)row
+- (VLCMediaLibraryParentGroupType)rowToVideoGroup:(NSInteger)row
{
return row + [self rowToVideoGroupAdjustment];
}
@@ -352,7 +346,7 @@ NSString * const VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
case VLCMediaLibraryParentGroupTypeVideoLibrary:
return _libraryArray.count;
default:
- NSAssert(1, @"Reached unreachable case for video library section");
+ NSAssert(NO, @"Reached unreachable case for video library section");
break;
}
}
@@ -376,7 +370,7 @@ NSString * const VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
case VLCMediaLibraryParentGroupTypeVideoLibrary:
return _libraryArray[row];
default:
- NSAssert(1, @"Reached unreachable case for video library section");
+ NSAssert(NO, @"Reached unreachable case for video library section");
break;
}
}
@@ -402,18 +396,15 @@ NSString * const VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
- (id<VLCMediaLibraryItemProtocol>)libraryItemAtIndexPath:(NSIndexPath *)indexPath
forCollectionView:(NSCollectionView *)collectionView
{
- const NSInteger videoGroup = [self rowToVideoGroup:indexPath.section];
- id<VLCMediaLibraryItemProtocol> item;
- switch (videoGroup) {
- case VLCMediaLibraryParentGroupTypeRecentVideos:
- item = _recentsArray[indexPath.item];
- break;
- case VLCMediaLibraryParentGroupTypeVideoLibrary:
- item = _libraryArray[indexPath.item];
- break;
+ switch ([self rowToVideoGroup:indexPath.section]) {
+ case VLCMediaLibraryParentGroupTypeRecentVideos:
+ return _recentsArray[indexPath.item];
+ case VLCMediaLibraryParentGroupTypeVideoLibrary:
+ return _libraryArray[indexPath.item];
+ default:
+ NSAssert(NO, @"Unknown video group received");
+ return nil;
}
- NSAssert(item != nil, @"item should not be nil");
- return item;
}
- (NSIndexPath *)indexPathForLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
@@ -429,31 +420,32 @@ NSString * const VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
- (NSArray<VLCLibraryRepresentedItem *> *)representedItemsAtIndexPaths:(NSSet<NSIndexPath *> *const)indexPaths
forCollectionView:(NSCollectionView *)collectionView
{
- NSMutableArray<VLCLibraryRepresentedItem *> * const representedItems =
+ NSMutableArray<VLCLibraryRepresentedItem *> * const representedItems =
[NSMutableArray arrayWithCapacity:indexPaths.count];
-
+
for (NSIndexPath * const indexPath in indexPaths) {
- const id<VLCMediaLibraryItemProtocol> libraryItem =
+ const VLCMediaLibraryParentGroupType parentType = [self rowToVideoGroup:indexPath.section];
+ const id<VLCMediaLibraryItemProtocol> libraryItem =
[self libraryItemAtIndexPath:indexPath forCollectionView:collectionView];
- VLCLibraryRepresentedItem * const representedItem =
- [[VLCLibraryRepresentedItem alloc] initWithItem:libraryItem
- parentType:self.currentParentType];
+ VLCLibraryRepresentedItem * const representedItem =
+ [[VLCLibraryRepresentedItem alloc] initWithItem:libraryItem parentType:parentType];
[representedItems addObject:representedItem];
}
return representedItems;
}
-- (NSString *)titleForVideoGroup:(NSInteger)videoGroup
+- (NSString *)titleForVideoGroup:(VLCMediaLibraryParentGroupType)videoGroup
{
switch (videoGroup) {
- case VLCMediaLibraryParentGroupTypeRecentVideos:
- return _NS("Recents");
- case VLCMediaLibraryParentGroupTypeVideoLibrary:
- return _NS("Library");
+ case VLCMediaLibraryParentGroupTypeRecentVideos:
+ return _NS("Recents");
+ case VLCMediaLibraryParentGroupTypeVideoLibrary:
+ return _NS("Library");
+ default:
+ NSAssert(NO, @"Received unknown video group");
+ return @"";
}
- NSAssert(NO, @"Received unknown video group");
- return @"";
}
- (NSInteger)numberOfSectionsInCollectionView:(NSCollectionView *)collectionView
@@ -465,23 +457,27 @@ NSString * const VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
- (NSInteger)collectionView:(NSCollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
- const NSInteger videoGroup = [self rowToVideoGroup:section];
- switch (videoGroup) {
- case VLCMediaLibraryParentGroupTypeRecentVideos:
- return _recentsArray.count;
- case VLCMediaLibraryParentGroupTypeVideoLibrary:
- return _libraryArray.count;
+ switch ([self rowToVideoGroup:section]) {
+ case VLCMediaLibraryParentGroupTypeRecentVideos:
+ return _recentsArray.count;
+ case VLCMediaLibraryParentGroupTypeVideoLibrary:
+ return _libraryArray.count;
+ default:
+ NSAssert(NO, @"Unknown video group received.");
+ return NSNotFound;
}
- NSAssert(NO, @"Unknown video group received.");
- return NSNotFound;
}
- (NSCollectionViewItem *)collectionView:(NSCollectionView *)collectionView
itemForRepresentedObjectAtIndexPath:(NSIndexPath *)indexPath
{
- VLCLibraryCollectionViewItem * const viewItem = [collectionView makeItemWithIdentifier:VLCLibraryCellIdentifier forIndexPath:indexPath];
- const id<VLCMediaLibraryItemProtocol> item = [self libraryItemAtIndexPath:indexPath forCollectionView:collectionView];
- VLCLibraryRepresentedItem * const representedItem = [[VLCLibraryRepresentedItem alloc] initWithItem:item parentType:self.currentParentType];
+ VLCLibraryCollectionViewItem * const viewItem =
+ [collectionView makeItemWithIdentifier:VLCLibraryCellIdentifier forIndexPath:indexPath];
+ const VLCMediaLibraryParentGroupType parentType = [self rowToVideoGroup:indexPath.section];
+ const id<VLCMediaLibraryItemProtocol> item =
+ [self libraryItemAtIndexPath:indexPath forCollectionView:collectionView];
+ VLCLibraryRepresentedItem * const representedItem =
+ [[VLCLibraryRepresentedItem alloc] initWithItem:item parentType:parentType];
viewItem.representedItem = representedItem;
return viewItem;
}
@@ -491,8 +487,11 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
atIndexPath:(NSIndexPath *)indexPath
{
if([kind isEqualToString:NSCollectionElementKindSectionHeader]) {
- VLCLibraryCollectionViewSupplementaryElementView * const sectionHeadingView = [collectionView makeSupplementaryViewOfKind:kind withIdentifier:VLCLibrarySupplementaryElementViewIdentifier forIndexPath:indexPath];
- const NSInteger videoGroup = [self rowToVideoGroup:indexPath.section];
+ VLCLibraryCollectionViewSupplementaryElementView * const sectionHeadingView =
+ [collectionView makeSupplementaryViewOfKind:kind
+ withIdentifier:VLCLibrarySupplementaryElementViewIdentifier
+ forIndexPath:indexPath];
+ const VLCMediaLibraryParentGroupType videoGroup = [self rowToVideoGroup:indexPath.section];
sectionHeadingView.stringValue = [self titleForVideoGroup:videoGroup];
return sectionHeadingView;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5bffcca2d211e5fb0720a7d772ad5e558349884f...d677a00a0737f1d79a2103ee6ea554e4efeb0b02
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5bffcca2d211e5fb0720a7d772ad5e558349884f...d677a00a0737f1d79a2103ee6ea554e4efeb0b02
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list