[apps] use variable box leaf cells in variable box controller

Change-Id: If3ef3850318b9a4c29af8539d09dd1111f2c985e
This commit is contained in:
Émilie Feral
2016-11-14 14:44:12 +01:00
parent df830b3b28
commit 0e3804d784
3 changed files with 46 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
#include "variable_box_controller.h"
#include "constant.h"
#include "variable_box_node.h"
const VariableBoxNode numberChildren[10] = {VariableBoxNode("A"), VariableBoxNode("B"), VariableBoxNode("C"),
@@ -14,6 +15,10 @@ const VariableBoxNode menu[3] = {VariableBoxNode("Nombres", numberChildren, 10),
VariableBoxNode("Matrices", matriceChildren, 10)};
const VariableBoxNode variableBoxModel = VariableBoxNode("Variables", menu, 3);
VariableBoxController::VariableBoxController(Context * context) :
m_context(context)
{
}
const char * VariableBoxController::title() const {
return "VariableBoxController";
@@ -28,8 +33,40 @@ TableViewCell * VariableBoxController::nodeCellAtIndex(int index) {
}
void VariableBoxController::willDisplayCellForIndex(TableViewCell * cell, int index) {
MenuListCell * myCell = (MenuListCell *)cell;
myCell->setText(m_listViewController.nodeModel()->children(index)->label());
const Node * node = m_listViewController.nodeModel()->children(index);
const char * label = node->label();
if (node->numberOfChildren() > 0) {
MenuListCell * myCell = (MenuListCell *)cell;
myCell->setText(label);
return;
}
const char * parentNodeLabel = m_listViewController.nodeModel()->label();
VariableBoxLeafCell * myCell = (VariableBoxLeafCell *)cell;
myCell->setLabel(label);
const Expression * expression = m_context->scalarExpressionForIndex(index);
if (strcmp(parentNodeLabel, "Matrices") == 0) {
//expression = m_context->matrixExpressionForIndex(index);
}
if (strcmp(parentNodeLabel, "Listes") == 0) {
//expression = m_context->listExpressionForIndex(index);
}
if (expression) {
myCell->setExpression(expression->createLayout());
}
if (strcmp(parentNodeLabel, "Nombres") == 0) {
myCell->setSubtitle("");
} else {
if (expression == nullptr) {
myCell->setSubtitle("Vide");
}
// TODO: display the dimension of the list/matrice
/* char buffer[4];
* buffer[0] = (Matrice *)expression->dim(0);
* buffer[1] = 'x';
* buffer[2] = (Matrice *)expression->dim(1)
* buffer[3] = 0;
* myCell->setSubtitle(buffer);*/
}
}
Node * VariableBoxController::nodeModel() {