mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/graph] Specific error pop ups when renaming function
This commit is contained in:
@@ -20,3 +20,5 @@ NoIntersectionFound = "Kein Schnittpunkt gefunden"
|
||||
DerivativeFunctionColumn = "Spalte der Ableitungsfunktion"
|
||||
HideDerivativeColumn = "Ableitungsfunktion ausblenden"
|
||||
AllowedCharactersAZaz09 = "Erlaubte Zeichen: A-Z, a-z, 0-9, _"
|
||||
ReservedName = "Nom réservé"
|
||||
NameCannotStartWithNumber = "Un nom ne peut pas commencer par un chiffre"
|
||||
|
||||
@@ -20,3 +20,5 @@ NoIntersectionFound = "No intersection found"
|
||||
DerivativeFunctionColumn = "Derivative function column"
|
||||
HideDerivativeColumn = "Hide the derivative function"
|
||||
AllowedCharactersAZaz09 = "Allowed characters: A-Z, a-z, 0-9, _"
|
||||
ReservedName = "Reserved name"
|
||||
NameCannotStartWithNumber = "A name cannot start with a number"
|
||||
|
||||
@@ -20,3 +20,5 @@ NoIntersectionFound = "Ninguna intersección encontrada"
|
||||
DerivativeFunctionColumn = "Columna de la derivada"
|
||||
HideDerivativeColumn = "Ocultar la derivada"
|
||||
AllowedCharactersAZaz09 = "Caracteres permitidos : A-Z, a-z, 0-9, _"
|
||||
ReservedName = "Nombre reservado"
|
||||
NameCannotStartWithNumber = "Un nombre no puede empezar con un número"
|
||||
|
||||
@@ -20,3 +20,5 @@ NoIntersectionFound = "Aucune intersection trouvée"
|
||||
DerivativeFunctionColumn = "Colonne de la fonction derivee"
|
||||
HideDerivativeColumn = "Masquer la fonction derivee"
|
||||
AllowedCharactersAZaz09 = "Caractères autorisés : A-Z, a-z, 0-9, _"
|
||||
ReservedName = "Nom réservé"
|
||||
NameCannotStartWithNumber = "Un nom ne peut pas commencer par un chiffre"
|
||||
|
||||
@@ -20,3 +20,5 @@ NoIntersectionFound = "Nenhuma interseção encontrada"
|
||||
DerivativeFunctionColumn = "Coluna da funcao derivada"
|
||||
HideDerivativeColumn = "Esconder funcao derivada"
|
||||
AllowedCharactersAZaz09 = "Caracteres permitidos : A-Z, a-z, 0-9, _"
|
||||
ReservedName = "Nome reservado"
|
||||
NameCannotStartWithNumber = "Um nome não pode começar com um número"
|
||||
|
||||
@@ -58,7 +58,8 @@ bool StorageListController::textFieldDidFinishEditing(TextField * textField, con
|
||||
GlobalContext::DestroyRecordsBaseNamedWithoutExtension(baseName, GlobalContext::funcExtension /*TODO store elsewhere?*/);
|
||||
|
||||
// Set the name
|
||||
Ion::Storage::Record::ErrorStatus error = StorageFunction::BaseNameCompliant(baseName) ? modelStore()->recordAtIndex(m_selectableTableView.selectedRow()).setBaseNameWithExtension(baseName, GlobalContext::funcExtension /*TODO store elsewhere?*/) : Ion::Storage::Record::ErrorStatus::NonCompliantName;
|
||||
StorageFunction::NameNotCompliantError nameError = StorageFunction::NameNotCompliantError::None;
|
||||
Ion::Storage::Record::ErrorStatus error = StorageFunction::BaseNameCompliant(baseName, &nameError) ? modelStore()->recordAtIndex(m_selectableTableView.selectedRow()).setBaseNameWithExtension(baseName, GlobalContext::funcExtension /*TODO store elsewhere?*/) : Ion::Storage::Record::ErrorStatus::NonCompliantName;
|
||||
|
||||
// Handle any error
|
||||
if (error == Ion::Storage::Record::ErrorStatus::None) {
|
||||
@@ -85,7 +86,15 @@ bool StorageListController::textFieldDidFinishEditing(TextField * textField, con
|
||||
} else if (error == Ion::Storage::Record::ErrorStatus::NameTaken) {
|
||||
app()->displayWarning(I18n::Message::NameTaken);
|
||||
} else if (error == Ion::Storage::Record::ErrorStatus::NonCompliantName) {
|
||||
app()->displayWarning(I18n::Message::AllowedCharactersAZaz09);
|
||||
assert(nameError != StorageFunction::NameNotCompliantError::None);
|
||||
if (nameError == StorageFunction::NameNotCompliantError::CharacterNotAllowed) {
|
||||
app()->displayWarning(I18n::Message::AllowedCharactersAZaz09);
|
||||
} else if (nameError == StorageFunction::NameNotCompliantError::NameCannotStartWithNumber) {
|
||||
app()->displayWarning(I18n::Message::NameCannotStartWithNumber);
|
||||
} else {
|
||||
assert(nameError == StorageFunction::NameNotCompliantError::ReservedName);
|
||||
app()->displayWarning(I18n::Message::ReservedName);
|
||||
}
|
||||
} else {
|
||||
assert(error == Ion::Storage::Record::ErrorStatus::NotEnoughSpaceAvailable);
|
||||
app()->displayWarning(I18n::Message::NameTooLong);
|
||||
@@ -106,6 +115,13 @@ bool StorageListController::textFieldShouldFinishEditing(TextField * textField,
|
||||
return event == Ion::Events::Up || event == Ion::Events::Down || Shared::TextFieldDelegate::textFieldShouldFinishEditing(textField, event);
|
||||
}
|
||||
|
||||
bool StorageListController::textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) {
|
||||
if (textField->isEditing() && textField->shouldFinishEditing(event)) {
|
||||
return false;
|
||||
}
|
||||
return Shared::TextFieldDelegate::textFieldDidReceiveEvent(textField, event);
|
||||
}
|
||||
|
||||
StorageListParameterController * StorageListController::parameterController() {
|
||||
return &m_parameterController;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
|
||||
bool textFieldDidAbortEditing(TextField * textField) override;
|
||||
bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) override;
|
||||
bool textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) override;
|
||||
private:
|
||||
constexpr static int k_maxNumberOfDisplayableRows = 5;
|
||||
Shared::StorageListParameterController * parameterController() override;
|
||||
|
||||
@@ -11,11 +11,16 @@ namespace Shared {
|
||||
|
||||
char StorageFunction::k_parenthesedArgument[]("(x)");
|
||||
|
||||
bool StorageFunction::BaseNameCompliant(const char * baseName) {
|
||||
if (baseName[0] == 0 || (baseName[0] >= '0' && baseName[0] <= '9')) {
|
||||
// The name cannot be empty nor start with a number
|
||||
bool StorageFunction::BaseNameCompliant(const char * baseName, NameNotCompliantError * error) {
|
||||
assert(baseName[0] != 0);
|
||||
if (baseName[0] >= '0' && baseName[0] <= '9') {
|
||||
// The name cannot start with a number
|
||||
if (error != nullptr) {
|
||||
*error = NameNotCompliantError::NameCannotStartWithNumber;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char * currentChar = baseName;
|
||||
|
||||
// The name should only have allowed characters
|
||||
@@ -23,7 +28,11 @@ bool StorageFunction::BaseNameCompliant(const char * baseName) {
|
||||
if (!((*currentChar >= 'A' && *currentChar <= 'Z')
|
||||
|| (*currentChar >= 'a' && *currentChar <= 'z')
|
||||
|| (*currentChar >= '0' && *currentChar <= '9')
|
||||
|| *currentChar == '_')) {
|
||||
|| *currentChar == '_'))
|
||||
{
|
||||
if (error != nullptr) {
|
||||
*error = NameNotCompliantError::CharacterNotAllowed;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
currentChar++;
|
||||
@@ -31,6 +40,9 @@ bool StorageFunction::BaseNameCompliant(const char * baseName) {
|
||||
|
||||
// The name should not be a reserved name
|
||||
if (Parser::IsReservedName(baseName, strlen(baseName))) {
|
||||
if (error != nullptr) {
|
||||
*error = NameNotCompliantError::ReservedName;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -8,10 +8,16 @@ namespace Shared {
|
||||
|
||||
class StorageFunction : public StorageExpressionModel {
|
||||
public:
|
||||
enum class NameNotCompliantError {
|
||||
None = 0,
|
||||
CharacterNotAllowed,
|
||||
NameCannotStartWithNumber,
|
||||
ReservedName
|
||||
};
|
||||
constexpr static int k_parenthesedArgumentLength = 3;
|
||||
static char k_parenthesedArgument[k_parenthesedArgumentLength+1];
|
||||
constexpr static int k_maxNameWithArgumentSize = Poincare::SymbolAbstract::k_maxNameSize + k_parenthesedArgumentLength; /* Function name and null-terminating char + "(x)" */;
|
||||
static bool BaseNameCompliant(const char * baseName);
|
||||
static bool BaseNameCompliant(const char * baseName, NameNotCompliantError * error = nullptr);
|
||||
|
||||
// Constructors
|
||||
StorageFunction(Ion::Storage::Record record) : StorageExpressionModel(record){}
|
||||
|
||||
Reference in New Issue
Block a user