aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTableStructure.h3
-rw-r--r--Source/SPTableStructure.m57
2 files changed, 60 insertions, 0 deletions
diff --git a/Source/SPTableStructure.h b/Source/SPTableStructure.h
index d5229153..b6c29f45 100644
--- a/Source/SPTableStructure.h
+++ b/Source/SPTableStructure.h
@@ -54,6 +54,8 @@
IBOutlet NSSplitView *tablesIndexesSplitView;
IBOutlet NSButton *indexesShowButton;
+ IBOutlet id viewColumnsMenu;
+
IBOutlet id encodingPopupCell;
id databaseDataInstance;
@@ -85,6 +87,7 @@
- (IBAction)removeField:(id)sender;
- (IBAction)resetAutoIncrement:(id)sender;
- (IBAction)showOptimizedFieldType:(id)sender;
+- (IBAction)toggleColumnView:(id)sender;
- (BOOL)cancelRowEditing;
// Index sheet methods
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index a51fa12e..55309cb1 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -151,6 +151,24 @@
object:tableDocumentInstance];
[prefs addObserver:indexesController forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL];
+
+ // Init the view column submenu according to saved hidden status;
+ // menu items are identified by their tag number which represents the initial column index
+ for(NSMenuItem *item in [viewColumnsMenu itemArray]) [item setState:NSOnState]; // Set all items to NSOnState
+ for(NSTableColumn *col in [tableSourceView tableColumns]) {
+ if([col isHidden]) {
+ if([[col identifier] isEqualToString:@"Key"])
+ [[viewColumnsMenu itemWithTag:7] setState:NSOffState];
+ else if([[col identifier] isEqualToString:@"encoding"])
+ [[viewColumnsMenu itemWithTag:10] setState:NSOffState];
+ else if([[col identifier] isEqualToString:@"collation"])
+ [[viewColumnsMenu itemWithTag:11] setState:NSOffState];
+ else if([[col identifier] isEqualToString:@"comment"])
+ [[viewColumnsMenu itemWithTag:12] setState:NSOffState];
+ }
+ }
+ [tableSourceView reloadData];
+
}
#pragma mark -
@@ -471,6 +489,45 @@
}
/**
+ * Control the visibility of the columns
+ */
+- (IBAction)toggleColumnView:(id)sender
+{
+
+ NSString *columnIdentifierName = nil;
+
+ switch([sender tag]) {
+ case 7:
+ columnIdentifierName = @"Key";
+ break;
+ case 10:
+ columnIdentifierName = @"encoding";
+ break;
+ case 11:
+ columnIdentifierName = @"collation";
+ break;
+ case 12:
+ columnIdentifierName = @"comment";
+ break;
+ default:
+ return;
+ }
+
+ for(NSTableColumn *col in [tableSourceView tableColumns]) {
+
+ if([[col identifier] isEqualToString:columnIdentifierName]) {
+ [col setHidden:([sender state] == NSOffState) ? NO : YES];
+ [sender setState:![sender state]];
+ break;
+ }
+
+ }
+
+ [tableSourceView reloadData];
+
+}
+
+/**
* Copies a field and goes in edit mode for the new field
*/
- (IBAction)copyField:(id)sender