lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 041ccfc 30/46: Optimize changing grid columns


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 041ccfc 30/46: Optimize changing grid columns number too
Date: Wed, 22 Jul 2020 11:05:14 -0400 (EDT)

branch: master
commit 041ccfc246e94b2fb046d765974a5d71beac8285
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Vadim Zeitlin <vadim@tt-solutions.com>

    Optimize changing grid columns number too
    
    Although this is less important than for the rows (as there can be many
    more rows than columns), it still seems useless to recreate all columns
    when we can just adjust their number more precisely.
    
    It also makes it unnecessary to call make_cell_number_column_read_only()
    from update_visible_columns(), paving way for removing the former
    entirely in the upcoming commit.
---
 census_view.cpp | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/census_view.cpp b/census_view.cpp
index 17e784f..32b5206 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -2257,11 +2257,18 @@ void CensusGridView::update_visible_columns()
 
         grid_table_->set_visible_columns(std::move(new_visible_columns));
 
-        if(old_columns_count != new_columns_count)
+        // Bring the number of columns actually shown in the grid in sync with
+        // the number of columns in the table if necessary.
+        if(new_columns_count < old_columns_count)
             {
-            grid_window_->DeleteCols(0, old_columns_count);
-            grid_window_->AppendCols(new_columns_count);
-            grid_table_->make_cell_number_column_read_only();
+            grid_table_->DeleteCols
+                (new_columns_count
+                ,old_columns_count - new_columns_count
+                );
+            }
+        else if(old_columns_count < new_columns_count)
+            {
+            grid_table_->AppendCols(new_columns_count - old_columns_count);
             }
 
         grid_window_->SetGridCursor



reply via email to

[Prev in Thread] Current Thread [Next in Thread]