mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/calculation] Factorize code to avoid selecting ellipsis on cell
where ellipsis is not displayed
This commit is contained in:
@@ -128,10 +128,6 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
|
||||
return true;
|
||||
}
|
||||
m_selectableTableView.selectCellAtLocation(0, focusRow > 0 ? focusRow - 1 : 0);
|
||||
HistoryViewCell * selectedCell = static_cast<HistoryViewCell *>(m_selectableTableView.selectedCell());
|
||||
if (subviewType == SubviewType::Ellipsis && selectedCell->additionalInformationType() == Calculation::AdditionalInformationType::None) {
|
||||
subviewType = SubviewType::Output;
|
||||
}
|
||||
setSelectedSubviewType(subviewType, true, 0, selectedRow());
|
||||
return true;
|
||||
}
|
||||
@@ -168,9 +164,6 @@ void HistoryController::tableViewDidChangeSelectionAndDidScroll(SelectableTableV
|
||||
if (selectedCell && !selectedCell->displaysSingleLine()) {
|
||||
nextSelectedSubviewType = previousSelectedCellY < selectedRow() ? SubviewType::Input : SubviewType::Output;
|
||||
}
|
||||
if (nextSelectedSubviewType == SubviewType::Ellipsis && selectedCell->additionalInformationType() == Calculation::AdditionalInformationType::None) {
|
||||
nextSelectedSubviewType = SubviewType::Output;
|
||||
}
|
||||
setSelectedSubviewType(nextSelectedSubviewType, false, previousSelectedCellX, previousSelectedCellY);
|
||||
}
|
||||
// The selectedCell may change during setSelectedSubviewType
|
||||
@@ -227,6 +220,16 @@ bool HistoryController::calculationAtIndexToggles(int index) {
|
||||
return index >= 0 && index < m_calculationStore->numberOfCalculations() && calculationAtIndex(index)->displayOutput(context) == Calculation::DisplayOutput::ExactAndApproximateToggle;
|
||||
}
|
||||
|
||||
|
||||
void HistoryController::setSelectedSubviewType(SubviewType subviewType, bool sameCell, int previousSelectedX, int previousSelectedY) {
|
||||
// Avoid selecting non-displayed ellipsis
|
||||
HistoryViewCell * selectedCell = static_cast<HistoryViewCell *>(m_selectableTableView.selectedCell());
|
||||
if (subviewType == SubviewType::Ellipsis && selectedCell && selectedCell->additionalInformationType() == Calculation::AdditionalInformationType::None) {
|
||||
subviewType = SubviewType::Output;
|
||||
}
|
||||
HistoryViewCellDataSource::setSelectedSubviewType(subviewType, sameCell, previousSelectedX, previousSelectedY);
|
||||
}
|
||||
|
||||
void HistoryController::historyViewCellDidChangeSelection(HistoryViewCell ** cell, HistoryViewCell ** previousCell, int previousSelectedCellX, int previousSelectedCellY, SubviewType type, SubviewType previousType) {
|
||||
/* If the selection change triggers the toggling of the outputs, we update
|
||||
* the whole table as the height of the selected cell row might have changed. */
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
void setSelectedSubviewType(SubviewType subviewType, bool sameCell, int previousSelectedX = -1, int previousSelectedY = -1) override;
|
||||
void tableViewDidChangeSelectionAndDidScroll(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) override;
|
||||
private:
|
||||
int storeIndex(int i) { return numberOfRows() - i - 1; }
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
Ellipsis = 3
|
||||
};
|
||||
HistoryViewCellDataSource() : m_selectedSubviewType(SubviewType::Output) {}
|
||||
void setSelectedSubviewType(SubviewType subviewType, bool sameCell, int previousSelectedX = -1, int previousSelectedY = -1);
|
||||
virtual void setSelectedSubviewType(SubviewType subviewType, bool sameCell, int previousSelectedX = -1, int previousSelectedY = -1);
|
||||
SubviewType selectedSubviewType() const { return m_selectedSubviewType; }
|
||||
private:
|
||||
/* This method should belong to a delegate instead of a data source but as
|
||||
|
||||
Reference in New Issue
Block a user