From 703e78c5b147261417718d56281e91603b1e8356 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 12 Jan 2010 00:03:47 +0000 Subject: - Fix incorrect pagination task text ("Filtering table...") when no filtering is occurring, just pagination - If the table count is estimated (eg InnoDB), but the end is reached via pagination, make the row count accurate based on the known number of rows --- Source/TableContent.m | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Source/TableContent.m b/Source/TableContent.m index 7f8f5ab4..594822ec 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1007,9 +1007,29 @@ */ - (IBAction)filterTable:(id)sender { + NSString *taskString; + if ([tableDocumentInstance isWorking]) return; [self setPaginationViewVisibility:FALSE]; - [tableDocumentInstance startTaskWithDescription:NSLocalizedString(@"Filtering table...", @"Filtering table task description")]; + + // Select the correct pagination value + if (![prefs boolForKey:SPLimitResults] || [paginationPageField integerValue] <= 0) + contentPage = 1; + else if (([paginationPageField integerValue] - 1) * [prefs integerForKey:SPLimitResultsValue] >= maxNumRows) + contentPage = ceil((CGFloat)maxNumRows / [prefs floatForKey:SPLimitResultsValue]); + else + contentPage = [paginationPageField integerValue]; + + if ([self tableFilterString]) { + taskString = NSLocalizedString(@"Filtering table...", @"Filtering table task description"); + } else if (contentPage == 1) { + taskString = [NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), selectedTable]; + } else { + taskString = [NSString stringWithFormat:NSLocalizedString(@"Loading page %lu...", @"Loading table page task string"), (unsigned long)contentPage]; + } + + [tableDocumentInstance startTaskWithDescription:taskString]; + if ([NSThread isMainThread]) { [NSThread detachNewThreadSelector:@selector(filterTableTask) toTarget:self withObject:nil]; } else { @@ -1026,14 +1046,6 @@ // Update history [spHistoryControllerInstance updateHistoryEntries]; - // Select the correct pagination value - if (![prefs boolForKey:SPLimitResults] || [paginationPageField integerValue] <= 0) - contentPage = 1; - else if (([paginationPageField integerValue] - 1) * [prefs integerForKey:SPLimitResultsValue] >= maxNumRows) - contentPage = ceil((CGFloat)maxNumRows / [prefs floatForKey:SPLimitResultsValue]); - else - contentPage = [paginationPageField integerValue]; - // Reset and reload data using the new filter settings previousTableRowsCount = 0; [self clearTableValues]; @@ -2518,6 +2530,9 @@ maxNumRows = foundMaxRows; maxNumRowsIsEstimate = NO; } + } else if (!isInterruptedLoad && tableRowsCount < [prefs integerForKey:SPLimitResultsValue]) { + maxNumRows = foundMaxRows; + maxNumRowsIsEstimate = NO; } } else if (tableRowsCount > maxNumRows) { maxNumRows = tableRowsCount; -- cgit v1.2.3