From 572b761e971c732585ef5f0fcf852e1842d44e31 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sat, 26 Sep 2009 16:36:32 +0000 Subject: =?UTF-8?q?=E2=80=A2=20changed=20the=20progress=20wheel=20updating?= =?UTF-8?q?=20behaviour=20while=20loading=20table=20data=20slightly=20to?= =?UTF-8?q?=20increase=20the=20loading=20speed;=20this=20is=20up=20to=20no?= =?UTF-8?q?w=20a=20compromise=20between=20speed=20and=20user=20information?= =?UTF-8?q?,=20the=20progress=20wheel=20will=20be=20updated=20every=20~15%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableContent.m | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'Source') diff --git a/Source/TableContent.m b/Source/TableContent.m index 806e1f47..19cb1dcf 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1204,10 +1204,17 @@ NSArray *tempRow; NSMutableArray *newRow; NSMutableArray *columnBlobStatuses = [[NSMutableArray alloc] init]; - int i; - int lastProgressValue = 0; + NSUInteger i; + + // Update the progress wheel every ~15% + NSUInteger loadingIndicatorDelta = 15; + + NSUInteger lastProgressValue = loadingIndicatorDelta; + float relativeTargetRowCount = 100.0/targetRowCount; + long rowsProcessed = 0; long columnsCount = [dataColumns count]; + NSAutoreleasePool *dataLoadingPool; NSProgressIndicator *dataLoadingIndicator = [tableDocumentInstance valueForKey:@"queryProgressBar"]; id prefsNullValue = [[prefs objectForKey:@"NullValue"] retain]; @@ -1222,7 +1229,7 @@ // Remove all items from the table and reset the progress indicator [tableValues removeAllObjects]; if (targetRowCount) [dataLoadingIndicator setIndeterminate:NO]; - [dataLoadingIndicator setDoubleValue:0]; + [dataLoadingIndicator setDoubleValue:(int)loadingIndicatorDelta/2]; [dataLoadingIndicator display]; // Set up an autorelease pool for row processing @@ -1253,14 +1260,14 @@ // Update the progress bar as necessary, minimising updates rowsProcessed++; - if (rowsProcessed == targetRowCount) { - [dataLoadingIndicator setIndeterminate:YES]; - } else if (rowsProcessed < targetRowCount) { - [dataLoadingIndicator setDoubleValue:(rowsProcessed*100/targetRowCount)]; + if (rowsProcessed < targetRowCount) { + [dataLoadingIndicator setDoubleValue:(rowsProcessed*relativeTargetRowCount)]; if ((int)[dataLoadingIndicator doubleValue] > lastProgressValue) { [dataLoadingIndicator display]; - lastProgressValue = (int)[dataLoadingIndicator doubleValue]; + lastProgressValue = (int)[dataLoadingIndicator doubleValue] + loadingIndicatorDelta; } + } else if (rowsProcessed == targetRowCount) { + [dataLoadingIndicator setIndeterminate:YES]; } // Drain and reset the autorelease pool every ~1024 rows -- cgit v1.2.3