[apps/calculation] Clean how cell subtype is selected/

This fixes crashes: indeed, in the way it was done before, we called
scrollToSubviewOfTypeOfCellAtLocation after setting the new selected subtype
and before reloading the data. However, selecting a new subtype might expand
the selected cell which can temper with the cell repartition. If so, we need to
reload the data to be able to call 'selectedCell' for instance.
This commit is contained in:
Émilie Feral
2020-02-19 17:59:00 +01:00
committed by LeaNumworks
parent cf37e5c45a
commit 24d9f37205
4 changed files with 11 additions and 16 deletions

View File

@@ -44,10 +44,8 @@ void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(Histo
}
/* As we scroll, the selected calculation does not use the same history view
* cell, thus, we want to deselect the previous used history view cell. */
if (selectedRow() >= 0) {
HighlightCell * previousCell = selectedCell();
previousCell->setHighlighted(false);
}
unhighlightSelectedCell();
/* Main part of the scroll */
KDCoordinate contentOffsetX = contentOffset().x();
KDCoordinate contentOffsetY = dataSource()->cumulatedHeightFromIndex(j+1) - maxContentHeightDisplayableWithoutScrolling();
@@ -58,16 +56,13 @@ void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(Histo
contentOffsetY = dataSource()->cumulatedHeightFromIndex(j);
}
}
/* For the same reason, we have to rehighlight the new history view cell and
* inform the delegate which history view cell is highlighted even if the
* selected calculation has not changed. */
setContentOffset(KDPoint(contentOffsetX, contentOffsetY));
HighlightCell * cell = cellAtLocation(i, j);
/* For the same reason, we have to rehighlight the new history view cell and
* reselect the first responder. */
HistoryViewCell * cell = (HistoryViewCell *)(selectedCell());
assert(cell);
cell->setHighlighted(true);
if (m_delegate) {
m_delegate->tableViewDidChangeSelection(this, selectedColumn(), selectedRow());
}
Container::activeApp()->setFirstResponder(cell);
}