diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-06-23 22:21:23 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-06-23 22:21:23 +0000 |
commit | 24f0afbfe3416b7896d0a3b4f654f04944adf39d (patch) | |
tree | 8baf8e6d89d5b57df23b5e88080e8747afaa368b /Source/CustomQuery.m | |
parent | ed2d754e46bd6a104f1b093b979720727e95dcb5 (diff) | |
download | sequelpro-24f0afbfe3416b7896d0a3b4f654f04944adf39d.tar.gz sequelpro-24f0afbfe3416b7896d0a3b4f654f04944adf39d.tar.bz2 sequelpro-24f0afbfe3416b7896d0a3b4f654f04944adf39d.zip |
• added to SPDataAdditions:
- (NSString *) shortStringRepresentationUsingEncoding:
--mainly used for displaying large blob data in a tableView
• tiny speed improvements for tableView:objectValueForTableColumn and tableView:setObjectValueForTableColumn in Content Browser and Custom Query
Diffstat (limited to 'Source/CustomQuery.m')
-rw-r--r-- | Source/CustomQuery.m | 52 |
1 files changed, 11 insertions, 41 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index ac2d08c7..1a5e3860 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -29,6 +29,7 @@ #import "SPStringAdditions.h" #import "SPTextViewAdditions.h" #import "SPArrayAdditions.h" +#import "SPDataAdditions.h" #import "SPDataCellFormatter.h" #import "TableDocument.h" #import "TablesList.h" @@ -1147,50 +1148,19 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { - id theRow; if ( aTableView == customQueryView ) { - // theRow = [fullResult objectAtIndex:rowIndex]; - // theValue = [theRow objectForKey:[[aTableColumn headerCell] stringValue]]; - // // Convert data objects to their string representation in the current encoding, falling back to ascii - // if ( [theValue isKindOfClass:[NSData class]] ) { - // NSString *dataRepresentation = [[NSString alloc] initWithData:theValue encoding:[mySQLConnection encoding]]; - // if (dataRepresentation == nil) - // dataRepresentation = [[NSString alloc] initWithData:theValue encoding:NSASCIIStringEncoding]; - // if (dataRepresentation == nil) { - // theValue = @"- cannot be displayed -"; - // } else { - // if([theValue length] > 255) - // theValue = [NSString stringWithString:dataRepresentation]; - // else - // theValue = [NSString stringWithString:dataRepresentation]; - // // if([theValue length] > 255) - // // theValue = [theValue substringToIndex:255]; - // } - // if (dataRepresentation) [dataRepresentation release]; - // } - // return theValue; - - int theIdentifier = [[aTableColumn identifier] intValue]; - theRow = [queryResult objectAtIndex:rowIndex]; - - if ( [[theRow objectAtIndex:theIdentifier] isKindOfClass:[NSData class]] ) { - NSString *tmp = [[NSString alloc] initWithData:[theRow objectAtIndex:theIdentifier] - encoding:[mySQLConnection encoding]]; - if (tmp == nil) { - tmp = [[NSString alloc] initWithData:[theRow objectAtIndex:theIdentifier] - encoding:NSASCIIStringEncoding]; - } - // If field contains binary data show only the first 255 bytes for speed - if([tmp length] > 255) { - return [[tmp autorelease] substringToIndex:255]; - } else - return [tmp autorelease]; - } - if ( [[theRow objectAtIndex:theIdentifier] isMemberOfClass:[NSNull class]] ) + + id theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(queryResult, rowIndex), [[aTableColumn identifier] intValue]); + + if ( [theValue isKindOfClass:[NSData class]] ) + return [theValue shortStringRepresentationUsingEncoding:[mySQLConnection encoding]]; + + if ( [theValue isMemberOfClass:[NSNull class]] ) return [prefs objectForKey:@"NullValue"]; - - return [theRow objectAtIndex:theIdentifier]; + + return theValue; + } else if ( aTableView == queryFavoritesView ) { |