diff options
author | Max <post@wickenrode.com> | 2015-01-06 23:14:21 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-01-06 23:15:49 +0100 |
commit | 56949ac737a3838f3276d0e558fd0dac7632aae5 (patch) | |
tree | 1c24380ce3b6bbc1ddb0a21f7bc9acb948258c6c | |
parent | 4ffde6a4867ae005405f586947cf943097c212c1 (diff) | |
download | sequelpro-56949ac737a3838f3276d0e558fd0dac7632aae5.tar.gz sequelpro-56949ac737a3838f3276d0e558fd0dac7632aae5.tar.bz2 sequelpro-56949ac737a3838f3276d0e558fd0dac7632aae5.zip |
Change some code formatting
-rw-r--r-- | Source/SPDatabaseDocument.m | 25 | ||||
-rw-r--r-- | Source/SPExportController.m | 71 | ||||
-rw-r--r-- | Source/SPTablesList.m | 110 |
3 files changed, 108 insertions, 98 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index a0a6bf1c..269e62d4 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -5312,9 +5312,7 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; } NSInteger itemType = SPTableTypeNone; - NSString *itemTypeStr = @"TABLE"; NSUInteger i; - NSInteger queryCol = 1; // Loop through the unfiltered tables/views to find the desired item for (i = 0; i < [availableItems count]; i++) { @@ -5327,19 +5325,26 @@ static NSString *SPAlterDatabaseAction = @"SPAlterDatabase"; // If no match found, continue if (itemType == SPTableTypeNone) continue; + NSString *itemTypeStr; + NSInteger queryCol; + switch(itemType) { case SPTableTypeTable: case SPTableTypeView: - itemTypeStr = @"TABLE"; - break; + itemTypeStr = @"TABLE"; + queryCol = 1; + break; case SPTableTypeProc: - itemTypeStr = @"PROCEDURE"; - queryCol = 2; - break; + itemTypeStr = @"PROCEDURE"; + queryCol = 2; + break; case SPTableTypeFunc: - itemTypeStr = @"FUNCTION"; - queryCol = 2; - break; + itemTypeStr = @"FUNCTION"; + queryCol = 2; + break; + default: + NSLog(@"%s: Unhandled SPTableType=%ld for item=%@ (skipping)", __func__, itemType, item); + continue; } // Ensure that queries are made in UTF8 diff --git a/Source/SPExportController.m b/Source/SPExportController.m index 752e8521..f650bab9 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -431,45 +431,50 @@ static const NSString *SPSQLExportDropEnabled = @"SQLExportDropEnabled"; [tables removeAllObjects]; // For all modes, retrieve table and view names - NSArray *tablesAndViews = [tablesListInstance allTableAndViewNames]; - - for (id itemName in tablesAndViews) { - [tables addObject:[NSMutableArray arrayWithObjects: - itemName, - @YES, - @YES, - @YES, - [NSNumber numberWithInt:SPTableTypeTable], - nil]]; - } + { + NSArray *tablesAndViews = [tablesListInstance allTableAndViewNames]; + + for (id itemName in tablesAndViews) { + [tables addObject:[NSMutableArray arrayWithObjects: + itemName, + @YES, + @YES, + @YES, + [NSNumber numberWithInt:SPTableTypeTable], + nil]]; + } + } // The purpose of this extra { } is to limit visibility and thus catch copy&paste errors // For SQL only, add procedures and functions if (exportType == SPSQLExport) { - NSArray *procedures = [tablesListInstance allProcedureNames]; - - for (id procName in procedures) + // Procedures { - [tables addObject:[NSMutableArray arrayWithObjects: - procName, - @YES, - @YES, - @YES, - [NSNumber numberWithInt:SPTableTypeProc], - nil]]; + NSArray *procedures = [tablesListInstance allProcedureNames]; + + for (id procName in procedures) { + [tables addObject:[NSMutableArray arrayWithObjects: + procName, + @YES, + @YES, + @YES, + [NSNumber numberWithInt:SPTableTypeProc], + nil]]; + } } - - NSArray *functions = [tablesListInstance allFunctionNames]; - - for (id funcName in functions) + // Functions { - [tables addObject:[NSMutableArray arrayWithObjects: - funcName, - @YES, - @YES, - @YES, - [NSNumber numberWithInt:SPTableTypeFunc], - nil]]; - } + NSArray *functions = [tablesListInstance allFunctionNames]; + + for (id funcName in functions) { + [tables addObject:[NSMutableArray arrayWithObjects: + funcName, + @YES, + @YES, + @YES, + [NSNumber numberWithInt:SPTableTypeFunc], + nil]]; + } + } } if (sender) { diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index aa0d6ea2..1ae2e83f 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -273,13 +273,12 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; [tables addObject:NSLocalizedString(@"PROCS & FUNCS",@"header for procs & funcs list")]; [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeNone]]; - for (NSArray *eachRow in theResult) { - [tables addObject:NSArrayObjectAtIndex(eachRow, 3)]; - if ([NSArrayObjectAtIndex(eachRow, 4) isEqualToString:@"PROCEDURE"]) { - [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeProc]]; - } else { - [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeFunc]]; - } + for (NSArray *eachRow in theResult) { + [tables addObject:NSArrayObjectAtIndex(eachRow, 3)]; + if ([NSArrayObjectAtIndex(eachRow, 4) isEqualToString:@"PROCEDURE"]) { + [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeProc]]; + } else { + [tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeFunc]]; } } } @@ -885,31 +884,31 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; switch (lastType) { case SPTableTypeTable: - [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Tables", @"delete tables menu title")]; - [truncateTableButton setTitle:NSLocalizedString(@"Truncate Tables", @"truncate tables menu item")]; - [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Tables", @"delete tables menu title")]; - [truncateTableContextMenuItem setTitle:NSLocalizedString(@"Truncate Tables", @"truncate tables menu item")]; - [truncateTableButton setHidden:NO]; - [truncateTableContextMenuItem setHidden:NO]; - break; + [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Tables", @"delete tables menu title")]; + [truncateTableButton setTitle:NSLocalizedString(@"Truncate Tables", @"truncate tables menu item")]; + [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Tables", @"delete tables menu title")]; + [truncateTableContextMenuItem setTitle:NSLocalizedString(@"Truncate Tables", @"truncate tables menu item")]; + [truncateTableButton setHidden:NO]; + [truncateTableContextMenuItem setHidden:NO]; + break; case SPTableTypeView: - [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Views", @"delete views menu title")]; - [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Views", @"delete views menu title")]; - [truncateTableButton setHidden:YES]; - [truncateTableContextMenuItem setHidden:YES]; - break; + [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Views", @"delete views menu title")]; + [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Views", @"delete views menu title")]; + [truncateTableButton setHidden:YES]; + [truncateTableContextMenuItem setHidden:YES]; + break; case SPTableTypeProc: - [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Procedures", @"delete procedures menu title")]; - [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Procedures", @"delete procedures menu title")]; - [truncateTableButton setHidden:YES]; - [truncateTableContextMenuItem setHidden:YES]; - break; + [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Procedures", @"delete procedures menu title")]; + [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Procedures", @"delete procedures menu title")]; + [truncateTableButton setHidden:YES]; + [truncateTableContextMenuItem setHidden:YES]; + break; case SPTableTypeFunc: - [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Functions", @"delete functions menu title")]; - [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Functions", @"delete functions menu title")]; - [truncateTableButton setHidden:YES]; - [truncateTableContextMenuItem setHidden:YES]; - break; + [removeTableMenuItem setTitle:NSLocalizedString(@"Delete Functions", @"delete functions menu title")]; + [removeTableContextMenuItem setTitle:NSLocalizedString(@"Delete Functions", @"delete functions menu title")]; + [truncateTableButton setHidden:YES]; + [truncateTableContextMenuItem setHidden:YES]; + break; } } else { @@ -1274,10 +1273,11 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; - (NSArray *)allTableAndViewNames { NSMutableArray *returnArray = [NSMutableArray array]; - NSInteger i; + NSUInteger i; NSInteger cnt = [[self tables] count]; for(i=0; i<cnt; i++) { - if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeTable || [NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeView) + SPTableType tt = (SPTableType)[NSArrayObjectAtIndex([self tableTypes],i) integerValue]; + if(tt == SPTableTypeTable || tt == SPTableTypeView) [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; } return returnArray; @@ -1497,9 +1497,9 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; similarTables = [self allFunctionNames]; break; default: - // if some other table type is given, just return yes - // better a mysql error than not being able to change something at all - return YES; + // if some other table type is given, just return yes + // better a mysql error than not being able to change something at all + return YES; } for(id table in similarTables) { @@ -1783,32 +1783,32 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; switch([NSArrayObjectAtIndex(filteredTableTypes, rowIndex) integerValue]) { case SPTableTypeView: - [aCell setImage:[NSImage imageNamed:@"table-view-small"]]; - [aCell setIndentationLevel:1]; - [aCell setFont:smallSystemFont]; - break; + [aCell setImage:[NSImage imageNamed:@"table-view-small"]]; + [aCell setIndentationLevel:1]; + [aCell setFont:smallSystemFont]; + break; case SPTableTypeTable: - [aCell setImage:[NSImage imageNamed:@"table-small"]]; - [aCell setIndentationLevel:1]; - [aCell setFont:smallSystemFont]; - break; + [aCell setImage:[NSImage imageNamed:@"table-small"]]; + [aCell setIndentationLevel:1]; + [aCell setFont:smallSystemFont]; + break; case SPTableTypeProc: - [aCell setImage:[NSImage imageNamed:@"proc-small"]]; - [aCell setIndentationLevel:1]; - [aCell setFont:smallSystemFont]; - break; + [aCell setImage:[NSImage imageNamed:@"proc-small"]]; + [aCell setIndentationLevel:1]; + [aCell setFont:smallSystemFont]; + break; case SPTableTypeFunc: - [aCell setImage:[NSImage imageNamed:@"func-small"]]; - [aCell setIndentationLevel:1]; - [aCell setFont:smallSystemFont]; - break; + [aCell setImage:[NSImage imageNamed:@"func-small"]]; + [aCell setIndentationLevel:1]; + [aCell setFont:smallSystemFont]; + break; case SPTableTypeNone: - [aCell setImage:nil]; - [aCell setIndentationLevel:0]; - break; + [aCell setImage:nil]; + [aCell setIndentationLevel:0]; + break; default: - [aCell setIndentationLevel:1]; - [aCell setFont:smallSystemFont]; + [aCell setIndentationLevel:1]; + [aCell setFont:smallSystemFont]; } } |