RATreeNodeCollectionController.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //The MIT License (MIT)
  2. //
  3. //Copyright (c) 2014 Rafał Augustyniak
  4. //
  5. //Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. //this software and associated documentation files (the "Software"), to deal in
  7. //the Software without restriction, including without limitation the rights to
  8. //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. //the Software, and to permit persons to whom the Software is furnished to do so,
  10. //subject to the following conditions:
  11. //
  12. //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  14. //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  15. //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  16. //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. //
  19. #import <Foundation/Foundation.h>
  20. @class RATreeNodeController, RATreeNode, RATreeNodeCollectionController;
  21. @protocol RATreeNodeCollectionControllerDataSource <NSObject>
  22. - (NSInteger)treeNodeCollectionController:(RATreeNodeCollectionController *)controller numberOfChildrenForItem:(id)item;
  23. - (id)treeNodeCollectionController:(RATreeNodeCollectionController *)controller child:(NSInteger)childIndex ofItem:(id)item;
  24. @end
  25. @interface RATreeNodeCollectionController : NSObject
  26. @property (nonatomic, weak) id<RATreeNodeCollectionControllerDataSource> dataSource;
  27. @property (nonatomic, readonly) NSInteger numberOfVisibleRowsForItems;
  28. - (RATreeNode *)treeNodeForIndex:(NSInteger)index;
  29. - (NSInteger)levelForItem:(id)item;
  30. - (id)parentForItem:(id)item;
  31. - (id)childInParent:(id)parent atIndex:(NSInteger)index;
  32. - (NSInteger)indexForItem:(id)item;
  33. - (NSInteger)lastVisibleDescendantIndexForItem:(id)item;
  34. - (void)collapseRowForItem:(id)item collapseChildren:(BOOL)collapseChildren updates:(void(^)(NSIndexSet *))updates;
  35. - (void)expandRowForItem:(id)item expandChildren:(BOOL)expandChildren updates:(void (^)(NSIndexSet *))updates;
  36. - (void)insertItemsAtIndexes:(NSIndexSet *)indexes inParent:(id)item;
  37. - (void)moveItemAtIndex:(NSInteger)index inParent:(id)parent toIndex:(NSInteger)newIndex inParent:(id)newParent updates:(void(^)(NSIndexSet *deletions, NSIndexSet *additions))updates;
  38. - (void)removeItemsAtIndexes:(NSIndexSet *)indexes inParent:(id)item updates:(void(^)(NSIndexSet *))updates;
  39. @end