aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-08-15 09:31:03 +0000
committerBibiko <bibiko@eva.mpg.de>2009-08-15 09:31:03 +0000
commit0cd7f29373fa0db65e1f46ef7423c051712c07f1 (patch)
tree68b07d5a46fee0f55809b414591a8822da81f01a /Source
parent5e14414cb9c7123ba2131ceba0a7833568b98c1c (diff)
downloadsequelpro-0cd7f29373fa0db65e1f46ef7423c051712c07f1.tar.gz
sequelpro-0cd7f29373fa0db65e1f46ef7423c051712c07f1.tar.bz2
sequelpro-0cd7f29373fa0db65e1f46ef7423c051712c07f1.zip
• added SPTooltip to CustomQuery result table to display the cell's content as text with line breaks and tabs or as image
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.m42
1 files changed, 42 insertions, 0 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index f37d8613..6bdfe191 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -36,6 +36,7 @@
#import "RegexKitLite.h"
#import "SPFieldEditorController.h"
#import "SPTextAndLinkCell.h"
+#import "SPTooltip.h"
#define SP_MYSQL_DEV_SEARCH_URL @"http://search.mysql.com/search?q=%@&site=refman-%@"
#define SP_HELP_SEARCH_IN_MYSQL 0
@@ -1685,6 +1686,47 @@
#pragma mark -
#pragma mark TableView delegate methods
+/**
+ * Show the table cell content as tooltip
+ * - for text displays line breaks and tabs as well
+ * - 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
+{
+
+ 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]]) {
+ NSImage *image = [[NSImage alloc] initWithData:theValue];
+ if(image) {
+ int imageWidth = [image size].width;
+ if (imageWidth > 100) imageWidth = 100;
+ [SPTooltip showWithObject:[NSString stringWithFormat:
+ @"<IMG WIDTH='%d' SRC=\"data:image/auto;base64,%@\">",
+ imageWidth,
+ [[image TIFFRepresentationUsingCompression:NSTIFFCompressionJPEG factor:0.01] base64EncodingWithLineLength:0]]
+ atLocation:pos
+ ofType:@"html"
+ displayOptions:[NSDictionary dictionaryWithObjectsAndKeys:@"transparent", @"transparent", nil]];
+ }
+ [image release];
+ return nil;
+ }
+
+ // 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;
+}
+
+
/*
* Double-click action on a field
*/