aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPFieldEditor.h3
-rw-r--r--Source/SPFieldEditor.m96
2 files changed, 55 insertions, 44 deletions
diff --git a/Source/SPFieldEditor.h b/Source/SPFieldEditor.h
index ff7cd5c6..1271b483 100644
--- a/Source/SPFieldEditor.h
+++ b/Source/SPFieldEditor.h
@@ -12,7 +12,6 @@
@interface SPFieldEditor : NSWindow {
IBOutlet id editSheetProgressBar;
- IBOutlet id editSheet;
IBOutlet id editSheetSegmentControl;
IBOutlet id editSheetQuickLookButton;
IBOutlet id editImage;
@@ -21,7 +20,7 @@
IBOutlet id editTextScrollView;
IBOutlet id hexTextScrollView;
- id editData;
+ id sheetEditData;
NSString *stringValue;
diff --git a/Source/SPFieldEditor.m b/Source/SPFieldEditor.m
index 3a389f6e..e8ac915f 100644
--- a/Source/SPFieldEditor.m
+++ b/Source/SPFieldEditor.m
@@ -16,10 +16,18 @@
@implementation SPFieldEditor
+// - (id) init
+// {
+// [self clean];
+// self = [super init];
+// return self;
+// }
- (void)initWithObject:(id)data usingEncoding:(NSStringEncoding)anEncoding isObjectBlob:(BOOL)isFieldBlob
{
+ [self clean];
+
// hide all views in editSheet
[hexTextView setHidden:YES];
[hexTextScrollView setHidden:YES];
@@ -33,7 +41,9 @@
isBlob = isFieldBlob;
- editData = [data retain];
+ // sheetEditData = data;
+ sheetEditData = [data copy];
+ NSLog(@"bbb:%@", sheetEditData);
// hide all views in editSheet
[hexTextView setHidden:YES];
@@ -48,15 +58,15 @@
[editSheetProgressBar startAnimation:self];
NSImage *image = nil;
- if ( [editData isKindOfClass:[NSData class]] ) {
- image = [[[NSImage alloc] initWithData:editData] autorelease];
+ if ( [sheetEditData isKindOfClass:[NSData class]] ) {
+ image = [[[NSImage alloc] initWithData:sheetEditData] autorelease];
// Set hex view to "" - load on demand only
[hexTextView setString:@""];
- stringValue = [[NSString alloc] initWithData:editData encoding:encoding];
+ stringValue = [[NSString alloc] initWithData:sheetEditData encoding:encoding];
if (stringValue == nil)
- stringValue = [[NSString alloc] initWithData:editData encoding:NSASCIIStringEncoding];
+ stringValue = [[NSString alloc] initWithData:sheetEditData encoding:NSASCIIStringEncoding];
[hexTextView setHidden:NO];
[hexTextScrollView setHidden:NO];
@@ -65,7 +75,7 @@
[editTextScrollView setHidden:YES];
[editSheetSegmentControl setSelectedSegment:2];
} else {
- stringValue = [editData retain];
+ stringValue = [sheetEditData retain];
[hexTextView setString:@""];
@@ -91,6 +101,7 @@
}
if (stringValue) {
[editTextView setString:stringValue];
+ NSLog(@"tv:%@", [editTextView class]);
if(image == nil) {
[hexTextView setHidden:YES];
@@ -126,17 +137,18 @@
- (void)clean
{
[hexTextView setString:@""];
- [editTextView setString:@""];
+ [editTextView setString:@"AA"];
[editImage setImage:nil];
- if ( editData ) {
- [editData release];
+ if ( sheetEditData ) {
+ [sheetEditData release];
}
}
- (id)editData
{
- return editData;
+ NSLog(@"aa:%@", sheetEditData);
+ return [sheetEditData copy];
}
@@ -158,17 +170,17 @@
[editSheetProgressBar startAnimation:self];
// free old data
- if ( editData != nil ) {
- [editData release];
+ if ( sheetEditData != nil ) {
+ [sheetEditData release];
}
// load new data/images
- editData = [[NSData alloc] initWithContentsOfFile:fileName];
+ sheetEditData = [[NSData alloc] initWithContentsOfFile:fileName];
- NSImage *image = [[NSImage alloc] initWithData:editData];
- contents = [[NSString alloc] initWithData:editData encoding:encoding];
+ NSImage *image = [[NSImage alloc] initWithData:sheetEditData];
+ contents = [[NSString alloc] initWithData:sheetEditData encoding:encoding];
if (contents == nil)
- contents = [[NSString alloc] initWithData:editData encoding:NSASCIIStringEncoding];
+ contents = [[NSString alloc] initWithData:sheetEditData encoding:NSASCIIStringEncoding];
// set the image preview, string contents and hex representation
[editImage setImage:image];
@@ -181,7 +193,7 @@
// Load hex data only if user has already displayed them
if(![[hexTextView string] isEqualToString:@""])
- [hexTextView setString:[editData dataToFormattedHexString]];
+ [hexTextView setString:[sheetEditData dataToFormattedHexString]];
// If the image cell now contains a valid image, select the image view
if (image) {
@@ -222,7 +234,7 @@
[editImage setHidden:YES];
[hexTextView setHidden:YES];
[hexTextScrollView setHidden:YES];
- [editSheet makeFirstResponder:editTextView];
+ // [self makeFirstResponder:editTextView];
break;
case 1: // image
[editTextView setHidden:YES];
@@ -230,12 +242,12 @@
[editImage setHidden:NO];
[hexTextView setHidden:YES];
[hexTextScrollView setHidden:YES];
- [editSheet makeFirstResponder:editImage];
+ // [self makeFirstResponder:editImage];
break;
case 2: // hex - load on demand
- if([editData length] && [[hexTextView string] isEqualToString:@""]) {
+ if([sheetEditData length] && [[hexTextView string] isEqualToString:@""]) {
[editSheetProgressBar startAnimation:self];
- [hexTextView setString:[editData dataToFormattedHexString]];
+ [hexTextView setString:[sheetEditData dataToFormattedHexString]];
[editSheetProgressBar stopAnimation:self];
}
[editTextView setHidden:YES];
@@ -243,7 +255,7 @@
[editImage setHidden:YES];
[hexTextView setHidden:NO];
[hexTextScrollView setHidden:NO];
- [editSheet makeFirstResponder:hexTextView];
+ // [self makeFirstResponder:hexTextView];
break;
}
}
@@ -263,12 +275,12 @@
// Write binary field types directly to the file
//// || [editSheetBinaryButton state] == NSOnState
- if ( [editData isKindOfClass:[NSData class]] ) {
- [editData writeToFile:fileName atomically:YES];
+ if ( [sheetEditData isKindOfClass:[NSData class]] ) {
+ [sheetEditData writeToFile:fileName atomically:YES];
// Write other field types' representations to the file via the current encoding
} else {
- [[editData description] writeToFile:fileName
+ [[sheetEditData description] writeToFile:fileName
atomically:YES
encoding:encoding
error:NULL];
@@ -314,12 +326,12 @@
NSString *tmpFileName = [NSString stringWithFormat:@"/tmp/SequelProQuickLook.%@", type];
// if data are binary
- if ( [editData isKindOfClass:[NSData class]] || !isText) {
- [editData writeToFile:tmpFileName atomically:YES];
+ if ( [sheetEditData isKindOfClass:[NSData class]] || !isText) {
+ [sheetEditData writeToFile:tmpFileName atomically:YES];
// write other field types' representations to the file via the current encoding
} else {
- [[editData description] writeToFile:tmpFileName
+ [[sheetEditData description] writeToFile:tmpFileName
atomically:YES
encoding:encoding
error:NULL];
@@ -406,21 +418,21 @@
image = [[[NSImage alloc] initWithPasteboard:[NSPasteboard generalPasteboard]] autorelease];
if (image) {
- if (nil != editData) [editData release];
+ if (nil != sheetEditData) [sheetEditData release];
[editImage setImage:image];
- editData = [[NSData alloc] initWithData:[image TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1]];
+ sheetEditData = [[NSData alloc] initWithData:[image TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1]];
- NSString *contents = [[NSString alloc] initWithData:editData encoding:encoding];
+ NSString *contents = [[NSString alloc] initWithData:sheetEditData encoding:encoding];
if (contents == nil)
- contents = [[NSString alloc] initWithData:editData encoding:NSASCIIStringEncoding];
+ contents = [[NSString alloc] initWithData:sheetEditData encoding:NSASCIIStringEncoding];
// Set the string contents and hex representation
if(contents)
[editTextView setString:contents];
if(![[hexTextView string] isEqualToString:@""])
- [hexTextView setString:[editData dataToFormattedHexString]];
+ [hexTextView setString:[sheetEditData dataToFormattedHexString]];
[contents release];
@@ -437,11 +449,11 @@
editSheetWillBeInitialized = YES;
- if (nil != editData) [editData release];
+ if (nil != sheetEditData) [sheetEditData release];
// If the image was not processed, set a blank string as the contents of the edit and hex views.
if ( data == nil ) {
- editData = [[NSData alloc] init];
+ sheetEditData = [[NSData alloc] init];
[editTextView setString:@""];
[hexTextView setString:@""];
editSheetWillBeInitialized = NO;
@@ -449,7 +461,7 @@
}
// Process the provided image
- editData = [[NSData alloc] initWithData:data];
+ sheetEditData = [[NSData alloc] initWithData:data];
NSString *contents = [[NSString alloc] initWithData:data encoding:encoding];
if (contents == nil)
contents = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
@@ -458,7 +470,7 @@
if(contents)
[editTextView setString:contents];
if(![[hexTextView string] isEqualToString:@""])
- [hexTextView setString:[editData dataToFormattedHexString]];
+ [hexTextView setString:[sheetEditData dataToFormattedHexString]];
[contents release];
editSheetWillBeInitialized = NO;
@@ -470,8 +482,8 @@
// If the image was deleted, set a blank string as the contents of the edit and hex views.
// The actual dropped image processing is handled by processUpdatedImageData:.
if ( [editImage image] == nil ) {
- if (nil != editData) [editData release];
- editData = [[NSData alloc] init];
+ if (nil != sheetEditData) [sheetEditData release];
+ sheetEditData = [[NSData alloc] init];
[editTextView setString:@""];
[hexTextView setString:@""];
return;
@@ -493,12 +505,12 @@
[hexTextView setString:@""];
// free old data
- if ( editData != nil ) {
- [editData release];
+ if ( sheetEditData != nil ) {
+ [sheetEditData release];
}
// set edit data to text
- editData = [[editTextView string] retain];
+ sheetEditData = [[editTextView string] retain];
}