From b967aeff1d12af4e9b1f27bc65c8506e5a3a2d2d Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 17 Oct 2009 16:02:58 +0000 Subject: - Update the row count a bit more intelligently when the table content is LMITed or FILTERed but the table content is increasing. This addresses Issue #421. --- Source/TableContent.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Source/TableContent.m') diff --git a/Source/TableContent.m b/Source/TableContent.m index ed74a005..6f8f8dcd 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -2172,6 +2172,7 @@ */ - (void)updateNumberOfRows { + BOOL checkStatusCount = NO; // For unfiltered and non-limited tables, use the result count - and update the status count if (!isLimited && !isFiltered) { @@ -2186,6 +2187,7 @@ } else if ([[tableDataInstance statusValueForKey:@"RowsCountAccurate"] boolValue]) { maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] intValue]; maxNumRowsIsEstimate = NO; + checkStatusCount = YES; // Choose whether to display an estimate, or to fetch the correct row count, based on prefs } else if ([prefs boolForKey:SPFetchCorrectRowCount]) { @@ -2200,6 +2202,30 @@ } else { maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] intValue]; maxNumRowsIsEstimate = YES; + checkStatusCount = YES; + } + + // Check whether the estimated count requires updating, ie if the retrieved count exceeds it + if (checkStatusCount) { + NSInteger foundMaxRows; + if ([prefs boolForKey:SPLimitResults]) { + foundMaxRows = [limitRowsField intValue] - 1 + [tableValues count]; + if (foundMaxRows > maxNumRows) { + if (foundMaxRows == [limitRowsField intValue] - 1 + [prefs integerForKey:SPLimitResultsValue]) { + maxNumRows = foundMaxRows + 1; + maxNumRowsIsEstimate = YES; + } else { + maxNumRows = foundMaxRows; + maxNumRowsIsEstimate = NO; + } + } + } else if ([tableValues count] > maxNumRows) { + maxNumRows = [tableValues count]; + maxNumRowsIsEstimate = YES; + } + [tableDataInstance setStatusValue:[NSString stringWithFormat:@"%d", maxNumRows] forKey:@"Rows"]; + [tableDataInstance setStatusValue:maxNumRowsIsEstimate?@"n":@"y" forKey:@"RowsCountAccurate"]; + [tableInfoInstance tableChanged:nil]; } } -- cgit v1.2.3