diff options
author | stuconnolly <stuart02@gmail.com> | 2009-05-19 19:57:34 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-05-19 19:57:34 +0000 |
commit | dad2c2af5af18890fa927d171f1ff58530a1a810 (patch) | |
tree | 3ec05044742bdad1a6e963fe19b2d5057e5fdafe /Source/CustomQuery.m | |
parent | 641eeff363a2864456a985b246576bfd5d41b144 (diff) | |
download | sequelpro-dad2c2af5af18890fa927d171f1ff58530a1a810.tar.gz sequelpro-dad2c2af5af18890fa927d171f1ff58530a1a810.tar.bz2 sequelpro-dad2c2af5af18890fa927d171f1ff58530a1a810.zip |
New preference to allow the displaying of vertical grid lines in table views.
Diffstat (limited to 'Source/CustomQuery.m')
-rw-r--r-- | Source/CustomQuery.m | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 27f72b04..9245d953 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -39,13 +39,10 @@ #define SP_HELP_GOFORWARD_BUTTON 2 #define SP_HELP_NOT_AVAILABLE @"__no_help_available" - @implementation CustomQuery - #pragma mark IBAction methods - /* * Split all the queries in the text view, split them into individual queries, * and run sequentially. @@ -912,7 +909,6 @@ sets the connection (received from TableDocument) and makes things that have to mySQLConnection = theConnection; - prefs = [[NSUserDefaults standardUserDefaults] retain]; if ( [prefs objectForKey:@"queryFavorites"] ) { queryFavorites = [[NSMutableArray alloc] initWithArray:[prefs objectForKey:@"queryFavorites"]]; } else { @@ -1802,7 +1798,6 @@ traps enter key and } } - /* * Manage contextual menu in helpWebView * Ignore "Reload", "Open Link", "Open Link in new Window", "Download link" etc. @@ -1872,44 +1867,65 @@ traps enter key and } +#pragma mark - +#pragma mark Other + +/** + * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface. + */ +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if ([keyPath isEqualToString:@"DisplayTableViewVerticalGridlines"]) { + [customQueryView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + } +} #pragma mark - // Last but not least - (id)init; { - self = [super init]; - prefs = nil; - usedQuery = [[NSString stringWithString:@""] retain]; - - // init helpHTMLTemplate - NSError *error; - helpHTMLTemplate = [[NSString alloc] - initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"sequel-pro-mysql-help-template" ofType:@"html"] - encoding:NSUTF8StringEncoding - error:&error]; - // an error occurred while reading - if (helpHTMLTemplate == nil) - { - NSLog(@"%@", [NSString stringWithFormat:@"Error reading “sequel-pro-mysql-help-template.html”!<br>%@", [error localizedFailureReason]]); - NSBeep(); + if ((self = [super init])) { + + usedQuery = [[NSString stringWithString:@""] retain]; + + // init helpHTMLTemplate + NSError *error; + + helpHTMLTemplate = [[NSString alloc] + initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"sequel-pro-mysql-help-template" ofType:@"html"] + encoding:NSUTF8StringEncoding + error:&error]; + + // an error occurred while reading + if (helpHTMLTemplate == nil) { + NSLog(@"%@", [NSString stringWithFormat:@"Error reading “sequel-pro-mysql-help-template.html”!<br>%@", [error localizedFailureReason]]); + NSBeep(); + } + + // init search history + [helpWebView setMaintainsBackForwardList:YES]; + [[helpWebView backForwardList] setCapacity:20]; + + prefs = [NSUserDefaults standardUserDefaults]; } - // init search history - [helpWebView setMaintainsBackForwardList:YES]; - [[helpWebView backForwardList] setCapacity:20]; - return self; } +- (void)awakeFromNib +{ + // Set the structure and index view's vertical gridlines if required + [customQueryView setGridStyleMask:([prefs boolForKey:@"DisplayTableViewVerticalGridlines"]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; +} + - (void)dealloc { [queryResult release]; - [prefs release]; [queryFavorites release]; [usedQuery release]; + [super dealloc]; - } @end |