[apps/calculations] Make the history view controller a delegate

to the table view

Change-Id: I69302f1999b7f6b7f051c71bcaeac43279b27ed2
This commit is contained in:
Émilie Feral
2016-10-26 17:52:32 +02:00
parent fa91379f51
commit db2374f75c
2 changed files with 8 additions and 2 deletions

View File

@@ -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();
};

View File

@@ -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;