diff options
author | stuconnolly <stuart02@gmail.com> | 2011-07-11 21:47:07 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2011-07-11 21:47:07 +0000 |
commit | fa36e8280a3e3b02bbb39c152bd08061b302f168 (patch) | |
tree | c13dbb4dc4311a4a413de80429e40b720e5e7bca | |
parent | 79bba63e1bed358c458f49351d8c4836c0fec20b (diff) | |
download | sequelpro-fa36e8280a3e3b02bbb39c152bd08061b302f168.tar.gz sequelpro-fa36e8280a3e3b02bbb39c152bd08061b302f168.tar.bz2 sequelpro-fa36e8280a3e3b02bbb39c152bd08061b302f168.zip |
Minor tidy up.
-rw-r--r-- | Source/SPDataCellFormatter.h | 4 | ||||
-rw-r--r-- | Source/SPDataImport.m | 69 | ||||
-rw-r--r-- | Source/SPDatabaseViewController.m | 1 | ||||
-rw-r--r-- | Source/SPExportFileNameTokenObject.h | 8 | ||||
-rw-r--r-- | Source/SPExportFileNameTokenObject.m | 2 | ||||
-rw-r--r-- | Source/SPExportFileUtilities.m | 33 | ||||
-rw-r--r-- | Source/SPTableRelations.m | 6 | ||||
-rw-r--r-- | Source/SPTableTriggers.m | 2 | ||||
-rw-r--r-- | Source/SPUserMO.m | 34 | ||||
-rw-r--r-- | Source/SPWindow.h | 5 | ||||
-rw-r--r-- | Source/SPWindow.m | 1 |
11 files changed, 82 insertions, 83 deletions
diff --git a/Source/SPDataCellFormatter.h b/Source/SPDataCellFormatter.h index c5d9cd99..a2710bf6 100644 --- a/Source/SPDataCellFormatter.h +++ b/Source/SPDataCellFormatter.h @@ -29,7 +29,7 @@ NSString *fieldType; } -@property(readwrite, assign) NSInteger textLimit; -@property(readwrite, retain) NSString* fieldType; +@property (readwrite, assign) NSInteger textLimit; +@property (readwrite, retain) NSString* fieldType; @end diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index d1b2b67a..e5d7e36c 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -45,10 +45,10 @@ #define SP_FILE_READ_ERROR_STRING NSLocalizedString(@"File read error", @"File read error title (Import Dialog)") -@interface SPDataImport (PrivateAPI) +@interface SPDataImport () -- (void) _importBackgroundProcess:(NSString *)filename; -- (void) _resetFieldMappingGlobals; +- (void)_importBackgroundProcess:(NSString *)filename; +- (void)_resetFieldMappingGlobals; @end @@ -1683,56 +1683,29 @@ } #pragma mark - - -/** - * Dealloc. - */ -- (void)dealloc -{ - if (fieldMappingImportArray) [fieldMappingImportArray release]; - if (geometryFields) [geometryFields release]; - if (geometryFieldsMapIndex) [geometryFieldsMapIndex release]; - if (bitFields) [bitFields release]; - if (nullableNumericFields) [nullableNumericFields release]; - if (bitFieldsMapIndex) [bitFieldsMapIndex release]; - if (nullableNumericFieldsMapIndex) [nullableNumericFieldsMapIndex release]; - - if (lastFilename) [lastFilename release]; - if (prefs) [prefs release]; - if(selectedTableTarget) [selectedTableTarget release]; - - for (id retainedObject in nibObjectsToRelease) [retainedObject release]; - - [nibObjectsToRelease release]; - - [super dealloc]; -} - -@end - -@implementation SPDataImport (PrivateAPI) +#pragma mark Private API /** * Starts the import process on a background thread. */ -- (void) _importBackgroundProcess:(NSString *)filename +- (void)_importBackgroundProcess:(NSString *)filename { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *fileType = [[importFormatPopup selectedItem] title]; - + // Use the appropriate processing function for the file type if ([fileType isEqualToString:@"SQL"]) [self importSQLFile:filename]; else if ([fileType isEqualToString:@"CSV"]) [self importCSVFile:filename]; - + [pool release]; } /** * Release and reset any field mapping global variables. */ -- (void) _resetFieldMappingGlobals +- (void)_resetFieldMappingGlobals { if (csvImportTailString) [csvImportTailString release], csvImportTailString = nil; if (csvImportHeaderString) [csvImportHeaderString release], csvImportHeaderString = nil; @@ -1743,4 +1716,30 @@ if (fieldMapperOperator) [fieldMapperOperator release], fieldMapperOperator = nil; } +#pragma mark - + +/** + * Dealloc. + */ +- (void)dealloc +{ + if (fieldMappingImportArray) [fieldMappingImportArray release]; + if (geometryFields) [geometryFields release]; + if (geometryFieldsMapIndex) [geometryFieldsMapIndex release]; + if (bitFields) [bitFields release]; + if (nullableNumericFields) [nullableNumericFields release]; + if (bitFieldsMapIndex) [bitFieldsMapIndex release]; + if (nullableNumericFieldsMapIndex) [nullableNumericFieldsMapIndex release]; + + if (lastFilename) [lastFilename release]; + if (prefs) [prefs release]; + if(selectedTableTarget) [selectedTableTarget release]; + + for (id retainedObject in nibObjectsToRelease) [retainedObject release]; + + [nibObjectsToRelease release]; + + [super dealloc]; +} + @end diff --git a/Source/SPDatabaseViewController.m b/Source/SPDatabaseViewController.m index 171ff8f6..19716a22 100644 --- a/Source/SPDatabaseViewController.m +++ b/Source/SPDatabaseViewController.m @@ -43,7 +43,6 @@ @end - @implementation SPDatabaseDocument (SPDatabaseViewController) #pragma mark - diff --git a/Source/SPExportFileNameTokenObject.h b/Source/SPExportFileNameTokenObject.h index 24022745..76c8fa2e 100644 --- a/Source/SPExportFileNameTokenObject.h +++ b/Source/SPExportFileNameTokenObject.h @@ -22,13 +22,11 @@ // // More info at <http://code.google.com/p/sequel-pro/> -#import <Cocoa/Cocoa.h> - - -@interface SPExportFileNameTokenObject : NSObject<NSCoding> { +@interface SPExportFileNameTokenObject : NSObject<NSCoding> +{ NSString *tokenContent; } -@property(retain) NSString *tokenContent; +@property (retain) NSString *tokenContent; @end diff --git a/Source/SPExportFileNameTokenObject.m b/Source/SPExportFileNameTokenObject.m index 9e589f79..f62c50d2 100644 --- a/Source/SPExportFileNameTokenObject.m +++ b/Source/SPExportFileNameTokenObject.m @@ -24,7 +24,6 @@ #import "SPExportFileNameTokenObject.h" - @implementation SPExportFileNameTokenObject @synthesize tokenContent; @@ -37,6 +36,7 @@ if ((self = [super init])) { [self setTokenContent:[decoder decodeObjectForKey:@"TokenContent"]]; } + return self; } diff --git a/Source/SPExportFileUtilities.m b/Source/SPExportFileUtilities.m index f3ae56e9..b5f30470 100644 --- a/Source/SPExportFileUtilities.m +++ b/Source/SPExportFileUtilities.m @@ -132,7 +132,7 @@ SPExportErrorChoice; */ - (void)errorCreatingExportFileHandles:(NSArray *)files { - // Get the number of files that already exists as well as couldn't be created because of other reasons + // Get the number of files that already exist as well as couldn't be created because of other reasons NSUInteger filesAlreadyExisting = 0; NSUInteger filesFailed = 0; @@ -140,17 +140,25 @@ SPExportErrorChoice; { if ([file exportFileHandleStatus] == SPExportFileHandleExists) { filesAlreadyExisting++; - + } // For file handles that we failed to create for some unknown reason, ignore them and remove any // exporters that are associated with them. - } else if ([file exportFileHandleStatus] == SPExportFileHandleFailed) { + else if ([file exportFileHandleStatus] == SPExportFileHandleFailed) { + filesFailed++; + + NSMutableArray *exportersToRemove = [[NSMutableArray alloc] init]; + for (SPExporter *exporter in exporters) { if ([[exporter exportOutputFile] isEqualTo:file]) { - [exporters removeObject:exporter]; + [exportersToRemove addObject:exporter]; } } + + [exporters removeObjectsInArray:exportersToRemove]; + + [exportersToRemove release]; } } @@ -166,10 +174,12 @@ SPExportErrorChoice; if (filesAlreadyExisting == 1) { [alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"“%@” already exists. Do you want to replace it?", @"Export file already exists message"), [[[files objectAtIndex:0] exportFilePath] lastPathComponent]]]; [alert setInformativeText:[NSString stringWithFormat:@"%@%@", NSLocalizedString(@"A file with the same name already exists in the target folder. Replacing it will overwrite its current contents.", @"Export file already exists explanatory text"), additionalErrors]]; - } else if (filesAlreadyExisting == [exportFiles count]) { + } + else if (filesAlreadyExisting == [exportFiles count]) { [alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"All the export files already exist. Do you want to replace them?", @"All export files already exist message")]]; [alert setInformativeText:[NSString stringWithFormat:@"%@%@", NSLocalizedString(@"Files with the same names already exist in the target folder. Replacing them will overwrite their current contents.", @"All export files already exist explanatory text"), additionalErrors]]; - } else { + } + else { [alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"%lu files already exist. Do you want to replace them?", @"Export file already exists message"), filesAlreadyExisting]]; [alert setInformativeText:[NSString stringWithFormat:@"%@%@", [NSString stringWithFormat:NSLocalizedString(@"%lu files with the same names already exist in the target folder. Replacing them will overwrite their current contents.", @"Some export files already exist explanatory text"), filesAlreadyExisting], additionalErrors]]; } @@ -189,20 +199,21 @@ SPExportErrorChoice; [[[alert buttons] objectAtIndex:2] setKeyEquivalent:@"s"]; [[[alert buttons] objectAtIndex:2] setKeyEquivalentModifierMask:NSCommandKeyMask]; } - + } // If one or multiple files failed, but only due to unhandled errors, show a short dialog - } else { + else { if (filesFailed == 1) { [alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"“%@” could not be created", @"Export file creation error title"), [[[files objectAtIndex:0] exportFilePath] lastPathComponent]]]; [alert setInformativeText:NSLocalizedString(@"An unhandled error occurred when attempting to create the export file. Please check the details and try again.", @"Export file creation error explanatory text")]; - } else if (filesFailed == [exportFiles count]) { + } + else if (filesFailed == [exportFiles count]) { [alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"No files could be created", @"All export files creation error title")]]; [alert setInformativeText:NSLocalizedString(@"An unhandled error occurred when attempting to create each of the export files. Please check the details and try again.", @"All export files creation error explanatory text")]; - } else { + } + else { [alert setMessageText:[NSString stringWithFormat:NSLocalizedString(@"%lu files could not be created", @"Export files creation error title"), filesFailed]]; [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString(@"An unhandled error occurred when attempting to create %lu of the export files. Please check the details and try again.", @"Export files creation error explanatory text"), filesFailed]]; } - [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"cancel button")]; [[[alert buttons] objectAtIndex:0] setTag:SPExportErrorCancelExport]; diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index f6d51cad..01fc4a6e 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -30,7 +30,7 @@ #import "SPTableView.h" #import "SPAlertSheets.h" -@interface SPTableRelations (PrivateAPI) +@interface SPTableRelations () - (void)_refreshRelationDataForcingCacheRefresh:(BOOL)clearAllCaches; - (void)_updateAvailableTableColumns; @@ -553,10 +553,6 @@ [super dealloc]; } -@end - -@implementation SPTableRelations (PrivateAPI) - /** * Refresh the displayed relations, optionally forcing a refresh of the underlying cache. */ diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m index de2c51cd..59fbb673 100644 --- a/Source/SPTableTriggers.m +++ b/Source/SPTableTriggers.m @@ -41,7 +41,7 @@ static const NSString *SPTriggerDefiner = @"TriggerDefiner"; static const NSString *SPTriggerCreated = @"TriggerCreated"; static const NSString *SPTriggerSQLMode = @"TriggerSQLMode"; -@interface SPTableTriggers (PrivateAPI) +@interface SPTableTriggers () - (void)_editTriggerAtIndex:(NSInteger)index; - (void)_toggleConfirmAddTriggerButtonEnabled; diff --git a/Source/SPUserMO.m b/Source/SPUserMO.m index a9e9ddbb..d952f9da 100644 --- a/Source/SPUserMO.m +++ b/Source/SPUserMO.m @@ -24,6 +24,11 @@ #import "SPUserMO.h" +static NSString *SPUserMOParentKey = @"parent"; +static NSString *SPUserMOUserKey = @"user"; +static NSString *SPUserMOHostKey = @"host"; +static NSString *SPUserMOChildrenKey = @"children"; + @implementation NSManagedObject (CoreDataGeneratedAccessors) @dynamic user; @@ -33,23 +38,17 @@ - (NSString *)displayName { - return ([self valueForKey:@"parent"] == nil) ? self.user : self.host; + return ([self valueForKey:SPUserMOParentKey] == nil) ? self.user : self.host; } - (void)setDisplayName:(NSString *)value { - if ([self valueForKey:@"parent"] == nil) - [self setValue:value forKey:@"user"]; + if ([self valueForKey:SPUserMOParentKey] == nil) { + [self setValue:value forKey:SPUserMOUserKey]; + } else { - if (value == nil) - { - [self setValue:@"%" forKey:@"host"]; - } - else - { - [self setValue:value forKey:@"host"]; - } + [self setValue:(value == nil) ? @"%" : value forKey:SPUserMOHostKey]; } } @@ -57,11 +56,12 @@ { NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1]; - [self willChangeValueForKey:@"children" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects]; - [[self primitiveValueForKey:@"children"] addObject:value]; - [self didChangeValueForKey:@"children" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects]; + [self willChangeValueForKey:SPUserMOChildrenKey withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects]; + [[self primitiveValueForKey:SPUserMOChildrenKey] addObject:value]; + [self didChangeValueForKey:SPUserMOChildrenKey withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects]; [changedObjects release]; + value.user = self.user; } @@ -69,9 +69,9 @@ { NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1]; - [self willChangeValueForKey:@"children" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects]; - [[self primitiveValueForKey:@"children"] removeObject:value]; - [self didChangeValueForKey:@"children" withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects]; + [self willChangeValueForKey:SPUserMOChildrenKey withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects]; + [[self primitiveValueForKey:SPUserMOChildrenKey] removeObject:value]; + [self didChangeValueForKey:SPUserMOChildrenKey withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects]; [changedObjects release]; } diff --git a/Source/SPWindow.h b/Source/SPWindow.h index 369ce769..74c4f804 100644 --- a/Source/SPWindow.h +++ b/Source/SPWindow.h @@ -24,9 +24,6 @@ #import <Cocoa/Cocoa.h> - -@interface SPWindow : NSWindow { - -} +@interface SPWindow : NSWindow @end diff --git a/Source/SPWindow.m b/Source/SPWindow.m index 22a096c3..5a485ede 100644 --- a/Source/SPWindow.m +++ b/Source/SPWindow.m @@ -37,7 +37,6 @@ */ - (void) sendEvent:(NSEvent *)theEvent { - if ([theEvent type] == NSKeyDown && [[theEvent charactersIgnoringModifiers] length]) { unichar theCharacter = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; |