[escher] TableView::cellAtLocation should return nullptr if the cell is

invisible and therefore no view displays it.

Fix bug: add 4 functions, in the values table one cell is wrong as soon
as you edit an x value
This commit is contained in:
Émilie Feral
2018-11-26 10:25:36 +01:00
committed by LeaNumworks
parent f30df04dba
commit 55be86ef50
6 changed files with 16 additions and 3 deletions

View File

@@ -63,6 +63,7 @@ void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(Histo
* selected calculation has not changed. */
setContentOffset(KDPoint(contentOffsetX, contentOffsetY));
HighlightCell * cell = cellAtLocation(i, j);
assert(cell);
cell->setHighlighted(true);
if (m_delegate) {
m_delegate->tableViewDidChangeSelection(this, selectedColumn(), selectedRow());

View File

@@ -223,7 +223,9 @@ void ConsoleController::tableViewDidChangeSelection(SelectableTableView * t, int
if (previousSelectedCellY > -1 && previousSelectedCellY < m_consoleStore.numberOfLines()) {
// Reset the scroll of the previous cell
ConsoleLineCell * previousCell = (ConsoleLineCell *)(t->cellAtLocation(previousSelectedCellX, previousSelectedCellY));
previousCell->reloadCell();
if (previousCell) {
previousCell->reloadCell();
}
}
ConsoleLineCell * selectedCell = (ConsoleLineCell *)(t->selectedCell());
selectedCell->reloadCell();

View File

@@ -91,6 +91,7 @@ void CalculationController::tableViewDidChangeSelection(SelectableTableView * t,
/* 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. */
assert(myPreviousCell);
firstSubCellSelected = t->selectedColumn() == previousSelectedCellX ? myPreviousCell->firstTextSelected() : !myPreviousCell->firstTextSelected();
}
myCell->selectFirstText(firstSubCellSelected);

View File

@@ -159,7 +159,9 @@ void ListParameterController::tableViewDidChangeSelection(SelectableTableView *
if (previousSelectedCellY == 1) {
#endif
MessageTableCellWithEditableText * myCell = (MessageTableCellWithEditableText *)t->cellAtLocation(previousSelectedCellX, previousSelectedCellY);
myCell->setEditing(false);
if (myCell) {
myCell->setEditing(false);
}
app()->setFirstResponder(&m_selectableTableView);
}
#if FUNCTION_COLOR_CHOICE

View File

@@ -158,6 +158,7 @@ void SelectableTableView::unhighlightSelectedCell() {
if (selectedColumn() >= 0 && selectedColumn() < dataSource()->numberOfColumns() &&
selectedRow() >= 0 && selectedRow() < dataSource()->numberOfRows()) {
HighlightCell * previousCell = cellAtLocation(selectedColumn(), selectedRow());
assert(previousCell);
previousCell->setHighlighted(false);
}
}

View File

@@ -98,7 +98,10 @@ void TableView::ContentView::scrollToCell(int x, int y) const {
}
void TableView::ContentView::reloadCellAtLocation(int i, int j) {
m_dataSource->willDisplayCellAtLocation(cellAtLocation(i, j), i, j);
HighlightCell * cell = cellAtLocation(i, j);
if (cell) {
m_dataSource->willDisplayCellAtLocation(cellAtLocation(i, j), i, j);
}
}
int TableView::ContentView::typeOfSubviewAtIndex(int index) const {
@@ -123,6 +126,9 @@ int TableView::ContentView::typeIndexFromSubviewIndex(int index, int type) const
HighlightCell * TableView::ContentView::cellAtLocation(int x, int y) {
int relativeX = x-columnsScrollingOffset();
int relativeY = y-rowsScrollingOffset();
if (relativeY >= numberOfDisplayableRows() || relativeX >= numberOfDisplayableColumns()) {
return nullptr;
}
int type = m_dataSource->typeAtLocation(x, y);
int index = relativeY*numberOfDisplayableColumns()+relativeX;
int typeIndex = typeIndexFromSubviewIndex(index, type);