aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableStructure.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-10-15 10:40:15 +0000
committerBibiko <bibiko@eva.mpg.de>2010-10-15 10:40:15 +0000
commit1d5ac4c0f11e84ba5612c04c7984768f797a729c (patch)
treeaeb768a2d99a6760f2e03e8e5ec0b59d3733878b /Source/SPTableStructure.m
parentf0e656abd33789d8ad00a95c89b13bd891ae3879 (diff)
downloadsequelpro-1d5ac4c0f11e84ba5612c04c7984768f797a729c.tar.gz
sequelpro-1d5ac4c0f11e84ba5612c04c7984768f797a729c.tar.bz2
sequelpro-1d5ac4c0f11e84ba5612c04c7984768f797a729c.zip
• implemented for TableStructure's source table the possibility to hide/unhide the columns: Key, encoding, collation, comment by adding a gear menu 'View Columns'; the hide status will be saved inside the Pref key: 'NSTableView Hidden Columns SPTableStructureSource'
- this implements the feature request issue 868
Diffstat (limited to 'Source/SPTableStructure.m')
-rw-r--r--Source/SPTableStructure.m57
1 files changed, 57 insertions, 0 deletions
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