aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-08-20 22:51:50 +0000
committerBibiko <bibiko@eva.mpg.de>2009-08-20 22:51:50 +0000
commite25c021cf7473c033e65d2472f25913aaff44c50 (patch)
treee723ff2b0912567cc14b84b5c740f9df086ba218
parentb3956171e9dbad34a4ef12b22d0b99b07a545d7d (diff)
downloadsequelpro-e25c021cf7473c033e65d2472f25913aaff44c50.tar.gz
sequelpro-e25c021cf7473c033e65d2472f25913aaff44c50.tar.bz2
sequelpro-e25c021cf7473c033e65d2472f25913aaff44c50.zip
• re-implemented tooltips for Content and Query tables
- catch exceptions while retrieving the original table data while/before reloading/changing the table source data - 'image' is now set to autorelease
-rw-r--r--Source/CustomQuery.m65
-rw-r--r--Source/TableContent.m65
2 files changed, 69 insertions, 61 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index a45cc972..06255662 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -1693,38 +1693,41 @@
* - if blob data can be interpret as image data display the image as transparent thumbnail
* (up to now using base64 encoded HTML data)
*/
-// - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(SPTextAndLinkCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation
-// {
-//
-//
-// NSImage *image;
-//
-// if([[aCell stringValue] length] < 1) return nil;
-//
-// NSPoint pos = [NSEvent mouseLocation];
-// pos.y -= 20;
-//
-// // Get the original data for trying to display the blob data as an image
-// id theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(fullResult, row), [[aTableColumn identifier] intValue]);
-// if ([theValue isKindOfClass:[NSData class]]) {
-// image = [[NSImage alloc] initWithData:theValue];
-// if(image) {
-// [SPTooltip showWithObject:image atLocation:pos ofType:@"image"];
-// [image release];
-// theValue = nil;
-// return nil;
-// }
-// }
-//
-// if(image) [image release];
-//
-// // Show the cell string value as tooltip (including line breaks and tabs)
-// if([[aCell stringValue] length] > 1)
-// [SPTooltip showWithObject:[aCell stringValue] atLocation:pos];
-//
-// return nil;
-// }
+- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(SPTextAndLinkCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation
+{
+
+ if([[aCell stringValue] length] < 2) return nil;
+
+ NSImage *image;
+
+ NSPoint pos = [NSEvent mouseLocation];
+ pos.y -= 20;
+
+ // Try to get the original data. If not possible return nil.
+ // @try clause is used due to the multifarious cases of
+ // possible exceptions (eg for reloading tables etc.)
+ id theValue;
+ @try{
+ theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(fullResult, row), [[aTableColumn identifier] intValue]);
+ }
+ @catch(id ae) {
+ return nil;
+ }
+
+ // Get the original data for trying to display the blob data as an image
+ if ([theValue isKindOfClass:[NSData class]]) {
+ image = [[[NSImage alloc] initWithData:theValue] autorelease];
+ if(image) {
+ [SPTooltip showWithObject:image atLocation:pos ofType:@"image"];
+ return nil;
+ }
+ }
+
+ // Show the cell string value as tooltip (including line breaks and tabs)
+ [SPTooltip showWithObject:[aCell stringValue] atLocation:pos];
+ return nil;
+}
/*
* Double-click action on a field
diff --git a/Source/TableContent.m b/Source/TableContent.m
index f4e3d01b..7b458947 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -1796,36 +1796,41 @@
* - if blob data can be interpret as image data display the image as transparent thumbnail
* (up to now using base64 encoded HTML data)
*/
-// - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(SPTextAndLinkCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation
-// {
-//
-// NSImage *image;
-//
-// if([[aCell stringValue] length] < 1) return nil;
-//
-// NSPoint pos = [NSEvent mouseLocation];
-// pos.y -= 20;
-//
-// // Get the original data for trying to display the blob data as an image
-// id theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(tableValues, row), [[aTableColumn identifier] intValue]);
-// if ([theValue isKindOfClass:[NSData class]]) {
-// image = [[NSImage alloc] initWithData:theValue];
-// if(image) {
-// [SPTooltip showWithObject:image atLocation:pos ofType:@"image"];
-// [image release];
-// theValue = nil;
-// return nil;
-// }
-// }
-//
-// if(image) [image release];
-//
-// // Show the cell string value as tooltip (including line breaks and tabs)
-// if([[aCell stringValue] length] > 1)
-// [SPTooltip showWithObject:[aCell stringValue] atLocation:pos];
-//
-// return nil;
-// }
+- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(SPTextAndLinkCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation
+{
+
+ if([[aCell stringValue] length] < 2) return nil;
+
+ NSImage *image;
+
+ NSPoint pos = [NSEvent mouseLocation];
+ pos.y -= 20;
+
+ // Try to get the original data. If not possible return nil.
+ // @try clause is used due to the multifarious cases of
+ // possible exceptions (eg for reloading tables etc.)
+ id theValue;
+ @try{
+ theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(tableValues, row), [[aTableColumn identifier] intValue]);
+ }
+ @catch(id ae) {
+ return nil;
+ }
+
+ // Get the original data for trying to display the blob data as an image
+ if ([theValue isKindOfClass:[NSData class]]) {
+ image = [[[NSImage alloc] initWithData:theValue] autorelease];
+ if(image) {
+ [SPTooltip showWithObject:image atLocation:pos ofType:@"image"];
+ return nil;
+ }
+ }
+
+ // Show the cell string value as tooltip (including line breaks and tabs)
+ [SPTooltip showWithObject:[aCell stringValue] atLocation:pos];
+
+ return nil;
+}
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{