[apps/calculation] Fix relayouting when highlighted cell changed

This fixes the following scenario: add "1.2" 5 times, go up three times,
and down three times, the last cell was not correctly relayout.
This commit is contained in:
Émilie Feral
2020-01-22 16:44:24 +01:00
committed by Léa Saviot
parent 86bd4be03e
commit 39dbb7d68c
3 changed files with 12 additions and 3 deletions

View File

@@ -192,7 +192,7 @@ void HistoryController::willDisplayCellForIndex(HighlightCell * cell, int index)
HistoryViewCell * myCell = (HistoryViewCell *)cell;
myCell->setCalculation(calculationAtIndex(index).pointer(), index == selectedRow() && selectedSubviewType() == SubviewType::Output);
myCell->setEven(index%2 == 0);
myCell->setHighlighted(myCell->isHighlighted());
myCell->reloadSubviewHighlight();
}
KDCoordinate HistoryController::rowHeight(int j) {

View File

@@ -22,7 +22,7 @@ void HistoryViewCellDataSource::setSelectedSubviewType(SubviewType subviewType,
HistoryViewCell * previouslySelectedCell = nullptr;
historyViewCellDidChangeSelection(&selectedCell, &previouslySelectedCell, previousSelectedCellX, previousSelectedCellY);
if (selectedCell) {
selectedCell->setHighlighted(selectedCell->isHighlighted());
selectedCell->reloadSubviewHighlight();
selectedCell->cellDidSelectSubview(subviewType);
}
if (previouslySelectedCell) {
@@ -56,8 +56,16 @@ void HistoryViewCell::setEven(bool even) {
}
void HistoryViewCell::setHighlighted(bool highlight) {
assert(m_dataSource);
if (m_highlighted == highlight) {
return;
}
m_highlighted = highlight;
// Re-layout as the ellispsis subview might have appear/disappear
layoutSubviews();
}
void HistoryViewCell::reloadSubviewHighlight() {
assert(m_dataSource);
m_inputView.setExpressionBackgroundColor(backgroundColor());
m_scrollableOutputView.evenOddCell()->setHighlighted(false);
m_ellipsis.setHighlighted(false);

View File

@@ -34,6 +34,7 @@ public:
void cellDidSelectSubview(HistoryViewCellDataSource::SubviewType type);
void setEven(bool even) override;
void setHighlighted(bool highlight) override;
void reloadSubviewHighlight();
void setDataSource(HistoryViewCellDataSource * dataSource) { m_dataSource = dataSource; }
Responder * responder() override {
return this;