Changeset 12897
- Timestamp:
- Sep 19, 2011, 12:48:30 AM (12 years ago)
- Location:
- trunk/macosx
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r12774 r12897 2001 2001 const BOOL filterGroup = groupFilterValue != GROUP_FILTER_ALL_TAG; 2002 2002 2003 NS String * searchString = [fFilterBar searchString];2004 if (searchString && [searchString isEqualToString: @""])2005 searchString = nil;2006 const BOOL filterTracker = searchString && [[fDefaults stringForKey: @"FilterSearchType"] isEqualToString: FILTER_TYPE_TRACKER];2003 NSArray * searchStrings = [fFilterBar searchStrings]; 2004 if (searchStrings && [searchStrings count] == 0) 2005 searchStrings = nil; 2006 const BOOL filterTracker = searchStrings && [[fDefaults stringForKey: @"FilterSearchType"] isEqualToString: FILTER_TYPE_TRACKER]; 2007 2007 2008 2008 NSMutableArray * allTorrents = [NSMutableArray arrayWithCapacity: [fTorrents count]]; … … 2044 2044 2045 2045 //check text field 2046 if (searchString) 2047 { 2046 if (searchStrings) 2047 { 2048 BOOL removeTextField = NO; 2048 2049 if (filterTracker) 2049 2050 { 2050 BOOL removeTextField = YES; 2051 for (NSString * tracker in [torrent allTrackersFlat]) 2051 NSArray * trackers = [torrent allTrackersFlat]; 2052 2053 //to count, we need each string in atleast 1 tracker 2054 for (NSString * searchString in searchStrings) 2052 2055 { 2053 if ([tracker rangeOfString: searchString options:2054 (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location != NSNotFound)2056 BOOL found = NO; 2057 for (NSString * tracker in trackers) 2055 2058 { 2056 removeTextField = NO; 2059 if ([tracker rangeOfString: searchString options: 2060 (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location != NSNotFound) 2061 { 2062 found = YES; 2063 break; 2064 } 2065 } 2066 if (!found) 2067 { 2068 removeTextField = YES; 2057 2069 break; 2058 2070 } 2059 2071 } 2060 2061 if (removeTextField)2062 continue;2063 2072 } 2064 2073 else 2065 2074 { 2066 if ([[torrent name] rangeOfString: searchString options: 2067 (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location == NSNotFound) 2068 continue; 2075 for (NSString * searchString in searchStrings) 2076 if ([[torrent name] rangeOfString: searchString options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location == NSNotFound) 2077 { 2078 removeTextField = YES; 2079 break; 2080 } 2069 2081 } 2082 2083 if (removeTextField) 2084 continue; 2070 2085 } 2071 2086 … … 2153 2168 [self resetInfo]; //if group is already selected, but the torrents in it change 2154 2169 2155 [self setBottomCountText: groupRows || filterStatus || filterGroup || searchString ];2170 [self setBottomCountText: groupRows || filterStatus || filterGroup || searchStrings]; 2156 2171 2157 2172 [self setWindowSizeToFit]; -
trunk/macosx/FileOutlineController.m
r12608 r12897 30 30 #import "NSApplicationAdditions.h" 31 31 #import "NSMutableArrayAdditions.h" 32 #import "NSStringAdditions.h" 32 33 #import <Quartz/Quartz.h> 33 34 … … 113 114 - (void) setFilterText: (NSString *) text 114 115 { 115 if ([text isEqualToString: @""]) 116 NSArray * components = [text betterComponentsSeparatedByCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; 117 if (!components || [components count] == 0) 118 { 116 119 text = nil; 120 components = nil; 121 } 117 122 118 123 if ((!text && !fFilterText) || (text && fFilterText && [text isEqualToString: fFilterText])) 119 {120 124 return; 121 }122 125 123 126 const BOOL onLion = [NSApp isOnLionOrBetter]; … … 143 146 for (FileListNode * item in tempList) 144 147 { 145 if (!text || [[item name] rangeOfString: text options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location != NSNotFound) 148 BOOL filter = NO; 149 if (components) 150 { 151 for (NSString * sub in components) 152 if ([[item name] rangeOfString: sub options: (NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)].location == NSNotFound) 153 { 154 filter = YES; 155 break; 156 } 157 } 158 159 if (!filter) 146 160 { 147 161 FileListNode * parent = nil; -
trunk/macosx/FilterBarController.h
r12152 r12897 56 56 - (void) setGroupFilter: (id) sender; 57 57 58 - (NS String *) searchString;58 - (NSArray *) searchStrings; 59 59 - (void) focusSearchField; 60 60 -
trunk/macosx/FilterBarController.m
r12535 r12897 26 26 #import "FilterButton.h" 27 27 #import "GroupsController.h" 28 #import "NSStringAdditions.h" 28 29 29 30 #define FILTER_TYPE_TAG_NAME 401 … … 238 239 } 239 240 240 - (NS String *) searchString241 { 242 return [ fSearchField stringValue];241 - (NSArray *) searchStrings 242 { 243 return [[fSearchField stringValue] betterComponentsSeparatedByCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; 243 244 } 244 245 -
trunk/macosx/NSStringAdditions.h
r11647 r12897 47 47 - (NSComparisonResult) compareNumeric: (NSString *) string; //simple compare method for strings with numbers (works for IP addresses) 48 48 49 - (NSArray *) betterComponentsSeparatedByCharactersInSet: (NSCharacterSet *) separator; //like betterComponentsSeparatedByCharactersInSet:, but excludes blank values 50 49 51 @end -
trunk/macosx/NSStringAdditions.m
r12186 r12897 183 183 } 184 184 185 - (NSArray *) betterComponentsSeparatedByCharactersInSet: (NSCharacterSet *) separator 186 { 187 NSMutableArray * components = [NSMutableArray arrayWithArray: [self componentsSeparatedByCharactersInSet: separator]]; 188 [components removeObject: @""]; 189 return components; 190 } 191 185 192 @end 186 193
Note: See TracChangeset
for help on using the changeset viewer.