[regression] CalculationController: fix sub cell selection

This commit is contained in:
Émilie Feral
2018-11-20 10:59:10 +01:00
committed by LeaNumworks
parent f6edf05708
commit 1982af1613

View File

@@ -82,11 +82,17 @@ void CalculationController::tableViewDidChangeSelection(SelectableTableView * t,
}
}
if (t->selectedColumn() > 0 && t->selectedRow() >= 0 && t->selectedRow() <= k_totalNumberOfDoubleBufferRows) {
// If we are on a double text cell, we have to choose which subcell to select
EvenOddDoubleBufferTextCellWithSeparator * myCell = (EvenOddDoubleBufferTextCellWithSeparator *)t->selectedCell();
// Default selected subcell is the left one
bool firstSubCellSelected = true;
if (previousSelectedCellX > 0 && previousSelectedCellY >= 0 && previousSelectedCellY <= k_totalNumberOfDoubleBufferRows) {
// If we come from another double text cell, we have to update subselection
EvenOddDoubleBufferTextCellWithSeparator * myPreviousCell = (EvenOddDoubleBufferTextCellWithSeparator *)t->cellAtLocation(previousSelectedCellX, previousSelectedCellY);
firstSubCellSelected = myPreviousCell->firstTextSelected();
/* If the selection stays in the same column, we copy the subselection
* from previous cell. Otherwise, the selection has jumped to another
* column, we thus subselect the other subcell. */
firstSubCellSelected = t->selectedColumn() == previousSelectedCellX ? myPreviousCell->firstTextSelected() : !myPreviousCell->firstTextSelected();
}
myCell->selectFirstText(firstSubCellSelected);
}