[apps/*/editable_cell_table_view_controller] Use typeAtLocation

This commit is contained in:
Ruben Dashyan
2019-08-01 10:21:08 +02:00
parent dbb7d3d01c
commit 04fcc0eac4
7 changed files with 17 additions and 24 deletions

View File

@@ -23,8 +23,7 @@ ValuesController::ValuesController(Responder * parentResponder, InputEventHandle
}
bool ValuesController::handleEvent(Ion::Events::Event event) {
if ((event == Ion::Events::OK || event == Ion::Events::EXE) && selectedRow() == 0
&& selectedColumn()>0 && isDerivativeColumn(selectedColumn())) {
if ((event == Ion::Events::OK || event == Ion::Events::EXE) && typeAtLocation(selectedColumn(), selectedRow()) == 1 && isDerivativeColumn(selectedColumn())) {
configureDerivativeFunction();
return true;
}
@@ -34,13 +33,13 @@ bool ValuesController::handleEvent(Ion::Events::Event event) {
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
// The cell is the abscissa title cell:
if (j == 0 && i == 0) {
if (typeAtLocation(i,j) == 0) {
EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
mytitleCell->setMessage(I18n::Message::X);
return;
}
// The cell is a function title cell:
if (j == 0 && i > 0) {
if (typeAtLocation(i,j) == 1) {
Shared::BufferFunctionTitleCell * myFunctionCell = (Shared::BufferFunctionTitleCell *)cell;
const size_t bufferNameSize = Shared::Function::k_maxNameWithArgumentSize + 1;
char bufferName[bufferNameSize];
@@ -70,7 +69,7 @@ IntervalParameterController * ValuesController::intervalParameterController() {
}
Ion::Storage::Record ValuesController::recordAtColumn(int i) {
assert(i > 0);
assert(typeAtLocation(i, 0) == 1);
int index = 1;
for (int k = 0; k < functionStore()->numberOfDefinedModels(); k++) {
Ion::Storage::Record record = functionStore()->definedRecordAtIndex(k);
@@ -93,7 +92,7 @@ Ion::Storage::Record ValuesController::recordAtColumn(int i) {
}
bool ValuesController::isDerivativeColumn(int i) {
assert(i >= 1);
assert(typeAtLocation(i, 0) == 1);
int index = 1;
for (int k = 0; k < functionStore()->numberOfDefinedModels(); k++) {
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(functionStore()->definedRecordAtIndex(k));

View File

@@ -36,7 +36,7 @@ bool StoreController::fillColumnWithFormula(Expression formula) {
void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
::StoreController::willDisplayCellAtLocation(cell, i, j);
if (cellAtLocationIsEditable(i, j)) {
if (typeAtLocation(i, j) != k_titleCellType) {
return;
}
Shared::StoreTitleCell * mytitleCell = static_cast<Shared::StoreTitleCell *>(cell);

View File

@@ -23,13 +23,13 @@ ValuesController::ValuesController(Responder * parentResponder,InputEventHandler
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
// The cell is the abscissa title cell:
if (j == 0 && i == 0) {
if (typeAtLocation(i,j) == 0) {
EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
mytitleCell->setMessage(I18n::Message::N);
return;
}
// The cell is a function title cell:
if (j == 0 && i > 0) {
if (typeAtLocation(i,j) == 1) {
SequenceTitleCell * myCell = (SequenceTitleCell *)cell;
Sequence * sequence = functionStore()->modelForRecord(recordAtColumn(i));
myCell->setLayout(sequence->nameLayout());

View File

@@ -153,7 +153,7 @@ int StoreController::typeAtLocation(int i, int j) {
void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
// Handle the separator
if (cellAtLocationIsEditable(i, j)) {
if (typeAtLocation(i, j) == k_editableCellType) {
bool shouldHaveLeftSeparator = i % DoublePairStore::k_numberOfColumnsPerSeries == 0;
static_cast<StoreCell *>(cell)->setSeparatorLeft(shouldHaveLeftSeparator);
}
@@ -170,7 +170,7 @@ void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int
}
return;
}
if (cellAtLocationIsEditable(i, j)) {
if (typeAtLocation(i, j) == k_editableCellType) {
static_cast<StoreCell *>(cell)->setHide(false);
}
willDisplayCellAtLocationWithDisplayMode(cell, i, j, Preferences::PrintFloatMode::Decimal);
@@ -220,10 +220,7 @@ Responder * StoreController::tabController() const {
}
bool StoreController::cellAtLocationIsEditable(int columnIndex, int rowIndex) {
if (rowIndex > 0) {
return true;
}
return false;
return typeAtLocation(columnIndex, rowIndex) == k_editableCellType;
}
bool StoreController::setDataAtLocation(double floatBody, int columnIndex, int rowIndex) {

View File

@@ -75,7 +75,6 @@ protected:
};
Responder * tabController() const override;
bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override;
bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override;
double dataAtLocation(int columnIndex, int rowIndex) override;
virtual HighlightCell * titleCells(int index) = 0;
@@ -88,6 +87,7 @@ private:
SelectableTableView * selectableTableView() override {
return m_contentView.dataView();
}
bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override;
int numberOfElementsInColumn(int columnIndex) override;
int maxNumberOfElements() const override {
return DoublePairStore::k_maxNumberOfPairs;

View File

@@ -104,7 +104,7 @@ bool ValuesController::handleEvent(Ion::Events::Event event) {
return header()->handleEvent(event);
}
if ((event == Ion::Events::OK || event == Ion::Events::EXE) && selectedRow() == 0) {
if (selectedColumn() == 0) {
if (typeAtLocation(selectedColumn(), 0) == 0) {
configureAbscissa();
return true;
}
@@ -146,7 +146,7 @@ Button * ValuesController::buttonAtIndex(int index, ButtonRowController::Positio
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
willDisplayCellAtLocationWithDisplayMode(cell, i, j, Preferences::sharedPreferences()->displayMode());
// The cell is not a title cell and not editable
if (j > 0 && i > 0) {
if (typeAtLocation(i,j) == 3) {
constexpr int precision = Preferences::LargeNumberOfSignificantDigits;
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(precision)];
// Special case: last row
@@ -254,7 +254,7 @@ void ValuesController::viewDidDisappear() {
}
Ion::Storage::Record ValuesController::recordAtColumn(int i) {
assert(i > 0);
assert(typeAtLocation(i, 0) == 1);
return functionStore()->activeRecordAtIndex(i-1);
}
@@ -286,10 +286,7 @@ void ValuesController::configureFunction() {
}
bool ValuesController::cellAtLocationIsEditable(int columnIndex, int rowIndex) {
if (rowIndex > 0 && columnIndex == 0) {
return true;
}
return false;
return typeAtLocation(columnIndex, rowIndex) == 2;
}
bool ValuesController::setDataAtLocation(double floatBody, int columnIndex, int rowIndex) {

View File

@@ -39,7 +39,7 @@ bool StoreController::fillColumnWithFormula(Expression formula) {
void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
Shared::StoreController::willDisplayCellAtLocation(cell, i, j);
if (cellAtLocationIsEditable(i, j)) {
if (typeAtLocation(i, j) != k_titleCellType) {
return;
}
Shared::StoreTitleCell * mytitleCell = static_cast<Shared::StoreTitleCell *>(cell);