mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/calculation] Fix HistoryController/Store index
This commit is contained in:
@@ -49,7 +49,7 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
|
||||
EditExpressionController * editController = (EditExpressionController *)parentResponder();
|
||||
m_selectableTableView.deselectTable();
|
||||
Container::activeApp()->setFirstResponder(editController);
|
||||
Shared::ExpiringPointer<Calculation> calculation = m_calculationStore->calculationAtIndex(focusRow);
|
||||
Shared::ExpiringPointer<Calculation> calculation = calculationAtIndex(focusRow);
|
||||
if (subviewType == SubviewType::Input) {
|
||||
editController->insertTextBody(calculation->inputText());
|
||||
} else {
|
||||
@@ -69,7 +69,7 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
|
||||
SubviewType subviewType = selectedSubviewType();
|
||||
m_selectableTableView.deselectTable();
|
||||
EditExpressionController * editController = (EditExpressionController *)parentResponder();
|
||||
m_calculationStore->deleteCalculationAtIndex(focusRow);
|
||||
m_calculationStore->deleteCalculationAtIndex(storeIndex(focusRow));
|
||||
reload();
|
||||
if (numberOfRows()== 0) {
|
||||
Container::activeApp()->setFirstResponder(editController);
|
||||
@@ -104,6 +104,10 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Shared::ExpiringPointer<Calculation> HistoryController::calculationAtIndex(int i) {
|
||||
return m_calculationStore->calculationAtIndex(storeIndex(i));
|
||||
}
|
||||
|
||||
void HistoryController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
|
||||
if (withinTemporarySelection || previousSelectedCellY == selectedRow()) {
|
||||
return;
|
||||
@@ -141,7 +145,7 @@ int HistoryController::reusableCellCount(int type) {
|
||||
|
||||
void HistoryController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
HistoryViewCell * myCell = (HistoryViewCell *)cell;
|
||||
myCell->setCalculation((m_calculationStore->calculationAtIndex(numberOfRows()-index-1)).pointer(), index == selectedRow() && selectedSubviewType() == SubviewType::Output);
|
||||
myCell->setCalculation(calculationAtIndex(index).pointer(), index == selectedRow() && selectedSubviewType() == SubviewType::Output);
|
||||
myCell->setEven(index%2 == 0);
|
||||
myCell->setHighlighted(myCell->isHighlighted());
|
||||
}
|
||||
@@ -150,7 +154,7 @@ KDCoordinate HistoryController::rowHeight(int j) {
|
||||
if (j >= m_calculationStore->numberOfCalculations()) {
|
||||
return 0;
|
||||
}
|
||||
Shared::ExpiringPointer<Calculation> calculation = m_calculationStore->calculationAtIndex(j);
|
||||
Shared::ExpiringPointer<Calculation> calculation = calculationAtIndex(j);
|
||||
return calculation->height(App::app()->localContext(), j == selectedRow() && selectedSubviewType() == SubviewType::Output) + 4 * Metric::CommonSmallMargin;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ public:
|
||||
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) override;
|
||||
void scrollToCell(int i, int j);
|
||||
private:
|
||||
int storeIndex(int i) { return numberOfRows() - i - 1; }
|
||||
Shared::ExpiringPointer<Calculation> calculationAtIndex(int i);
|
||||
CalculationSelectableTableView * selectableTableView();
|
||||
void historyViewCellDidChangeSelection() override;
|
||||
constexpr static int k_maxNumberOfDisplayedRows = 5;
|
||||
|
||||
Reference in New Issue
Block a user