diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/NoodleLineNumberView.m | 12 | ||||
-rw-r--r-- | Source/SPConnectionController.h | 3 | ||||
-rw-r--r-- | Source/SPConnectionController.m | 30 | ||||
-rw-r--r-- | Source/SPConnectionControllerDelegate.m | 2 | ||||
-rw-r--r-- | Source/SPConnectionControllerInitializer.m | 6 | ||||
-rw-r--r-- | Source/SPConnectionHandler.m | 2 | ||||
-rw-r--r-- | Source/SPContentFilterManager.h | 2 | ||||
-rw-r--r-- | Source/SPContentFilterManager.m | 8 | ||||
-rw-r--r-- | Source/SPCopyTable.m | 4 | ||||
-rw-r--r-- | Source/SPCustomQuery.h | 10 | ||||
-rw-r--r-- | Source/SPCustomQuery.m | 84 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.h | 15 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.m | 65 | ||||
-rw-r--r-- | Source/SPQueryFavoriteManager.h | 5 | ||||
-rw-r--r-- | Source/SPQueryFavoriteManager.m | 16 | ||||
-rw-r--r-- | Source/SPTableContent.m | 11 | ||||
-rw-r--r-- | Source/SPTableContentDelegate.m | 4 | ||||
-rw-r--r-- | Source/SPTableContentFilter.h | 4 | ||||
-rw-r--r-- | Source/SPTableContentFilter.m | 2 | ||||
-rw-r--r-- | Source/SPTablesList.h | 2 | ||||
-rw-r--r-- | Source/SPTablesList.m | 2 | ||||
-rw-r--r-- | Source/SPTextView.m | 12 |
22 files changed, 218 insertions, 83 deletions
diff --git a/Source/NoodleLineNumberView.m b/Source/NoodleLineNumberView.m index 32bd42f6..1f8e4e50 100644 --- a/Source/NoodleLineNumberView.m +++ b/Source/NoodleLineNumberView.m @@ -79,7 +79,11 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); [self font], NSFontAttributeName, [self textColor], NSForegroundColorAttributeName, nil] retain]; +#ifndef SP_REFACTOR NSSize s = [[NSString stringWithString:@"8"] sizeWithAttributes:textAttributes]; +#else + NSSize s = [@"8" sizeWithAttributes:textAttributes]; +#endif maxWidthOfGlyph = s.width; maxHeightOfGlyph = s.height; [self updateGutterThicknessConstants]; @@ -131,7 +135,11 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); font, NSFontAttributeName, [self textColor], NSForegroundColorAttributeName, nil] retain]; +#ifndef SP_REFACTOR NSSize s = [[NSString stringWithString:@"8"] sizeWithAttributes:textAttributes]; +#else + NSSize s = [@"8" sizeWithAttributes:textAttributes]; +#endif maxWidthOfGlyph = s.width; maxHeightOfGlyph = s.height; [self updateGutterThicknessConstants]; @@ -157,7 +165,11 @@ typedef NSRange (*RangeOfLineIMP)(id object, SEL selector, NSRange range); [self font], NSFontAttributeName, textColor, NSForegroundColorAttributeName, nil] retain]; +#ifndef SP_REFACTOR NSSize s = [[NSString stringWithString:@"8"] sizeWithAttributes:textAttributes]; +#else + NSSize s = [@"8" sizeWithAttributes:textAttributes]; +#endif maxWidthOfGlyph = s.width; maxHeightOfGlyph = s.height; [self updateGutterThicknessConstants]; diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index e0ed6c54..014454bf 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -212,6 +212,9 @@ // Connection processes - (IBAction)initiateConnection:(id)sender; - (IBAction)cancelConnection:(id)sender; +#ifdef SP_REFACTOR +- (BOOL)cancellingConnection; +#endif #ifndef SP_REFACTOR // Interface interaction diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 752c0c00..00ec3283 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -56,10 +56,12 @@ #import <SPMySQL/SPMySQL.h> // Constants +#ifndef SP_REFACTOR static NSString *SPRemoveNode = @"RemoveNode"; static NSString *SPImportFavorites = @"ImportFavorites"; static NSString *SPExportFavorites = @"ExportFavorites"; static NSString *SPExportFavoritesFilename = @"SequelProFavorites.plist"; +#endif @interface NSSavePanel (NSSavePanel_unpublishedUntilSnowLeopardAPI) @@ -327,6 +329,14 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, #endif } +#ifdef SP_REFACTOR +- (BOOL)cancellingConnection +{ + return cancellingConnection; +} +#endif + + #pragma mark - #pragma mark Interface interaction @@ -361,6 +371,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (IBAction)chooseKeyLocation:(NSButton *)sender { +#ifndef SP_REFACTOR NSString *directoryPath = nil; NSString *filePath = nil; keySelectionPanel = [NSOpenPanel openPanel]; @@ -424,6 +435,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, modalDelegate:self didEndSelector:@selector(chooseKeyLocationSheetDidEnd:returnCode:contextInfo:) contextInfo:sender]; +#endif } /** @@ -439,8 +451,10 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (IBAction)updateSSLInterface:(id)sender { +#ifndef SP_REFACTOR [self resizeTabViewToConnectionType:[self type] animating:YES]; [self _startEditingConnection]; +#endif } /** @@ -456,6 +470,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (void)updateSplitViewSize { +#ifndef SP_REFACTOR if ([dbDocument getConnection]) { return; } @@ -463,6 +478,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [connectionSplitView setDelegate:nil]; [connectionSplitView setPosition:[[[databaseConnectionView subviews] objectAtIndex:0] frame].size.width ofDividerAtIndex:0]; [connectionSplitView setDelegate:self]; +#endif } #pragma mark - @@ -981,7 +997,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, } } } -#endif /** * Called after closing the SSH/SSL key selection sheet. @@ -1036,7 +1051,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, /** * Called when the user dismisses either the import of export favorites panels. */ -#ifndef SP_REFACTOR - (void)importExportFavoritesSheetDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { @@ -1085,7 +1099,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, */ - (void)_saveCurrentDetailsCreatingNewFavorite:(BOOL)createNewFavorite validateDetails:(BOOL)validateDetails { - +#ifndef SP_REFACTOR // Complete any active editing if ([[connectionView window] firstResponder]) { [[connectionView window] endEditingFor:[[connectionView window] firstResponder]]; @@ -1342,6 +1356,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, } [[NSNotificationCenter defaultCenter] postNotificationName:SPConnectionFavoritesChangedNotification object:self]; +#endif } /** @@ -1407,7 +1422,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [[NSNotificationCenter defaultCenter] postNotificationName:SPConnectionFavoritesChangedNotification object:self]; } -#endif /** * Sorts the supplied tree node using the supplied sort key. @@ -1498,8 +1512,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, * Updates the favorite's host when the type changes. */ -#ifndef SP_REFACTOR - - (void)_favoriteTypeDidChange { NSDictionary *favorite = [self selectedFavorite]; @@ -1559,8 +1571,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, } } -#endif - /** * Restores the connection interface to its original state. */ @@ -1606,8 +1616,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [connectButton setAction:@selector(initiateConnection:)]; } -#ifndef SP_REFACTOR - /** * Selected the supplied node in the favorites outline view. * @@ -1740,6 +1748,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, return [result stringByReplacingOccurrencesOfString:@"\n" withString:@""]; } +#ifndef SP_REFACTOR /** * Generate a name for the current connection based on any other populated details. * Currently uses the host and database fields. @@ -1805,6 +1814,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2, [progressIndicatorText setHidden:YES]; [(NSView *)favoritesOutlineView display]; } +#endif - (void)_documentWillClose:(NSNotification *)notification { diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m index ac9ef296..191a5b32 100644 --- a/Source/SPConnectionControllerDelegate.m +++ b/Source/SPConnectionControllerDelegate.m @@ -42,9 +42,11 @@ #import "SPTreeNode.h" #endif +#ifndef SP_REFACTOR static NSString *SPDatabaseImage = @"database-small"; static NSString *SPQuickConnectImage = @"quick-connect-icon.pdf"; static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; +#endif @interface SPConnectionController () diff --git a/Source/SPConnectionControllerInitializer.m b/Source/SPConnectionControllerInitializer.m index 688b2016..66c39f2f 100644 --- a/Source/SPConnectionControllerInitializer.m +++ b/Source/SPConnectionControllerInitializer.m @@ -40,7 +40,9 @@ #import "SPDatabaseViewController.h" #import "SPSplitView.h" +#ifndef SP_REFACTOR static NSString *SPConnectionViewNibName = @"ConnectionView"; +#endif @interface SPConnectionController () @@ -152,6 +154,8 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; */ - (void)loadNib { +#ifndef SP_REFACTOR + // Load the connection nib, keeping references to the top-level objects for later release nibObjectsToRelease = [[NSMutableArray alloc] init]; @@ -161,6 +165,8 @@ static NSString *SPConnectionViewNibName = @"ConnectionView"; [nibLoader instantiateNibWithOwner:self topLevelObjects:&connectionViewTopLevelObjects]; [nibObjectsToRelease addObjectsFromArray:connectionViewTopLevelObjects]; [nibLoader release]; + +#endif } /** diff --git a/Source/SPConnectionHandler.m b/Source/SPConnectionHandler.m index 29c6e8fe..79ec0aba 100644 --- a/Source/SPConnectionHandler.m +++ b/Source/SPConnectionHandler.m @@ -213,7 +213,9 @@ static NSString *SPLocalhostAddress = @"127.0.0.1"; if (sshTunnel) [sshTunnel disconnect], [sshTunnel release], sshTunnel = nil; [mySQLConnection release], mySQLConnection = nil; +#ifndef SP_REFACTOR if (!cancellingConnection) [self _restoreConnectionInterface]; +#endif [pool release]; return; diff --git a/Source/SPContentFilterManager.h b/Source/SPContentFilterManager.h index 2268ba2a..ad34621e 100644 --- a/Source/SPContentFilterManager.h +++ b/Source/SPContentFilterManager.h @@ -46,7 +46,9 @@ #endif SPDatabaseDocument *tableDocumentInstance; +#ifndef SP_REFACTOR /* ivars */ NSURL *delegatesFileURL; +#endif IBOutlet id encodingPopUp; IBOutlet id contentFilterTableView; diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m index 064f848d..d24e0faa 100644 --- a/Source/SPContentFilterManager.m +++ b/Source/SPContentFilterManager.m @@ -67,7 +67,9 @@ } tableDocumentInstance = [managerDelegate valueForKeyPath:@"tableDocumentInstance"]; +#ifndef SP_REFACTOR delegatesFileURL = [tableDocumentInstance fileURL]; +#endif filterType = [NSString stringWithString:compareType]; } @@ -104,7 +106,6 @@ [contentFilters addObject:f]; } } -#endif // Build doc-based filters [contentFilters addObject:[NSDictionary dictionaryWithObjectsAndKeys: @@ -119,6 +120,7 @@ for(id fav in [filters objectForKey:filterType]) [contentFilters addObject:[[fav mutableCopy] autorelease]]; } +#endif // Select the first query if any @@ -246,11 +248,13 @@ [contentFilters insertObject:filter atIndex:insertIndex]; } +#ifndef SP_REFACTOR // If the DatabaseDocument is an on-disk document, add the favourite to the bottom of that document's favourites else if (![tableDocumentInstance isUntitled]) { insertIndex = [contentFilters count] - 1; [contentFilters addObject:filter]; } +#endif // Otherwise, add to the bottom of the Global list by default else { @@ -381,11 +385,11 @@ if ([contentFilterTableView numberOfSelectedRows] == 1) [[self window] makeFirstResponder:contentFilterTableView]; +#ifndef SP_REFACTOR // Update current document's content filters in the SPQueryController [[SPQueryController sharedQueryController] replaceContentFilterByArray: [self contentFilterForFileURL:delegatesFileURL] ofType:filterType forFileURL:delegatesFileURL]; -#ifndef SP_REFACTOR // Update global preferences' list id cf = [[prefs objectForKey:SPContentFilters] mutableCopy]; [cf setObject:[self contentFilterForFileURL:nil] forKey:filterType]; diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index a8a7e9fd..a11f3a04 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -1187,8 +1187,8 @@ static const NSInteger kBlobAsImageFile = 4; { // Retrieve the column definition -#if SP_REFACTOR - NSDictionary *columnDefinition; +#ifdef SP_REFACTOR + NSDictionary *columnDefinition = nil; if ( [[self delegate] isKindOfClass:[SPTableContent class]] ) columnDefinition = [[(SPTableContent*)[self delegate] dataColumnDefinitions] objectAtIndex:colIndex]; diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h index ffbe4549..85c52e91 100644 --- a/Source/SPCustomQuery.h +++ b/Source/SPCustomQuery.h @@ -58,11 +58,18 @@ @class SPMySQLFastStreamingResult; @class SPTextView; +#ifdef SP_REFACTOR +@class SPDatabaseDocument; +@class SPTablesList; +#endif + + @interface SPCustomQuery : NSObject <NSTableViewDataSource, NSWindowDelegate, NSTableViewDelegate> { IBOutlet id tableDocumentInstance; IBOutlet id tablesListInstance; +#ifndef SP_REFACTOR IBOutlet id queryFavoritesButton; IBOutlet NSMenuItem *queryFavoritesSearchMenuItem; IBOutlet NSMenuItem *queryFavoritesSaveAsMenuItem; @@ -83,6 +90,7 @@ IBOutlet NSMenuItem *saveHistoryMenuItem; IBOutlet NSMenuItem *copyHistoryMenuItem; IBOutlet NSPopUpButton *encodingPopUp; +#endif IBOutlet SPTextView *textView; IBOutlet SPCopyTable *customQueryView; @@ -107,8 +115,10 @@ IBOutlet NSMenuItem *autouppercaseKeywordsMenuItem; IBOutlet NSMenuItem *commentCurrentQueryMenuItem; IBOutlet NSMenuItem *commentLineOrSelectionMenuItem; +#ifndef SP_REFACTOR IBOutlet NSMenuItem *previousHistoryMenuItem; IBOutlet NSMenuItem *nextHistoryMenuItem; +#endif #ifndef SP_REFACTOR IBOutlet NSWindow *helpWebViewWindow; diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 5abd0ef3..9fc4f1c6 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -206,6 +206,7 @@ */ - (IBAction)chooseQueryFavorite:(id)sender { +#ifndef SP_REFACTOR /* ui manip for query favorites */ if ([queryFavoritesButton indexOfSelectedItem] == 1) { // This should never evaluate to true as we are now performing menu validation, meaning the 'Save Query to Favorites' menu item will @@ -216,9 +217,7 @@ return; } -#ifndef SP_REFACTOR /* ui manip for query favorites */ if ([tableDocumentInstance isUntitled]) [saveQueryFavoriteGlobal setState:NSOnState]; -#endif [NSApp beginSheet:queryFavoritesSheet modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self @@ -236,9 +235,7 @@ return; } -#ifndef SP_REFACTOR /* ui manip for query favorites */ if ([tableDocumentInstance isUntitled]) [saveQueryFavoriteGlobal setState:NSOnState]; -#endif [NSApp beginSheet:queryFavoritesSheet modalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self @@ -248,7 +245,6 @@ else if ([queryFavoritesButton indexOfSelectedItem] == 3) { // init query favorites controller -#ifndef SP_REFACTOR [prefs synchronize]; if(favoritesManager) [favoritesManager release]; @@ -260,15 +256,10 @@ modalDelegate:favoritesManager didEndSelector:nil contextInfo:nil]; -#endif } else if ([queryFavoritesButton indexOfSelectedItem] > 5) { // Choose favorite -#ifndef SP_REFACTOR BOOL replaceContent = [prefs boolForKey:SPQueryFavoriteReplacesContent]; -#else - BOOL replaceContent = YES; -#endif if([[NSApp currentEvent] modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) replaceContent = !replaceContent; @@ -281,6 +272,7 @@ // The actual query strings have been already stored as tooltip [textView insertAsSnippet:[[queryFavoritesButton selectedItem] toolTip] atRange:NSMakeRange([textView selectedRange].location, 0)]; } +#endif } /* @@ -288,19 +280,13 @@ */ - (IBAction)chooseQueryHistory:(id)sender { - #ifndef SP_REFACTOR [prefs synchronize]; -#endif // Choose history item if ([queryHistoryButton indexOfSelectedItem] > 6) { -#ifndef SP_REFACTOR BOOL replaceContent = [prefs boolForKey:SPQueryHistoryReplacesContent]; -#else - BOOL replaceContent = YES; -#endif [textView breakUndoCoalescing]; if([[NSApp currentEvent] modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) replaceContent = !replaceContent; @@ -309,6 +295,7 @@ [textView insertText:[[[SPQueryController sharedQueryController] historyForFileURL:[tableDocumentInstance fileURL]] objectAtIndex:[queryHistoryButton indexOfSelectedItem]-7]]; } +#endif } /** @@ -326,7 +313,7 @@ */ - (IBAction)gearMenuItemSelected:(id)sender { - +#ifndef SP_REFACTOR if ( sender == previousHistoryMenuItem ) { NSInteger numberOfHistoryItems = [[SPQueryController sharedQueryController] numberOfHistoryItemsForFileURL:[tableDocumentInstance fileURL]]; currentHistoryOffsetIndex++; @@ -360,6 +347,7 @@ } historyItemWasJustInserted = NO; } +#endif // "Shift Right" menu item - indent the selection with an additional tab. if (sender == shiftRightMenuItem) { @@ -479,16 +467,13 @@ */ - (IBAction)clearQueryHistory:(id)sender { +#ifndef SP_REFACTOR NSString *infoString; -#ifndef SP_REFACTOR /* if ([tableDocumentInstance isUntitled]) */ if ([tableDocumentInstance isUntitled]) -#endif infoString = NSLocalizedString(@"Are you sure you want to clear the global history list? This action cannot be undone.", @"clear global history list informative message"); -#ifndef SP_REFACTOR /* if ([tableDocumentInstance isUntitled]) */ else infoString = [NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to clear the history list for “%@”? This action cannot be undone.", @"clear history list for “%@” informative message"), [tableDocumentInstance displayName]]; -#endif NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Clear History?", @"clear history message") defaultButton:NSLocalizedString(@"Clear", @"clear button") @@ -509,7 +494,7 @@ modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"clearHistory"]; - +#endif } /* * @@ -783,9 +768,11 @@ [errors setString:[mySQLConnection lastErrorMessage]]; } +#ifndef SP_REFACTOR // add query to history if(!reloadingExistingResult && [usedQuery length]) [self performSelectorOnMainThread:@selector(addHistoryEntry:) withObject:usedQuery waitUntilDone:NO]; +#endif // Update status/errors text NSDictionary *statusDetails = [NSDictionary dictionaryWithObjectsAndKeys: @@ -839,9 +826,8 @@ ]; } } -#ifndef SP_REFACTOR + [[affectedRowsText onMainThread] setStringValue:statusString]; -#endif // Restore automatic query retries [mySQLConnection setRetryQueriesOnConnectionFailure:YES]; @@ -884,7 +870,7 @@ // Scroll the viewport to the saved location selectionViewportToRestore.size = [customQueryView visibleRect].size; - [[customQueryView onMainThread] scrollRectToVisible:selectionViewportToRestore]; + [(SPCopyTable*)[customQueryView onMainThread] scrollRectToVisible:selectionViewportToRestore]; } //query finished @@ -1571,10 +1557,11 @@ // Update font size on the table #ifndef SP_REFACTOR NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; + [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; #else NSFont *tableFont = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; + [customQueryView setRowHeight:2.0f+NSSizeToCGSize([@"{ǞṶḹÜ∑zgyf" sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; #endif - [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; // If there are no table columns to add, return if (!cqColumnDefinition || ![cqColumnDefinition count]) return; @@ -2711,6 +2698,7 @@ */ - (void)controlTextDidChange:(NSNotification *)notification { +#ifndef SP_REFACTOR if ([notification object] == queryFavoriteNameTextField) [saveQueryFavoriteButton setEnabled:[[queryFavoriteNameTextField stringValue] length]]; else if ([notification object] == queryFavoritesSearchField){ @@ -2719,6 +2707,7 @@ else if ([notification object] == queryHistorySearchField) { [self filterQueryHistory:nil]; } +#endif } #ifndef SP_REFACTOR @@ -3284,6 +3273,8 @@ #pragma mark - #pragma mark Query favorites manager delegate methods +#ifndef SP_REFACTOR + /** * Rebuild history popup menu. */ @@ -3352,7 +3343,6 @@ [headerMenuItem setIndentationLevel:0]; [menu addItem:headerMenuItem]; [headerMenuItem release]; -#ifndef SP_REFACTOR for (NSDictionary *favorite in [prefs objectForKey:SPQueryFavorites]) { if (![favorite isKindOfClass:[NSDictionary class]] || ![favorite objectForKey:@"name"]) continue; NSMutableParagraphStyle *paraStyle = [[[NSMutableParagraphStyle alloc] init] autorelease]; @@ -3371,8 +3361,8 @@ [menu addItem:item]; [item release]; } -#endif } +#endif #pragma mark - #pragma mark Task interaction @@ -3464,7 +3454,11 @@ // Result Table Font preference changed else if ([keyPath isEqualToString:SPGlobalResultTableFont]) { NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]; +#ifndef SP_REFACTOR [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; +#else + [customQueryView setRowHeight:2.0f+NSSizeToCGSize([@"{ǞṶḹÜ∑zgyf" sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; +#endif [customQueryView setFont:tableFont]; [customQueryView reloadData]; } @@ -3480,6 +3474,7 @@ return; } +#ifndef SP_REFACTOR if ([contextInfo isEqualToString:@"clearHistory"]) { if (returnCode == NSOKButton) { // Remove items in the query controller @@ -3490,7 +3485,6 @@ if ([contextInfo isEqualToString:@"addAllToNewQueryFavorite"] || [contextInfo isEqualToString:@"addSelectionToNewQueryFavorite"]) { if (returnCode == NSOKButton) { -#ifndef SP_REFACTOR // Add the new query favorite directly the user's preferences here instead of asking the manager to do it // as it may not have been fully initialized yet. @@ -3528,24 +3522,22 @@ [saveQueryFavoriteGlobal setState:NSOffState]; [self queryFavoritesHaveBeenUpdated:nil]; -#endif - } } [queryFavoriteNameTextField setStringValue:@""]; +#endif } - (void)savePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(id)contextInfo { +#ifndef SP_REFACTOR if([contextInfo isEqualToString:@"saveHistory"]) { if (returnCode == NSOKButton) { NSError *error = nil; -#ifndef SP_REFACTOR [prefs setInteger:[[encodingPopUp selectedItem] tag] forKey:SPLastSQLFileEncoding]; [prefs synchronize]; -#endif [[self buildHistoryString] writeToURL:[panel URL] atomically:YES @@ -3555,6 +3547,7 @@ if (error) [[NSAlert alertWithError:error] runModal]; } } +#endif } /** @@ -3562,6 +3555,7 @@ */ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { +#ifndef SP_REFACTOR // Control "Save ... to Favorites" if ( [menuItem tag] == SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG ) { if ([[textView string] length] < 1) return NO; @@ -3583,17 +3577,13 @@ } // Control Clear History menu item title according to isUntitled else if ( [menuItem tag] == SP_HISTORY_CLEAR_MENUITEM_TAG ) { -#ifndef SP_REFACTOR /* if ( [tableDocumentInstance isUntitled] ) */ if ( [tableDocumentInstance isUntitled] ) { -#endif [menuItem setTitle:NSLocalizedString(@"Clear Global History", @"clear global history menu item title")]; [menuItem setToolTip:NSLocalizedString(@"Clear the global history list", @"clear the global history list tooltip message")]; -#ifndef SP_REFACTOR /* if ( [tableDocumentInstance isUntitled] ) */ } else { [menuItem setTitle:[NSString stringWithFormat:NSLocalizedString(@"Clear History for “%@”", @"clear history for “%@” menu title"), [tableDocumentInstance displayName]]]; [menuItem setToolTip:NSLocalizedString(@"Clear the document-based history list", @"clear the document-based history list tooltip message")]; } -#endif } // Check for History items else if ( [menuItem tag] >= SP_HISTORY_COPY_MENUITEM_TAG && [menuItem tag] <= SP_HISTORY_CLEAR_MENUITEM_TAG ) { @@ -3601,6 +3591,9 @@ } return YES; +#else + return NO; +#endif } - (void)processFieldEditorResult:(id)data contextInfo:(NSDictionary*)contextInfo @@ -3650,7 +3643,11 @@ { if ((self = [super init])) { +#ifndef SP_REFACTOR usedQuery = [[NSString stringWithString:@""] retain]; +#else + usedQuery = [@"" retain]; +#endif lastExecutedQuery = nil; fieldIDQueryString = nil; sortField = nil; @@ -3706,6 +3703,7 @@ return self; } +#ifndef SP_REFACTOR /** * Filters the query favorites menu. */ @@ -3734,6 +3732,7 @@ [[menu itemAtIndex:i] setHidden:(![[history objectAtIndex:i - 7] isMatchedByRegex:[NSString stringWithFormat:@"(?i).*%@.*", [queryHistorySearchField stringValue]]])]; } } +#endif /** * If user selected a table cell which is a blob field and tried to edit it @@ -3819,6 +3818,7 @@ */ - (BOOL)control:(NSControl*)control textView:(NSTextView*)aTextView doCommandBySelector:(SEL)command { +#ifndef SP_REFACTOR if(control == queryHistorySearchField || control == queryFavoritesSearchField) { if(command == @selector(moveDown:) || command == @selector(moveUp:)) { [queryHistorySearchField abortEditing]; @@ -3836,10 +3836,16 @@ } } - else if([control isKindOfClass:[SPCopyTable class]]) { + else +#endif + if([control isKindOfClass:[SPCopyTable class]]) { // Check firstly if SPCopyTable can handle command +#ifndef SP_REFACTOR if([customQueryView control:control textView:aTextView doCommandBySelector:(SEL)command]) +#else + if([customQueryView control:control textView:aTextView doCommandBySelector:command]) +#endif return YES; // Trap the escape key @@ -3867,9 +3873,11 @@ [customQueryView setFieldEditorSelectedRange:NSMakeRange(0,0)]; +#ifndef SP_REFACTOR // Set pre-defined menu tags [queryFavoritesSaveAsMenuItem setTag:SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG]; [queryFavoritesSaveAllMenuItem setTag:SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG]; +#endif // Set up the split views [queryEditorSplitView setMinSize:100 ofSubviewAtIndex:0]; diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index ac9f45bc..9f9b72b2 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -37,7 +37,9 @@ @class SPConnectionController; -#ifndef SP_REFACTOR /* class forward decls */ +#ifdef SP_REFACTOR +@class BottomBarSegmentedControl; +#else @class SPProcessListController; @class SPServerVariablesController; @class SPUserManager; @@ -79,8 +81,10 @@ IBOutlet SPTableData* tableDataInstance; IBOutlet id extendedTableInfoInstance; IBOutlet id databaseDataInstance; +#ifndef SP_REFACTOR IBOutlet id spHistoryControllerInstance; IBOutlet id exportControllerInstance; +#endif IBOutlet id statusTableAccessoryView; IBOutlet id statusTableView; @@ -232,12 +236,14 @@ NSString *queryEditorInitString; +#ifndef SP_REFACTOR /* ivars */ NSURL *spfFileURL; NSDictionary *spfSession; NSMutableDictionary *spfPreferences; NSMutableDictionary *spfDocData; NSMutableArray *runningActivitiesArray; +#endif NSString *keyChainID; @@ -267,6 +273,8 @@ @property (assign) SPDatabaseData* databaseDataInstance; @property (assign) SPTableData* tableDataInstance; @property (assign) SPCustomQuery* customQueryInstance; +@property (assign) BottomBarSegmentedControl* structureContentSwitcher; + @property (assign) id databaseNameField; @property (assign) id databaseEncodingButton; @property (assign) id addDatabaseButton; @@ -413,11 +421,11 @@ - (NSString *)user; - (NSString *)keyChainID; - (NSString *)connectionID; +#ifndef SP_REFACTOR /* method decls */ - (NSString *)tabTitleForTooltip; - (BOOL)isSaveInBundle; - (NSURL *)fileURL; - (NSString *)displayName; -#ifndef SP_REFACTOR /* method decls */ - (NSUndoManager *)undoManager; #endif - (NSArray *)allTableNames; @@ -453,8 +461,8 @@ // Tab methods - (void)makeKeyDocument; -- (BOOL)parentTabShouldClose; #endif +- (BOOL)parentTabShouldClose; - (void)parentTabDidClose; #ifndef SP_REFACTOR - (void)willResignActiveTabInWindow; @@ -486,6 +494,7 @@ #ifdef SP_REFACTOR /* method decls */ - (SPConnectionController*)createConnectionController; +- (SPConnectionController*)connectionController; - (void)connect; - (void)setTableSourceInstance:(SPTableStructure*)source; - (void)setTableContentInstance:(SPTableContent*)content; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 92e45d18..9c92a6f3 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -207,11 +207,13 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #endif queryEditorInitString = nil; +#ifndef SP_REFACTOR spfFileURL = nil; spfSession = nil; spfPreferences = [[NSMutableDictionary alloc] init]; spfDocData = [[NSMutableDictionary alloc] init]; runningActivitiesArray = [[NSMutableArray alloc] init]; +#endif titleAccessoryView = nil; #ifndef SP_REFACTOR /* init ivars */ @@ -496,7 +498,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [tableTriggersInstance setConnection:mySQLConnection]; [customQueryInstance setConnection:mySQLConnection]; [tableDumpInstance setConnection:mySQLConnection]; +#ifndef SP_REFACTOR [exportControllerInstance setConnection:mySQLConnection]; +#endif [tableDataInstance setConnection:mySQLConnection]; [extendedTableInfoInstance setConnection:mySQLConnection]; @@ -2492,7 +2496,6 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [mySQLConnection setDelegateQueryLogging:[[change objectForKey:NSKeyValueChangeNewKey] boolValue]]; } } -#endif /** * Is current document Untitled? @@ -2501,6 +2504,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; { return (!_isSavedInBundle && [self fileURL] && [[self fileURL] isFileURL]) ? NO : YES; } +#endif /** * Asks any currently editing views to commit their changes; @@ -2600,6 +2604,8 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; /** * Returns the full window title which is mainly used for tab tooltips */ +#ifndef SP_REFACTOR + - (NSString *)tabTitleForTooltip { NSMutableString *tabTitle; @@ -2634,6 +2640,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } return tabTitle; } + +#endif + /** * Returns the currently selected database */ @@ -3397,6 +3406,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [customQueryInstance showHelpFor:SP_HELP_TOC_SEARCH_STRING addToHistory:YES calledByAutoHelp:NO]; [[customQueryInstance helpWebViewWindow] makeKeyWindow]; } +#endif /** * Forwards a responder request to set the focus to the table list filter area or table list @@ -3421,6 +3431,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [menuItem action] == @selector(closeTab:)); } +#ifndef SP_REFACTOR if ([menuItem action] == @selector(openCurrentConnectionInNewWindow:)) { if ([self isUntitled]) { @@ -3432,6 +3443,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return YES; } } +#endif // Data export if ([menuItem action] == @selector(export:)) { @@ -3497,6 +3509,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return YES; } +#ifndef SP_REFACTOR if ([menuItem action] == @selector(printDocument:)) { return (([self database] != nil && [[tablesListInstance valueForKeyPath:@"tablesListView"] numberOfSelectedRows] == 1) || // If Custom Query Tab is active the textView will handle printDocument by itself @@ -3504,6 +3517,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // if no db/table is selected [tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 2); } +#endif if ([menuItem action] == @selector(chooseEncoding:)) { return [self supportsEncoding]; @@ -3521,6 +3535,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return [[[tablesListInstance valueForKeyPath:@"tablesListView"] selectedRowIndexes] count]; } +#ifndef SP_REFACTOR if ([menuItem action] == @selector(addConnectionToFavorites:)) { return ![connectionController selectedFavorite]; } @@ -3534,6 +3549,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; if (([menuItem action] == @selector(backForwardInHistory:)) && ([menuItem tag] == 1)) { return (([[spHistoryControllerInstance history] count]) && (([spHistoryControllerInstance historyPosition] + 1) < [[spHistoryControllerInstance history] count])); } +#endif // Show/hide console if ([menuItem action] == @selector(toggleConsole:)) { @@ -3581,6 +3597,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (IBAction)addConnectionToFavorites:(id)sender { +#ifndef SP_REFACTOR // Obviously don't add if it already exists. We shouldn't really need this as the menu item validation // enables or disables the menu item based on the same method. Although to be safe do the check anyway // as we don't know what's calling this method. @@ -3588,6 +3605,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // Request the connection controller to add its details to favorites [connectionController addFavorite:self]; +#endif } /** @@ -3595,7 +3613,11 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (BOOL)isCustomQuerySelected { +#ifndef SP_REFACTOR return [[self selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarCustomQuery]; +#else + return ([_structureContentSwitcher selectedSegment] == 2); +#endif } /** @@ -3603,6 +3625,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { +#ifndef SP_REFACTOR if (returnCode == NSOKButton) { if ([contextInfo isEqualToString:SPCreateSyntx]) { @@ -3615,6 +3638,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } } } +#endif } /** @@ -3633,6 +3657,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void) updateWindowTitle:(id)sender { +#ifndef SP_REFACTOR // Ensure a call on the main thread if (![NSThread isMainThread]) return [[self onMainThread] updateWindowTitle:sender]; @@ -3703,6 +3728,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // If the sender wasn't the window controller, update other tabs in this window // for shared pathname updates if ([sender class] != [SPWindowController class]) [parentWindowController updateAllTabTitles:self]; +#endif } /** @@ -3710,17 +3736,21 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)setStatusIconToImageWithName:(NSString *)imageName { +#ifndef SP_REFACTOR NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageName ofType:@"png"]; if (!imagePath) return; NSImage *image = [[[NSImage alloc] initByReferencingFile:imagePath] autorelease]; [titleImageView setImage:image]; +#endif } - (void)setTitlebarStatus:(NSString *)status { +#ifndef SP_REFACTOR [self clearStatusIcon]; [titleStringView setStringValue:status]; +#endif } /** @@ -3728,7 +3758,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)clearStatusIcon { +#ifndef SP_REFACTOR [titleImageView setImage:nil]; +#endif } /** @@ -3737,6 +3769,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; */ - (void)updateTitlebarStatusVisibilityForcingHide:(BOOL)forceHide { +#ifndef SP_REFACTOR BOOL newIsVisible = !forceHide; if (newIsVisible && [parentWindow styleMask] & NSFullScreenWindowMask) newIsVisible = NO; if (newIsVisible && [parentWindowController selectedTableDocument] != self) newIsVisible = NO; @@ -3757,11 +3790,14 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } windowTitleStatusViewIsVisible = newIsVisible; +#endif } #pragma mark - #pragma mark Toolbar Methods +#ifndef SP_REFACTOR + /** * set up the standard toolbar */ @@ -4017,6 +4053,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return YES; } +#endif + + #pragma mark - #pragma mark Tab methods @@ -4027,7 +4066,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; - (void)makeKeyDocument { [[[self parentWindow] onMainThread] makeKeyAndOrderFront:self]; +#ifndef SP_REFACTOR [[[[self parentTabViewItem] onMainThread] tabView] selectTabViewItemWithIdentifier:self]; +#endif } /** @@ -4046,6 +4087,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // edits in progress in various views. if ( ![tablesListInstance selectionShouldChangeInTableView:nil] ) return NO; +#ifndef SP_REFACTOR // Auto-save spf file based connection and return if the save was not successful if([self fileURL] && [[[self fileURL] path] length] && ![self isUntitled]) { BOOL isSaved = [self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:YES contextInfo:nil]; @@ -4072,11 +4114,11 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; // Note that this call does not need to be removed in release builds as leaks analysis output is only // dumped if [[SPLogger logger] setDumpLeaksOnTermination]; has been called first. [[SPLogger logger] dumpLeaks]; - +#endif // Return YES by default return YES; } -#endif + /** * Invoked when the parent tab is about to close @@ -4236,10 +4278,12 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; /** * Retrieve the NSURL for the .spf file for this connection instance (if any) */ +#ifndef SP_REFACTOR - (NSURL *)fileURL { return [[spfFileURL copy] autorelease]; } +#endif #ifndef SP_REFACTOR /* writeSafelyToURL: */ /** @@ -4268,7 +4312,6 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; || [[[[SPQueryController sharedQueryController] contentFilterForFileURL:[self fileURL]] objectForKey:@"string"] count]) ); } -#endif /** * The window title for this document. @@ -4283,15 +4326,11 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; return [[[self fileURL] path] lastPathComponent]; } -#ifndef SP_REFACTOR - (NSUndoManager *)undoManager { return undoManager; } -#endif - -#ifndef SP_REFACTOR /* state saving and setting */ #pragma mark - #pragma mark State saving and setting @@ -4924,6 +4963,12 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; #ifdef SP_REFACTOR + +- (SPConnectionController*)connectionController +{ + return connectionController; +} + - (void)databaseDocumentConnectionFailed:(id)sender { if ( delegate && [delegate respondsToSelector:@selector(databaseDocumentConnectionFailed:)] ) @@ -6161,10 +6206,12 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; if (taskFadeInStartDate) [taskFadeInStartDate release]; #endif if (queryEditorInitString) [queryEditorInitString release]; +#ifndef SP_REFACTOR if (spfFileURL) [spfFileURL release]; if (spfPreferences) [spfPreferences release]; if (spfSession) [spfSession release]; if (spfDocData) [spfDocData release]; +#endif if (keyChainID) [keyChainID release]; #ifndef SP_REFACTOR if (mainToolbar) [mainToolbar release]; @@ -6176,8 +6223,8 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; if (serverSupport) [serverSupport release]; #ifndef SP_REFACTOR /* dealloc ivars */ if (processID) [processID release]; -#endif if (runningActivitiesArray) [runningActivitiesArray release]; +#endif #ifdef SP_REFACTOR if (tablesListInstance) [tablesListInstance release]; diff --git a/Source/SPQueryFavoriteManager.h b/Source/SPQueryFavoriteManager.h index 017e3cc1..cb5c4dd5 100644 --- a/Source/SPQueryFavoriteManager.h +++ b/Source/SPQueryFavoriteManager.h @@ -44,9 +44,9 @@ { #ifndef SP_REFACTOR /* ivars */ NSUserDefaults *prefs; -#endif NSURL *delegatesFileURL; +#endif SPDatabaseDocument *tableDocumentInstance; IBOutlet NSPopUpButton *encodingPopUp; IBOutlet NSTableView *favoritesTableView; @@ -65,6 +65,8 @@ - (id)initWithDelegate:(id)managerDelegate; +#ifndef SP_REFACTOR + // Accessors - (NSMutableArray *)queryFavoritesForFileURL:(NSURL *)fileURL; - (id)customQueryInstance; @@ -85,5 +87,6 @@ - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo; - (void)importPanelDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo; - (void)savePanelDidEnd:(NSSavePanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo; +#endif @end diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m index 485aa3ff..c645ce47 100644 --- a/Source/SPQueryFavoriteManager.m +++ b/Source/SPQueryFavoriteManager.m @@ -73,7 +73,9 @@ return nil; } tableDocumentInstance = [managerDelegate valueForKeyPath:@"tableDocumentInstance"]; +#ifndef SP_REFACTOR delegatesFileURL = [tableDocumentInstance fileURL]; +#endif } return self; @@ -84,6 +86,7 @@ */ - (void)awakeFromNib { +#ifndef SP_REFACTOR [favorites addObject:[NSDictionary dictionaryWithObjectsAndKeys: @"Global", @"name", @"", @"headerOfFileURL", @@ -94,14 +97,12 @@ [favoritesSplitView setMinSize:152.f ofSubviewAtIndex:0]; [favoritesSplitView setMinSize:385.f ofSubviewAtIndex:1]; -#ifndef SP_REFACTOR // Build data source for global queryFavorites (as mutable copy! otherwise each // change will be stored in the prefs at once) if([prefs objectForKey:SPQueryFavorites]) { for(id fav in [prefs objectForKey:SPQueryFavorites]) [favorites addObject:[[fav mutableCopy] autorelease]]; } -#endif [favorites addObject:[NSDictionary dictionaryWithObjectsAndKeys: [[[delegatesFileURL absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] lastPathComponent], @"name", @@ -131,6 +132,7 @@ // Set Remove button state [removeButton setEnabled:([favoritesTableView numberOfSelectedRows] > 0)]; +#endif } #pragma mark - @@ -140,6 +142,7 @@ * Returns the query favorites array for fileURL. * fileURL == nil → global favorites */ +#ifndef SP_REFACTOR - (NSMutableArray *)queryFavoritesForFileURL:(NSURL *)fileURL { NSMutableArray *favs = [NSMutableArray array]; @@ -174,6 +177,7 @@ return favs; } +#endif /** * This method is only implemented to be compatible with SPTextView. @@ -191,6 +195,7 @@ */ - (IBAction)addQueryFavorite:(id)sender { +#ifndef SP_REFACTOR NSMutableDictionary *favorite; NSUInteger insertIndex; @@ -234,6 +239,7 @@ [removeButton setEnabled:([favoritesTableView numberOfSelectedRows] > 0)]; [[self window] makeFirstResponder:favoriteNameTextField]; +#endif } /** @@ -434,6 +440,7 @@ */ - (IBAction)closeQueryManagerSheet:(id)sender { +#ifndef SP_REFACTOR // First check for ESC if pressed while inline editing if(![sender tag] && isTableCellEditing) { @@ -458,10 +465,8 @@ [[SPQueryController sharedQueryController] replaceFavoritesByArray: [self queryFavoritesForFileURL:delegatesFileURL] forFileURL:delegatesFileURL]; -#ifndef SP_REFACTOR // Update global preferences' list [prefs setObject:[self queryFavoritesForFileURL:nil] forKey:SPQueryFavorites]; -#endif // Inform all opened documents to update the query favorites list for(id doc in [[NSApp delegate] orderedDocuments]) @@ -470,13 +475,16 @@ } +#endif } +#ifndef SP_REFACTOR - (IBAction)showHelp:(id)sender { [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:NSLocalizedString(@"http://www.sequelpro.com/docs/Query_Favorites", @"Localized help page for query favourites - do not localize if no translated webpage is available")]]; } +#endif #pragma mark - #pragma mark TableView datasource methods diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 9c03618e..a587c945 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -68,7 +68,9 @@ #import <pthread.h> #import <SPMySQL/SPMySQL.h> +#ifndef SP_REFACTOR static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOperator"; +#endif @interface SPTableContent () @@ -529,10 +531,11 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper NSString *nullValue = [prefs objectForKey:SPNullValue]; #ifndef SP_REFACTOR /* get font from prefs */ NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; + [tableContentView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; #else NSFont *tableFont = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; + [tableContentView setRowHeight:2.0f+NSSizeToCGSize([@"{ǞṶḹÜ∑zgyf" sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; #endif - [tableContentView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; // Add the new columns to the table and filterTable for ( i = 0 ; i < (NSInteger)[dataColumns count] ; i++ ) { @@ -1483,7 +1486,11 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper */ - (IBAction)filterTable:(id)sender { - BOOL senderIsPaginationButton = (sender == paginationPreviousButton || sender == paginationNextButton || sender == paginationGoButton); + BOOL senderIsPaginationButton = (sender == paginationPreviousButton || sender == paginationNextButton +#ifndef SP_REFACTOR + || sender == paginationGoButton +#endif + ); // Record whether the filter is being triggered by using delete/backspace in the filter field, which // can trigger the effect of clicking the "clear filter" button in the field. diff --git a/Source/SPTableContentDelegate.m b/Source/SPTableContentDelegate.m index e1976762..69a8f953 100644 --- a/Source/SPTableContentDelegate.m +++ b/Source/SPTableContentDelegate.m @@ -762,7 +762,7 @@ // Check firstly if SPCopyTable can handle command if ([control control:control textView:textView doCommandBySelector:(SEL)command]) #else - if ([control control:control textView:textView doCommandBySelector:(SEL)command]) + if ([control control:control textView:textView doCommandBySelector:command]) #endif return YES; @@ -771,7 +771,7 @@ // Abort editing [control abortEditing]; - if (control == tableContentView) { + if ((SPCopyTable*)control == tableContentView) { [self cancelRowEditing]; } diff --git a/Source/SPTableContentFilter.h b/Source/SPTableContentFilter.h index 1efe8039..b108e02c 100644 --- a/Source/SPTableContentFilter.h +++ b/Source/SPTableContentFilter.h @@ -32,12 +32,8 @@ @interface SPTableContent (SPTableContentFilter) -#ifndef SP_REFACTOR - - (void)makeContentFilterHaveFocus; - (void)updateFilterTableClause:(id)currentValue; - (NSString*)escapeFilterTableDefaultOperator:(NSString*)operator; -#endif - @end diff --git a/Source/SPTableContentFilter.m b/Source/SPTableContentFilter.m index 8d2c80ce..b3d032de 100644 --- a/Source/SPTableContentFilter.m +++ b/Source/SPTableContentFilter.m @@ -61,7 +61,6 @@ */ - (void)updateFilterTableClause:(id)currentValue { -#ifndef SP_REFACTOR NSMutableString *clause = [NSMutableString string]; NSInteger numberOfRows = [self numberOfRowsInTableView:filterTableView]; NSInteger numberOfCols = [[filterTableView tableColumns] count]; @@ -216,7 +215,6 @@ if ([filterTableLiveSearchCheckbox state] == NSOnState) { [self filterTable:filterTableFilterButton]; } -#endif } /** diff --git a/Source/SPTablesList.h b/Source/SPTablesList.h index 1d4fd6ca..81ee3bbb 100644 --- a/Source/SPTablesList.h +++ b/Source/SPTablesList.h @@ -164,10 +164,8 @@ // Getters - (NSArray *)selectedTableNames; -#ifndef SP_REFACTOR /* method decls */ - (NSArray *)selectedTableItems; - (NSArray *)selectedTableTypes; -#endif - (NSString *)tableName; - (SPTableType)tableType; - (NSArray *)tables; diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 93ebfe91..3fd71139 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -1114,7 +1114,6 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; return selTables; } -#ifndef SP_REFACTOR /* getters */ - (NSArray *)selectedTableItems { NSIndexSet *indexes = [tablesListView selectedRowIndexes]; @@ -1142,7 +1141,6 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; } return selTables; } -#endif /** * Returns the currently selected table or nil if no table or mulitple tables are selected diff --git a/Source/SPTextView.m b/Source/SPTextView.m index 9a29460e..f659a3cd 100644 --- a/Source/SPTextView.m +++ b/Source/SPTextView.m @@ -86,7 +86,9 @@ @interface SPTextView (Private_API) NSInteger _alphabeticSort(id string1, id string2, void *reverse); +#ifndef SP_REFACTOR - (void)_setTextSelectionColor:(NSColor *)newSelectionColor onBackgroundColor:(NSColor *)aBackgroundColor; +#endif - (void)_positionCompletionPopup:(SPNarrowDownCompletion *)aPopup relativeToTextAtLocation:(NSUInteger)aLocation; @end @@ -318,7 +320,11 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS { NSMutableArray *possibleCompletions = [[NSMutableArray alloc] initWithCapacity:32]; +#ifndef SP_REFACTOR if(currentWord == nil) currentWord = [NSString stringWithString:@""]; +#else + if(currentWord == nil) currentWord = @""; +#endif // If caret is not inside backticks add keywords and all words coming from the view. if(!dbBrowseMode) { @@ -2911,7 +2917,11 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS #endif if(tabStopWidth < 1) tabStopWidth = 1; +#ifndef SP_REFACTOR float tabWidth = NSSizeToCGSize([[NSString stringWithString:@" "] sizeWithAttributes:[NSDictionary dictionaryWithObject:tvFont forKey:NSFontAttributeName]]).width; +#else + float tabWidth = NSSizeToCGSize([@" " sizeWithAttributes:[NSDictionary dictionaryWithObject:tvFont forKey:NSFontAttributeName]]).width; +#endif tabWidth = (float)tabStopWidth * tabWidth; NSInteger numberOfTabs = 256/tabStopWidth; @@ -3715,6 +3725,7 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse) return [string1 localizedCaseInsensitiveCompare:string2]; } +#ifndef SP_REFACTOR /** * Take a supplied text selection colour, and if it contains an alpha component, * pre-multiply it by the background colour before setting it to avoid drawing problems. @@ -3738,6 +3749,7 @@ NSInteger _alphabeticSort(id string1, id string2, void *reverse) // Set the selection colour [self setSelectedTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:newSelectionColor, NSBackgroundColorAttributeName, nil]]; } +#endif /** * Take a supplied autocompletion popup, and position it to the correct position |