diff options
author | rowanbeentje <rowan@beent.je> | 2009-10-22 23:49:30 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-10-22 23:49:30 +0000 |
commit | 41b5cc6f8c339fee5af8ac8f07d3b81f9889b975 (patch) | |
tree | 4ea7d1110f1e132f4b27f58b4f27bd1f8a819b35 /Source/TableContent.m | |
parent | 20baed5257ce1152c1f25c5a953ca821b50050db (diff) | |
download | sequelpro-41b5cc6f8c339fee5af8ac8f07d3b81f9889b975.tar.gz sequelpro-41b5cc6f8c339fee5af8ac8f07d3b81f9889b975.tar.bz2 sequelpro-41b5cc6f8c339fee5af8ac8f07d3b81f9889b975.zip |
- Improve table and task redrawing during threaded table content loads
- Correctly update the table content count when duplicating a row, and cancelling the add. This addresses issue #440.
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r-- | Source/TableContent.m | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m index 2dc18727..d038dfef 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -474,6 +474,8 @@ SEL callbackMethod = NULL; int rowsToLoad = [[tableDataInstance statusValueForKey:@"Rows"] intValue]; + [countText setStringValue:NSLocalizedString(@"Loading table data...", @"Loading table data string")]; + // Remove all items from the table tableValuesCount = 0; [tableContentView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:YES]; @@ -561,8 +563,6 @@ if (encodedTableContentCallbackMethod) { [encodedTableContentCallbackMethod getValue:&callbackMethod]; [self performSelectorOnMainThread:callbackMethod withObject:nil waitUntilDone:NO]; - } else { - [tableContentView reloadData]; } [tableDocumentInstance endTask]; @@ -940,6 +940,7 @@ //copy row tempRow = [NSMutableArray arrayWithArray:[tableValues objectAtIndex:[tableContentView selectedRow]]]; [tableValues insertObject:tempRow atIndex:[tableContentView selectedRow]+1]; + tableValuesCount++; //if we don't show blobs, read data for this duplicate column from db if ([prefs boolForKey:SPLoadBlobsAsNeeded]) { @@ -1370,6 +1371,7 @@ float relativeTargetRowCount = 100.0/targetRowCount; NSUInteger nextTableDisplayBoundary = 50; + BOOL tableViewRedrawn = NO; long rowsProcessed = 0; long columnsCount = [dataColumns count]; @@ -1412,14 +1414,18 @@ rowsProcessed++; if (!isFiltered) { if (rowsProcessed < targetRowCount) { - [tableDocumentInstance performSelectorOnMainThread:@selector(setTaskPercentage:) withObject:[NSNumber numberWithFloat:(rowsProcessed*relativeTargetRowCount)] waitUntilDone:NO]; + [tableDocumentInstance setTaskPercentage:(rowsProcessed*relativeTargetRowCount)]; } else if (rowsProcessed == targetRowCount) { [tableDocumentInstance performSelectorOnMainThread:@selector(setTaskProgressToIndeterminate) withObject:nil waitUntilDone:NO]; } if (rowsProcessed > nextTableDisplayBoundary) { - [tableContentView noteNumberOfRowsChanged]; - nextTableDisplayBoundary *= 3; + [tableContentView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:NO]; + if (!tableViewRedrawn) { + [tableContentView performSelectorOnMainThread:@selector(displayIfNeeded) withObject:nil waitUntilDone:NO]; + tableViewRedrawn = YES; + } + nextTableDisplayBoundary *= 2; } } @@ -1429,6 +1435,9 @@ dataLoadingPool = [[NSAutoreleasePool alloc] init]; } } + + [tableContentView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:NO]; + [tableContentView setNeedsDisplay:YES]; // Clean up the autorelease pool and reset the progress indicator [dataLoadingPool drain]; @@ -2667,7 +2676,6 @@ // Only enable elements if the current tab is the content view if (![[aNotification object] isEqualToString:@"SwitchToTableContentToolbarItemIdentifier"]) return; - [tableContentView setEnabled:YES]; if ( ![[[tableDataInstance statusValues] objectForKey:@"Rows"] isNSNull] && selectedTable && [selectedTable length] && [tableDataInstance tableEncoding]) [addButton setEnabled:YES]; if ([tableContentView numberOfSelectedRows] > 0) { [removeButton setEnabled:YES]; @@ -2675,7 +2683,8 @@ } [reloadButton setEnabled:YES]; [filterButton setEnabled:[fieldField isEnabled]]; - [tableContentView setNeedsDisplay:YES]; + [tableContentView setEnabled:YES]; + [tableContentView displayIfNeeded]; } #pragma mark - @@ -2738,6 +2747,7 @@ } else if ( isEditingNewRow ) { isEditingRow = NO; isEditingNewRow = NO; + tableValuesCount--; [tableValues removeObjectAtIndex:row]; [tableContentView reloadData]; } |