From b9183eb84d22ea96f0ae0709e57529e04dd66a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 10 Apr 2017 10:52:22 +0200 Subject: [PATCH] [apps/graph][apps/sequence] In function store model, specify the implementation of removeAll (always let an empty function in cartesian functions) Change-Id: I5e91a0ea427ba823eee4f86cdd8b7cd5426df2c6 --- apps/graph/cartesian_function_store.cpp | 8 ++++++++ apps/graph/cartesian_function_store.h | 1 + apps/sequence/sequence_store.cpp | 7 +++++++ apps/sequence/sequence_store.h | 1 + apps/shared/function_store.cpp | 6 ------ apps/shared/function_store.h | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/apps/graph/cartesian_function_store.cpp b/apps/graph/cartesian_function_store.cpp index 46a2cfc07..fd7fc373c 100644 --- a/apps/graph/cartesian_function_store.cpp +++ b/apps/graph/cartesian_function_store.cpp @@ -100,4 +100,12 @@ const KDColor CartesianFunctionStore::firstAvailableColor() { return k_defaultColors[0]; } +void CartesianFunctionStore::removeAll() { + for (int i = 0; i < m_numberOfFunctions; i++) { + m_functions[i] = CartesianFunction("", KDColorBlack); + } + m_numberOfFunctions = 0; + addEmptyFunction(); +} + } diff --git a/apps/graph/cartesian_function_store.h b/apps/graph/cartesian_function_store.h index f02c6cdb9..0d146e2b8 100644 --- a/apps/graph/cartesian_function_store.h +++ b/apps/graph/cartesian_function_store.h @@ -19,6 +19,7 @@ public: void removeFunction(Shared::Function * f) override; int maxNumberOfFunctions() override; char symbol() const override; + void removeAll() override; static constexpr int k_maxNumberOfFunctions = 8; private: const char * firstAvailableName() override; diff --git a/apps/sequence/sequence_store.cpp b/apps/sequence/sequence_store.cpp index ea4df6f29..adbb9f642 100644 --- a/apps/sequence/sequence_store.cpp +++ b/apps/sequence/sequence_store.cpp @@ -93,4 +93,11 @@ const KDColor SequenceStore::firstAvailableColor() { return k_defaultColors[0]; } +void SequenceStore::removeAll() { + for (int i = 0; i < m_numberOfFunctions; i++) { + m_sequences[i] = Sequence("", KDColorBlack); + } + m_numberOfFunctions = 0; +} + } diff --git a/apps/sequence/sequence_store.h b/apps/sequence/sequence_store.h index 83b1d9335..05f9c4583 100644 --- a/apps/sequence/sequence_store.h +++ b/apps/sequence/sequence_store.h @@ -20,6 +20,7 @@ public: int maxNumberOfFunctions() override; const char * firstAvailableName() override; char symbol() const override; + void removeAll() override; static constexpr int k_maxNumberOfSequences = 3; private: const KDColor firstAvailableColor() override; diff --git a/apps/shared/function_store.cpp b/apps/shared/function_store.cpp index af99fe14f..0c735f7aa 100644 --- a/apps/shared/function_store.cpp +++ b/apps/shared/function_store.cpp @@ -62,10 +62,4 @@ int FunctionStore::numberOfDefinedFunctions() { return result; } -void FunctionStore::removeAll() { - for (int i = 0; i < numberOfFunctions(); i++) { - removeFunction(functionAtIndex(i)); - } -} - } diff --git a/apps/shared/function_store.h b/apps/shared/function_store.h index 9e298238c..b8d8272ae 100644 --- a/apps/shared/function_store.h +++ b/apps/shared/function_store.h @@ -18,7 +18,7 @@ public: virtual Function * definedFunctionAtIndex(int i); virtual Function * addEmptyFunction() = 0; virtual void removeFunction(Function * f) = 0; - void removeAll(); + virtual void removeAll() = 0; int numberOfFunctions(); // Functions can be undefined when they have a color and a name but no content int numberOfDefinedFunctions();