diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-07 15:12:25 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-01-10 15:16:52 -0800 |
commit | d77f25432850ea2e2ea9e7fb84c49d52c3a308eb (patch) | |
tree | 49c284199f232585dc5c74b4767c845605d747da | |
parent | e7907c494f7f78831c2e2d523f7eb43e25ee77c0 (diff) | |
download | subsurface-d77f25432850ea2e2ea9e7fb84c49d52c3a308eb.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | Subsurface-mobile.pro | 2 | ||||
-rw-r--r-- | mobile-widgets/CMakeLists.txt | 1 | ||||
-rw-r--r-- | mobile-widgets/statsmanager.cpp | 28 | ||||
-rw-r--r-- | mobile-widgets/statsmanager.h | 20 | ||||
-rw-r--r-- | subsurface-helper.cpp | 2 |
5 files changed, 53 insertions, 0 deletions
diff --git a/Subsurface-mobile.pro b/Subsurface-mobile.pro index db1ef8911..959af95c8 100644 --- a/Subsurface-mobile.pro +++ b/Subsurface-mobile.pro @@ -129,6 +129,7 @@ SOURCES += subsurface-mobile-main.cpp \ backend-shared/roundrectitem.cpp \ mobile-widgets/qmlinterface.cpp \ mobile-widgets/qmlmanager.cpp \ + mobile-widgets/statsmanager.cpp \ mobile-widgets/themeinterface.cpp \ qt-models/divesummarymodel.cpp \ qt-models/diveplotdatamodel.cpp \ @@ -264,6 +265,7 @@ HEADERS += \ backend-shared/roundrectitem.h \ mobile-widgets/qmlinterface.h \ mobile-widgets/qmlmanager.h \ + mobile-widgets/statsmanager.h \ mobile-widgets/themeinterface.h \ map-widget/qmlmapwidgethelper.h \ qt-models/divesummarymodel.h \ 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 diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index 45cadcfa1..8fbb74b6a 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -16,6 +16,7 @@ #include "mobile-widgets/themeinterface.h" #include "mobile-widgets/qmlmanager.h" #include "mobile-widgets/qmlinterface.h" +#include "mobile-widgets/statsmanager.h" #include "qt-models/divesummarymodel.h" #include "qt-models/gpslistmodel.h" #include "qt-models/messagehandlermodel.h" @@ -207,6 +208,7 @@ static void register_qml_types(QQmlEngine *engine) #ifdef SUBSURFACE_MOBILE register_qml_type<QMLManager>("QMLManager"); + register_qml_type<StatsManager>("StatsManager"); register_qml_type<QMLProfile>("QMLProfile"); register_qml_type<DiveImportedModel>("DCImportModel"); register_qml_type<DiveSummaryModel>("DiveSummaryModel"); |