Skip to content

Commit

Permalink
merge some smaller classes (part of #2789)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoagx committed Jan 20, 2018
1 parent 8b221ee commit 0b09642
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 283 deletions.
2 changes: 1 addition & 1 deletion Source/SPCharsetCollationHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#import "SPServerSupport.h"
#import "SPDatabaseData.h"

@interface SPCharsetCollationHelper (Hidden)
@interface SPCharsetCollationHelper ()

- (void)charsetButtonClicked:(id)sender;
- (void)collationButtonClicked:(id)sender;
Expand Down
6 changes: 0 additions & 6 deletions Source/SPContentFilterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
@class SPDatabaseDocument;
@class SPSplitView;

@interface NSObject (SPContentFilterManagerDelegate)

- (void)contentFiltersHaveBeenUpdated:(id)manager;

@end

@interface SPContentFilterManager : NSWindowController <NSOpenSavePanelDelegate>
{
#ifndef SP_CODA /* ivars */
Expand Down
7 changes: 7 additions & 0 deletions Source/SPFieldEditorController.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,10 @@
- (void)setDoGroupDueToChars;

@end

@protocol SPFieldEditorControllerDelegate <NSObject>

@optional
- (void)processFieldEditorResult:(id)data contextInfo:(NSDictionary*)contextInfo;

@end
10 changes: 3 additions & 7 deletions Source/SPFieldEditorController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
HexSegment
} FieldEditorSegment;

@interface SPFieldEditorController (SPFieldEditorControllerDelegate)

- (void)processFieldEditorResult:(id)data contextInfo:(NSDictionary*)contextInfo;

@end

@implementation SPFieldEditorController

@synthesize editedFieldInfo;
Expand Down Expand Up @@ -672,7 +666,9 @@ - (IBAction)closeEditSheet:(id)sender
else if ( [callerInstance isKindOfClass:[SPTableContent class]] )
[(SPTableContent*)callerInstance processFieldEditorResult:returnData contextInfo:contextInfo];
#else
[callerInstance processFieldEditorResult:returnData contextInfo:contextInfo];
if([callerInstance respondsToSelector:@selector(processFieldEditorResult:contextInfo:)]) {
[(id <SPFieldEditorControllerDelegate>)callerInstance processFieldEditorResult:returnData contextInfo:contextInfo];
}
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/SPGotoDatabaseController.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#import "SPGotoDatabaseController.h"

@interface SPGotoDatabaseController (Private)
@interface SPGotoDatabaseController ()

/** Update the list of matched names
* @param filter The string to be matched.
Expand Down
1 change: 1 addition & 0 deletions Source/SPQueryFavoriteManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ - (IBAction)closeQueryManagerSheet:(id)sender
[prefs setObject:[self queryFavoritesForFileURL:nil] forKey:SPQueryFavorites];

// Inform all opened documents to update the query favorites list
#warning This should be done using notifications
for(id doc in [SPAppDelegate orderedDocuments])
if([[doc valueForKeyPath:@"customQueryInstance"] respondsToSelector:@selector(queryFavoritesHaveBeenUpdated:)])
[[doc valueForKeyPath:@"customQueryInstance"] queryFavoritesHaveBeenUpdated:self];
Expand Down
2 changes: 1 addition & 1 deletion Source/SPTableInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#import "SPTableTextFieldCell.h"
#import "SPAppController.h"

@interface SPTableInfo (PrivateAPI)
@interface SPTableInfo ()

- (NSString *)_getUserDefinedDateStringFromMySQLDate:(NSString *)mysqlDate;

Expand Down
51 changes: 51 additions & 0 deletions Source/SPTableRelations.m
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,57 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
return YES;
}

#pragma mark -
#pragma mark TextField delegate methods

- (void)controlTextDidChange:(NSNotification *)notification
{
// Make sure the user does not enter a taken name, using the quickly-generated incomplete list
if ([notification object] == constraintName) {
NSString *userValue = [[constraintName stringValue] lowercaseString];

// Make field red and disable add button
if ([takenConstraintNames containsObject:userValue]) {
[constraintName setTextColor:[NSColor redColor]];
[confirmAddRelationButton setEnabled:NO];
}
else {
[constraintName setTextColor:[NSColor controlTextColor]];
[confirmAddRelationButton setEnabled:YES];
}
}
}

#pragma mark -
#pragma mark Tableview delegate methods

/**
* Called whenever the relations table view selection changes.
*/
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
[removeRelationButton setEnabled:([relationsTableView numberOfSelectedRows] > 0)];
}

/*
* Double-click action on table cells - for the time being, return
* NO to disable editing.
*/
- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
if ([tableDocumentInstance isWorking]) return NO;

return NO;
}

/**
* Disable row selection while the document is working.
*/
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)rowIndex
{
return ![tableDocumentInstance isWorking];
}

#pragma mark -
#pragma mark Private API

Expand Down
35 changes: 0 additions & 35 deletions Source/SPTableRelationsDelegate.h

This file was deleted.

87 changes: 0 additions & 87 deletions Source/SPTableRelationsDelegate.m

This file was deleted.

59 changes: 59 additions & 0 deletions Source/SPTableTriggers.m
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,65 @@ - (void)_removePreferenceObservers
[prefs removeObserver:self forKeyPath:SPDisplayTableViewVerticalGridlines];
}

#pragma mark -
#pragma mark Tableview delegate methods

/**
* Called whenever the triggers table view selection changes.
*/
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
[removeTriggerButton setEnabled:([triggersTableView numberOfSelectedRows] > 0)];
}

/**
* Alter the colour of cells displaying NULL values
*/
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
if (![cell respondsToSelector:@selector(setTextColor:)]) {
return;
}

id value = [[triggerData objectAtIndex:rowIndex] objectForKey:[tableColumn identifier]];

[cell setTextColor:[value isNSNull] ? [NSColor lightGrayColor] : [NSColor blackColor]];
}

/**
* Double-click action on table cells - for the time being, return NO to disable editing.
*/
- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
if ([tableDocumentInstance isWorking]) return NO;

// Start Edit panel
if (((NSInteger)[triggerData count] > rowIndex) && [triggerData objectAtIndex:rowIndex]) {
[self _editTriggerAtIndex:rowIndex];
}

return NO;
}

/**
* Disable row selection while the document is working.
*/
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)rowIndex
{
return (![tableDocumentInstance isWorking]);
}

#pragma mark -
#pragma mark Textfield delegate methods

/**
* Toggles the enabled state of confirm add trigger button based on the editing of the trigger's name.
*/
- (void)controlTextDidChange:(NSNotification *)notification
{
[self _toggleConfirmAddTriggerButtonEnabled];
}

#pragma mark -

- (void)dealloc
Expand Down
33 changes: 0 additions & 33 deletions Source/SPTableTriggersDelegate.h

This file was deleted.

Loading

0 comments on commit 0b09642

Please sign in to comment.