[apps/calculation] HistoryViewCell: when reloading the entire table due

to a cell selection, the cell used for the selected row might change. We
thereby have to update the selected cell once the table has been
reloaded.

This fixes the following bug: add 5 times the calculation "12.2". Go up,
the selected expression is the left one instead of the right one.
This commit is contained in:
Émilie Feral
2020-01-03 12:40:39 +01:00
committed by LeaNumworks
parent 6a5708a562
commit f3c6aab669
4 changed files with 13 additions and 11 deletions

View File

@@ -112,13 +112,12 @@ void HistoryController::tableViewDidChangeSelection(SelectableTableView * t, int
if (withinTemporarySelection || previousSelectedCellY == selectedRow()) {
return;
}
HistoryViewCell * cell = static_cast<HistoryViewCell *>(t->selectedCell());
if (previousSelectedCellY == -1) {
setSelectedSubviewType(SubviewType::Output, cell);
setSelectedSubviewType(SubviewType::Output);
} else if (selectedRow() < previousSelectedCellY) {
setSelectedSubviewType(SubviewType::Output, cell);
setSelectedSubviewType(SubviewType::Output);
} else if (selectedRow() > previousSelectedCellY) {
setSelectedSubviewType(SubviewType::Input, cell);
setSelectedSubviewType(SubviewType::Input);
}
HistoryViewCell * selectedCell = (HistoryViewCell *)(t->selectedCell());
if (selectedCell == nullptr) {
@@ -166,10 +165,12 @@ void HistoryController::scrollToCell(int i, int j) {
m_selectableTableView.scrollToCell(i, j);
}
void HistoryController::historyViewCellDidChangeSelection() {
HistoryViewCell * HistoryController::historyViewCellDidChangeSelection() {
/* Update the whole table as the height of the selected cell row might have
* changed. */
m_selectableTableView.reloadData();
// Return the selected cell if one
return static_cast<HistoryViewCell *>(m_selectableTableView.selectedCell());
}
}