lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 735b39f 3/3: Conditionally enable pasting cen


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 735b39f 3/3: Conditionally enable pasting census out
Date: Fri, 15 Jun 2018 13:52:07 -0400 (EDT)

branch: master
commit 735b39f604635783e278af6b57963c6007b61b24
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Conditionally enable pasting census out
---
 census_view.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 census_view.hpp |  1 +
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/census_view.cpp b/census_view.cpp
index 9f9e707..e0d7bc3 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -878,7 +878,7 @@ BEGIN_EVENT_TABLE(CensusView, ViewEx)
     EVT_UPDATE_UI(XRCID("print_group_roster"   
),CensusView::UponUpdateAlwaysEnabled    )
     EVT_UPDATE_UI(XRCID("print_group_quote"    
),CensusView::UponUpdateAlwaysEnabled    )
     EVT_UPDATE_UI(XRCID("paste_census_in"      
),CensusView::UponUpdateAlwaysEnabled    )
-    EVT_UPDATE_UI(XRCID("paste_census_out"     
),CensusView::UponUpdateAlwaysEnabled    )
+    EVT_UPDATE_UI(XRCID("paste_census_out"     
),CensusView::UponUpdateColumnValuesVary )
     EVT_UPDATE_UI(XRCID("add_cell"             
),CensusView::UponUpdateAlwaysEnabled    )
     EVT_UPDATE_UI(XRCID("delete_cells"         
),CensusView::UponUpdateNonemptySelection)
     EVT_UPDATE_UI(XRCID("column_width_varying" 
),CensusView::UponUpdateAlwaysEnabled    )
@@ -1363,6 +1363,56 @@ void 
CensusView::UponUpdateNonemptySelection(wxUpdateUIEvent& e)
     e.Enable(0 < list_window_->GetSelections(selection));
 }
 
+/// Conditionally enable pasting out.
+///
+/// Pasting out is forbidden if it would produce only whitespace; that
+/// is, if no "interesting" column varies across cells. All columns
+/// are interesting except:
+///  - the cell serial number that is always shown in the first column
+///    (that's just a GUI artifact, not an actual cell datum); and
+///  - the "UseDOB" and "IssueAge" columns that are filtered out by
+///    DoPasteCensusOut().
+/// This implementation ignores the first column, then enables the
+/// command unless "UseDOB" is the only other column; the rationale is
+/// clear only in the problem domain: "IssueAge" needn't be tested,
+/// because if "IssueAge" varies, then so must either "DateOfBirth"
+/// or "EffectiveDate".
+
+void CensusView::UponUpdateColumnValuesVary(wxUpdateUIEvent& e)
+{
+    static const std::string dob_header = 
insert_spaces_between_words("UseDOB");
+    int const n_cols = bourn_cast<int>(list_window_->GetColumnCount());
+    bool const disable =
+            1 == n_cols
+        || (2 == n_cols && dob_header == 
list_window_->GetColumn(1)->GetTitle())
+        ;
+    e.Enable(!disable);
+// Temporary testing scaffold...
+    std::vector<std::string> distinct_headers;
+    std::vector<std::string> const& 
all_headers(case_parms()[0].member_names());
+    for(auto const& header : all_headers)
+        {
+        bool const varies = column_value_varies_across_cells(header);
+        if(header != "UseDOB" && header != "IssueAge" && varies)
+            {
+            distinct_headers.push_back(header);
+            }
+        }
+    if(disable != distinct_headers.empty())
+        status()
+            << "Hey! "
+            << list_window_->GetColumnCount() - 1
+            << " != "
+            << distinct_headers.size()
+            << " "
+            << list_window_->GetColumn(0)->GetTitle()
+            << ", "
+            << list_window_->GetColumn(1)->GetTitle()
+            << std::flush
+            ;
+    else status() << " " << std::flush;
+}
+
 /// Update the dataview display.
 ///
 /// If a parameter was formerly the same for all cells but now differs due
diff --git a/census_view.hpp b/census_view.hpp
index 337fa0b..f33118b 100644
--- a/census_view.hpp
+++ b/census_view.hpp
@@ -86,6 +86,7 @@ class CensusView final
     void UponUpdateAlwaysEnabled    (wxUpdateUIEvent&);
     void UponUpdateSingleSelection  (wxUpdateUIEvent&);
     void UponUpdateNonemptySelection(wxUpdateUIEvent&);
+    void UponUpdateColumnValuesVary (wxUpdateUIEvent&);
 
     bool DoAllCells(mcenum_emission);
 



reply via email to

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