aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-10-22 23:49:30 +0000
committerrowanbeentje <rowan@beent.je>2009-10-22 23:49:30 +0000
commit41b5cc6f8c339fee5af8ac8f07d3b81f9889b975 (patch)
tree4ea7d1110f1e132f4b27f58b4f27bd1f8a819b35 /Source
parent20baed5257ce1152c1f25c5a953ca821b50050db (diff)
downloadsequelpro-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')
-rw-r--r--Source/TableContent.m24
-rw-r--r--Source/TableDocument.h2
-rw-r--r--Source/TableDocument.m6
-rw-r--r--Source/YRKSpinningProgressIndicator.m5
4 files changed, 25 insertions, 12 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];
}
diff --git a/Source/TableDocument.h b/Source/TableDocument.h
index 6720527a..a6969136 100644
--- a/Source/TableDocument.h
+++ b/Source/TableDocument.h
@@ -187,7 +187,7 @@ enum sp_current_query_mode
- (void) startTaskWithDescription:(NSString *)description;
- (void) showTaskProgressLayer:(NSTimer *)theTimer;
- (void) setTaskDescription:(NSString *)description;
-- (void) setTaskPercentage:(NSNumber *)taskPercentage;
+- (void) setTaskPercentage:(float)taskPercentage;
- (void) setTaskProgressToIndeterminate;
- (void) endTask;
- (BOOL) isWorking;
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 1d95c695..daa8d049 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -211,7 +211,7 @@
// Set up the progress indicator layer - add to main window, change indicator color and size
[taskProgressLayer setHidden:YES];
[taskProgressLayer setFrame:[contentViewSplitter frame]];
- [[tableWindow contentView] addSubview:taskProgressLayer];
+ [[tableWindow contentView] addSubview:taskProgressLayer positioned:NSWindowAbove relativeTo:contentViewSplitter];
[taskProgressIndicator setForeColor:[NSColor whiteColor]];
}
@@ -1242,9 +1242,9 @@
* Sets the task percentage progress - the first call to this automatically
* switches the progress display to determinate.
*/
-- (void) setTaskPercentage:(NSNumber *)taskPercentage
+- (void) setTaskPercentage:(float)taskPercentage
{
- taskProgressValue = [taskPercentage floatValue];
+ taskProgressValue = taskPercentage;
if (taskProgressValue > taskDisplayLastValue + taskProgressValueDisplayInterval
|| taskProgressValue < taskDisplayLastValue - taskProgressValueDisplayInterval)
{
diff --git a/Source/YRKSpinningProgressIndicator.m b/Source/YRKSpinningProgressIndicator.m
index f3ccab87..a1f70e9d 100644
--- a/Source/YRKSpinningProgressIndicator.m
+++ b/Source/YRKSpinningProgressIndicator.m
@@ -287,7 +287,10 @@
{
if (_isIndeterminate) _isIndeterminate = NO;
_currentValue = doubleValue;
- [self displayIfNeeded];
+ if ([NSThread isMainThread])
+ [self displayIfNeeded];
+ else
+ [self performSelectorOnMainThread:@selector(displayIfNeeded) withObject:nil waitUntilDone:NO];
}
- (double)maxValue