[vlc-commits] [Git][videolan/vlc][master] 2 commits: macosx: Fix handling of clicked row in VLCLibraryTableView when there are no selections
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Mon Aug 19 15:10:12 UTC 2024
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
ba831b9b by Claudio Cambra at 2024-08-19T14:41:52+00:00
macosx: Fix handling of clicked row in VLCLibraryTableView when there are no selections
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
feb88734 by Claudio Cambra at 2024-08-19T14:41:52+00:00
macosx: Reduce getter usage in VLCLibraryTableView by caching retrieved property values
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1 changed file:
- modules/gui/macosx/library/VLCLibraryTableView.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryTableView.m
=====================================
@@ -69,18 +69,30 @@
- (void)menuNeedsUpdate:(NSMenu *)menu
{
- NSIndexSet * const indices = self.selectedRowIndexes;
- if (indices.count == 0 || self.dataSource == nil || !_vlcDataSourceConforming) {
+ const id<NSTableViewDataSource> dataSource = self.dataSource;
+ if (dataSource == nil || !_vlcDataSourceConforming) {
return;
}
- if([self.dataSource conformsToProtocol:@protocol(VLCLibraryTableViewDataSource)]) {
+ NSMutableIndexSet * const indices = self.selectedRowIndexes.mutableCopy;
+ const NSUInteger hasSelectedIndices = indices.count > 0;
+ const NSUInteger clickedRow = self.clickedRow;
+
+ if (!hasSelectedIndices) {
+ if (clickedRow == -1) {
+ return;
+ } else {
+ [indices addIndex:clickedRow];
+ }
+ }
+
+ if([dataSource conformsToProtocol:@protocol(VLCLibraryTableViewDataSource)]) {
NSMutableArray<VLCLibraryRepresentedItem *> * const representedItems =
NSMutableArray.array;
const id<VLCLibraryTableViewDataSource> vlcLibraryDataSource =
- (id<VLCLibraryTableViewDataSource>)self.dataSource;
+ (id<VLCLibraryTableViewDataSource>)dataSource;
- if ([indices containsIndex:self.clickedRow]) {
+ if ([indices containsIndex:clickedRow]) {
[indices enumerateIndexesUsingBlock:^(const NSUInteger index, BOOL * const stop) {
const id<VLCMediaLibraryItemProtocol> mediaItem =
[vlcLibraryDataSource libraryItemAtRow:index forTableView:self];
@@ -93,7 +105,7 @@
}];
} else {
const id<VLCMediaLibraryItemProtocol> mediaItem =
- [vlcLibraryDataSource libraryItemAtRow:self.clickedRow forTableView:self];
+ [vlcLibraryDataSource libraryItemAtRow:clickedRow forTableView:self];
const VLCMediaLibraryParentGroupType parentType =
vlcLibraryDataSource.currentParentType;
VLCLibraryRepresentedItem * const representedItem =
@@ -104,10 +116,10 @@
_menuController.representedItems = representedItems;
- } else if (self.dataSource.class == VLCMediaSourceDataSource.class) {
+ } else if (dataSource.class == VLCMediaSourceDataSource.class) {
NSMutableArray<VLCInputItem *> * const mediaSourceInputItems = NSMutableArray.array;
VLCMediaSourceDataSource * const mediaSourceDataSource =
- (VLCMediaSourceDataSource*)self.dataSource;
+ (VLCMediaSourceDataSource*)dataSource;
NSAssert(mediaSourceDataSource != nil, @"This should be a valid pointer");
[indices enumerateIndexesUsingBlock:^(const NSUInteger index, BOOL * const stop) {
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f697fef56687a7191cca647b97a1c7d1b25a469b...feb88734eb114cfb4057235d7672a74a5793901b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f697fef56687a7191cca647b97a1c7d1b25a469b...feb88734eb114cfb4057235d7672a74a5793901b
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