Add ignored property to FFResultNode

When a group node is ignored then it report all its children as excluded regardless of their actual state. It is still possible to query the children for the real state.
This commit is contained in:
Allan Odgaard
2014-10-15 15:40:27 +02:00
parent e2ab281343
commit 8de8291afe
2 changed files with 26 additions and 5 deletions

View File

@@ -26,6 +26,7 @@
@property (nonatomic) NSArray* children;
@property (nonatomic) BOOL excluded;
@property (nonatomic) BOOL replacementDone;
@property (nonatomic) BOOL ignored;
@property (nonatomic) NSImage* icon;
@property (nonatomic, readonly) document::document_ptr document;

View File

@@ -169,7 +169,7 @@ static NSAttributedString* AttributedStringForMatch (std::string const& text, si
[(NSMutableArray*)_children addObject:aMatch];
self.countOfLeafs += aMatch.countOfLeafs;
self.countOfExcluded += aMatch.countOfExcluded;
self.countOfExcluded += aMatch.ignored ? aMatch.countOfLeafs : aMatch.countOfExcluded;
}
- (void)removeFromParent
@@ -177,7 +177,7 @@ static NSAttributedString* AttributedStringForMatch (std::string const& text, si
_next.previous = _previous;
_previous.next = _next;
[(NSMutableArray*)_parent.children removeObject:self];
_parent.countOfExcluded -= _countOfExcluded;
_parent.countOfExcluded -= _ignored ? _countOfLeafs : _countOfExcluded;
_parent.countOfLeafs -= _countOfLeafs;
}
@@ -185,12 +185,17 @@ static NSAttributedString* AttributedStringForMatch (std::string const& text, si
{
if(_children)
{
for(FFResultNode* child in _children)
child.excluded = flag;
if(!_ignored)
{
for(FFResultNode* child in _children)
child.excluded = flag;
}
}
else
{
self.countOfExcluded = flag ? 1 : 0;
if(_ignored)
_countOfExcluded = flag ? 1 : 0;
else self.countOfExcluded = flag ? 1 : 0;
}
}
@@ -199,6 +204,21 @@ static NSAttributedString* AttributedStringForMatch (std::string const& text, si
return _countOfExcluded == (_children ? _countOfLeafs : 1);
}
- (void)setIgnored:(BOOL)flag
{
if(_ignored == flag)
return;
_ignored = flag;
if(_children)
{
NSUInteger countOfExcluded = 0;
for(FFResultNode* child in _children)
countOfExcluded += (child.ignored = flag) || child.excluded ? 1 : 0;
self.countOfExcluded = countOfExcluded;
}
}
- (FFResultNode*)firstResultNode { return [_children firstObject]; }
- (FFResultNode*)lastResultNode { return [_children lastObject]; }
- (document::document_ptr)document { return [_match match].document; }