From db2374f75cd96dbb550cebf0015e233ec48e5593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 26 Oct 2016 17:52:32 +0200 Subject: [PATCH] [apps/calculations] Make the history view controller a delegate to the table view Change-Id: I69302f1999b7f6b7f051c71bcaeac43279b27ed2 --- apps/calculation/history_controller.cpp | 7 ++++++- apps/calculation/history_controller.h | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/calculation/history_controller.cpp b/apps/calculation/history_controller.cpp index 456703e9a..4dfd44c2f 100644 --- a/apps/calculation/history_controller.cpp +++ b/apps/calculation/history_controller.cpp @@ -6,7 +6,7 @@ namespace Calculation { HistoryController::HistoryController(Responder * parentResponder, CalculationStore * calculationStore) : ViewController(parentResponder), - m_selectableTableView(SelectableTableView(this, this)), + m_selectableTableView(SelectableTableView(this, this, 0, 0, 0, 0, this)), m_calculationStore(calculationStore) { } @@ -43,6 +43,11 @@ bool HistoryController::handleEvent(Ion::Events::Event event) { } } +void HistoryController::tableViewDidChangeSelection(SelectableTableView * t) { + m_calculationHistory[t->selectedRow()].setParentResponder(t); + app()->setFirstResponder(&m_calculationHistory[t->selectedRow()]); +} + int HistoryController::numberOfRows() { return m_calculationStore->numberOfCalculations(); }; diff --git a/apps/calculation/history_controller.h b/apps/calculation/history_controller.h index c28eae673..db9c1b803 100644 --- a/apps/calculation/history_controller.h +++ b/apps/calculation/history_controller.h @@ -10,7 +10,7 @@ namespace Calculation { class App; -class HistoryController : public ViewController, ListViewDataSource { +class HistoryController : public ViewController, public ListViewDataSource, public SelectableTableViewDelegate { public: HistoryController(Responder * parentResponder, CalculationStore * calculationStore); @@ -28,6 +28,7 @@ public: KDCoordinate cumulatedHeightFromIndex(int j) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; int typeAtLocation(int i, int j) override; + void tableViewDidChangeSelection(SelectableTableView * t) override; private: constexpr static int k_maxNumberOfDisplayedRows = 10;