aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/statsmanager.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-12 10:28:04 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-13 11:39:36 -0800
commit12842f4a86761569d867e54a523a586409a03dc5 (patch)
tree64e95fcc0f8b1fd171d98e0ea1f1393441ef9123 /mobile-widgets/statsmanager.cpp
parente610fb248115cb70bc3ded65ad3ac6985658a4a9 (diff)
downloadsubsurface-12842f4a86761569d867e54a523a586409a03dc5.tar.gz
mobile/statistics: make charts model available to UI
Create a QML ChartListModel in the StatisticsPage and pass that to the StatsManager on initialization. [extracted from a slightly larger commit] Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/statsmanager.cpp')
-rw-r--r--mobile-widgets/statsmanager.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/mobile-widgets/statsmanager.cpp b/mobile-widgets/statsmanager.cpp
index 54fc804fd..a49259ff9 100644
--- a/mobile-widgets/statsmanager.cpp
+++ b/mobile-widgets/statsmanager.cpp
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include "statsmanager.h"
+#include "stats/chartlistmodel.h"
-StatsManager::StatsManager() : view(nullptr)
+StatsManager::StatsManager() : view(nullptr), charts(nullptr)
{
updateUi();
}
@@ -10,18 +11,19 @@ StatsManager::~StatsManager()
{
}
-void StatsManager::init(StatsView *v, QObject *o)
+void StatsManager::init(StatsView *v, ChartListModel *m)
{
if (!v)
fprintf(stderr, "StatsManager::init(): no StatsView - statistics will not work.\n");
+ if (!m)
+ fprintf(stderr, "StatsManager::init(): no ChartListModel - statistics will not work.\n");
view = v;
+ charts = m;
}
void StatsManager::doit()
{
- if (!view)
- return;
- view->plot(state);
+ updateUi();
}
static void setVariableList(const StatsState::VariableList &list, QStringList &stringList, int &idx)
@@ -59,6 +61,8 @@ void StatsManager::updateUi()
binner2IndexChanged();
operation2IndexChanged();
+ if (charts)
+ charts->update(uiState.charts);
if (view)
view->plot(state);
}
@@ -101,3 +105,9 @@ void StatsManager::var2OperationChanged(int idx)
state.var2OperationChanged(uiState.operations2.variables[idx].id);
updateUi();
}
+
+void StatsManager::setChart(int idx)
+{
+ state.chartChanged(idx);
+ updateUi();
+}