what is the best way to build a binding compatible outline view datasouce in cappuccino ? i.e. a kind of CPTreeController
my source is currently a jSON object (containing objects and arrays) and I would like to display it into an outline view as well as being able to change its parameters / get notified for the changes. (Once loaded into the CPTreeController, I do not need to serialize it back to jSON, I will work directly with the datasource)
Then:
A search through sources says there is no hidden CPTreeController so you can either write your own implementation of CPTreeController and contribute it to community or you can implement data source protocol for a specific model, something like this:
- (int)outlineView:(CPOutlineView)theOutlineView numberOfChildrenOfItem:(id)theItem
{
if (theItem == nil)
theItem = rootNode;
return [[theItem childNodes] count];
}
- (id)outlineView:(CPOutlineView)theOutlineView child:(int)theIndex ofItem:(id)theItem
{
if (theItem == nil)
theItem = rootNode;
return [[theItem childNodes] objectAtIndex:theIndex];
}
- (BOOL)outlineView:(CPOutlineView)theOutlineView isItemExpandable:(id)theItem
{
if (theItem == nil)
theItem = rootNode;
return [[theItem childNodes] count] > 0;
}
- (id)outlineView:(CPOutlineView)anOutlineView objectValueForTableColumn:(CPTableColumn)theColumn byItem:(id)theItem
{
return [[theItem representedObject] valueForKey:"name"];
}