Skip to content
This repository has been archived by the owner on Jun 5, 2018. It is now read-only.

Commit

Permalink
Fixing filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel committed Dec 3, 2009
1 parent 828018e commit 31ca550
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Classes/SharedUI/GHTestViewModel.h
Expand Up @@ -153,4 +153,6 @@ typedef enum {

- (void)notifyChanged;

- (void)setFilter:(GHTestNodeFilter)filter textFilter:(NSString *)textFilter;

@end
30 changes: 18 additions & 12 deletions Classes/SharedUI/GHTestViewModel.m
Expand Up @@ -143,7 +143,8 @@ - (void)_updateTestNodeWithDefaults:(GHTestNode *)node {
test.status = testDefault.status;
test.interval = testDefault.interval;
#if !TARGET_OS_IPHONE // Don't use hidden state for iPhone
test.hidden = testDefault.hidden;
if ([test isKindOfClass:[GHTest class]])
test.hidden = testDefault.hidden;
#endif
}
for(GHTestNode *childNode in [node children])
Expand Down Expand Up @@ -279,33 +280,38 @@ - (void)_applyFilters {
filteredChildren_ = [[NSMutableArray array] retain];
for(GHTestNode *childNode in children_) {
if ((!textFilter_ || [textFiltered containsObject:childNode]) &&
(filter_ == GHTestNodeFilterNone || [filtered containsObject:childNode])) {
(filter_ == GHTestNodeFilterNone || [filtered containsObject:childNode]) || [childNode hasChildren]) {
[filteredChildren_ addObject:childNode];
if (![childNode hasChildren])
if (![childNode hasChildren]) {
childNode.test.disabled = NO;
}
} else {
if (![childNode hasChildren])
if (![childNode hasChildren]) {
childNode.test.disabled = YES;
}
}
}
}

- (void)setTextFilter:(NSString *)textFilter {
[self setFilter:filter_ textFilter:textFilter];
}

- (void)setFilter:(GHTestNodeFilter)filter {
[self setFilter:filter textFilter:textFilter_];
}

- (void)setFilter:(GHTestNodeFilter)filter textFilter:(NSString *)textFilter {
if ([self isRunning]) [NSException raise:NSObjectNotAvailableException format:@"Can't filter while running"];
filter_ = filter;

textFilter = [textFilter stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([textFilter isEqualToString:@""]) textFilter = nil;

[textFilter retain];
[textFilter_ release];
textFilter_ = textFilter;
[self _applyFilters];
}

- (void)setFilter:(GHTestNodeFilter)filter {
if ([self isRunning]) [NSException raise:NSObjectNotAvailableException format:@"Can't filter while running"];
filter_ = filter;
[self _applyFilters];
textFilter_ = textFilter;
[self _applyFilters];
}

- (NSString *)name {
Expand Down

0 comments on commit 31ca550

Please sign in to comment.