[apps] Do not allow store expressions except in Calculation

This commit is contained in:
Léa Saviot
2018-11-16 15:38:25 +01:00
committed by Émilie Feral
parent c01d66c77b
commit 48d281e44d
8 changed files with 10 additions and 20 deletions

View File

@@ -52,7 +52,7 @@ StandardDeviation = "Standardabweichung"
Step = "Schrittwert"
StorageMemoryFull1 = "Der Speicher ist voll. Löschen Sie"
StorageMemoryFull2 = "von Daten und versuchen Sie es erneut."
StoreExpressionNotAcceptedAsFunction = "Eine Funktion darf kein 'store' enthalten"
StoreExpressionNotAllowed = "'store' ist verboten"
SyntaxError = "Syntaxfehler"
ToZoom = "Zoom: "
Trigonometric = "Trigonometrisch"

View File

@@ -48,7 +48,7 @@ RoundAbscissa = "Integer"
Sci = "sci/"
SquareSum = "Sum of squares"
StandardDeviation = "Standard deviation"
StoreExpressionNotAcceptedAsFunction = "A function cannot have a 'store'"
StoreExpressionNotAllowed = "'store' is not allowed"
StatTab = "Stats"
Step = "Step"
StorageMemoryFull1 = "The memory is full."

View File

@@ -52,7 +52,7 @@ StatTab = "Medidas"
Step = "Incremento"
StorageMemoryFull1 = "La memoria esta llena."
StorageMemoryFull2 = "Borre datos e intente de nuevo."
StoreExpressionNotAcceptedAsFunction = "Una funcion no puede incluir 'store'"
StoreExpressionNotAllowed = "'store' no está permitido"
SyntaxError = "Error sintactico"
ToZoom = "Zoom : "
Trigonometric = "Trigonometrico"

View File

@@ -52,7 +52,7 @@ StatTab = "Stats"
Step = "Pas"
StorageMemoryFull1 = "La mémoire est pleine."
StorageMemoryFull2 = "Effacez des données et réessayez."
StoreExpressionNotAcceptedAsFunction = "Une fonction ne peut pas contenir 'store'"
StoreExpressionNotAllowed = "'store' n'est pas autorisé"
SyntaxError = "Attention a la syntaxe"
ToZoom = "Zoomer : "
Trigonometric = "Trigonometrique"

View File

@@ -52,7 +52,7 @@ StatTab = "Estat"
Step = "Passo"
StorageMemoryFull1 = "A memoria esta chéia."
StorageMemoryFull2 = "Apage dados e tente novamente."
StoreExpressionNotAcceptedAsFunction = "Uma função não pode conter 'store'"
StoreExpressionNotAllowed = "'store' não está permitido"
SyntaxError = "Erro de sintaxe"
ToZoom = "Zoom : "
Trigonometric = "Trigonometrico"

View File

@@ -38,18 +38,4 @@ void StorageFunctionApp::willBecomeInactive() {
::App::willBecomeInactive();
}
bool StorageFunctionApp::isAcceptableExpression(const Expression exp, Responder * responder) {
if (TextFieldDelegateApp::isAcceptableExpression(exp, responder)) {
assert(!exp.isUninitialized());
if (exp.type() == ExpressionNode::Type::Store) {
// We do not want to allow a function to be "3->a" or "5->f(x)"
responder->app()->displayWarning(I18n::Message::StoreExpressionNotAcceptedAsFunction);
return false;
}
return true;
}
return false;
}
}

View File

@@ -39,7 +39,6 @@ protected:
StorageFunctionApp(Container * container, Snapshot * snapshot, ViewController * rootViewController) :
ExpressionFieldDelegateApp(container, snapshot, rootViewController)
{}
bool isAcceptableExpression(const Poincare::Expression expression, Responder * responder) override;
};
}

View File

@@ -64,6 +64,11 @@ bool TextFieldDelegateApp::isAcceptableExpression(const Expression exp, Responde
responder->app()->displayWarning(I18n::Message::SyntaxError);
return false;
}
if (exp.type() == ExpressionNode::Type::Store) {
// Most textfields do not allow Store "3->a" or "5->f(x)"
responder->app()->displayWarning(I18n::Message::StoreExpressionNotAllowed);
return false;
}
return true;
}