From 837e0694d16622dfab4e860ec52a728991427824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 23 May 2018 16:40:51 +0200 Subject: [PATCH] [shared] Remove New Function Cell class which is a duplicate of Even Odd Message Text Cell --- apps/code/menu_controller.cpp | 3 ++- apps/code/menu_controller.h | 3 +-- apps/graph/list/list_controller.h | 1 - apps/sequence/list/list_controller.h | 1 - apps/shared/Makefile | 1 - apps/shared/list_controller.cpp | 3 ++- apps/shared/list_controller.h | 3 +-- apps/shared/new_function_cell.cpp | 35 ---------------------------- apps/shared/new_function_cell.h | 22 ----------------- 9 files changed, 6 insertions(+), 66 deletions(-) delete mode 100644 apps/shared/new_function_cell.cpp delete mode 100644 apps/shared/new_function_cell.h diff --git a/apps/code/menu_controller.cpp b/apps/code/menu_controller.cpp index 46c4488e1..fe2ff2793 100644 --- a/apps/code/menu_controller.cpp +++ b/apps/code/menu_controller.cpp @@ -12,7 +12,7 @@ MenuController::MenuController(Responder * parentResponder, ScriptStore * script ViewController(parentResponder), ButtonRowDelegate(nullptr, footer), m_scriptStore(scriptStore), - m_addNewScriptCell(I18n::Message::AddScript), + m_addNewScriptCell(), m_consoleButton(this, I18n::Message::Console, Invocation([](void * context, void * sender) { MenuController * menu = (MenuController *)context; if (menu->consoleController()->loadPythonEnvironment()) { @@ -29,6 +29,7 @@ MenuController::MenuController(Responder * parentResponder, ScriptStore * script { m_selectableTableView.setMargins(0); m_selectableTableView.setShowsIndicators(false); + m_addNewScriptCell.setMessage(I18n::Message::AddScript); for (int i = 0; i < k_maxNumberOfDisplayableScriptCells; i++) { m_scriptCells[i].setParentResponder(&m_selectableTableView); m_scriptCells[i].editableTextCell()->textField()->setDelegate(this); diff --git a/apps/code/menu_controller.h b/apps/code/menu_controller.h index a1665a3f0..61b5f565a 100644 --- a/apps/code/menu_controller.h +++ b/apps/code/menu_controller.h @@ -2,7 +2,6 @@ #define CODE_MENU_CONTROLLER_H #include -#include #include "console_controller.h" #include "editor_controller.h" #include "script_parameter_controller.h" @@ -99,7 +98,7 @@ private: * constructor of an EvenOddEditableTextCell. */ char m_draftTextBuffer[TextField::maxBufferSize()]; EvenOddCellWithEllipsis m_scriptParameterCells[k_maxNumberOfDisplayableScriptCells]; - Shared::NewFunctionCell m_addNewScriptCell; + EvenOddMessageTextCell m_addNewScriptCell; EvenOddCell m_emptyCell; Button m_consoleButton; SelectableTableView m_selectableTableView; diff --git a/apps/graph/list/list_controller.h b/apps/graph/list/list_controller.h index 4bcedbe21..e0684f0a0 100644 --- a/apps/graph/list/list_controller.h +++ b/apps/graph/list/list_controller.h @@ -4,7 +4,6 @@ #include #include "../function_title_cell.h" #include "../cartesian_function_store.h" -#include "../../shared/new_function_cell.h" #include "../../shared/model_expression_cell.h" #include "../../shared/list_controller.h" #include "../../shared/list_parameter_controller.h" diff --git a/apps/sequence/list/list_controller.h b/apps/sequence/list/list_controller.h index 98bfa1550..bbc932b86 100644 --- a/apps/sequence/list/list_controller.h +++ b/apps/sequence/list/list_controller.h @@ -5,7 +5,6 @@ #include "../sequence_title_cell.h" #include "../sequence_store.h" #include "../../shared/list_controller.h" -#include "../../shared/new_function_cell.h" #include "../../shared/model_expression_cell.h" #include "../../shared/expression_layout_field_delegate.h" #include "../../shared/text_field_delegate.h" diff --git a/apps/shared/Makefile b/apps/shared/Makefile index 20e6df53d..69766774b 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -33,7 +33,6 @@ app_objs += $(addprefix apps/shared/,\ memoized_curve_view_range.o\ message_view.o\ model_expression_cell.o\ - new_function_cell.o\ ok_view.o\ parameter_text_field_delegate.o\ range_parameter_controller.o\ diff --git a/apps/shared/list_controller.cpp b/apps/shared/list_controller.cpp index a2f83efc0..7698f6db4 100644 --- a/apps/shared/list_controller.cpp +++ b/apps/shared/list_controller.cpp @@ -294,7 +294,8 @@ void ListController::addEmptyFunction() { View * ListController::loadView() { m_emptyCell = new EvenOddCell(); - m_addNewFunction = new NewFunctionCell(m_addNewMessage); + m_addNewFunction = new EvenOddMessageTextCell(); + m_addNewFunction->setMessage(m_addNewMessage); SelectableTableView * selectableTableView = new SelectableTableView(this, this, this, this); selectableTableView->setMargins(0); selectableTableView->setVerticalCellOverlap(0); diff --git a/apps/shared/list_controller.h b/apps/shared/list_controller.h index 4a0824f48..8ce5575b2 100644 --- a/apps/shared/list_controller.h +++ b/apps/shared/list_controller.h @@ -4,7 +4,6 @@ #include #include "function_store.h" #include "list_parameter_controller.h" -#include "new_function_cell.h" #include "../i18n.h" namespace Shared { @@ -53,7 +52,7 @@ private: virtual void willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) = 0; EvenOddCell * m_emptyCell; I18n::Message m_addNewMessage; - NewFunctionCell * m_addNewFunction; + EvenOddMessageTextCell * m_addNewFunction; Button m_plotButton; Button m_valuesButton; }; diff --git a/apps/shared/new_function_cell.cpp b/apps/shared/new_function_cell.cpp deleted file mode 100644 index 18387df61..000000000 --- a/apps/shared/new_function_cell.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "new_function_cell.h" -#include "assert.h" - -namespace Shared { - -NewFunctionCell::NewFunctionCell(I18n::Message text) : - EvenOddCell(), - m_messageTextView(KDText::FontSize::Large, text, 0.5f, 0.5f) -{ -} - -void NewFunctionCell::setEven(bool even) { - EvenOddCell::setEven(even); - m_messageTextView.setBackgroundColor(backgroundColor()); -} - -void NewFunctionCell::setHighlighted(bool highlight) { - EvenOddCell::setHighlighted(highlight); - m_messageTextView.setBackgroundColor(backgroundColor()); -} - -int NewFunctionCell::numberOfSubviews() const { - return 1; -} - -View * NewFunctionCell::subviewAtIndex(int index) { - assert(index == 0); - return &m_messageTextView; -} - -void NewFunctionCell::layoutSubviews() { - m_messageTextView.setFrame(bounds()); -} - -} diff --git a/apps/shared/new_function_cell.h b/apps/shared/new_function_cell.h deleted file mode 100644 index 7a8418b6c..000000000 --- a/apps/shared/new_function_cell.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef SHARED_NEW_FUNCTION_CELL_H -#define SHARED_NEW_FUNCTION_CELL_H - -#include - -namespace Shared { - -class NewFunctionCell : public EvenOddCell { -public: - NewFunctionCell(I18n::Message text); - void setEven(bool even) override; - void setHighlighted(bool highlight) override; - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - void layoutSubviews() override; -private: - MessageTextView m_messageTextView; -}; - -} - -#endif