[apps/shared] didChangeCell reload only cells corresponding to the

modified abscissa
This commit is contained in:
Émilie Feral
2019-10-07 11:10:46 +02:00
committed by LeaNumworks
parent cd7071277b
commit e87a096689
6 changed files with 15 additions and 11 deletions

View File

@@ -207,6 +207,10 @@ Shared::Interval * ValuesController::intervalAtColumn(int columnIndex) {
// Number of columns
int ValuesController::numberOfColumnsForAbscissaColumn(int column) {
return numberOfColumnsForPlotType((int)plotTypeAtColumn(&column));
}
int ValuesController::numberOfColumnsForRecord(Ion::Storage::Record record) const {
ExpiringPointer<ContinuousFunction> f = functionStore()->modelForRecord(record);
ContinuousFunction::PlotType plotType = f->plotType();

View File

@@ -65,6 +65,7 @@ private:
Shared::Interval * intervalAtColumn(int columnIndex) override;
// Number of columns
int numberOfColumnsForAbscissaColumn(int column) override;
int numberOfColumnsForRecord(Ion::Storage::Record record) const;
int numberOfColumnsForPlotType(int plotTypeIndex) const;
int numberOfAbscissaColumnsBeforeColumn(int column);

View File

@@ -40,11 +40,11 @@ bool EditableCellTableViewController::textFieldDidFinishEditing(TextField * text
* data is reloaded, which means that the right cell is selected but the data
* may be incorrect. The data is reloaded afterwards. */
if (event == Ion::Events::EXE || event == Ion::Events::OK) {
selectableTableView()->selectCellAtLocation(selectedColumn(), selectedRow()+1);
selectableTableView()->selectCellAtLocation(column, selectedRow()+1);
} else {
selectableTableView()->handleEvent(event);
}
didChangeRow(previousRow);
didChangeCell(column, previousRow);
if (previousNumberOfElementsInColumn != numberOfElementsInColumn(column)) {
// Reload the whole table, if a value was appended.
selectableTableView()->reloadData();

View File

@@ -25,7 +25,7 @@ protected:
static constexpr KDCoordinate k_margin = Metric::TableSeparatorThickness;
static constexpr KDCoordinate k_scrollBarMargin = Metric::CommonRightMargin;
private:
virtual void didChangeRow(int row) {}
virtual void didChangeCell(int column, int row) {}
virtual bool cellAtLocationIsEditable(int columnIndex, int rowIndex) = 0;
virtual bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) = 0;
virtual double dataAtLocation(int columnIndex, int rowIndex) = 0;

View File

@@ -225,7 +225,7 @@ double ValuesController::dataAtLocation(int columnIndex, int rowIndex) {
return intervalAtColumn(columnIndex)->element(rowIndex-1);
}
void ValuesController::didChangeRow(int row) {
void ValuesController::didChangeCell(int column, int row) {
/* Update the row memoization if it exists */
// the first row is never reloaded as it corresponds to title row
assert(row > 0);
@@ -236,14 +236,12 @@ void ValuesController::didChangeRow(int row) {
return;
}
// Update the memoization of rows linked to the changed cell
int memoizedRow = valuesRow - m_firstMemoizedRow;
int maxI = numberOfValuesColumns() - m_firstMemoizedColumn;
int nbOfMemoizedColumns = numberOfMemoizedColumn();
for (int i = 0; i < minInt(nbOfMemoizedColumns, maxI); i++) {
// Fill only visible cells
if (valuesRow < numberOfElementsInColumn(i)) {
fillMemoizedBuffer(absoluteColumnForValuesColumn(m_firstMemoizedColumn + i), row, nbOfMemoizedColumns*memoizedRow+i);
}
for (int i = column+1; i < column+numberOfColumnsForAbscissaColumn(column); i++) {
int memoizedI = valuesColumnForAbsoluteColumn(i) - m_firstMemoizedColumn;
fillMemoizedBuffer(i, row, nbOfMemoizedColumns*memoizedRow+memoizedI);
}
}

View File

@@ -92,7 +92,7 @@ private:
// EditableCellTableViewController
bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override;
double dataAtLocation(int columnIndex, int rowIndex) override;
void didChangeRow(int row) override;
void didChangeCell(int column, int row) override;
virtual int numberOfValuesColumns() { return functionStore()->numberOfActiveFunctions(); }
int maxNumberOfElements() const override {
return Interval::k_maxNumberOfElements;
@@ -113,6 +113,7 @@ private:
virtual void fillMemoizedBuffer(int i, int j, int index) = 0;
/* m_firstMemoizedColumn and m_firstMemoizedRow are coordinates of the table
* of values cells.*/
virtual int numberOfColumnsForAbscissaColumn(int column) { assert(column == 0); return numberOfColumns(); }
mutable int m_firstMemoizedColumn;
mutable int m_firstMemoizedRow;