From 27156550b646a74d2345b4ff9650b7a3b4ba052e Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sat, 16 Feb 2013 22:03:09 +0000 Subject: Fix more wanrings by creating a protocol that delegates of the copy table should conform to. --- Source/SPCopyTable.m | 22 ++++++++------------- Source/SPCustomQuery.h | 5 +++-- Source/SPCustomQuery.m | 20 ++++++++++--------- Source/SPDatabaseContentViewDelegate.h | 35 ++++++++++++++++++++++++++++++++++ Source/SPFavoriteTextFieldCell.m | 11 +++++++---- Source/SPFontPreviewTextField.m | 2 ++ Source/SPPrintAccessory.m | 6 +++++- Source/SPTableContent.h | 3 ++- Source/SPTableContent.m | 8 -------- Source/SPTableContentDelegate.h | 2 +- Source/SPTableContentDelegate.m | 11 +++++++++++ Source/SPTextView.m | 15 ++++++++------- Source/SPWindowControllerDelegate.m | 5 ++++- sequel-pro.xcodeproj/project.pbxproj | 2 ++ 14 files changed, 99 insertions(+), 48 deletions(-) create mode 100644 Source/SPDatabaseContentViewDelegate.h diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index c5d3f62d..807a204d 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -51,6 +51,7 @@ #endif #import "SPTablesList.h" #import "SPBundleCommandRunner.h" +#import "SPDatabaseContentViewDelegate.h" #import @@ -1185,19 +1186,8 @@ static const NSInteger kBlobAsImageFile = 4; */ - (BOOL)shouldUseFieldEditorForRow:(NSUInteger)rowIndex column:(NSUInteger)colIndex { - // Retrieve the column definition -#ifdef SP_CODA - NSDictionary *columnDefinition = nil; - - if ( [[self delegate] isKindOfClass:[SPTableContent class]] ) - columnDefinition = [[(SPTableContent*)[self delegate] dataColumnDefinitions] objectAtIndex:colIndex]; - - else if ( [[self delegate] isKindOfClass:[SPCustomQuery class]] ) - columnDefinition = [[(SPCustomQuery*)[self delegate] dataColumnDefinitions] objectAtIndex:colIndex]; -#else - NSDictionary *columnDefinition = [[[self delegate] dataColumnDefinitions] objectAtIndex:colIndex]; -#endif + NSDictionary *columnDefinition = [[(id )[self delegate] dataColumnDefinitions] objectAtIndex:colIndex]; NSString *columnType = [columnDefinition objectForKey:@"typegrouping"]; @@ -1368,7 +1358,9 @@ static const NSInteger kBlobAsImageFile = 4; NSMutableString *tableMetaData = [NSMutableString string]; if([[self delegate] isKindOfClass:[SPCustomQuery class]]) { [env setObject:@"query" forKey:SPBundleShellVariableDataTableSource]; - NSArray *defs = [[self delegate] dataColumnDefinitions]; + + NSArray *defs = [(id )[self delegate] dataColumnDefinitions]; + if(defs && [defs count] == numColumns) for( c = 0; c < numColumns; c++ ) { NSDictionary *col = NSArrayObjectAtIndex(defs, columnMappings[c]); @@ -1383,7 +1375,9 @@ static const NSInteger kBlobAsImageFile = 4; } else if([[self delegate] isKindOfClass:[SPTableContent class]]) { [env setObject:@"content" forKey:SPBundleShellVariableDataTableSource]; - NSArray *defs = [[self delegate] dataColumnDefinitions]; + + NSArray *defs = [(id )[self delegate] dataColumnDefinitions]; + if(defs && [defs count] == numColumns) for( c = 0; c < numColumns; c++ ) { NSDictionary *col = NSArrayObjectAtIndex(defs, columnMappings[c]); diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h index c34c0bc1..896889f1 100644 --- a/Source/SPCustomQuery.h +++ b/Source/SPCustomQuery.h @@ -31,6 +31,8 @@ // // More info at +#import "SPDatabaseContentViewDelegate.h" + #import #define SP_HELP_TOC_SEARCH_STRING @"contents" @@ -63,8 +65,7 @@ @class SPTablesList; #endif - -@interface SPCustomQuery : NSObject +@interface SPCustomQuery : NSObject { IBOutlet id tableDocumentInstance; IBOutlet id tablesListInstance; diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 18b14c58..9f97e7b4 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -1629,14 +1629,6 @@ return [customQueryView visibleRect]; } -/** - * Provide a getter for the custom query result table's current viewport - */ -- (NSArray *)dataColumnDefinitions -{ - return cqColumnDefinition; -} - /** * Set the selected row indexes to restore on next custom query result table load */ @@ -3280,7 +3272,6 @@ */ - (void)historyItemsHaveBeenUpdated:(id)manager { - // Abort if the connection has been closed already - sign of a closed window if (![mySQLConnection isConnected]) return; @@ -3364,6 +3355,17 @@ } #endif +#pragma mark - +#pragma mark Database content view delegate methods + +/** + * Provide a getter for the custom query result table's current viewport + */ +- (NSArray *)dataColumnDefinitions +{ + return cqColumnDefinition; +} + #pragma mark - #pragma mark Task interaction diff --git a/Source/SPDatabaseContentViewDelegate.h b/Source/SPDatabaseContentViewDelegate.h new file mode 100644 index 00000000..f4d0785b --- /dev/null +++ b/Source/SPDatabaseContentViewDelegate.h @@ -0,0 +1,35 @@ +// +// $Id$ +// +// SPDatabaseContentViewDelegate.h +// sequel-pro +// +// Created by Stuart Connolly (stuconnolly.com) on February 2, 2013. +// Copyright (c) 2013 Stuart Connolly. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +@protocol SPDatabaseContentViewDelegate + +- (NSArray *)dataColumnDefinitions; + +@end diff --git a/Source/SPFavoriteTextFieldCell.m b/Source/SPFavoriteTextFieldCell.m index f9ebd280..313fdc92 100644 --- a/Source/SPFavoriteTextFieldCell.m +++ b/Source/SPFavoriteTextFieldCell.m @@ -34,9 +34,6 @@ @implementation SPFavoriteTextFieldCell -/** - * Init. - */ - (id)init { if ((self = [super init])) { @@ -91,20 +88,26 @@ if ([controlView isFlipped]) { startPoint.y += cellFrame.size.height + 8.5f; endPoint.y += cellFrame.size.height + 8.5f; - } else { + } + else { startPoint.y -= cellFrame.size.height + 8.5f; endPoint.y -= cellFrame.size.height + 8.5f; } [NSGraphicsContext saveGraphicsState]; [[NSColor gridColor] set]; + NSShadow *lineGlow = [[NSShadow alloc] init]; + [lineGlow setShadowBlurRadius:1]; [lineGlow setShadowColor:[[NSColor controlLightHighlightColor] colorWithAlphaComponent:0.75f]]; [lineGlow setShadowOffset:NSMakeSize(0, -1)]; [lineGlow set]; + [NSBezierPath strokeLineFromPoint:startPoint toPoint:endPoint]; + [lineGlow release]; + [NSGraphicsContext restoreGraphicsState]; } } diff --git a/Source/SPFontPreviewTextField.m b/Source/SPFontPreviewTextField.m index 964b5926..5eea2e56 100644 --- a/Source/SPFontPreviewTextField.m +++ b/Source/SPFontPreviewTextField.m @@ -50,10 +50,12 @@ // Take the supplied font and apply all its traits except for a standardised // font size to the text field NSFont *displayFont = [[NSFontManager sharedFontManager] convertFont:theFont toSize:11.0f]; + [super setFont:displayFont]; // Set up a paragraph style for display, setting bounds and display settings NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle new] autorelease]; + [paragraphStyle setAlignment:NSNaturalTextAlignment]; [paragraphStyle setLineBreakMode:NSLineBreakByTruncatingMiddle]; [paragraphStyle setMaximumLineHeight:NSHeight([self bounds]) + [displayFont descender]]; diff --git a/Source/SPPrintAccessory.m b/Source/SPPrintAccessory.m index 2722b574..ce8c950c 100644 --- a/Source/SPPrintAccessory.m +++ b/Source/SPPrintAccessory.m @@ -45,6 +45,7 @@ - (void)awakeFromNib { [self setView:printAccessoryView]; + [defaultsController addObserver:self forKeyPath:@"values.PrintBackground" options:NSKeyValueObservingOptionNew context:@"PrinterSettingsChanged"]; } @@ -63,7 +64,8 @@ if ([(NSString *)context isEqualToString:@"PrinterSettingsChanged"]) { if (printWebView) [[printWebView preferences] setShouldPrintBackgrounds:[[defaultsController valueForKeyPath:@"values.PrintBackground"] boolValue]]; - } else { + } + else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } } @@ -74,12 +76,14 @@ - (void)setPrintView:(WebView *)theWebView { printWebView = theWebView; + [[printWebView preferences] setShouldPrintBackgrounds:[[defaultsController valueForKeyPath:@"values.PrintBackground"] boolValue]]; } - (void)dealloc { [defaultsController removeObserver:self forKeyPath:@"values.PrintBackground"]; + [super dealloc]; } diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h index eb3aa881..2bbdefde 100644 --- a/Source/SPTableContent.h +++ b/Source/SPTableContent.h @@ -51,6 +51,8 @@ @class SPSplitView; #endif +#import "SPDatabaseContentViewDelegate.h" + @interface SPTableContent : NSObject { IBOutlet SPDatabaseDocument *tableDocumentInstance; @@ -284,7 +286,6 @@ - (NSRect) viewport; - (CGFloat) tablesListWidth; - (NSDictionary *) filterSettings; -- (NSArray *)dataColumnDefinitions; - (void) setSortColumnNameToRestore:(NSString *)theSortColumnName isAscending:(BOOL)isAscending; - (void) setPageToRestore:(NSUInteger)thePage; - (void)setSelectionToRestore:(NSDictionary *)theSelection; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 986cffb8..15de8157 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -3899,14 +3899,6 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper return theDictionary; } -/** - * Retrieve the data column definitions - */ -- (NSArray *)dataColumnDefinitions -{ - return dataColumns; -} - /** * Set the sort column and sort order to restore on next table load */ diff --git a/Source/SPTableContentDelegate.h b/Source/SPTableContentDelegate.h index c3bfedd4..94a12305 100644 --- a/Source/SPTableContentDelegate.h +++ b/Source/SPTableContentDelegate.h @@ -32,6 +32,6 @@ #import "SPTableContent.h" -@interface SPTableContent (SPTableContentDelegate) +@interface SPTableContent (SPTableContentDelegate) @end diff --git a/Source/SPTableContentDelegate.m b/Source/SPTableContentDelegate.m index 182386fb..9b11eb3d 100644 --- a/Source/SPTableContentDelegate.m +++ b/Source/SPTableContentDelegate.m @@ -781,4 +781,15 @@ return NO; } +#pragma mark - +#pragma mark Database content view delegate methods + +/** + * Retrieve the data column definitions + */ +- (NSArray *)dataColumnDefinitions +{ + return dataColumns; +} + @end diff --git a/Source/SPTextView.m b/Source/SPTextView.m index 76a80774..fe013503 100644 --- a/Source/SPTextView.m +++ b/Source/SPTextView.m @@ -1790,15 +1790,16 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS currentDb = [tablesListInstance selectedDatabase]; #ifndef SP_CODA - while([theHintString isMatchedByRegex:@"(?)[[aTabView delegate] style] drawBackgroundInRect:tabFrame]; + [(id )[(PSMTabBarControl *)[aTabView delegate] style] drawBackgroundInRect:tabFrame]; + [viewImage unlockFocus]; return [viewImage autorelease]; diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index b8d41ab2..7ffc1841 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -608,6 +608,7 @@ 17148564125F5FF500321285 /* SPDatabaseCharacterSets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDatabaseCharacterSets.m; sourceTree = ""; }; 171B373F15DA654300EBC7AB /* SPTableContentFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPTableContentFilter.h; sourceTree = ""; }; 171B374015DA654300EBC7AB /* SPTableContentFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPTableContentFilter.m; sourceTree = ""; }; + 171C398D16BD634600209EC6 /* SPDatabaseContentViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDatabaseContentViewDelegate.h; sourceTree = ""; }; 17292441107AC41000B21980 /* SPXMLExporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPXMLExporter.h; sourceTree = ""; }; 17292442107AC41000B21980 /* SPXMLExporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPXMLExporter.m; sourceTree = ""; }; 172A650F0F7BED7A001E861A /* SPConsoleMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPConsoleMessage.h; sourceTree = ""; }; @@ -1839,6 +1840,7 @@ BC8C8531100E0A8000D7A129 /* SPTableView.m */, BC398A2B121D526200BE3EF4 /* SPCopyTable.h */, BC398A2C121D526200BE3EF4 /* SPCopyTable.m */, + 171C398D16BD634600209EC6 /* SPDatabaseContentViewDelegate.h */, ); name = "Table Views"; sourceTree = ""; -- cgit v1.2.3