[apps/sequence/list] Enable to delete all sequences

Change-Id: I923a5461b81352730ed4cba182c851c53b4cd33e
This commit is contained in:
Émilie Feral
2017-02-09 09:48:18 +01:00
parent 4f7658b271
commit 64280be6ac
4 changed files with 21 additions and 19 deletions

View File

@@ -9,8 +9,7 @@ namespace Sequence {
ListParameterController::ListParameterController(Responder * parentResponder, SequenceStore * sequenceStore) :
Shared::ListParameterController(parentResponder, sequenceStore),
m_typeCell(ChevronExpressionMenuListCell((char *)"Type de suite")),
m_sequence(nullptr)
m_typeCell(ChevronExpressionMenuListCell((char *)"Type de suite"))
{
}
@@ -27,31 +26,35 @@ const char * ListParameterController::title() const {
void ListParameterController::setSequence(Sequence * sequence) {
setFunction(sequence);
m_sequence = sequence;
if (m_typeLayout != nullptr) {
delete m_typeLayout;
m_typeLayout = nullptr;
}
if (m_sequence->type() == Sequence::Type::Explicite) {
m_typeLayout = new BaselineRelativeLayout(new StringLayout(m_sequence->name(), 1), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
if (sequence->type() == Sequence::Type::Explicite) {
m_typeLayout = new BaselineRelativeLayout(new StringLayout(sequence->name(), 1), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
}
if (m_sequence->type() == Sequence::Type::SingleRecurrence) {
m_typeLayout = new BaselineRelativeLayout(new StringLayout(m_sequence->name(), 1), new StringLayout("n+1", 3, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
if (sequence->type() == Sequence::Type::SingleRecurrence) {
m_typeLayout = new BaselineRelativeLayout(new StringLayout(sequence->name(), 1), new StringLayout("n+1", 3, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
}
if (m_sequence->type() == Sequence::Type::DoubleRecurrence) {
m_typeLayout = new BaselineRelativeLayout(new StringLayout(m_sequence->name(), 1), new StringLayout("n+2", 3, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
if (sequence->type() == Sequence::Type::DoubleRecurrence) {
m_typeLayout = new BaselineRelativeLayout(new StringLayout(sequence->name(), 1), new StringLayout("n+2", 3, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
}
m_typeCell.setExpression(m_typeLayout);
}
bool ListParameterController::handleEvent(Ion::Events::Event event) {
if (Shared::ListParameterController::handleEvent(event)) {
return true;
}
if (event == Ion::Events::OK && m_selectableTableView.selectedRow() == 4) {
if (event == Ion::Events::OK && m_selectableTableView.selectedRow() == 3) {
return false;
}
return false;
if (event == Ion::Events::OK && m_selectableTableView.selectedRow() == 2) {
if (m_functionStore->numberOfFunctions() > 0) {
m_functionStore->removeFunction(m_function);
StackViewController * stack = (StackViewController *)(parentResponder());
stack->pop();
return true;
}
}
return Shared::ListParameterController::handleEvent(event);
}
int ListParameterController::numberOfRows() {

View File

@@ -21,7 +21,6 @@ private:
constexpr static int k_totalNumberOfCell = 4;
ChevronExpressionMenuListCell m_typeCell;
Poincare::ExpressionLayout * m_typeLayout;
Sequence * m_sequence;
};
}

View File

@@ -7,10 +7,10 @@ ListParameterController::ListParameterController(Responder * parentResponder, Fu
ViewController(parentResponder),
m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin,
Metric::BottomMargin, Metric::LeftMargin)),
m_functionStore(functionStore),
m_colorCell(ChevronMenuListCell((char*)"Couleur de la fonction")),
m_enableCell(SwitchMenuListCell((char*)"Activer/Desactiver")),
m_deleteCell(MenuListCell((char*)"Supprimer la fonction")),
m_functionStore(functionStore)
m_deleteCell(MenuListCell((char*)"Supprimer la fonction"))
{
}

View File

@@ -23,13 +23,13 @@ public:
void willDisplayCellForIndex(TableViewCell * cell, int index) override;
protected:
SelectableTableView m_selectableTableView;
FunctionStore * m_functionStore;
Function * m_function;
private:
constexpr static int k_totalNumberOfCell = 3;
ChevronMenuListCell m_colorCell;
SwitchMenuListCell m_enableCell;
MenuListCell m_deleteCell;
Function * m_function;
FunctionStore * m_functionStore;
};
}