aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableContent.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-08-16 00:15:28 +0000
committerrowanbeentje <rowan@beent.je>2010-08-16 00:15:28 +0000
commita4b8942109134428b04f355679e410146d07ff89 (patch)
tree56d8169ec47c41881b1b59ee6abe22b8189b5af7 /Source/SPTableContent.m
parent0d927d60ad66010af39e7c171ebbac4feb5e84f4 (diff)
downloadsequelpro-a4b8942109134428b04f355679e410146d07ff89.tar.gz
sequelpro-a4b8942109134428b04f355679e410146d07ff89.tar.bz2
sequelpro-a4b8942109134428b04f355679e410146d07ff89.zip
- Apply column autosizing improvements to custom query loading
- Move Table Content progress tracking onto the main thread's load timer - Improve thread safety when autosizing - Improve autosize to not contrain wide columns as much in tables where all columns can be shown, or if the column is double-clicked to size. (This completes work on Issue #271 and Issue #272)
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r--Source/SPTableContent.m33
1 files changed, 18 insertions, 15 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 26eeb568..795c9970 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -691,14 +691,13 @@
NSUInteger i;
NSUInteger dataColumnsCount = [dataColumns count];
BOOL *columnBlobStatuses = malloc(dataColumnsCount * sizeof(BOOL));
+ tableLoadTargetRowCount = targetRowCount;
// Set up the table updates timer
[[self onMainThread] initTableLoadTimer];
// Set the column count on the data store
[tableValues setColumnCount:dataColumnsCount];
-
- CGFloat relativeTargetRowCount = 100.0/targetRowCount;
NSAutoreleasePool *dataLoadingPool;
NSProgressIndicator *dataLoadingIndicator = [tableDocumentInstance valueForKey:@"queryProgressBar"];
@@ -735,16 +734,6 @@
pthread_mutex_unlock(&tableValuesLock);
- // Update the task interface as necessary
- if (!isFiltered) {
- if (tableRowsCount < targetRowCount) {
- [tableDocumentInstance setTaskPercentage:(tableRowsCount*relativeTargetRowCount)];
- } else if (tableRowsCount == targetRowCount) {
- [tableDocumentInstance setTaskPercentage:100.0];
- [[tableDocumentInstance onMainThread] setTaskProgressToIndeterminateAfterDelay:YES];
- }
- }
-
// Drain and reset the autorelease pool every ~1024 rows
if (!(tableRowsCount % 1024)) {
[dataLoadingPool drain];
@@ -1047,6 +1036,18 @@
*/
- (void) tableLoadUpdate:(NSTimer *)theTimer
{
+
+ // Update the task interface as necessary
+ if (!isFiltered && tableLoadTargetRowCount != NSUIntegerMax) {
+ if (tableRowsCount < tableLoadTargetRowCount) {
+ [tableDocumentInstance setTaskPercentage:(tableRowsCount*100/tableLoadTargetRowCount)];
+ } else if (tableRowsCount >= tableLoadTargetRowCount) {
+ [tableDocumentInstance setTaskPercentage:100.0];
+ [tableDocumentInstance setTaskProgressToIndeterminateAfterDelay:YES];
+ tableLoadTargetRowCount = NSUIntegerMax;
+ }
+ }
+
if (tableLoadTimerTicksSinceLastUpdate < tableLoadInterfaceUpdateInterval) {
tableLoadTimerTicksSinceLastUpdate++;
return;
@@ -1064,7 +1065,7 @@
// Update column widths in two cases: on very first rows displayed, and once
// more than 200 rows are present.
- if (tableLoadInterfaceUpdateInterval || (tableRowsCount >= 200 && tableLoadLastRowCount < 200)) {
+ if (tableLoadInterfaceUpdateInterval == 1 || (tableRowsCount >= 200 && tableLoadLastRowCount < 200)) {
[self autosizeColumns];
}
@@ -2823,7 +2824,9 @@
*/
- (void)autosizeColumns
{
- NSDictionary *columnWidths = [tableContentView autodetectColumnWidthsForFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]];
+ if (isWorking) pthread_mutex_lock(&tableValuesLock);
+ NSDictionary *columnWidths = [tableContentView autodetectColumnWidths];
+ if (isWorking) pthread_mutex_unlock(&tableValuesLock);
[tableContentView setDelegate:nil];
for (NSDictionary *columnDefinition in dataColumns) {
@@ -3255,7 +3258,7 @@
NSDictionary *columnDefinition = [dataColumns objectAtIndex:[[theColumn identifier] integerValue]];
// Get the column width
- NSUInteger targetWidth = [tableContentView autodetectWidthForColumnDefinition:columnDefinition usingFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]] maxRows:500];
+ NSUInteger targetWidth = [tableContentView autodetectWidthForColumnDefinition:columnDefinition maxRows:500];
// Clear any saved widths for the column
NSString *dbKey = [NSString stringWithFormat:@"%@@%@", [tableDocumentInstance database], [tableDocumentInstance host]];