From d77f25432850ea2e2ea9e7fb84c49d52c3a308eb Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 7 Jan 2021 15:12:25 +0100 Subject: statistics: add a skeleton StatsManager class In analogy to "QMLManager", add a "StatsManager" class, which manages the statistics module on mobile. Signed-off-by: Berthold Stoeger --- mobile-widgets/CMakeLists.txt | 1 + mobile-widgets/statsmanager.cpp | 28 ++++++++++++++++++++++++++++ mobile-widgets/statsmanager.h | 20 ++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 mobile-widgets/statsmanager.cpp create mode 100644 mobile-widgets/statsmanager.h (limited to 'mobile-widgets') diff --git a/mobile-widgets/CMakeLists.txt b/mobile-widgets/CMakeLists.txt index 4e4135a5a..b02929bcb 100644 --- a/mobile-widgets/CMakeLists.txt +++ b/mobile-widgets/CMakeLists.txt @@ -3,6 +3,7 @@ set(SUBSURFACE_MOBILE_SRCS qmlinterface.cpp qmlmanager.cpp + statsmanager.cpp themeinterface.cpp ) diff --git a/mobile-widgets/statsmanager.cpp b/mobile-widgets/statsmanager.cpp new file mode 100644 index 000000000..2864a5f16 --- /dev/null +++ b/mobile-widgets/statsmanager.cpp @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "statsmanager.h" + +StatsManager::StatsManager() : view(nullptr) +{ + // Test: show some random data. Let's see what happens. + state.var1Changed(2); + state.var2Changed(3); + state.binner2Changed(2); +} + +StatsManager::~StatsManager() +{ +} + +void StatsManager::init(StatsView *v) +{ + if (!v) + fprintf(stderr, "StatsManager::init(): no StatsView - statistics will not work.\n"); + view = v; +} + +void StatsManager::doit() +{ + if (!view) + return; + view->plot(state); +} diff --git a/mobile-widgets/statsmanager.h b/mobile-widgets/statsmanager.h new file mode 100644 index 000000000..3cae244c0 --- /dev/null +++ b/mobile-widgets/statsmanager.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef STATSMANAGER_H +#define STATSMANAGER_H + +#include "stats/statsview.h" +#include "stats/statsstate.h" + +class StatsManager : public QObject { + Q_OBJECT +public: + StatsManager(); + ~StatsManager(); + Q_INVOKABLE void init(StatsView *v); + Q_INVOKABLE void doit(); +private: + StatsView *view; + StatsState state; +}; + +#endif -- cgit v1.2.3-70-g09d2