Ignore case when sorting.

This commit is contained in:
Mitchell Livingston 2006-07-23 21:29:24 +00:00
parent 802345f5ed
commit e5fc3b555e
2 changed files with 11 additions and 11 deletions

View File

@ -945,10 +945,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
//doesn't remember selected rows
- (void) sortTorrentsIgnoreSelected
{
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"name" ascending: YES] autorelease],
* orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"orderValue" ascending: YES] autorelease];
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name"
ascending: YES selector: @selector(caseInsensitiveCompare:)] autorelease],
* orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"orderValue"
ascending: YES] autorelease];
NSArray * descriptors;
if ([fSortType isEqualToString: @"Name"])
@ -972,8 +972,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
}
else if ([fSortType isEqualToString: @"Date"])
{
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"date" ascending: YES] autorelease];
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"date" ascending: YES] autorelease];
descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, orderDescriptor, nil];
}

View File

@ -154,7 +154,9 @@
- (void) keyDown: (NSEvent *) event
{
unichar newChar = [[event characters] characterAtIndex: 0];
if (newChar == ' ' || [[NSCharacterSet alphanumericCharacterSet] characterIsMember: newChar])
if (newChar == ' ' || [[NSCharacterSet alphanumericCharacterSet] characterIsMember: newChar]
|| [[NSCharacterSet symbolCharacterSet] characterIsMember: newChar]
|| [[NSCharacterSet punctuationCharacterSet] characterIsMember: newChar])
{
if ([fKeyStrokes count] > 0 && [event timestamp] - [[fKeyStrokes lastObject] timestamp] > 1.0)
[fKeyStrokes removeAllObjects];
@ -173,10 +175,9 @@
- (void) insertText: (NSString *) text
{
NSLog(text);
//sort torrents by name before finding closest match
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES] autorelease];
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES
selector: @selector(caseInsensitiveCompare:)] autorelease];
NSArray * descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, nil];
NSArray * tempTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors];
@ -186,7 +187,7 @@
NSEnumerator * enumerator = [tempTorrents objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{
{NSLog([[torrent name] lowercaseString]);
if ([[torrent name] caseInsensitiveCompare: text] != NSOrderedAscending)
{
[self selectRow: [fTorrents indexOfObject: torrent] byExtendingSelection: NO];