mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
e610fb2481
commit
12842f4a86
2 changed files with 20 additions and 6 deletions
|
@ -1,7 +1,8 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "statsmanager.h"
|
#include "statsmanager.h"
|
||||||
|
#include "stats/chartlistmodel.h"
|
||||||
|
|
||||||
StatsManager::StatsManager() : view(nullptr)
|
StatsManager::StatsManager() : view(nullptr), charts(nullptr)
|
||||||
{
|
{
|
||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
|
@ -10,18 +11,19 @@ StatsManager::~StatsManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsManager::init(StatsView *v, QObject *o)
|
void StatsManager::init(StatsView *v, ChartListModel *m)
|
||||||
{
|
{
|
||||||
if (!v)
|
if (!v)
|
||||||
fprintf(stderr, "StatsManager::init(): no StatsView - statistics will not work.\n");
|
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;
|
view = v;
|
||||||
|
charts = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsManager::doit()
|
void StatsManager::doit()
|
||||||
{
|
{
|
||||||
if (!view)
|
updateUi();
|
||||||
return;
|
|
||||||
view->plot(state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setVariableList(const StatsState::VariableList &list, QStringList &stringList, int &idx)
|
static void setVariableList(const StatsState::VariableList &list, QStringList &stringList, int &idx)
|
||||||
|
@ -59,6 +61,8 @@ void StatsManager::updateUi()
|
||||||
binner2IndexChanged();
|
binner2IndexChanged();
|
||||||
operation2IndexChanged();
|
operation2IndexChanged();
|
||||||
|
|
||||||
|
if (charts)
|
||||||
|
charts->update(uiState.charts);
|
||||||
if (view)
|
if (view)
|
||||||
view->plot(state);
|
view->plot(state);
|
||||||
}
|
}
|
||||||
|
@ -101,3 +105,9 @@ void StatsManager::var2OperationChanged(int idx)
|
||||||
state.var2OperationChanged(uiState.operations2.variables[idx].id);
|
state.var2OperationChanged(uiState.operations2.variables[idx].id);
|
||||||
updateUi();
|
updateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StatsManager::setChart(int idx)
|
||||||
|
{
|
||||||
|
state.chartChanged(idx);
|
||||||
|
updateUi();
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
class ChartListModel;
|
||||||
|
|
||||||
class StatsManager : public QObject {
|
class StatsManager : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -23,13 +25,14 @@ public:
|
||||||
|
|
||||||
StatsManager();
|
StatsManager();
|
||||||
~StatsManager();
|
~StatsManager();
|
||||||
Q_INVOKABLE void init(StatsView *v, QObject *o);
|
Q_INVOKABLE void init(StatsView *v, ChartListModel *charts);
|
||||||
Q_INVOKABLE void doit();
|
Q_INVOKABLE void doit();
|
||||||
Q_INVOKABLE void var1Changed(int idx);
|
Q_INVOKABLE void var1Changed(int idx);
|
||||||
Q_INVOKABLE void var1BinnerChanged(int idx);
|
Q_INVOKABLE void var1BinnerChanged(int idx);
|
||||||
Q_INVOKABLE void var2Changed(int idx);
|
Q_INVOKABLE void var2Changed(int idx);
|
||||||
Q_INVOKABLE void var2BinnerChanged(int idx);
|
Q_INVOKABLE void var2BinnerChanged(int idx);
|
||||||
Q_INVOKABLE void var2OperationChanged(int idx);
|
Q_INVOKABLE void var2OperationChanged(int idx);
|
||||||
|
Q_INVOKABLE void setChart(int idx);
|
||||||
signals:
|
signals:
|
||||||
void var1ListChanged();
|
void var1ListChanged();
|
||||||
void binner1ListChanged();
|
void binner1ListChanged();
|
||||||
|
@ -43,6 +46,7 @@ signals:
|
||||||
void operation2IndexChanged();
|
void operation2IndexChanged();
|
||||||
private:
|
private:
|
||||||
StatsView *view;
|
StatsView *view;
|
||||||
|
ChartListModel *charts;
|
||||||
StatsState state;
|
StatsState state;
|
||||||
QStringList var1List;
|
QStringList var1List;
|
||||||
QStringList binner1List;
|
QStringList binner1List;
|
||||||
|
|
Loading…
Add table
Reference in a new issue