mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +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. */
|
||||
|
||||
Reference in New Issue
Block a user