2017-04-27 18:30:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-06-04 10:29:50 +00:00
|
|
|
#ifndef QMLMANAGER_H
|
|
|
|
#define QMLMANAGER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2015-12-05 03:34:59 +00:00
|
|
|
#include <QNetworkAccessManager>
|
2016-03-09 03:31:05 +00:00
|
|
|
#include <QScreen>
|
QML UI: don't immediately save data after we make changes
Much as this felt like the prudent thing to do, it makes the UI painful
to use. In bad network conditions, with a large dive log, on a phone,
the save operation can take more than a minute - which is just completely
ludicrous.
So instead we mark the dive list changed when we make changes and wait
for the app to not be in the foreground. Once the OS tells us that we are
hidden (on the desktop that generally means we don't have focus, on a
mobile device it usually does mean that the app is not on the screen), we
check if there are data to be saved and do so.
There is of course a major problem with this logic. If the user switches
away from Subsurface-mobile but comes back fairly quickly (just reacting
to a notification or briefly checking something, changing a song,
something... then the app may still be non-responsive for quite a while.
So we need to do something about the time it takes us to save the git
tree locally, and then figure out if we can move at least some of the
network traffic to another thread.
And we need to make sure the user immediately notices that the app is not
crashed but is actually saving their data. But that's for another commit.
tl;dr: CAREFUL, don't kill Subsurface-mobile before it had time to save
your data or your changes may be gone. In typical use that shouldn't be
an issue, but it is something that we need to tell the user about.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 00:37:17 +00:00
|
|
|
#include <QElapsedTimer>
|
2017-06-23 14:31:44 +00:00
|
|
|
#include <QColor>
|
2015-06-04 10:29:50 +00:00
|
|
|
|
2017-06-06 02:41:57 +00:00
|
|
|
#include "core/btdiscovery.h"
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "core/gpslocation.h"
|
2017-06-08 11:38:52 +00:00
|
|
|
#include "core/downloadfromdcthread.h"
|
2016-04-14 12:48:51 +00:00
|
|
|
#include "qt-models/divelistmodel.h"
|
2018-01-28 08:52:51 +00:00
|
|
|
#include "qt-models/completionmodels.h"
|
2018-01-28 14:21:28 +00:00
|
|
|
#include "qt-models/divelocationmodel.h"
|
2015-11-11 20:34:56 +00:00
|
|
|
|
2016-01-11 14:14:45 +00:00
|
|
|
class QMLManager : public QObject {
|
2015-06-04 10:29:50 +00:00
|
|
|
Q_OBJECT
|
2017-08-03 12:55:09 +00:00
|
|
|
Q_ENUMS(cloud_status_qml)
|
2018-01-17 20:15:43 +00:00
|
|
|
Q_PROPERTY(QString cloudUserName MEMBER m_cloudUserName WRITE setCloudUserName NOTIFY cloudUserNameChanged)
|
|
|
|
Q_PROPERTY(QString cloudPassword MEMBER m_cloudPassword WRITE setCloudPassword NOTIFY cloudPasswordChanged)
|
|
|
|
Q_PROPERTY(QString cloudPin MEMBER m_cloudPin WRITE setCloudPin NOTIFY cloudPinChanged)
|
2015-08-19 07:17:52 +00:00
|
|
|
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)
|
2018-01-17 20:15:43 +00:00
|
|
|
Q_PROPERTY(bool locationServiceEnabled MEMBER m_locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged)
|
|
|
|
Q_PROPERTY(bool locationServiceAvailable MEMBER m_locationServiceAvailable WRITE setLocationServiceAvailable NOTIFY locationServiceAvailableChanged)
|
|
|
|
Q_PROPERTY(int distanceThreshold MEMBER m_distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged)
|
|
|
|
Q_PROPERTY(int timeThreshold MEMBER m_timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged)
|
2017-06-24 02:35:48 +00:00
|
|
|
Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged)
|
2018-01-17 20:15:43 +00:00
|
|
|
Q_PROPERTY(bool loadFromCloud MEMBER m_loadFromCloud WRITE setLoadFromCloud NOTIFY loadFromCloudChanged)
|
|
|
|
Q_PROPERTY(QString startPageText MEMBER m_startPageText WRITE setStartPageText NOTIFY startPageTextChanged)
|
|
|
|
Q_PROPERTY(bool verboseEnabled MEMBER m_verboseEnabled WRITE setVerboseEnabled NOTIFY verboseEnabledChanged)
|
|
|
|
Q_PROPERTY(cloud_status_qml credentialStatus MEMBER m_credentialStatus WRITE setCredentialStatus NOTIFY credentialStatusChanged)
|
|
|
|
Q_PROPERTY(cloud_status_qml oldStatus MEMBER m_oldStatus WRITE setOldStatus NOTIFY oldStatusChanged)
|
|
|
|
Q_PROPERTY(QString notificationText MEMBER m_notificationText WRITE setNotificationText NOTIFY notificationTextChanged)
|
|
|
|
Q_PROPERTY(bool syncToCloud MEMBER m_syncToCloud WRITE setSyncToCloud NOTIFY syncToCloudChanged)
|
|
|
|
Q_PROPERTY(int updateSelectedDive MEMBER m_updateSelectedDive WRITE setUpdateSelectedDive NOTIFY updateSelectedDiveChanged)
|
|
|
|
Q_PROPERTY(int selectedDiveTimestamp MEMBER m_selectedDiveTimestamp WRITE setSelectedDiveTimestamp NOTIFY selectedDiveTimestampChanged)
|
2018-01-28 08:52:51 +00:00
|
|
|
Q_PROPERTY(QStringList suitList READ suitList NOTIFY suitListChanged)
|
2018-01-28 09:26:45 +00:00
|
|
|
Q_PROPERTY(QStringList buddyList READ buddyList NOTIFY buddyListChanged)
|
2018-01-28 10:28:01 +00:00
|
|
|
Q_PROPERTY(QStringList divemasterList READ divemasterList NOTIFY divemasterListChanged)
|
2018-01-28 14:21:28 +00:00
|
|
|
Q_PROPERTY(QStringList locationList READ locationList NOTIFY locationListChanged)
|
2017-04-15 00:32:32 +00:00
|
|
|
Q_PROPERTY(QStringList cylinderInit READ cylinderInit CONSTANT)
|
2018-01-17 20:15:43 +00:00
|
|
|
Q_PROPERTY(bool showPin MEMBER m_showPin WRITE setShowPin NOTIFY showPinChanged)
|
|
|
|
Q_PROPERTY(QString progressMessage MEMBER m_progressMessage WRITE setProgressMessage NOTIFY progressMessageChanged)
|
|
|
|
Q_PROPERTY(bool libdcLog MEMBER m_libdcLog WRITE setLibdcLog NOTIFY libdcLogChanged)
|
|
|
|
Q_PROPERTY(bool developer MEMBER m_developer WRITE setDeveloper NOTIFY developerChanged)
|
|
|
|
Q_PROPERTY(bool btEnabled MEMBER m_btEnabled WRITE setBtEnabled NOTIFY btEnabledChanged)
|
2016-03-03 01:13:42 +00:00
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
public:
|
|
|
|
QMLManager();
|
|
|
|
~QMLManager();
|
|
|
|
|
2017-08-03 12:55:09 +00:00
|
|
|
enum cloud_status_qml {
|
|
|
|
CS_UNKNOWN,
|
|
|
|
CS_INCORRECT_USER_PASSWD,
|
|
|
|
CS_NEED_TO_VERIFY,
|
|
|
|
CS_VERIFIED,
|
|
|
|
CS_NOCLOUD
|
2016-02-11 01:45:23 +00:00
|
|
|
};
|
|
|
|
|
2015-12-03 23:59:40 +00:00
|
|
|
static QMLManager *instance();
|
2018-01-24 21:56:52 +00:00
|
|
|
Q_INVOKABLE void registerError(const QString &error);
|
|
|
|
QString consumeError();
|
2015-12-03 23:59:40 +00:00
|
|
|
|
2015-07-10 07:47:26 +00:00
|
|
|
QString cloudUserName() const;
|
|
|
|
void setCloudUserName(const QString &cloudUserName);
|
|
|
|
|
|
|
|
QString cloudPassword() const;
|
|
|
|
void setCloudPassword(const QString &cloudPassword);
|
|
|
|
|
2016-06-13 23:41:26 +00:00
|
|
|
QString cloudPin() const;
|
|
|
|
void setCloudPin(const QString &cloudPin);
|
|
|
|
|
2015-11-11 20:34:56 +00:00
|
|
|
bool locationServiceEnabled() const;
|
|
|
|
void setLocationServiceEnabled(bool locationServiceEnable);
|
|
|
|
|
2016-04-18 05:54:53 +00:00
|
|
|
bool locationServiceAvailable() const;
|
|
|
|
void setLocationServiceAvailable(bool locationServiceAvailable);
|
|
|
|
|
2015-12-20 02:41:10 +00:00
|
|
|
bool verboseEnabled() const;
|
|
|
|
void setVerboseEnabled(bool verboseMode);
|
|
|
|
|
2015-11-14 17:10:06 +00:00
|
|
|
int distanceThreshold() const;
|
|
|
|
void setDistanceThreshold(int distance);
|
|
|
|
|
|
|
|
int timeThreshold() const;
|
|
|
|
void setTimeThreshold(int time);
|
|
|
|
|
2017-06-24 02:35:48 +00:00
|
|
|
QString theme() const;
|
|
|
|
void setTheme(QString theme);
|
|
|
|
|
2015-12-03 02:49:02 +00:00
|
|
|
bool loadFromCloud() const;
|
|
|
|
void setLoadFromCloud(bool done);
|
2016-02-08 19:08:49 +00:00
|
|
|
void syncLoadFromCloud();
|
2015-12-03 02:49:02 +00:00
|
|
|
|
2015-12-15 07:00:19 +00:00
|
|
|
QString startPageText() const;
|
2016-01-26 15:02:42 +00:00
|
|
|
void setStartPageText(const QString& text);
|
2015-12-15 07:00:19 +00:00
|
|
|
|
2017-08-03 12:55:09 +00:00
|
|
|
cloud_status_qml credentialStatus() const;
|
|
|
|
void setCredentialStatus(const cloud_status_qml value);
|
2016-02-11 01:45:23 +00:00
|
|
|
|
2017-08-03 12:55:09 +00:00
|
|
|
cloud_status_qml oldStatus() const;
|
|
|
|
void setOldStatus(const cloud_status_qml value);
|
2016-04-06 18:42:38 +00:00
|
|
|
|
2015-08-19 07:17:52 +00:00
|
|
|
QString logText() const;
|
|
|
|
void setLogText(const QString &logText);
|
|
|
|
|
2017-06-18 06:22:37 +00:00
|
|
|
QString notificationText() const;
|
|
|
|
void setNotificationText(QString text);
|
2016-03-03 01:13:42 +00:00
|
|
|
|
2016-04-04 01:33:40 +00:00
|
|
|
bool syncToCloud() const;
|
|
|
|
void setSyncToCloud(bool status);
|
|
|
|
|
2016-04-14 13:01:36 +00:00
|
|
|
int updateSelectedDive() const;
|
|
|
|
void setUpdateSelectedDive(int idx);
|
|
|
|
|
|
|
|
int selectedDiveTimestamp() const;
|
|
|
|
void setSelectedDiveTimestamp(int when);
|
|
|
|
|
2017-07-09 22:07:16 +00:00
|
|
|
QString progressMessage() const;
|
|
|
|
void setProgressMessage(QString text);
|
|
|
|
|
2017-07-10 01:08:06 +00:00
|
|
|
bool libdcLog() const;
|
|
|
|
void setLibdcLog(bool value);
|
|
|
|
|
2017-07-19 14:35:46 +00:00
|
|
|
bool developer() const;
|
|
|
|
void setDeveloper(bool value);
|
|
|
|
|
2017-10-12 07:43:40 +00:00
|
|
|
bool btEnabled() const;
|
|
|
|
void setBtEnabled(bool value);
|
|
|
|
|
2016-04-14 12:48:51 +00:00
|
|
|
DiveListSortModel *dlSortModel;
|
2015-12-05 03:34:59 +00:00
|
|
|
|
2018-01-28 08:52:51 +00:00
|
|
|
QStringList suitList() const;
|
2018-01-28 09:26:45 +00:00
|
|
|
QStringList buddyList() const;
|
2018-01-28 10:28:01 +00:00
|
|
|
QStringList divemasterList() const;
|
2018-01-28 14:21:28 +00:00
|
|
|
QStringList locationList() const;
|
2017-04-15 00:32:32 +00:00
|
|
|
QStringList cylinderInit() const;
|
2016-06-13 23:41:26 +00:00
|
|
|
bool showPin() const;
|
|
|
|
void setShowPin(bool enable);
|
2017-06-23 14:31:44 +00:00
|
|
|
Q_INVOKABLE void setStatusbarColor(QColor color);
|
2017-10-12 07:43:40 +00:00
|
|
|
void btHostModeChange(QBluetoothLocalDevice::HostMode state);
|
2017-07-12 11:14:24 +00:00
|
|
|
|
2017-07-10 00:03:57 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
void writeToAppLogFile(QString logText);
|
|
|
|
#endif
|
2016-06-13 23:41:26 +00:00
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
public slots:
|
QML UI: don't immediately save data after we make changes
Much as this felt like the prudent thing to do, it makes the UI painful
to use. In bad network conditions, with a large dive log, on a phone,
the save operation can take more than a minute - which is just completely
ludicrous.
So instead we mark the dive list changed when we make changes and wait
for the app to not be in the foreground. Once the OS tells us that we are
hidden (on the desktop that generally means we don't have focus, on a
mobile device it usually does mean that the app is not on the screen), we
check if there are data to be saved and do so.
There is of course a major problem with this logic. If the user switches
away from Subsurface-mobile but comes back fairly quickly (just reacting
to a notification or briefly checking something, changing a song,
something... then the app may still be non-responsive for quite a while.
So we need to do something about the time it takes us to save the git
tree locally, and then figure out if we can move at least some of the
network traffic to another thread.
And we need to make sure the user immediately notices that the app is not
crashed but is actually saving their data. But that's for another commit.
tl;dr: CAREFUL, don't kill Subsurface-mobile before it had time to save
your data or your changes may be gone. In typical use that shouldn't be
an issue, but it is something that we need to tell the user about.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 00:37:17 +00:00
|
|
|
void applicationStateChanged(Qt::ApplicationState state);
|
2015-07-10 07:47:26 +00:00
|
|
|
void savePreferences();
|
2015-12-03 22:30:30 +00:00
|
|
|
void saveCloudCredentials();
|
2015-12-05 03:34:59 +00:00
|
|
|
void tryRetrieveDataFromBackend();
|
|
|
|
void handleError(QNetworkReply::NetworkError nError);
|
|
|
|
void handleSslErrors(const QList<QSslError> &errors);
|
|
|
|
void retrieveUserid();
|
|
|
|
void loadDivesWithValidCredentials();
|
|
|
|
void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
|
2016-08-30 14:24:19 +00:00
|
|
|
void commitChanges(QString diveId, QString date, QString location, QString gps,
|
|
|
|
QString duration, QString depth, QString airtemp,
|
|
|
|
QString watertemp, QString suit, QString buddy,
|
|
|
|
QString diveMaster, QString weight, QString notes, QString startpressure,
|
2017-07-28 17:28:52 +00:00
|
|
|
QString endpressure, QString gasmix, QString cylinder, int rating, int visibility);
|
2016-04-11 02:22:16 +00:00
|
|
|
void changesNeedSaving();
|
mobile: No cloud repo creation more explicit
Before this change, there was only one way to create the local
no cloud repo on the device. The user needed to add at least
one dive to the no cloud account (so that there is something
to save). While this worked in some scenarios, it could also
get things in an inconsistent state: credential status = CS_NOCLOUD
but no local repo. This was a dead end.
In this commit, the creation of the no cloud repo is made more
explicit. When asking for no cloud mode, just create an (empty)
repo for it when it does not yet exist, and otherwise, just
open the existing (possibly empty) repo.
Now, a user can have no cloud repo, next to (any number of)
cloud accounts.
This leaves one functional aspect left: how does a user abandon
the no cloud repo, by merging his data into a true cloud
account. This is code for this, that tries to do this merge in
a smart way. This seems to be broken (too). To be clear: this
is no part of this commit.
Fixes: #667
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-17 07:51:00 +00:00
|
|
|
void openNoCloudRepo();
|
2016-04-06 18:47:12 +00:00
|
|
|
void saveChangesLocal();
|
2016-04-08 19:35:45 +00:00
|
|
|
void saveChangesCloud(bool forceRemoteSync);
|
2016-02-23 12:39:40 +00:00
|
|
|
void deleteDive(int id);
|
2016-04-11 19:10:46 +00:00
|
|
|
bool undoDelete(int id);
|
2015-12-27 05:37:18 +00:00
|
|
|
QString addDive();
|
2016-01-29 14:25:13 +00:00
|
|
|
void addDiveAborted(int id);
|
2015-11-13 04:23:00 +00:00
|
|
|
void applyGpsData();
|
2015-11-14 01:14:22 +00:00
|
|
|
void sendGpsData();
|
2016-01-08 05:37:36 +00:00
|
|
|
void downloadGpsData();
|
2016-01-08 05:40:15 +00:00
|
|
|
void populateGpsData();
|
2017-07-19 07:16:47 +00:00
|
|
|
void cancelDownloadDC();
|
2015-11-14 01:14:22 +00:00
|
|
|
void clearGpsData();
|
mobile: No cloud repo creation more explicit
Before this change, there was only one way to create the local
no cloud repo on the device. The user needed to add at least
one dive to the no cloud account (so that there is something
to save). While this worked in some scenarios, it could also
get things in an inconsistent state: credential status = CS_NOCLOUD
but no local repo. This was a dead end.
In this commit, the creation of the no cloud repo is made more
explicit. When asking for no cloud mode, just create an (empty)
repo for it when it does not yet exist, and otherwise, just
open the existing (possibly empty) repo.
Now, a user can have no cloud repo, next to (any number of)
cloud accounts.
This leaves one functional aspect left: how does a user abandon
the no cloud repo, by merging his data into a true cloud
account. This is code for this, that tries to do this merge in
a smart way. This seems to be broken (too). To be clear: this
is no part of this commit.
Fixes: #667
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-17 07:51:00 +00:00
|
|
|
void clearCredentials();
|
2017-09-27 15:24:03 +00:00
|
|
|
void cancelCredentialsPinSetup();
|
2015-12-05 03:34:59 +00:00
|
|
|
void finishSetup();
|
2016-02-09 15:53:22 +00:00
|
|
|
void openLocalThenRemote(QString url);
|
2016-04-29 13:28:09 +00:00
|
|
|
void mergeLocalRepo();
|
2016-01-26 15:02:42 +00:00
|
|
|
QString getNumber(const QString& diveId);
|
|
|
|
QString getDate(const QString& diveId);
|
2016-01-02 01:23:29 +00:00
|
|
|
QString getCurrentPosition();
|
2017-11-22 18:22:02 +00:00
|
|
|
QString getGpsFromSiteName(const QString& siteName);
|
2016-02-10 20:53:58 +00:00
|
|
|
QString getVersion() const;
|
2016-01-09 07:18:41 +00:00
|
|
|
void deleteGpsFix(quint64 when);
|
2016-04-29 13:28:09 +00:00
|
|
|
void revertToNoCloudIfNeeded();
|
2016-04-22 14:10:20 +00:00
|
|
|
void consumeFinishedLoad(timestamp_t currentDiveTimestamp);
|
2016-01-11 03:34:21 +00:00
|
|
|
void refreshDiveList();
|
2016-03-09 03:31:05 +00:00
|
|
|
void screenChanged(QScreen *screen);
|
|
|
|
qreal lastDevicePixelRatio();
|
2017-04-04 00:29:06 +00:00
|
|
|
void setDevicePixelRatio(qreal dpr, QScreen *screen);
|
2016-03-27 04:31:41 +00:00
|
|
|
void appendTextToLog(const QString &newText);
|
2016-04-15 21:42:08 +00:00
|
|
|
void quit();
|
2016-04-18 05:54:53 +00:00
|
|
|
void hasLocationSourceChanged();
|
2017-12-05 19:58:54 +00:00
|
|
|
void btRescan();
|
|
|
|
|
2015-11-11 20:34:56 +00:00
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
private:
|
2018-01-28 08:52:51 +00:00
|
|
|
BuddyCompletionModel buddyModel;
|
|
|
|
SuitCompletionModel suitModel;
|
2018-01-28 10:28:01 +00:00
|
|
|
DiveMasterCompletionModel divemasterModel;
|
2018-01-28 14:21:28 +00:00
|
|
|
LocationInformationModel locationModel;
|
2015-07-10 07:47:26 +00:00
|
|
|
QString m_cloudUserName;
|
|
|
|
QString m_cloudPassword;
|
2016-06-13 23:41:26 +00:00
|
|
|
QString m_cloudPin;
|
2015-11-14 01:14:22 +00:00
|
|
|
QString m_ssrfGpsWebUserid;
|
2015-12-15 07:00:19 +00:00
|
|
|
QString m_startPageText;
|
2015-08-19 07:17:52 +00:00
|
|
|
QString m_logText;
|
2018-01-24 21:56:52 +00:00
|
|
|
QString m_lastError;
|
2015-11-11 20:34:56 +00:00
|
|
|
bool m_locationServiceEnabled;
|
2016-04-18 05:54:53 +00:00
|
|
|
bool m_locationServiceAvailable;
|
2015-12-20 02:41:10 +00:00
|
|
|
bool m_verboseEnabled;
|
2015-11-14 17:10:06 +00:00
|
|
|
int m_distanceThreshold;
|
|
|
|
int m_timeThreshold;
|
2015-11-11 20:34:56 +00:00
|
|
|
GpsLocation *locationProvider;
|
2015-12-03 02:49:02 +00:00
|
|
|
bool m_loadFromCloud;
|
2015-12-03 23:59:40 +00:00
|
|
|
static QMLManager *m_instance;
|
2015-12-05 03:34:59 +00:00
|
|
|
QNetworkReply *reply;
|
|
|
|
QNetworkRequest request;
|
2016-02-29 14:53:26 +00:00
|
|
|
struct dive *deletedDive;
|
|
|
|
struct dive_trip *deletedTrip;
|
2017-06-18 06:22:37 +00:00
|
|
|
QString m_notificationText;
|
2016-04-04 01:33:40 +00:00
|
|
|
bool m_syncToCloud;
|
2016-04-14 13:01:36 +00:00
|
|
|
int m_updateSelectedDive;
|
|
|
|
int m_selectedDiveTimestamp;
|
2017-08-03 12:55:09 +00:00
|
|
|
cloud_status_qml m_credentialStatus;
|
|
|
|
cloud_status_qml m_oldStatus;
|
2016-03-09 03:31:05 +00:00
|
|
|
qreal m_lastDevicePixelRatio;
|
QML UI: don't immediately save data after we make changes
Much as this felt like the prudent thing to do, it makes the UI painful
to use. In bad network conditions, with a large dive log, on a phone,
the save operation can take more than a minute - which is just completely
ludicrous.
So instead we mark the dive list changed when we make changes and wait
for the app to not be in the foreground. Once the OS tells us that we are
hidden (on the desktop that generally means we don't have focus, on a
mobile device it usually does mean that the app is not on the screen), we
check if there are data to be saved and do so.
There is of course a major problem with this logic. If the user switches
away from Subsurface-mobile but comes back fairly quickly (just reacting
to a notification or briefly checking something, changing a song,
something... then the app may still be non-responsive for quite a while.
So we need to do something about the time it takes us to save the git
tree locally, and then figure out if we can move at least some of the
network traffic to another thread.
And we need to make sure the user immediately notices that the app is not
crashed but is actually saving their data. But that's for another commit.
tl;dr: CAREFUL, don't kill Subsurface-mobile before it had time to save
your data or your changes may be gone. In typical use that shouldn't be
an issue, but it is something that we need to tell the user about.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 00:37:17 +00:00
|
|
|
QElapsedTimer timer;
|
|
|
|
bool alreadySaving;
|
QML UI: rewrite the commitChanges function
I couldn't figure out how to break this down into small, useful commits.
Part of the problem is that I kept going while working on this and as you
can see from looking at the commit, diff tries so hard to find small code
fragments that moved around, that the diff overall becomes quite
unreadable and it seemed impossible to recreate the sequence of steps
after the fact.
It all started with adding the parsing for the GPS coordinates. But while
testing that code I found several issues with the rest of the function.
Most importantly it seemed ridiculous that we carefully tried to match the
texts that the DiveObjectHelper would create for the various fields,
instead of just using the DiveObjectHelper to do just that. And once I had
converted that I once again realized just how long and hard to understand
that function was getting and decided to break out some of the more
complex parts into their own helper functions.
But of course all this didn't happen in this logical, structured, ordered
way. Instead I did all of these things at the same time, testing,
rearranging, etc.
So in the end I went with one BIG commit that does all of this in one fell
swoop.
This adds four helper functions to deal with start time/date, duration,
location and gps coordinates, and depth of the dive.
To avoid mistakes when dealing with the GPS coordinates, there's another
helper to encapsulate the creation of the dive site and we switched to a
current GPS location.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-15 13:01:14 +00:00
|
|
|
bool checkDate(DiveObjectHelper *myDive, struct dive * d, QString date);
|
|
|
|
bool checkLocation(DiveObjectHelper *myDive, struct dive *d, QString location, QString gps);
|
|
|
|
bool checkDuration(DiveObjectHelper *myDive, struct dive *d, QString duration);
|
|
|
|
bool checkDepth(DiveObjectHelper *myDive, struct dive *d, QString depth);
|
2016-04-30 18:08:33 +00:00
|
|
|
bool currentGitLocalOnly;
|
2016-06-13 23:41:26 +00:00
|
|
|
bool m_showPin;
|
2017-06-08 11:38:52 +00:00
|
|
|
DCDeviceData *m_device_data;
|
2017-07-09 22:07:16 +00:00
|
|
|
QString m_progressMessage;
|
2017-07-10 01:08:06 +00:00
|
|
|
bool m_libdcLog;
|
2017-07-19 14:35:46 +00:00
|
|
|
bool m_developer;
|
2017-07-12 11:14:24 +00:00
|
|
|
bool m_btEnabled;
|
2018-01-28 16:39:01 +00:00
|
|
|
void updateAllGlobalLists();
|
2017-07-12 11:14:24 +00:00
|
|
|
|
2017-07-10 00:03:57 +00:00
|
|
|
#if defined(Q_OS_ANDROID)
|
|
|
|
QString appLogFileName;
|
|
|
|
QFile appLogFile;
|
|
|
|
bool appLogFileOpen;
|
|
|
|
#endif
|
2017-06-01 18:07:19 +00:00
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
signals:
|
2015-07-10 07:47:26 +00:00
|
|
|
void cloudUserNameChanged();
|
|
|
|
void cloudPasswordChanged();
|
2016-06-13 23:41:26 +00:00
|
|
|
void cloudPinChanged();
|
2015-11-11 20:34:56 +00:00
|
|
|
void locationServiceEnabledChanged();
|
2016-04-18 05:54:53 +00:00
|
|
|
void locationServiceAvailableChanged();
|
2015-12-20 02:41:10 +00:00
|
|
|
void verboseEnabledChanged();
|
2015-08-19 07:17:52 +00:00
|
|
|
void logTextChanged();
|
2015-11-14 17:10:06 +00:00
|
|
|
void timeThresholdChanged();
|
2017-06-24 02:35:48 +00:00
|
|
|
void themeChanged();
|
2015-11-14 17:10:06 +00:00
|
|
|
void distanceThresholdChanged();
|
2015-12-03 02:49:02 +00:00
|
|
|
void loadFromCloudChanged();
|
2015-12-15 07:00:19 +00:00
|
|
|
void startPageTextChanged();
|
2016-02-11 01:45:23 +00:00
|
|
|
void credentialStatusChanged();
|
2016-04-06 18:42:38 +00:00
|
|
|
void oldStatusChanged();
|
2017-06-18 06:22:37 +00:00
|
|
|
void notificationTextChanged();
|
2016-04-04 01:33:40 +00:00
|
|
|
void syncToCloudChanged();
|
2016-04-14 13:01:36 +00:00
|
|
|
void updateSelectedDiveChanged();
|
|
|
|
void selectedDiveTimestampChanged();
|
2016-06-13 23:41:26 +00:00
|
|
|
void showPinChanged();
|
2016-03-09 03:31:05 +00:00
|
|
|
void sendScreenChanged(QScreen *screen);
|
2017-07-09 22:07:16 +00:00
|
|
|
void progressMessageChanged();
|
2017-07-10 01:08:06 +00:00
|
|
|
void libdcLogChanged();
|
2017-07-19 14:35:46 +00:00
|
|
|
void developerChanged();
|
2017-10-12 07:43:40 +00:00
|
|
|
void btEnabledChanged();
|
2018-01-28 08:52:51 +00:00
|
|
|
void suitListChanged();
|
2018-01-28 09:26:45 +00:00
|
|
|
void buddyListChanged();
|
2018-01-28 10:28:01 +00:00
|
|
|
void divemasterListChanged();
|
2018-01-28 14:21:28 +00:00
|
|
|
void locationListChanged();
|
2015-06-04 10:29:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|