diff --git a/apps/shared/editable_cell_table_view_controller.cpp b/apps/shared/editable_cell_table_view_controller.cpp index 0c7c733d7..c77296769 100644 --- a/apps/shared/editable_cell_table_view_controller.cpp +++ b/apps/shared/editable_cell_table_view_controller.cpp @@ -22,7 +22,10 @@ bool EditableCellTableViewController::textFieldDidFinishEditing(TextField * text app()->displayWarning(I18n::Message::UndefinedValue); return false; } - setDataAtLocation(floatBody, m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()); + if (!setDataAtLocation(floatBody, m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow())) { + app()->displayWarning(I18n::Message::ForbiddenValue); + return false; + } willDisplayCellAtLocation(m_selectableTableView.cellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()), m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()); m_selectableTableView.reloadData(); m_selectableTableView.selectCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()+1); diff --git a/apps/shared/editable_cell_table_view_controller.h b/apps/shared/editable_cell_table_view_controller.h index 9702ec8aa..6518207dd 100644 --- a/apps/shared/editable_cell_table_view_controller.h +++ b/apps/shared/editable_cell_table_view_controller.h @@ -27,7 +27,7 @@ private: TextFieldDelegateApp * textFieldDelegateApp() override; static constexpr KDCoordinate k_cellHeight = 20; virtual bool cellAtLocationIsEditable(int columnIndex, int rowIndex) = 0; - virtual void setDataAtLocation(float floatBody, int columnIndex, int rowIndex) = 0; + virtual bool setDataAtLocation(float floatBody, int columnIndex, int rowIndex) = 0; virtual float dataAtLocation(int columnIndex, int rowIndex) = 0; virtual int numberOfElements() = 0; virtual int maxNumberOfElements() const = 0; diff --git a/apps/shared/store_controller.cpp b/apps/shared/store_controller.cpp index 00f425ebc..692b9de74 100644 --- a/apps/shared/store_controller.cpp +++ b/apps/shared/store_controller.cpp @@ -112,8 +112,9 @@ bool StoreController::cellAtLocationIsEditable(int columnIndex, int rowIndex) { return false; } -void StoreController::setDataAtLocation(float floatBody, int columnIndex, int rowIndex) { +bool StoreController::setDataAtLocation(float floatBody, int columnIndex, int rowIndex) { m_store->set(floatBody, columnIndex, rowIndex-1); + return true; } float StoreController::dataAtLocation(int columnIndex, int rowIndex) { diff --git a/apps/shared/store_controller.h b/apps/shared/store_controller.h index a1204d60b..6ed900e7c 100644 --- a/apps/shared/store_controller.h +++ b/apps/shared/store_controller.h @@ -28,7 +28,7 @@ protected: constexpr static int k_numberOfTitleCells = 2; Responder * tabController() const override; bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override; - void setDataAtLocation(float floatBody, int columnIndex, int rowIndex) override; + bool setDataAtLocation(float floatBody, int columnIndex, int rowIndex) override; float dataAtLocation(int columnIndex, int rowIndex) override; int numberOfElements() override; int maxNumberOfElements() const override; diff --git a/apps/shared/values_controller.cpp b/apps/shared/values_controller.cpp index c07e0b03a..cfac54c19 100644 --- a/apps/shared/values_controller.cpp +++ b/apps/shared/values_controller.cpp @@ -260,8 +260,9 @@ bool ValuesController::cellAtLocationIsEditable(int columnIndex, int rowIndex) { return false; } -void ValuesController::setDataAtLocation(float floatBody, int columnIndex, int rowIndex) { +bool ValuesController::setDataAtLocation(float floatBody, int columnIndex, int rowIndex) { m_interval.setElement(rowIndex-1, floatBody); + return true; } float ValuesController::dataAtLocation(int columnIndex, int rowIndex) { diff --git a/apps/shared/values_controller.h b/apps/shared/values_controller.h index c9a4f6632..66802a629 100644 --- a/apps/shared/values_controller.h +++ b/apps/shared/values_controller.h @@ -47,7 +47,7 @@ private: void configureAbscissa(); void configureFunction(); bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override; - void setDataAtLocation(float floatBody, int columnIndex, int rowIndex) override; + bool setDataAtLocation(float floatBody, int columnIndex, int rowIndex) override; float dataAtLocation(int columnIndex, int rowIndex) override; int numberOfElements() override; int maxNumberOfElements() const override; diff --git a/apps/statistics/store_controller.cpp b/apps/statistics/store_controller.cpp index 66d087bec..271290e67 100644 --- a/apps/statistics/store_controller.cpp +++ b/apps/statistics/store_controller.cpp @@ -32,4 +32,15 @@ HighlightCell * StoreController::titleCells(int index) { return &m_titleCells[index]; } +bool StoreController::setDataAtLocation(float floatBody, int columnIndex, int rowIndex) { + if (columnIndex == 1) { + if (floatBody < 0) { + return false; + } + m_store->set(roundf(floatBody), columnIndex, rowIndex-1); + return true; + } + return Shared::StoreController::setDataAtLocation(floatBody, columnIndex, rowIndex); +} + } diff --git a/apps/statistics/store_controller.h b/apps/statistics/store_controller.h index 3d50afdc9..5ecaaf5fa 100644 --- a/apps/statistics/store_controller.h +++ b/apps/statistics/store_controller.h @@ -12,6 +12,7 @@ public: StoreController(Responder * parentResponder, Store * store, ButtonRowController * header); void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; private: + bool setDataAtLocation(float floatBody, int columnIndex, int rowIndex) override; HighlightCell * titleCells(int index) override; EvenOddMessageTextCell m_titleCells[k_numberOfTitleCells]; };