From 5bdc94a1717113855661d1e532e6e809f5d95d80 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 20 Mar 2012 22:22:55 +0000 Subject: - When refreshing the table content view, preserve column widths for columns which keep the same name, fixing flickering when refreshing (addresses issue #1279) --- Source/SPTableContent.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Source') diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 7afbfe84..e0af1d54 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -338,6 +338,7 @@ #endif NSArray *columnNames; NSDictionary *columnDefinition; + NSMutableDictionary *preservedColumnWidths = nil; NSTableColumn *theCol; #ifndef SP_REFACTOR NSTableColumn *filterCol; @@ -374,6 +375,12 @@ if ([selectedTable isEqualToString:newTableName]) { previousTableRowsCount = tableRowsCount; + // Store the column widths for later restoration + preservedColumnWidths = [NSMutableDictionary dictionaryWithCapacity:[[tableContentView tableColumns] count]]; + for (NSTableColumn *eachColumn in [tableContentView tableColumns]) { + [preservedColumnWidths setObject:[NSNumber numberWithFloat:[eachColumn width]] forKey:[[eachColumn headerCell] stringValue]]; + } + // Otherwise store the newly selected table name and reset the data } else { if (selectedTable) [selectedTable release], selectedTable = nil; @@ -533,6 +540,11 @@ ]]; [theCol setEditable:YES]; + // Copy in the width if present in a reloaded table + if ([preservedColumnWidths objectForKey:[columnDefinition objectForKey:@"name"]]) { + [theCol setWidth:[[preservedColumnWidths objectForKey:[columnDefinition objectForKey:@"name"]] floatValue]]; + } + #ifndef SP_REFACTOR // Set up column for filterTable filterCol = [[NSTableColumn alloc] initWithIdentifier:[columnDefinition objectForKey:@"datacolumnindex"]]; -- cgit v1.2.3