diff --git a/Headers/AppKit/NSCollectionView.h b/Headers/AppKit/NSCollectionView.h index 0a861b57b..2c0051b2b 100644 --- a/Headers/AppKit/NSCollectionView.h +++ b/Headers/AppKit/NSCollectionView.h @@ -402,6 +402,7 @@ APPKIT_EXPORT_CLASS BOOL _isSelectable; BOOL _allowsEmptySelection; NSIndexSet *_selectionIndexes; + NSSet *_selectionIndexPaths; NSArray *_backgroundColors; @@ -437,7 +438,6 @@ APPKIT_EXPORT_CLASS NSMutableDictionary *_visibleSupplementaryViews; NSMutableSet *_indexPathsForSupplementaryElementsOfKind; NSMutableDictionary *_itemsToAttributes; - NSSet *_selectionIndexPaths; // Registered class/nib for item identifier NSMapTable *_registeredNibs; diff --git a/Source/NSCollectionView.m b/Source/NSCollectionView.m index 68cd3bf16..e8ab63d99 100644 --- a/Source/NSCollectionView.m +++ b/Source/NSCollectionView.m @@ -408,9 +408,28 @@ static NSString *placeholderItem = nil; [item setSelected:NO]; } } + + FOR_IN(NSIndexPath*, i, _selectionIndexPaths) + { + id item = [self itemAtIndexPath: i]; + if ([item respondsToSelector: @selector(setSelected:)]) + { + [item setSelected: NO]; + } + } + END_FOR_IN(_selectionIndexPaths); } } +- (NSSet *) selectionIndexPaths +{ + return _selectionIndexPaths; +} + +- (void) setSelectionIndexPaths: (NSSet *)indexPaths +{ +} + - (NSIndexSet *) selectionIndexes { return _selectionIndexes; @@ -943,10 +962,9 @@ static NSString *placeholderItem = nil; - (void) _selectWithEvent: (NSEvent *)theEvent indexPath: (NSIndexPath *)index { - /* - NSMutableIndexSet *currentIndexSet = [[NSMutableIndexSet alloc] initWithIndexSet: [self selectionIndexes]]; - - if (_isSelectable && ((index < [_items count]) || index < [_visibleItems count])) + NSMutableSet *currentSet = [[NSMutableSet alloc] initWithSet: [self selectionIndexPaths]]; + + if (_isSelectable) { if (_allowsMultipleSelection && (([theEvent modifierFlags] & NSControlKeyMask) @@ -954,22 +972,23 @@ static NSString *placeholderItem = nil; { if ([theEvent modifierFlags] & NSControlKeyMask) { - if ([currentIndexSet containsIndex: index]) + if ([currentSet containsObject: index]) { - [currentIndexSet removeIndex: index]; + [currentSet removeObject: index]; } else { - [currentIndexSet addIndex: index]; + [currentSet addObject: index]; } - [self setSelectionIndexes: currentIndexSet]; + [self setSelectionIndexPaths: currentSet]; } else if ([theEvent modifierFlags] & NSShiftKeyMask) { - NSUInteger firstSelectedIndex = [currentIndexSet firstIndex]; + /* + id firstSelected = [currentSet firstObject]; NSRange selectedRange; - if (firstSelectedIndex == NSNotFound) + if (firstSelected == nil) { selectedRange = NSMakeRange(index, index); } @@ -982,21 +1001,22 @@ static NSString *placeholderItem = nil; selectedRange = NSMakeRange(firstSelectedIndex, (index - firstSelectedIndex + 1)); } [currentIndexSet addIndexesInRange: selectedRange]; - [self setSelectionIndexes: currentIndexSet]; + */ + [self setSelectionIndexPaths: currentSet]; } } else { - [self setSelectionIndexes: [NSIndexSet indexSetWithIndex: index]]; + [self setSelectionIndexPaths: [NSSet setWithObject: index]]; } [[self window] makeFirstResponder: self]; } else { - [self setSelectionIndexes: [NSIndexSet indexSet]]; + [self setSelectionIndexPaths: [NSSet set]]; } - RELEASE (currentIndexSet); - */ + + RELEASE (currentSet); } @@ -1707,16 +1727,6 @@ static NSString *placeholderItem = nil; _allowsEmptySelection = flag; } -- (NSSet *) selectionIndexPaths -{ - return _selectionIndexPaths; -} - -- (void) setSelectionIndexPaths: (NSSet *)indexPaths -{ - ASSIGN(_selectionIndexPaths, indexPaths); -} - - (IBAction) selectAll: (id)sender { }