From 95250e0f0c5780ac113a9a4c948c452038b4c02a Mon Sep 17 00:00:00 2001 From: Max Lohrmann Date: Sun, 12 Mar 2017 09:46:59 +0100 Subject: Replace some legacy NSIndexSet enumeration with 10.6+ style -enumerateIndexesUsingBlock: --- Source/SPTableRelations.m | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'Source/SPTableRelations.m') diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index f358d133..64a7b98b 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -529,10 +529,7 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; NSString *thisTable = [tablesListInstance tableName]; NSIndexSet *selectedSet = [relationsTableView selectedRowIndexes]; - NSUInteger row = [selectedSet lastIndex]; - - while (row != NSNotFound) - { + [selectedSet enumerateIndexesWithOptions:NSEnumerationReverse usingBlock:^(NSUInteger row, BOOL * _Nonnull stop) { NSString *relationName = [[relationData objectAtIndex:row] objectForKey:SPRelationNameKey]; NSString *query = [NSString stringWithFormat:@"ALTER TABLE %@ DROP FOREIGN KEY %@", [thisTable backtickQuotedString], [relationName backtickQuotedString]]; @@ -547,11 +544,9 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; ); // Abort loop - break; - } - - row = [selectedSet indexLessThanIndex:row]; - } + *stop = YES; + } + }]; [self _refreshRelationDataForcingCacheRefresh:YES]; } -- cgit v1.2.3 From 5f1b37e21c113101b2d72124f6dbd22b77a4fddc Mon Sep 17 00:00:00 2001 From: Stuart Connolly Date: Tue, 28 Mar 2017 23:15:10 +0100 Subject: Move table relations delegate methods into their own catrgory to be consistent with other controllers. --- Source/SPTableRelations.m | 56 ++--------------------------------------------- 1 file changed, 2 insertions(+), 54 deletions(-) (limited to 'Source/SPTableRelations.m') diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index 64a7b98b..20059fbb 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -372,27 +372,6 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; [self _refreshRelationDataForcingCacheRefresh:NO]; } -#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 datasource methods @@ -412,45 +391,14 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; return data; } -#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 Task interaction /** * Disable all content interactive elements during an ongoing task. */ -- (void)startDocumentTaskForTab:(NSNotification *)aNotification +- (void)startDocumentTaskForTab:(NSNotification *)notification { - // Only proceed if this view is selected. if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableRelations]) return; @@ -462,7 +410,7 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; /** * Enable all content interactive elements after an ongoing task. */ -- (void)endDocumentTaskForTab:(NSNotification *)aNotification +- (void)endDocumentTaskForTab:(NSNotification *)notification { // Only proceed if this view is selected. if (![[tableDocumentInstance selectedToolbarItemIdentifier] isEqualToString:SPMainToolbarTableRelations]) return; -- cgit v1.2.3