Re: NSOutlineView expand-by-default with NSTreeController

2009-12-08 Thread Benjamin Rister
On Dec 5, 2009, at 6:11 PM, Jason Foreman wrote:

>   [[treeController arrangedObjects] childNodes];
> 
> Iterate over this collection and find nodes where [node representedObject] is 
> equal to your newly inserted objects.  Then you can pass this NSTreeNode 
> instance to -[NSOutlineView exandItem:].
> 
> This isn't terribly clean, and it might fall down if you have a large number 
> of items in your tree controller, but it works for what I need and might work 
> for you.

Thanks, Jason.

Unfortunately, the content can still be fairly large, so I’m not sure about how 
the performance of a brute force method like this will be. On the other hand, 
premature optimization is the root of all evil, and this is really easy to 
implement. It might not be a bad idea to just do this for now, don’t worry 
about the inefficiency, see how it works for the content sizes that a human 
could deal with, and just revisit the question if it ends up being a practical 
problem.

So if anybody has a cleaner solution (which I’m guessing by the silence they 
don’t), I’m all ears. Otherwise I’ll try this, and just fall back to rewriting 
NSTreeController myself if the performance doesn’t work out. (Is there any open 
source NSTreeController reimplementation out there?)

Best,
Benjamin Rister___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSOutlineView expand-by-default with NSTreeController

2009-12-05 Thread Jason Foreman

On Dec 5, 2009, at 12:43 PM, Benjamin Rister wrote:

> I have an NSOutlineView in which I would like to have newly-appearing items 
> be expanded by default. (It would be nice if NSOutlineView had support for 
> this built in; rdar://problem/7421928.)
> 
> The list archives and a web search reveal a couple hacks to try and make this 
> work, but they depend on feeding the data to the outline view via the 
> NSOutlineViewDataSource protocol so that they can ask for an expansion either 
> at the time of insertion or in response to the outline view asking about the 
> new pieces of data. I’m using NSTreeController, which makes the situation 
> difficult as the actual “items” the outline view knows about aren’t anything 
> I create myself, so I can’t really queue up an expansion of items as I insert 
> them in the model, nor will the outline view ask me about the new data as 
> it’s getting it from NSTreeController.


You can get a collection of NSTreeNode instances from your tree controller like 
this:

[[treeController arrangedObjects] childNodes];

Iterate over this collection and find nodes where [node representedObject] is 
equal to your newly inserted objects.  Then you can pass this NSTreeNode 
instance to -[NSOutlineView exandItem:].

This isn't terribly clean, and it might fall down if you have a large number of 
items in your tree controller, but it works for what I need and might work for 
you.


Regards,

Jason




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSOutlineView expand-by-default with NSTreeController

2009-12-05 Thread Benjamin Rister
I have an NSOutlineView in which I would like to have newly-appearing items be 
expanded by default. (It would be nice if NSOutlineView had support for this 
built in; rdar://problem/7421928.)

The list archives and a web search reveal a couple hacks to try and make this 
work, but they depend on feeding the data to the outline view via the 
NSOutlineViewDataSource protocol so that they can ask for an expansion either 
at the time of insertion or in response to the outline view asking about the 
new pieces of data. I’m using NSTreeController, which makes the situation 
difficult as the actual “items” the outline view knows about aren’t anything I 
create myself, so I can’t really queue up an expansion of items as I insert 
them in the model, nor will the outline view ask me about the new data as it’s 
getting it from NSTreeController.

It would be unfortunate to have to reimplement all of the NSTreeController 
functionality I’m using just to get a hook to do this, so does anybody know a 
way to get expand-by-default while still using NSTreeController and bindings? 
This code requires 10.6, so newfangled API is just fine.

Thanks,
Benjamin Rister___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com