aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-08-14 22:57:11 +0000
committerBibiko <bibiko@eva.mpg.de>2009-08-14 22:57:11 +0000
commit44548eed4c7e103ced2c9e87bd056fe59fedf617 (patch)
tree328846e4d0666a82bf608ca09147d489f6d4d599 /Source/TableContent.m
parent8f82f023c394be8bba83c53e1ceeb3bbaf54e41d (diff)
downloadsequelpro-44548eed4c7e103ced2c9e87bd056fe59fedf617.tar.gz
sequelpro-44548eed4c7e103ced2c9e87bd056fe59fedf617.tar.bz2
sequelpro-44548eed4c7e103ced2c9e87bd056fe59fedf617.zip
• added SPTooltips for cell content in Content Table
- text strings are display with line breaks and tabs - if cell content represents image data display that image as transparent thumbnail (by using base64 encoded HTML img tag) Notes: - SPTooltip implementation to show an image via a NSImageView will be implemented soon (the HTML way needs too much memory due to base64 encoded string) - to discuss: Should we add a preference setting to display these tooltips?
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m41
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 5ebb15f9..3f8c9596 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -43,6 +43,7 @@
#import "SPTextAndLinkCell.h"
#import "QLPreviewPanel.h"
#import "SPFieldEditorController.h"
+#import "SPTooltip.h"
@implementation TableContent
@@ -1789,6 +1790,46 @@
#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(tableValues, 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;
+}
+
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [tableValues count];