From 400819d87df57576faa809d9e98d760006715dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 16 Oct 2019 14:59:56 +0200 Subject: [PATCH] [apps/calculation] HistoryViewCell: remove useless m_expandedCalculation --- apps/calculation/history_controller.cpp | 2 +- apps/calculation/history_view_cell.cpp | 23 ++++++----------------- apps/calculation/history_view_cell.h | 5 +---- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/apps/calculation/history_controller.cpp b/apps/calculation/history_controller.cpp index 244940127..49f88c0ba 100644 --- a/apps/calculation/history_controller.cpp +++ b/apps/calculation/history_controller.cpp @@ -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()); } diff --git a/apps/calculation/history_view_cell.cpp b/apps/calculation/history_view_cell.cpp index 82fc86bdf..7160d9081 100644 --- a/apps/calculation/history_view_cell.cpp +++ b/apps/calculation/history_view_cell.cpp @@ -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; -} - } diff --git a/apps/calculation/history_view_cell.h b/apps/calculation/history_view_cell.h index 6c5bae38d..36f4e39b2 100644 --- a/apps/calculation/history_view_cell.h +++ b/apps/calculation/history_view_cell.h @@ -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;