[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master d4ad57b 42/46: Disallow "Edit/Run" cell when
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master d4ad57b 42/46: Disallow "Edit/Run" cell when multiple grid rows are selected |
Date: |
Wed, 22 Jul 2020 11:05:17 -0400 (EDT) |
branch: master
commit d4ad57bc1142b1db81da8ac2de5968d45a446457
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Vadim Zeitlin <vadim@tt-solutions.com>
Disallow "Edit/Run" cell when multiple grid rows are selected
Editing and running cells was accidentally enabled even in the case when
multiple rows were selected, when the intention was only to do it when
either a single row is selected or there is no selection at all, for
consistency with the rest of CensusGridView code, which considers the
current row (containing the cursor cell) implicitly selected, if there
is no explicit selection.
---
census_view.cpp | 27 +++++++++++++++++++--------
census_view.hpp | 4 +++-
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/census_view.cpp b/census_view.cpp
index bb876dd..ed4a953 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -1793,7 +1793,11 @@ BEGIN_EVENT_TABLE(CensusView, ViewEx)
EVT_MENU(XRCID("delete_cells" ),CensusView::UponDeleteCells
)
EVT_MENU(XRCID("column_width_varying"
),CensusView::UponColumnWidthVarying )
EVT_MENU(XRCID("column_width_fixed"
),CensusView::UponColumnWidthFixed )
+ EVT_UPDATE_UI(XRCID("edit_cell"
),CensusView::UponUpdateSingleSelection )
+ EVT_UPDATE_UI(XRCID("edit_class"
),CensusView::UponUpdateSingleSelection )
EVT_UPDATE_UI(XRCID("edit_case"
),CensusView::UponUpdateAlwaysEnabled )
+ EVT_UPDATE_UI(XRCID("run_cell"
),CensusView::UponUpdateSingleSelection )
+ EVT_UPDATE_UI(XRCID("run_class"
),CensusView::UponUpdateSingleSelection )
EVT_UPDATE_UI(XRCID("run_case"
),CensusView::UponUpdateAlwaysEnabled )
EVT_UPDATE_UI(XRCID("print_case"
),CensusView::UponUpdateAlwaysEnabled )
EVT_UPDATE_UI(XRCID("print_case_to_disk"
),CensusView::UponUpdateAlwaysEnabled )
@@ -1818,10 +1822,6 @@ IMPLEMENT_DYNAMIC_CLASS(CensusDVCView, CensusView)
BEGIN_EVENT_TABLE(CensusDVCView, CensusView)
EVT_DATAVIEW_ITEM_CONTEXT_MENU (wxID_ANY ,CensusDVCView::UponRightClick
)
EVT_DATAVIEW_ITEM_VALUE_CHANGED(wxID_ANY
,CensusDVCView::UponValueChanged )
- EVT_UPDATE_UI(XRCID("edit_cell"
),CensusDVCView::UponUpdateSingleSelection )
- EVT_UPDATE_UI(XRCID("edit_class"
),CensusDVCView::UponUpdateSingleSelection )
- EVT_UPDATE_UI(XRCID("run_cell"
),CensusDVCView::UponUpdateSingleSelection )
- EVT_UPDATE_UI(XRCID("run_class"
),CensusDVCView::UponUpdateSingleSelection )
EVT_UPDATE_UI(XRCID("delete_cells"
),CensusDVCView::UponUpdateNonemptySelection)
END_EVENT_TABLE()
@@ -1831,10 +1831,6 @@ BEGIN_EVENT_TABLE(CensusGridView, CensusView)
EVT_GRID_CELL_RIGHT_CLICK(
CensusGridView::UponRightClick )
EVT_GRID_CELL_CHANGED(
CensusGridView::UponValueChanged )
EVT_GRID_COL_AUTO_SIZE(
CensusGridView::UponColumnAutoSize )
- EVT_UPDATE_UI(XRCID("edit_cell"
),CensusGridView::UponUpdateAlwaysEnabled)
- EVT_UPDATE_UI(XRCID("edit_class"
),CensusGridView::UponUpdateAlwaysEnabled)
- EVT_UPDATE_UI(XRCID("run_cell"
),CensusGridView::UponUpdateAlwaysEnabled)
- EVT_UPDATE_UI(XRCID("run_class"
),CensusGridView::UponUpdateAlwaysEnabled)
EVT_UPDATE_UI(XRCID("delete_cells"
),CensusGridView::UponUpdateAlwaysEnabled)
END_EVENT_TABLE()
@@ -2458,6 +2454,21 @@ void
CensusDVCView::UponUpdateSingleSelection(wxUpdateUIEvent& e)
e.Enable(is_single_sel);
}
+void CensusGridView::UponUpdateSingleSelection(wxUpdateUIEvent& e)
+{
+ // We consider that in absence of any selected rows, the current row is the
+ // selected/active one, so what we actually check for here is that we do
+ // not have more than a single row selected.
+ auto const sel_blocks = grid_window_->GetSelectedRowBlocks();
+ bool const is_single_sel
+ = sel_blocks.empty()
+ || (sel_blocks.size() == 1
+ && sel_blocks[0].GetTopRow() == sel_blocks[0].GetBottomRow())
+ ;
+
+ e.Enable(is_single_sel);
+}
+
void CensusDVCView::UponUpdateNonemptySelection(wxUpdateUIEvent& e)
{
wxDataViewItemArray selection;
diff --git a/census_view.hpp b/census_view.hpp
index da39248..abc491e 100644
--- a/census_view.hpp
+++ b/census_view.hpp
@@ -85,6 +85,7 @@ class CensusView
virtual void UponColumnWidthFixed (wxCommandEvent&) = 0;
void UponUpdateAlwaysDisabled (wxUpdateUIEvent&);
void UponUpdateAlwaysEnabled (wxUpdateUIEvent&);
+ virtual void UponUpdateSingleSelection (wxUpdateUIEvent&) = 0;
virtual void UponUpdateColumnValuesVary (wxUpdateUIEvent&) = 0;
bool DoAllCells(mcenum_emission);
@@ -157,7 +158,7 @@ class CensusDVCView final
void UponDeleteCells (wxCommandEvent&) override;
void UponColumnWidthVarying (wxCommandEvent&) override;
void UponColumnWidthFixed (wxCommandEvent&) override;
- void UponUpdateSingleSelection (wxUpdateUIEvent&);
+ void UponUpdateSingleSelection (wxUpdateUIEvent&) override;
void UponUpdateNonemptySelection(wxUpdateUIEvent&);
void UponUpdateColumnValuesVary (wxUpdateUIEvent&) override;
@@ -199,6 +200,7 @@ class CensusGridView final
void UponDeleteCells (wxCommandEvent&) override;
void UponColumnWidthVarying (wxCommandEvent&) override;
void UponColumnWidthFixed (wxCommandEvent&) override;
+ void UponUpdateSingleSelection (wxUpdateUIEvent&) override;
void UponUpdateColumnValuesVary (wxUpdateUIEvent&) override;
void Update() override;
- [lmi-commits] [lmi] master 337d81f 37/46: Make UponDeleteCells() more efficient for large censuses, (continued)
- [lmi-commits] [lmi] master 337d81f 37/46: Make UponDeleteCells() more efficient for large censuses, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master 2922db9 44/46: Disallow single cell operations when non-current row is selected, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master d337a22 45/46: Upgrade wx, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master c679655 19/46: Replace table_type_converter::get_all() with register_all(), Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master 7dc508e 35/46: Don't select the first row initially in the grid census view, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master 810de0a 26/46: Remove unnecessary wxGrid::IsCellEditControlEnabled() calls, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master adc4089 28/46: Optimize changing grid dimensions when pasting into the census, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master be4c2a4 32/46: Add a comment explaining why the first column is read-only, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master b7944ba 38/46: Resize only columns, not rows, in update_visible_columns(), Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master b399a7d 40/46: Remove automatic column auto-sizing in wxGrid-based census view, Greg Chicares, 2020/07/22
- [lmi-commits] [lmi] master d4ad57b 42/46: Disallow "Edit/Run" cell when multiple grid rows are selected,
Greg Chicares <=
- [lmi-commits] [lmi] master d39ff1d 07/46: Use wxGridCellAttrPtr instead of manual reference counting, Greg Chicares, 2020/07/22