aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFieldEditorController.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-09-15 23:12:32 +0000
committerBibiko <bibiko@eva.mpg.de>2010-09-15 23:12:32 +0000
commitcbb150b07fcb3a96db460a22c4eb5280d8bf9e08 (patch)
treee296d46cf2c2c84e9b2974dd0b2d8ae746467a28 /Source/SPFieldEditorController.m
parente9e2c969af896c025fd8daba7612751a8afe096f (diff)
downloadsequelpro-cbb150b07fcb3a96db460a22c4eb5280d8bf9e08.tar.gz
sequelpro-cbb150b07fcb3a96db460a22c4eb5280d8bf9e08.tar.bz2
sequelpro-cbb150b07fcb3a96db460a22c4eb5280d8bf9e08.zip
• further progress on the BIT field sheet editor
Diffstat (limited to 'Source/SPFieldEditorController.m')
-rw-r--r--Source/SPFieldEditorController.m101
1 files changed, 81 insertions, 20 deletions
diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m
index fa3029e1..fe3ae80f 100644
--- a/Source/SPFieldEditorController.m
+++ b/Source/SPFieldEditorController.m
@@ -109,7 +109,6 @@
qlTypes = [NSDictionary dictionaryWithObject:qlTypesItems forKey:SPQuickLookTypes];
[qlTypesItems release];
- bitSheetBitButtonsArray = nil;
fieldType = @"";
fieldEncoding = @"";
@@ -157,6 +156,16 @@
if(NO && [fieldType length] && [fieldType isEqualToString:@"BIT"]) {
+ sheetEditData = [(NSString*)data retain];
+
+ NSInteger i = 0;
+ NSInteger maxBit = (maxTextLength > 63) ? 63 : maxTextLength;
+ for(i=0; i<maxBit; i++)
+ [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]]
+ setState:([sheetEditData characterAtIndex:(maxBit-i-1)] == '1') ? NSOnState : NSOffState];
+ for(i=maxBit; i<64; i++)
+ [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setEnabled:NO];
+
usedSheet = bitSheet;
[NSApp beginSheet:usedSheet modalForWindow:theWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
@@ -398,25 +407,6 @@
wasCutPaste = YES;
}
-- (IBAction)closeBitSheet:(id)sender
-{
-
- editSheetReturnCode = 0;
-
- if(sender == bitSheetOkButton && _isEditable) {
- [NSApp stopModal];
- editSheetReturnCode = 1;
- }
-
- [NSApp abortModal];
-
-}
-
-- (IBAction)bitSheetOperatorButtonWasClicked:(id)sender
-{
-
-}
-
- (IBAction)closeEditSheet:(id)sender
{
@@ -909,6 +899,65 @@
#pragma mark -
#pragma mark BIT Field Sheet
+- (void)updateBitSheet
+{
+ NSInteger i = 0;
+ NSInteger maxBit = (maxTextLength > 63) ? 63 : maxTextLength;
+
+ NSMutableString *bitString = [NSMutableString string];
+ [bitString setString:@""];
+
+ for(i=0; i<maxBit; i++) {
+ if([[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] state] == NSOnState) {
+ [bitString appendString:@"1"];
+ } else {
+ [bitString appendString:@"0"];
+ }
+ }
+
+ // free old data
+ if ( sheetEditData != nil ) {
+ [sheetEditData release];
+ }
+
+ // set edit data to text
+ sheetEditData = [[NSString stringWithString:bitString] retain];
+
+}
+
+- (IBAction)closeBitSheet:(id)sender
+{
+
+ editSheetReturnCode = 0;
+
+ if(sender == bitSheetOkButton && _isEditable) {
+ [NSApp stopModal];
+ editSheetReturnCode = 1;
+ }
+
+ [NSApp abortModal];
+
+}
+
+- (IBAction)bitSheetOperatorButtonWasClicked:(id)sender
+{
+
+ NSInteger i = 0;
+ NSInteger maxBit = (maxTextLength > 63) ? 63 : maxTextLength;
+
+ switch([sender tag]) {
+ case 0:
+ for(i=0; i<maxBit; i++)
+ [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setState:NSOnState];
+ break;
+ case 1:
+ for(i=0; i<maxBit; i++)
+ [[self valueForKeyPath:[NSString stringWithFormat:@"bitSheetBitButton%ld", i]] setState:NSOffState];
+ break;
+ }
+ [self updateBitSheet];
+}
+
- (IBAction)bitSheetSelectBit0:(id)sender
{
@@ -917,6 +966,18 @@
- (IBAction)bitSheetBitButtonWasClicked:(id)sender
{
+ NSMutableString *bitString = [NSMutableString string];
+ [bitString setString:sheetEditData];
+ [bitString replaceCharactersInRange:NSMakeRange(maxTextLength-[sender tag]-1,1) withString:([sender state] == NSOnState) ? @"1" : @"0"];
+
+ // free old data
+ if ( sheetEditData != nil ) {
+ [sheetEditData release];
+ }
+
+ // set edit data to text
+ sheetEditData = [[NSString stringWithString:bitString] retain];
+
}
#pragma mark -