Skip to content

Commit

Permalink
Add code to get node data from NSTreeController
Browse files Browse the repository at this point in the history
  • Loading branch information
gcasa committed Oct 7, 2024
1 parent d04a1b8 commit 2916a92
Showing 1 changed file with 42 additions and 19 deletions.
61 changes: 42 additions & 19 deletions Source/NSBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -3381,29 +3381,46 @@ - (void) _performLoadOfColumn: (NSInteger)column

if (theBinding != nil)
{
id observedObject = [theBinding observedObject];
NSArray *children = nil;

rows = 0;
if (item == nil)
if ([observedObject isKindOfClass: [NSTreeController class]])
{
rows = [[item mutableChildNodes] count];
}
else
{
NSTreeController *tc = [theBinding observedObject];
NSString *childrenKeyPath = [tc childrenKeyPathForNode: item];
NSTreeController *tc = (NSTreeController *)observedObject;

if (childrenKeyPath != nil)
if (item == nil)
{
NSTreeNode *node = (NSTreeNode *)[theBinding destinationValue];

/* Per the documentation 10.4/5+ uses NSTreeNode as the return value for
* the contents of this tree node consists of a dictionary with a single
* key of "children". This is per the tests for this at
* https://github.com/gcasa/NSTreeController_test. Specifically it returns
* _NSControllerTreeProxy. The equivalent of that class in GNUstep is
* GSControllerTreeProxy.
*/
children = [node mutableChildNodes];
rows = [children count];
}
else
{
NSString *countKeyPath = [tc countKeyPathForNode: item];
NSArray *children = [item valueForKeyPath: childrenKeyPath];
NSString *childrenKeyPath = [tc childrenKeyPathForNode: item];

if (countKeyPath == nil)
{
rows = [children count]; // get the count directly...
}
else
if (childrenKeyPath != nil)
{
NSNumber *countValue = [item valueForKeyPath: countKeyPath];
rows = [countValue integerValue];
NSString *countKeyPath = [tc countKeyPathForNode: item];

children = [item valueForKeyPath: childrenKeyPath];
if (countKeyPath == nil)
{
rows = [children count]; // get the count directly...
}
else
{
NSNumber *countValue = [item valueForKeyPath: countKeyPath];
rows = [countValue integerValue];
}
}
}
}
Expand Down Expand Up @@ -3708,13 +3725,19 @@ - (void) setValue: (id)anObject forKey: (NSString*)aKey
if ([aKey isEqual: NSContentBinding])
{
// Reload data
// [self reloadData];
_passiveDelegate = NO;
_itemBasedDelegate = YES;

[self loadColumnZero];
NSDebugLLog(@"NSBinding", @"Setting browser view content to %@", anObject);
}
else if ([aKey isEqual: NSContentValuesBinding])
{
// Reload data
// [self reloadData];
_passiveDelegate = NO;
_itemBasedDelegate = YES;

[self loadColumnZero];
NSDebugLLog(@"NSBinding", @"Setting browser view content values to %@", anObject);
}
else if ([aKey isEqual: NSSelectionIndexesBinding])
Expand Down

0 comments on commit 2916a92

Please sign in to comment.