mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
divesummary: add DiveSummary class to shared and backend
Create DiveSummary class in backend-shared and make the DiveSummary calculation results available to QML. This adds a loop over all dives (could have been done with a model, but the models available to mobile are very limited, so use the basic way). [Dirk Hohndel: renamed the results variable and combined a couple of commits] Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
bb13065a75
commit
6cd46bee06
6 changed files with 222 additions and 1 deletions
|
@ -1,6 +1,5 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "qmlinterface.h"
|
||||
|
||||
#include <QQmlEngine>
|
||||
|
||||
QMLInterface *QMLInterface::instance()
|
||||
|
@ -92,4 +91,15 @@ void QMLInterface::setup(QQmlContext *ct)
|
|||
instance(), &QMLInterface::verbatim_planChanged);
|
||||
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_variationsChanged,
|
||||
instance(), &QMLInterface::display_variationsChanged);
|
||||
|
||||
// calculate divesummary first time.
|
||||
// this is needed in order to load the divesummary page
|
||||
diveSummary::summaryCalculation(0, 3);
|
||||
}
|
||||
|
||||
|
||||
void QMLInterface::summaryCalculation(int primaryPeriod, int secondaryPeriod)
|
||||
{
|
||||
diveSummary::summaryCalculation(primaryPeriod, secondaryPeriod);
|
||||
emit diveSummaryTextChanged(diveSummary::diveSummaryText);
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
#include "core/settings/qPrefTechnicalDetails.h"
|
||||
#include "qt-models/diveplannermodel.h"
|
||||
#include "backend-shared/plannershared.h"
|
||||
#include "backend-shared/divesummary.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QQmlContext>
|
||||
#include <QStringList>
|
||||
|
||||
// This class is a pure interface class and may not contain any implementation code
|
||||
// Allowed are:
|
||||
// header
|
||||
|
@ -74,6 +77,8 @@ class QMLInterface : public QObject {
|
|||
Q_PROPERTY(bool verbatim_plan READ verbatim_plan WRITE set_verbatim_plan NOTIFY verbatim_planChanged);
|
||||
Q_PROPERTY(bool display_variations READ display_variations WRITE set_display_variations NOTIFY display_variationsChanged);
|
||||
|
||||
Q_PROPERTY(QStringList diveSummaryText READ diveSummaryText NOTIFY diveSummaryTextChanged);
|
||||
|
||||
public:
|
||||
static QMLInterface *instance();
|
||||
|
||||
|
@ -163,6 +168,9 @@ public:
|
|||
};
|
||||
Q_ENUM(DIVE_MODE);
|
||||
|
||||
// Function to calculate dive summary
|
||||
Q_INVOKABLE void summaryCalculation(int primaryPeriod, int secondaryPeriod);
|
||||
|
||||
public:
|
||||
CLOUD_STATUS cloud_verification_status() { return (CLOUD_STATUS)prefs.cloud_verification_status; }
|
||||
DURATION duration_units() { return (DURATION)prefs.units.duration_units; }
|
||||
|
@ -209,6 +217,8 @@ public:
|
|||
bool verbatim_plan() { return prefs.verbatim_plan; }
|
||||
bool display_variations() { return prefs.display_variations; }
|
||||
|
||||
const QStringList &diveSummaryText() { return diveSummary::diveSummaryText; }
|
||||
|
||||
public slots:
|
||||
void set_cloud_verification_status(CLOUD_STATUS value) { qPrefCloudStorage::set_cloud_verification_status(value); }
|
||||
void set_duration_units(DURATION value) { qPrefUnits::set_duration_units((units::DURATION)value); }
|
||||
|
@ -301,6 +311,7 @@ signals:
|
|||
void verbatim_planChanged(bool value);
|
||||
void display_variationsChanged(bool value);
|
||||
|
||||
void diveSummaryTextChanged(QStringList);
|
||||
private:
|
||||
QMLInterface() {}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue