advice on filtering TreeNode objects
advice on filtering TreeNode objects
- Subject: advice on filtering TreeNode objects
- From: Alex Rice <email@hidden>
- Date: Sun, 3 Nov 2002 01:42:24 -0700
I am using TreeNode objects for my outlineview. The treenode
implementation is from Apple's NSOutlineView examples. I need to apply
a filter to the root treenode and have it filter all the children on
some condition, like hiding todo items that are completed, for example.
I'm sure I can code it for that particular case, but I would rather
implement a general-purpose filtering scheme, so I can expand it to
keyword searching or other filters later on. I just can't conceptualize
how to do it. Seems like there must be a design pattern here. Any
suggestions? My TreeNode subclass implements NSKeyValueCoding so maybe
that will help me out?
So far all I have is this method, not yet implemented:
- (void) setFilter: (TreeNodeFilter *) newFilter;
Here is the TreeNode interface
@interface TreeNode : NSObject {
@protected
TreeNode *nodeParent;
NSMutableArray *nodeChildren;
}
- (void) setNodeParent: (TreeNode*)parent;
- (TreeNode*) nodeParent;
- (void) appendChild: (TreeNode*)child;
- (void) insertChild: (TreeNode*)child atIndex:(int)index;
- (void) insertChildren: (NSArray*)children atIndex:(int)index;
- (void) removeChild: (TreeNode*)child;
- (void) removeFromParent;
- (int) indexOfChild: (TreeNode*)child;
- (int) indexOfChildIdenticalTo: (TreeNode*)child;
- (int) numberOfChildren;
- (NSArray*) children;
- (TreeNode*) firstChild;
- (TreeNode*) lastChild;
- (TreeNode*) childAtIndex: (int)index;
- (BOOL) isDescendantOfNode: (TreeNode*)node;
- (BOOL) isDescendantOfNodeInArray: (NSArray*)nodes;
Thanks,
Alex Rice <email@hidden>
Mindlube Software
http://mindlube.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.