blob: d52590d68fe542913d1a09f5de0c6c384e1b2815 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/* HBTreeNode.h $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class HBTreeNode;
/**
* Notify a delegate that something changed in the tree.
* KVO observing a tree looks complicated and expensive, so this is a lightweight
* way to track the changes we need to know.
*/
@protocol HBTreeNodeDelegate <NSObject>
- (void)nodeDidChange:(HBTreeNode *)node;
@optional
- (void)treeDidRemoveNode:(HBTreeNode *)node;
@end
/**
* HBTreeNode
*/
@interface HBTreeNode : NSObject <NSCopying>
// NSTreeController required properties
@property (nonatomic, readonly) NSMutableArray<HBTreeNode *> *children;
@property (nonatomic) BOOL isLeaf;
@property (nonatomic, weak) id<HBTreeNodeDelegate> delegate;
/**
* Executes a given block using each object in the tree, starting with the root object and continuing through the tree to the last object.
*
* @param block The block to apply to elements in the tree.
*/
- (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSIndexPath *idx, BOOL *stop))block;
/**
* Returns the index path of an object in the tree.
*
* @param obj the object of the wanted NSIndexPath
*
* @return The index path whose corresponding value is equal to the preset. Returns nil if not found.
*/
- (nullable NSIndexPath *)indexPathOfObject:(id)obj;
/**
* Removes the object at the specified index path.
*
* @param idx the NSIndexPath of the object to delete.
*/
- (void)removeObjectAtIndexPath:(NSIndexPath *)idx;
/// Replaces the object at the specified index path.
/// @param idx the NSIndexPath of the object to replace
/// @param object the new object
- (void)replaceObjectAtIndexPath:(NSIndexPath *)idx withObject:(HBTreeNode *)object;
// KVC Accessor Methods
@property (nonatomic, readonly) NSUInteger countOfChildren;
- (id)objectInChildrenAtIndex:(NSUInteger)index;
- (void)insertObject:(HBTreeNode *)presetObject inChildrenAtIndex:(NSUInteger)index;
- (void)replaceObjectInChildrenAtIndex:(NSUInteger)index withObject:(HBTreeNode *)object;
- (void)removeObjectFromChildrenAtIndex:(NSUInteger)index;
@end
NS_ASSUME_NONNULL_END
|