From 9ea06fcd80d8f5f779a3e263ba7c605bb649ac15 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 10 Aug 2010 13:10:39 +0000 Subject: =?UTF-8?q?=E2=80=A2=C2=A0remember=20user's=20last=20setting=20for?= =?UTF-8?q?=20"Resetting=20AUTO=5FINC"=20while=20deletion=20of=20all=20row?= =?UTF-8?q?s=20in=20a=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/Plists/PreferenceDefaults.plist | 2 ++ Source/SPConstants.h | 1 + Source/SPConstants.m | 3 ++- Source/SPTableContent.m | 12 ++++++++---- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Resources/Plists/PreferenceDefaults.plist b/Resources/Plists/PreferenceDefaults.plist index e501fae8..0fc3adc8 100644 --- a/Resources/Plists/PreferenceDefaults.plist +++ b/Resources/Plists/PreferenceDefaults.plist @@ -167,5 +167,7 @@ 0 FavoritesSortedInReverse + ResetAutoIncrementAfterDeletionOfAllRows + diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 3ba923ff..69efe326 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -304,6 +304,7 @@ extern NSString *SPProcessListAutoRrefreshInterval; extern NSString *SPFavoritesSortedBy; extern NSString *SPFavoritesSortedInReverse; extern NSString *SPAlwaysShowWindowTabBar; +extern NSString *SPResetAutoIncrementAfterDeletionOfAllRows; // Hidden Prefs extern NSString *SPPrintWarningRowLimit; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 36a9a25b..cb5ea82f 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -134,7 +134,8 @@ NSString *SPProcessListEnableAutoRefresh = @"ProcessListEnableAutoRefres NSString *SPProcessListAutoRrefreshInterval = @"ProcessListAutoRrefreshInterval"; NSString *SPFavoritesSortedBy = @"FavoritesSortedBy"; NSString *SPFavoritesSortedInReverse = @"FavoritesSortedInReverse"; -NSString *SPAlwaysShowWindowTabBar = @"WindowAlwaysShowTabBar"; +NSString *SPAlwaysShowWindowTabBar = @"WindowAlwaysShowTabBar"; +NSString *SPResetAutoIncrementAfterDeletionOfAllRows = @"ResetAutoIncrementAfterDeletionOfAllRows"; // Hidden Prefs NSString *SPPrintWarningRowLimit = @"PrintWarningRowLimit"; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 15f4df31..bf03c66e 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -1417,7 +1417,7 @@ // If table has PRIMARY KEY ask for resetting the auto increment after deletion if given if(![[tableDataInstance statusValueForKey:@"Auto_increment"] isKindOfClass:[NSNull class]]) { [alert setShowsSuppressionButton:YES]; - [[alert suppressionButton] setState:NSOnState]; + [[alert suppressionButton] setState:([prefs boolForKey:SPResetAutoIncrementAfterDeletionOfAllRows]) ? NSOnState : NSOffState]; [[[alert suppressionButton] cell] setControlSize:NSSmallControlSize]; [[[alert suppressionButton] cell] setFont:[NSFont systemFontOfSize:11]]; [[alert suppressionButton] setTitle:NSLocalizedString(@"Reset AUTO_INCREMENT after deletion?", @"reset auto_increment after deletion of all rows message")]; @@ -1453,7 +1453,7 @@ // Order out current sheet to suppress overlapping of sheets [[alert window] orderOut:nil]; - if ( [contextInfo isEqualToString:@"removeallrows"] ) { + if ( [contextInfo isEqualToString:@"removeallrows"] ) { if ( returnCode == NSAlertDefaultReturn ) { //check if the user is currently editing a row if (isEditingRow) { @@ -1461,15 +1461,19 @@ isEditingRow = NO; // in case the delete fails, make sure we at least stay in a somewhat consistent state [tableValues replaceRowAtIndex:currentlyEditingRow withRowContents:oldRow]; - currentlyEditingRow = -1; + currentlyEditingRow = -1; } [mySQLConnection queryString:[NSString stringWithFormat:@"DELETE FROM %@", [selectedTable backtickQuotedString]]]; if ( ![mySQLConnection queryErrored] ) { // Reset auto increment if suppression button was ticked - if([[alert suppressionButton] state] == NSOnState) + if([[alert suppressionButton] state] == NSOnState) { [tableSourceInstance setAutoIncrementTo:@"1"]; + [prefs setBool:YES forKey:SPResetAutoIncrementAfterDeletionOfAllRows]; + } else { + [prefs setBool:NO forKey:SPResetAutoIncrementAfterDeletionOfAllRows]; + } [self reloadTable:self]; -- cgit v1.2.3