Ignore case when sorting.
This commit is contained in:
parent
802345f5ed
commit
e5fc3b555e
|
@ -945,10 +945,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
//doesn't remember selected rows
|
//doesn't remember selected rows
|
||||||
- (void) sortTorrentsIgnoreSelected
|
- (void) sortTorrentsIgnoreSelected
|
||||||
{
|
{
|
||||||
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name"
|
||||||
@"name" ascending: YES] autorelease],
|
ascending: YES selector: @selector(caseInsensitiveCompare:)] autorelease],
|
||||||
* orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
* orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"orderValue"
|
||||||
@"orderValue" ascending: YES] autorelease];
|
ascending: YES] autorelease];
|
||||||
|
|
||||||
NSArray * descriptors;
|
NSArray * descriptors;
|
||||||
if ([fSortType isEqualToString: @"Name"])
|
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"])
|
else if ([fSortType isEqualToString: @"Date"])
|
||||||
{
|
{
|
||||||
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"date" ascending: YES] autorelease];
|
||||||
@"date" ascending: YES] autorelease];
|
|
||||||
|
|
||||||
descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, orderDescriptor, nil];
|
descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, orderDescriptor, nil];
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,9 @@
|
||||||
- (void) keyDown: (NSEvent *) event
|
- (void) keyDown: (NSEvent *) event
|
||||||
{
|
{
|
||||||
unichar newChar = [[event characters] characterAtIndex: 0];
|
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)
|
if ([fKeyStrokes count] > 0 && [event timestamp] - [[fKeyStrokes lastObject] timestamp] > 1.0)
|
||||||
[fKeyStrokes removeAllObjects];
|
[fKeyStrokes removeAllObjects];
|
||||||
|
@ -173,10 +175,9 @@
|
||||||
|
|
||||||
- (void) insertText: (NSString *) text
|
- (void) insertText: (NSString *) text
|
||||||
{
|
{
|
||||||
NSLog(text);
|
|
||||||
|
|
||||||
//sort torrents by name before finding closest match
|
//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 * descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, nil];
|
||||||
|
|
||||||
NSArray * tempTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors];
|
NSArray * tempTorrents = [fTorrents sortedArrayUsingDescriptors: descriptors];
|
||||||
|
@ -186,7 +187,7 @@
|
||||||
NSEnumerator * enumerator = [tempTorrents objectEnumerator];
|
NSEnumerator * enumerator = [tempTorrents objectEnumerator];
|
||||||
Torrent * torrent;
|
Torrent * torrent;
|
||||||
while ((torrent = [enumerator nextObject]))
|
while ((torrent = [enumerator nextObject]))
|
||||||
{
|
{NSLog([[torrent name] lowercaseString]);
|
||||||
if ([[torrent name] caseInsensitiveCompare: text] != NSOrderedAscending)
|
if ([[torrent name] caseInsensitiveCompare: text] != NSOrderedAscending)
|
||||||
{
|
{
|
||||||
[self selectRow: [fTorrents indexOfObject: torrent] byExtendingSelection: NO];
|
[self selectRow: [fTorrents indexOfObject: torrent] byExtendingSelection: NO];
|
||||||
|
|
Loading…
Reference in New Issue