diff options
author | ritsuka <[email protected]> | 2015-05-14 19:37:49 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2015-05-14 19:37:49 +0000 |
commit | 2659b80cc0d4e078db19436f4f144b50525f2983 (patch) | |
tree | 54a8813f4a53c25e1630e6aa654c348e603f9ee8 /macosx/HBTreeNode.m | |
parent | 970688a142998ddf68cf1950436bb92e0385139c (diff) |
MacGui: use libhb built-in presets and validation functions. Update the format and save the presets in UserPresets.json, the old presets are automatically imported if the new presets file is not found. The mac gui now requires 10.7 or later.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7181 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBTreeNode.m')
-rw-r--r-- | macosx/HBTreeNode.m | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/macosx/HBTreeNode.m b/macosx/HBTreeNode.m index 7b4a3bd76..786e9500b 100644 --- a/macosx/HBTreeNode.m +++ b/macosx/HBTreeNode.m @@ -33,13 +33,18 @@ [self.children insertObject:presetObject atIndex:index]; [presetObject setDelegate:self.delegate]; - [self.delegate nodeDidChange]; + for (HBTreeNode *node in self.children) + { + node.delegate = self.delegate; + } + + [self.delegate nodeDidChange:self]; } - (void)removeObjectFromChildrenAtIndex:(NSUInteger)index { [self.children removeObjectAtIndex:index]; - [self.delegate nodeDidChange]; + [self.delegate nodeDidChange:self]; } #pragma mark - Enumeration @@ -83,4 +88,54 @@ } } +- (NSIndexPath *)indexPathOfObject:(id)obj +{ + __block NSIndexPath *retValue = nil; + + // Visit the whole tree to find the index path. + [self enumerateObjectsUsingBlock:^(id obj2, NSIndexPath *idx, BOOL *stop) + { + if ([obj2 isEqualTo:obj]) + { + retValue = idx; + *stop = YES; + } + }]; + + return retValue; +} + +- (void)removeObjectAtIndexPath:(NSIndexPath *)idx +{ + HBTreeNode *parentNode = self; + + // Find the object parent array + // and delete it. + NSUInteger currIdx = 0; + NSUInteger i = 0; + for (i = 0; i < idx.length - 1; i++) + { + currIdx = [idx indexAtPosition:i]; + + if (parentNode.children.count > currIdx) + { + parentNode = (parentNode.children)[currIdx]; + } + } + + currIdx = [idx indexAtPosition:i]; + + if (parentNode.children.count > currIdx) + { + id removedNode = parentNode.children[currIdx]; + + [parentNode removeObjectFromChildrenAtIndex:currIdx]; + + if ([self.delegate respondsToSelector:@selector(treeDidRemoveNode:)]) + { + [self.delegate treeDidRemoveNode:removedNode]; + } + } +} + @end |