[apps/solver] Do not select "User variables used" row

This commit is contained in:
Léa Saviot
2020-01-28 11:54:57 +01:00
parent db0e7f0d8b
commit 016a68d469
5 changed files with 17 additions and 9 deletions

View File

@@ -23,7 +23,7 @@ constexpr KDColor SolutionsController::ContentView::k_backgroundColor;
SolutionsController::ContentView::ContentView(SolutionsController * controller) :
m_warningMessageView0(KDFont::SmallFont, I18n::Message::Default, 0.5f, 0.5f, KDColorBlack, k_backgroundColor),
m_warningMessageView1(KDFont::SmallFont, I18n::Message::Default, 0.5f, 0.5f, KDColorBlack, k_backgroundColor),
m_selectableTableView(controller),
m_selectableTableView(controller, controller, controller, controller),
m_displayWarningMoreSolutions(false)
{
m_selectableTableView.setBackgroundColor(k_backgroundColor);
@@ -341,6 +341,18 @@ void SolutionsController::didBecomeFirstResponder() {
Container::activeApp()->setFirstResponder(m_contentView.selectableTableView());
}
void SolutionsController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
const int rowOfUserVariablesMessage = userVariablesMessageRow();
if (rowOfUserVariablesMessage < 0) {
return;
}
assert(rowOfUserVariablesMessage > 0);
// Forbid the selection of the messages row
if (t->selectedRow() == rowOfUserVariablesMessage) {
t->selectCellAtLocation(t->selectedColumn(), rowOfUserVariablesMessage + (rowOfUserVariablesMessage < previousSelectedCellY ? -1 : 1));
}
}
int SolutionsController::userVariablesMessageRow() const {
assert(m_equationStore->numberOfUserVariables() >= 0);
return m_equationStore->numberOfUserVariables() == 0 ? -1 : m_equationStore->numberOfSolutions();

View File

@@ -8,7 +8,7 @@
namespace Solver {
class SolutionsController : public ViewController, public AlternateEmptyViewDefaultDelegate, public SelectableTableViewDataSource, public TableViewDataSource {
class SolutionsController : public ViewController, public AlternateEmptyViewDefaultDelegate, public SelectableTableViewDataSource, public TableViewDataSource, public SelectableTableViewDelegate {
public:
SolutionsController(Responder * parentResponder, EquationStore * equationStore);
void setShouldReplaceFuncionsButNotSymbols(bool shouldReplaceFuncionsButNotSymbols) { m_shouldReplaceFunctionsButNotSymbols = shouldReplaceFuncionsButNotSymbols; }
@@ -35,7 +35,8 @@ public:
int typeAtLocation(int i, int j) override;
/* Responder */
void didBecomeFirstResponder() override;
/* SelectableTableViewDelegate */
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) override;
private:
class ContentView : public View {
public:

View File

@@ -58,7 +58,6 @@ escher_src += $(addprefix escher/src/,\
scrollable_expression_view.cpp \
scrollable_view.cpp \
selectable_table_view.cpp \
selectable_table_view_delegate.cpp \
simple_list_view_data_source.cpp \
simple_table_view_data_source.cpp \
solid_color_view.cpp \

View File

@@ -12,7 +12,7 @@ public:
* we deselect the table before re-layouting the entire table and re-select
* the previous selected cell. We might implement different course of action
* when the selection change is 'real' or within temporary selection. */
virtual void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false);
virtual void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) {}
};
#endif

View File

@@ -1,4 +0,0 @@
#include <escher/selectable_table_view_delegate.h>
void SelectableTableViewDelegate::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) {
}