From 1982af1613ba095cbb0629d0c63d8f02c1c113b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 20 Nov 2018 10:59:10 +0100 Subject: [PATCH] [regression] CalculationController: fix sub cell selection --- apps/regression/calculation_controller.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index a8afa2b83..0d8a64aaf 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -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); }