Remove extra call to setSelected: in selectAll: deselectAll: etc methods, this should only happen in setSelectionIndexes and setSelectionIndexPaths

This commit is contained in:
Gregory John Casamento 2023-02-12 14:25:36 -05:00
parent b6048a27f4
commit ea398eab4c

View file

@ -1997,15 +1997,11 @@ static NSString *_placeholderItem = nil;
NSMutableSet *paths = [NSMutableSet setWithCapacity: [_itemsToIndexPaths count]]; NSMutableSet *paths = [NSMutableSet setWithCapacity: [_itemsToIndexPaths count]];
FOR_IN(NSCollectionViewItem*, obj, _itemsToIndexPaths) FOR_IN(NSCollectionViewItem*, obj, _itemsToIndexPaths)
{
if ([obj respondsToSelector: @selector(setSelected:)])
{ {
NSIndexPath *p = [_itemsToIndexPaths objectForKey: obj]; NSIndexPath *p = [_itemsToIndexPaths objectForKey: obj];
[obj setSelected: YES];
[paths addObject: p]; [paths addObject: p];
} }
}
END_FOR_IN(_itemsToIndexPaths); END_FOR_IN(_itemsToIndexPaths);
[self setSelectionIndexPaths: paths]; [self setSelectionIndexPaths: paths];
@ -2016,15 +2012,12 @@ static NSString *_placeholderItem = nil;
NSMutableSet *paths = [NSMutableSet setWithCapacity: [_itemsToIndexPaths count]]; NSMutableSet *paths = [NSMutableSet setWithCapacity: [_itemsToIndexPaths count]];
FOR_IN(NSCollectionViewItem*, obj, _itemsToIndexPaths) FOR_IN(NSCollectionViewItem*, obj, _itemsToIndexPaths)
{
if ([obj respondsToSelector: @selector(setSelected:)])
{ {
NSIndexPath *p = [_itemsToIndexPaths objectForKey: obj]; NSIndexPath *p = [_itemsToIndexPaths objectForKey: obj];
[obj setSelected: NO]; [obj setSelected: NO];
[paths addObject: p]; [paths addObject: p];
} }
}
END_FOR_IN(_itemsToIndexPaths); END_FOR_IN(_itemsToIndexPaths);
[self deselectItemsAtIndexPaths: paths]; [self deselectItemsAtIndexPaths: paths];
@ -2039,12 +2032,9 @@ static NSString *_placeholderItem = nil;
{ {
id item = [_indexPathsToItems objectForKey: p]; id item = [_indexPathsToItems objectForKey: p];
if ([item respondsToSelector: @selector(setSelected:)])
{
[item setSelected: YES]; [item setSelected: YES];
[paths addObject: p]; [paths addObject: p];
} }
}
END_FOR_IN(indexPaths); END_FOR_IN(indexPaths);
[self setSelectionIndexPaths: paths]; [self setSelectionIndexPaths: paths];
@ -2058,12 +2048,9 @@ static NSString *_placeholderItem = nil;
{ {
id item = [_indexPathsToItems objectForKey: p]; id item = [_indexPathsToItems objectForKey: p];
if ([item respondsToSelector: @selector(setSelected:)])
{
[item setSelected: NO]; [item setSelected: NO];
[newSelection removeObject: p]; [newSelection removeObject: p];
} }
}
END_FOR_IN(indexPaths); END_FOR_IN(indexPaths);
[self setSelectionIndexPaths: newSelection]; [self setSelectionIndexPaths: newSelection];