From eb976ad0cf689bdaaead088f18e75b8bd66bb1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 3 Jan 2017 15:30:45 +0100 Subject: [PATCH] [apps/graph/values] Enable to delete row by row Change-Id: I25b14091711af3d7afd64413839a2664fc98a051 --- apps/graph/values/interval.cpp | 8 ++++++++ apps/graph/values/interval.h | 1 + apps/graph/values/values_controller.cpp | 7 ++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/graph/values/interval.cpp b/apps/graph/values/interval.cpp index c1804fb93..6cc588b29 100644 --- a/apps/graph/values/interval.cpp +++ b/apps/graph/values/interval.cpp @@ -16,6 +16,14 @@ int Interval::numberOfElements() { return m_numberOfElements; } +void Interval::deleteElementAtIndex(int index) { + m_numberOfElements--; + for (int k = index; k < m_numberOfElements; k++) { + m_intervalBuffer[k] = m_intervalBuffer[k+1]; + } + m_intervalBuffer[m_numberOfElements] = 0.0f; +} + float Interval::element(int i) { assert(i >= 0 && i < numberOfElements()); computeElements(); diff --git a/apps/graph/values/interval.h b/apps/graph/values/interval.h index 34455c069..69476714a 100644 --- a/apps/graph/values/interval.h +++ b/apps/graph/values/interval.h @@ -9,6 +9,7 @@ public: // Delete the implicit copy constructor: the object is heavy Interval(const Interval&) = delete; int numberOfElements(); + void deleteElementAtIndex(int index); float element(int i); float start(); float end(); diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index ff03d4ad7..4ae13f643 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -56,7 +56,12 @@ bool ValuesController::handleEvent(Ion::Events::Event event) { headerViewController()->setSelectedButton(0); return true; } - + if (event == Ion::Events::Clear && activeRow() > 0 && + (activeRow() < numberOfRows()-1 || m_interval.numberOfElements() == Interval::k_maxNumberOfElements)) { + m_interval.deleteElementAtIndex(m_selectableTableView.selectedRow()-1); + m_selectableTableView.reloadData(); + return true; + } if (event == Ion::Events::OK) { if (activeRow() == -1) { return headerViewController()->handleEvent(event);