mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/calculation] HistoryViewCell: remove useless m_expandedCalculation
This commit is contained in:
@@ -161,7 +161,7 @@ int HistoryController::reusableCellCount(int type) {
|
||||
|
||||
void HistoryController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
HistoryViewCell * myCell = (HistoryViewCell *)cell;
|
||||
myCell->setCalculation(calculationAtIndex(index).pointer(), index == selectedRow() && selectedSubviewType() == SubviewType::Output);
|
||||
myCell->setCalculation(calculationAtIndex(index).pointer());
|
||||
myCell->setEven(index%2 == 0);
|
||||
myCell->setHighlighted(myCell->isHighlighted());
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ HistoryViewCell::HistoryViewCell(Responder * parentResponder) :
|
||||
Responder(parentResponder),
|
||||
m_calculationDisplayOutput(Calculation::DisplayOutput::Unknown),
|
||||
m_calculationAdditionalOutput(Calculation::AdditionalOutput::None),
|
||||
m_calculationExpanded(false),
|
||||
m_inputView(this),
|
||||
m_scrollableOutputView(this)
|
||||
{
|
||||
@@ -95,17 +94,17 @@ void HistoryViewCell::reloadOutputSelection() {
|
||||
}
|
||||
|
||||
void HistoryViewCell::cellDidSelectSubview(HistoryViewCellDataSource::SubviewType type) {
|
||||
bool outputSelected = type == HistoryViewCellDataSource::SubviewType::Output;
|
||||
// Init output selection
|
||||
if (type == HistoryViewCellDataSource::SubviewType::Output) {
|
||||
if (outputSelected) {
|
||||
reloadOutputSelection();
|
||||
}
|
||||
|
||||
/* The selected subview has changed. The displayed outputs might have changed.
|
||||
* For example, for the calculation 1.2+2 --> 3.2, selecting the output would
|
||||
* display 1.2+2 --> 16/5 = 3.2. */
|
||||
m_calculationExpanded = (type == HistoryViewCellDataSource::SubviewType::Output);
|
||||
m_scrollableOutputView.setDisplayLeftLayout(displayLeftLayout());
|
||||
m_scrollableOutputView.setDisplayBurger(displayBurger());
|
||||
m_scrollableOutputView.setDisplayLeftLayout(m_calculationDisplayOutput == Calculation::DisplayOutput::ExactAndApproximate || (m_calculationDisplayOutput == Calculation::DisplayOutput::ExactAndApproximateToggle && outputSelected));
|
||||
m_scrollableOutputView.setDisplayBurger(outputSelected && m_calculationAdditionalOutput != Calculation::AdditionalOutput::None);
|
||||
|
||||
/* The displayed outputs have changed. We need to re-layout the cell
|
||||
* and re-initialize the scroll. */
|
||||
@@ -144,9 +143,9 @@ void HistoryViewCell::layoutSubviews(bool force) {
|
||||
force);
|
||||
}
|
||||
|
||||
void HistoryViewCell::setCalculation(Calculation * calculation, bool expanded) {
|
||||
void HistoryViewCell::setCalculation(Calculation * calculation) {
|
||||
uint32_t newCalculationCRC = Ion::crc32Byte((const uint8_t *)calculation, ((char *)calculation->next()) - ((char *) calculation));
|
||||
if (m_calculationExpanded == expanded && newCalculationCRC == m_calculationCRC32) {
|
||||
if (newCalculationCRC == m_calculationCRC32) {
|
||||
return;
|
||||
}
|
||||
Poincare::Context * context = App::app()->localContext();
|
||||
@@ -157,7 +156,6 @@ void HistoryViewCell::setCalculation(Calculation * calculation, bool expanded) {
|
||||
|
||||
// Memoization
|
||||
m_calculationCRC32 = newCalculationCRC;
|
||||
m_calculationExpanded = expanded;
|
||||
m_calculationDisplayOutput = calculation->displayOutput(context);
|
||||
m_calculationAdditionalOutput = calculation->additionalOuput(context);
|
||||
m_inputView.setLayout(calculation->createInputLayout());
|
||||
@@ -201,13 +199,4 @@ bool HistoryViewCell::handleEvent(Ion::Events::Event event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HistoryViewCell::displayLeftLayout() const {
|
||||
return (m_calculationDisplayOutput == Calculation::DisplayOutput::ExactAndApproximate)
|
||||
|| (m_calculationDisplayOutput == Calculation::DisplayOutput::ExactAndApproximateToggle && m_calculationExpanded);
|
||||
}
|
||||
|
||||
bool HistoryViewCell::displayBurger() const {
|
||||
return m_calculationAdditionalOutput != Calculation::AdditionalOutput::None && m_calculationExpanded;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
}
|
||||
Poincare::Layout layout() const override;
|
||||
KDColor backgroundColor() const override;
|
||||
void setCalculation(Calculation * calculation, bool expanded = false);
|
||||
void setCalculation(Calculation * calculation);
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews(bool force = false) override;
|
||||
@@ -51,12 +51,9 @@ private:
|
||||
constexpr static KDCoordinate k_resultWidth = 80;
|
||||
void reloadScroll();
|
||||
void reloadOutputSelection();
|
||||
bool displayLeftLayout() const;
|
||||
bool displayBurger() const;
|
||||
uint32_t m_calculationCRC32;
|
||||
Calculation::DisplayOutput m_calculationDisplayOutput;
|
||||
Calculation::AdditionalOutput m_calculationAdditionalOutput;
|
||||
bool m_calculationExpanded;
|
||||
ScrollableExpressionView m_inputView;
|
||||
Shared::ScrollableExactApproximateExpressionsView m_scrollableOutputView;
|
||||
HistoryViewCellDataSource * m_dataSource;
|
||||
|
||||
Reference in New Issue
Block a user