diff options
author | rowanbeentje <rowan@beent.je> | 2012-03-20 22:22:55 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-03-20 22:22:55 +0000 |
commit | 5bdc94a1717113855661d1e532e6e809f5d95d80 (patch) | |
tree | a7135437c7869392e7db7fd40d3264ad6c258fce /Source/SPTableContent.m | |
parent | 1e763cd2567e14266120fc45f7b3de9135b79d37 (diff) | |
download | sequelpro-5bdc94a1717113855661d1e532e6e809f5d95d80.tar.gz sequelpro-5bdc94a1717113855661d1e532e6e809f5d95d80.tar.bz2 sequelpro-5bdc94a1717113855661d1e532e6e809f5d95d80.zip |
- When refreshing the table content view, preserve column widths for columns which keep the same name, fixing flickering when refreshing (addresses issue #1279)
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r-- | Source/SPTableContent.m | 12 |
1 files changed, 12 insertions, 0 deletions
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"]]; |