[vlc-commits] [Git][videolan/vlc][master] macosx: Retain selections after audio library data reload
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Aug 19 08:02:04 UTC 2022
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
21276001 by Claudio Cambra at 2022-08-19T07:46:48+00:00
macosx: Retain selections after audio library data reload
Signed-off-by: Claudio Cambra <claudio.cambra at gmail.com>
- - - - -
1 changed file:
- modules/gui/macosx/library/VLCLibraryAudioDataSource.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryAudioDataSource.m
=====================================
@@ -112,11 +112,44 @@
return;
}
+ id<VLCMediaLibraryItemProtocol> selectedCollectionViewItem;
+ if(_collectionView.selectionIndexPaths.count > 0 && !_collectionView.hidden) {
+ selectedCollectionViewItem = [self selectedCollectionViewItem];
+ }
+
_displayedCollection = collectionToDisplay;
[self reloadData];
+
+ // Reopen supplementary view in the collection views
+ if(selectedCollectionViewItem) {
+ NSUInteger newIndexOfSelectedItem = [_displayedCollection indexOfObjectPassingTest:^BOOL(id element, NSUInteger idx, BOOL *stop) {
+ id<VLCMediaLibraryItemProtocol> itemElement = (id<VLCMediaLibraryItemProtocol>)element;
+ return itemElement.libraryID == selectedCollectionViewItem.libraryID;
+ }];
+
+ if(newIndexOfSelectedItem == NSNotFound) {
+ return;
+ }
+
+ NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:newIndexOfSelectedItem inSection:0];
+ NSSet *indexPathSet = [NSSet setWithObject:newIndexPath];
+ [_collectionView selectItemsAtIndexPaths:indexPathSet scrollPosition:NSCollectionViewScrollPositionTop];
+ // selectItemsAtIndexPaths does not call any delegate methods so we do it manually
+ [self collectionView:_collectionView didSelectItemsAtIndexPaths:indexPathSet];
+ }
});
}
+- (id<VLCMediaLibraryItemProtocol>)selectedCollectionViewItem
+{
+ NSIndexPath *indexPath = _collectionView.selectionIndexPaths.anyObject;
+ if (!indexPath) {
+ return nil;
+ }
+
+ return _displayedCollection[indexPath.item];
+}
+
- (void)setupAppearance
{
self.segmentedControl.segmentCount = 4;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/21276001e002bba18571a28be38e61b7edf270db
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/21276001e002bba18571a28be38e61b7edf270db
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