[apps/calculation] Fix history navigation

When calculations span on two lines, better selection
This commit is contained in:
Léa Saviot
2020-05-27 11:52:47 +02:00
committed by EmilieNumworks
parent a56a73b0ba
commit b034f8e054
2 changed files with 10 additions and 1 deletions

View File

@@ -169,8 +169,14 @@ void HistoryController::tableViewDidChangeSelection(SelectableTableView * t, int
} else if (selectedRow() == -1) { } else if (selectedRow() == -1) {
setSelectedSubviewType(SubviewType::Input, false, previousSelectedCellX, previousSelectedCellY); setSelectedSubviewType(SubviewType::Input, false, previousSelectedCellX, previousSelectedCellY);
} else { } else {
setSelectedSubviewType(selectedSubviewType(), false, previousSelectedCellX, previousSelectedCellY); HistoryViewCell * selectedCell = (HistoryViewCell *)(t->selectedCell());
SubviewType nextSelectedSubviewType = selectedSubviewType();
if (!selectedCell->displaysSingleLine()) {
nextSelectedSubviewType = previousSelectedCellY < selectedRow() ? SubviewType::Input : SubviewType::Output;
}
setSelectedSubviewType(nextSelectedSubviewType, false, previousSelectedCellX, previousSelectedCellY);
} }
// The selectedCell may change during setSelectedSubviewType
HistoryViewCell * selectedCell = (HistoryViewCell *)(t->selectedCell()); HistoryViewCell * selectedCell = (HistoryViewCell *)(t->selectedCell());
if (selectedCell == nullptr) { if (selectedCell == nullptr) {
return; return;

View File

@@ -42,6 +42,9 @@ public:
void setHighlighted(bool highlight) override; void setHighlighted(bool highlight) override;
void reloadSubviewHighlight(); void reloadSubviewHighlight();
void setDataSource(HistoryViewCellDataSource * dataSource) { m_dataSource = dataSource; } void setDataSource(HistoryViewCellDataSource * dataSource) { m_dataSource = dataSource; }
bool displaysSingleLine() const {
return m_calculationSingleLine;
}
Responder * responder() override { Responder * responder() override {
return this; return this;
} }