From bd8ecf73dbf8f23e84bce2ca1a88c14befc3bdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 20 Dec 2016 10:14:51 +0100 Subject: [PATCH] [apps/probability] Add a pointer to the data model in the histogram controller Change-Id: I1297e10f1e30133d93e96becfb4bc49eb7a8a28d --- apps/statistics/app.cpp | 2 +- apps/statistics/histogram_controller.cpp | 10 +++++++--- apps/statistics/histogram_controller.h | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/statistics/app.cpp b/apps/statistics/app.cpp index 75b547900..f96d28ec8 100644 --- a/apps/statistics/app.cpp +++ b/apps/statistics/app.cpp @@ -12,7 +12,7 @@ App::App(Container * container) : m_boxController(BoxController(&m_boxAlternateEmptyViewController)), m_boxAlternateEmptyViewController(AlternateEmptyViewController(nullptr, &m_boxController, &m_boxController)), m_boxStackViewController(StackViewController(&m_tabViewController, &m_boxAlternateEmptyViewController)), - m_histogramController(HistogramController(&m_histogramHeader, &m_histogramHeader)), + m_histogramController(HistogramController(&m_histogramHeader, &m_histogramHeader, &m_data)), m_histogramHeader(HeaderViewController(&m_histogramAlternateEmptyViewController, &m_histogramController, &m_histogramController)), m_histogramAlternateEmptyViewController(AlternateEmptyViewController(nullptr, &m_histogramHeader, &m_histogramController)), m_histogramStackViewController(StackViewController(&m_tabViewController, &m_histogramAlternateEmptyViewController)), diff --git a/apps/statistics/histogram_controller.cpp b/apps/statistics/histogram_controller.cpp index 0e9dcf5e3..9f0f1ace4 100644 --- a/apps/statistics/histogram_controller.cpp +++ b/apps/statistics/histogram_controller.cpp @@ -2,12 +2,13 @@ namespace Statistics { -HistogramController::HistogramController(Responder * parentResponder, HeaderViewController * headerViewController) : +HistogramController::HistogramController(Responder * parentResponder, HeaderViewController * headerViewController, Data * data) : ViewController(parentResponder), HeaderViewDelegate(headerViewController), m_view(SolidColorView(KDColorGreen)), m_settingButton(Button(this, "Reglages de l'histogramme",Invocation([](void * context, void * sender) {}, this))), - m_selectedBin(0) + m_selectedBin(0), + m_data(data) { } @@ -49,11 +50,14 @@ Button * HistogramController::buttonAtIndex(int index) { } bool HistogramController::isEmpty() { + if (m_data->numberOfPairs() == 0) { + return true; + } return false; } const char * HistogramController::emptyMessage() { - return "Aucune donnée à tracer"; + return "Aucune donnee à tracer"; } Responder * HistogramController::defaultController() { diff --git a/apps/statistics/histogram_controller.h b/apps/statistics/histogram_controller.h index c0fed2498..0f7726ad8 100644 --- a/apps/statistics/histogram_controller.h +++ b/apps/statistics/histogram_controller.h @@ -2,13 +2,14 @@ #define STATISTICS_HISTOGRAM_CONTROLLER_H #include +#include "data.h" namespace Statistics { class HistogramController : public ViewController, public HeaderViewDelegate, public AlternateEmptyViewDelegate { public: - HistogramController(Responder * parentResponder, HeaderViewController * headerViewController); + HistogramController(Responder * parentResponder, HeaderViewController * headerViewController, Data * m_data); const char * title() const override; View * view() override; bool handleEvent(Ion::Events::Event event) override; @@ -24,6 +25,7 @@ private: SolidColorView m_view; Button m_settingButton; int m_selectedBin; + Data * m_data; }; }