Interim changes before refactor of NSTreeController

This commit is contained in:
Gregory John Casamento 2024-06-24 08:50:22 -04:00
parent 1d29613491
commit f7afc331eb
7 changed files with 55 additions and 15 deletions

View file

@ -47,7 +47,7 @@ APPKIT_EXPORT_CLASS
NSString *_countKeyPath;
NSString *_leafKeyPath;
NSArray *_sortDescriptors;
NSArray *_arranged_objects;
NSTreeNode *_arranged_objects;
NSMutableArray *_selection_index_paths;
BOOL _alwaysUsesMultipleValuesMarker;
@ -113,7 +113,7 @@ APPKIT_EXPORT_CLASS
/**
* All objects managed by this tree controller.
*/
- (id) arrangedObjects;
- (NSTreeNode *) arrangedObjects;
/**
* An NSArray containing all selected objects.

View file

@ -26,6 +26,7 @@
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_NSTreeNode
#define _GNUstep_H_NSTreeNode

View file

@ -44,6 +44,7 @@
BOOL inReverseSet;
}
+ (void) _printObjectTable;
+ (void) exposeBinding: (NSString *)binding forClass: (Class)clazz;
+ (NSArray *) exposedBindingsForClass: (Class)clazz;
+ (GSKeyValueBinding *) getBinding: (NSString *)binding

View file

@ -141,6 +141,21 @@ void GSBindingInvokeAction(NSString *targetKey, NSString *argumentKey,
@implementation GSKeyValueBinding
+ (void) _printObjectTable
{
NSArray *keys = NSAllMapTableKeys(objectTable);
id k = nil;
NSEnumerator *en = [keys objectEnumerator];
NSLog(@"==== objectTable contents ====");
while ((k = [en nextObject]) != nil)
{
id v = NSMapGet(objectTable, k);
NSLog(@"k = %@, v = %@", k, v);
}
NSLog(@"END: objectTable contents ====");
}
+ (void) initialize
{
if (self == [GSKeyValueBinding class])
@ -192,8 +207,12 @@ void GSBindingInvokeAction(NSString *targetKey, NSString *argumentKey,
if (!objectTable)
return nil;
// NSLog(@"+++ called with %@, %@", binding, anObject);
// [self _printObjectTable];
[bindingLock lock];
bindings = (NSMutableDictionary *)NSMapGet(objectTable, (void *)anObject);
// NSLog(@"+++ Bindings found for %@ => %@", anObject, bindings);
if (bindings != nil)
{
theBinding = (GSKeyValueBinding*)[bindings objectForKey: binding];

View file

@ -158,6 +158,7 @@
if ([aDecoder containsValueForKey: @"NSBinding"])
{
ASSIGN(_binding, [aDecoder decodeObjectForKey: @"NSBinding"]);
NSLog(@"_binding = %@", _binding);
}
if ([aDecoder containsValueForKey: @"NSKeyPath"])
{

View file

@ -177,6 +177,7 @@ static NSImage *unexpandable = nil;
// Bindings..
[self exposeBinding: NSContentBinding];
// [self exposeBinding: NSContentArrayBinding];
[self exposeBinding: NSSelectionIndexesBinding];
[self exposeBinding: NSSortDescriptorsBinding];
}
@ -1830,15 +1831,27 @@ Also returns the child index relative to this parent. */
row: (NSInteger) index
{
id result = nil;
if ([_dataSource respondsToSelector:
@selector(outlineView:objectValueForTableColumn:byItem:)])
{
id item = [self itemAtRow: index];
result = [_dataSource outlineView: self
objectValueForTableColumn: tb
byItem: item];
// If we have content binding the data source is used only
// like a delegate
GSKeyValueBinding *theBinding = [GSKeyValueBinding getBinding: NSContentBinding
forObject: tb];
if (theBinding != nil)
{
NSLog(@"theBinding = %@", theBinding);
result = [_items objectAtIndex: index];
}
else
{
if ([_dataSource respondsToSelector:
@selector(outlineView:objectValueForTableColumn:byItem:)])
{
id item = [self itemAtRow: index];
result = [_dataSource outlineView: self
objectValueForTableColumn: tb
byItem: item];
}
}
return result;
@ -1991,9 +2004,9 @@ Also returns the child index relative to this parent. */
NSString *childrenKeyPath = [tc childrenKeyPath];
NSString *countKeyPath = [tc countKeyPath];
NSLog(@"leafKeyPath = %@", leafKeyPath);
NSLog(@"childrenKeyPath = %@", childrenKeyPath);
NSLog(@"countKeyPath = %@", countKeyPath);
// NSLog(@"leafKeyPath = %@", leafKeyPath);
// NSLog(@"childrenKeyPath = %@", childrenKeyPath);
// NSLog(@"countKeyPath = %@", countKeyPath);
if (startitem == nil)
{
@ -2094,6 +2107,7 @@ Also returns the child index relative to this parent. */
id object;
id sitem = (item == nil) ? (id)[NSNull null] : (id)item;
// NSLog(@"openItem: %@", item);
// open the item...
if (item != nil)
{

View file

@ -37,6 +37,7 @@
#import "AppKit/NSKeyValueBinding.h"
#import "AppKit/NSTreeController.h"
#import "AppKit/NSTreeNode.h"
#import "GSBindingHelpers.h"
#import "GSFastEnumeration.h"
@ -47,7 +48,8 @@
{
if (self == [NSTreeController class])
{
[self exposeBinding: NSContentArrayBinding];
// [self exposeBinding: NSContentArrayBinding];
[self exposeBinding: NSContentBinding];
[self setKeys: [NSArray arrayWithObjects: NSContentBinding, NSContentObjectBinding, nil]
triggerChangeNotificationsForDependentKey: @"arrangedObjects"];
}
@ -164,7 +166,7 @@
return [temp sortedArrayUsingDescriptors: _sortDescriptors];
}
- (id) arrangedObjects
- (NSTreeNode *) arrangedObjects
{
if (_arranged_objects == nil)
{
@ -178,8 +180,10 @@
NSLog(@"---- rearrangeObjects");
[self willChangeValueForKey: @"arrangedObjects"];
DESTROY(_arranged_objects);
NSLog(@"-- _content = %@", _content);
_arranged_objects = [[GSObservableArray alloc]
initWithArray: [self arrangeObjects: _content]];
NSLog(@"-- _arranged_objects = %@", _arranged_objects);
[self didChangeValueForKey: @"arrangedObjects"];
}