Implement makeItemWithIdentifier:atIndexPath:

This commit is contained in:
Gregory John Casamento 2022-06-29 01:50:00 -04:00
parent 8948aecae5
commit 04b0a15526

View file

@ -1256,6 +1256,25 @@ static NSString *placeholderItem = nil;
- (NSCollectionViewItem *) makeItemWithIdentifier: (NSUserInterfaceItemIdentifier)identifier
forIndexPath: (NSIndexPath *)indexPath
{
NSCollectionViewItem *item =
[_dataSource collectionView: self itemForRepresentedObjectAtIndexPath: indexPath];
NSNib *nib = [self _nibForClass: [item class]];
BOOL loaded = [nib instantiateWithOwner: item
topLevelObjects: NULL];
if (loaded == NO)
{
item = nil;
NSLog(@"Could not load model %@", nib);
}
return item;
}
- (NSView *) makeSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
withIdentifier: (NSUserInterfaceItemIdentifier)identifier
forIndexPath: (NSIndexPath *)indexPath
{
return nil;
}
@ -1276,13 +1295,6 @@ static NSString *placeholderItem = nil;
withIdentifier: identifier];
}
- (NSView *) makeSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
withIdentifier: (NSUserInterfaceItemIdentifier)identifier
forIndexPath: (NSIndexPath *)indexPath
{
return nil;
}
- (void) registerClass: (Class)viewClass
forSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)kind
withIdentifier:(NSUserInterfaceItemIdentifier)identifier
@ -1364,13 +1376,10 @@ static NSString *placeholderItem = nil;
/* Reloading Content */
- (void) _loadItemAtIndexPath: (NSIndexPath *)path
{
NSCollectionViewItem *item =
[_dataSource collectionView: self itemForRepresentedObjectAtIndexPath: path];
NSNib *nib = [self _nibForClass: [item class]];
BOOL loaded = [nib instantiateWithOwner: item
topLevelObjects: NULL];
NSCollectionViewItem *item = [self makeItemWithIdentifier: nil
forIndexPath: path];
if (loaded)
if (item != nil)
{
NSView *v = [item view];
if (_collectionViewLayout)
@ -1396,10 +1405,6 @@ static NSString *placeholderItem = nil;
NSLog(@"Layout view is not set");
}
}
else
{
NSLog(@"Could not load model %@", nib);
}
}
- (void) _loadSectionAtIndex: (NSUInteger)cs