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>
|
2015-06-04 10:29:50 +00:00
|
|
|
|
2015-11-19 02:30:55 +00:00
|
|
|
#include "gpslocation.h"
|
2015-11-11 20:34:56 +00:00
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
class QMLManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2015-07-10 07:47:26 +00:00
|
|
|
Q_PROPERTY(QString cloudUserName READ cloudUserName WRITE setCloudUserName NOTIFY cloudUserNameChanged)
|
|
|
|
Q_PROPERTY(QString cloudPassword READ cloudPassword WRITE setCloudPassword NOTIFY cloudPasswordChanged)
|
2015-07-21 08:57:10 +00:00
|
|
|
Q_PROPERTY(bool saveCloudPassword READ saveCloudPassword WRITE setSaveCloudPassword NOTIFY saveCloudPasswordChanged)
|
2015-08-19 07:17:52 +00:00
|
|
|
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)
|
2015-11-11 20:34:56 +00:00
|
|
|
Q_PROPERTY(bool locationServiceEnabled READ locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged)
|
2015-11-14 17:10:06 +00:00
|
|
|
Q_PROPERTY(int distanceThreshold READ distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged)
|
|
|
|
Q_PROPERTY(int timeThreshold READ timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged)
|
2015-12-03 02:49:02 +00:00
|
|
|
Q_PROPERTY(bool loadFromCloud READ loadFromCloud WRITE setLoadFromCloud NOTIFY loadFromCloudChanged)
|
2015-12-15 07:00:19 +00:00
|
|
|
Q_PROPERTY(QString startPageText READ startPageText WRITE setStartPageText NOTIFY startPageTextChanged)
|
2015-12-20 02:41:10 +00:00
|
|
|
Q_PROPERTY(bool verboseEnabled READ verboseEnabled WRITE setVerboseEnabled NOTIFY verboseEnabledChanged)
|
2015-06-04 10:29:50 +00:00
|
|
|
public:
|
|
|
|
QMLManager();
|
|
|
|
~QMLManager();
|
|
|
|
|
2015-12-03 23:59:40 +00:00
|
|
|
static QMLManager *instance();
|
|
|
|
|
2015-07-10 07:47:26 +00:00
|
|
|
QString cloudUserName() const;
|
|
|
|
void setCloudUserName(const QString &cloudUserName);
|
|
|
|
|
|
|
|
QString cloudPassword() const;
|
|
|
|
void setCloudPassword(const QString &cloudPassword);
|
|
|
|
|
2015-07-21 08:57:10 +00:00
|
|
|
bool saveCloudPassword() const;
|
|
|
|
void setSaveCloudPassword(bool saveCloudPassword);
|
|
|
|
|
2015-11-11 20:34:56 +00:00
|
|
|
bool locationServiceEnabled() const;
|
|
|
|
void setLocationServiceEnabled(bool locationServiceEnable);
|
|
|
|
|
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);
|
|
|
|
|
2015-12-03 02:49:02 +00:00
|
|
|
bool loadFromCloud() const;
|
|
|
|
void setLoadFromCloud(bool done);
|
|
|
|
|
2015-12-15 07:00:19 +00:00
|
|
|
QString startPageText() const;
|
|
|
|
void setStartPageText(QString text);
|
|
|
|
|
2015-08-19 07:17:52 +00:00
|
|
|
QString logText() const;
|
|
|
|
void setLogText(const QString &logText);
|
|
|
|
void appendTextToLog(const QString &newText);
|
|
|
|
|
2015-12-05 03:34:59 +00:00
|
|
|
typedef void(QMLManager::*execute_function_type)();
|
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
public slots:
|
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 checkCredentialsAndExecute(execute_function_type execute);
|
|
|
|
void tryRetrieveDataFromBackend();
|
|
|
|
void handleError(QNetworkReply::NetworkError nError);
|
|
|
|
void handleSslErrors(const QList<QSslError> &errors);
|
|
|
|
void retrieveUserid();
|
2015-07-10 08:31:24 +00:00
|
|
|
void loadDives();
|
2015-12-05 03:34:59 +00:00
|
|
|
void loadDivesWithValidCredentials();
|
2015-12-15 07:00:19 +00:00
|
|
|
void loadDiveProgress(int percent);
|
2015-12-05 03:34:59 +00:00
|
|
|
void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
|
2015-12-27 06:57:47 +00:00
|
|
|
void commitChanges(QString diveId, QString location, QString gps, QString duration, QString depth,
|
|
|
|
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes);
|
2015-07-17 15:28:01 +00:00
|
|
|
void saveChanges();
|
2015-12-27 05:37:18 +00:00
|
|
|
QString addDive();
|
2015-11-13 04:23:00 +00:00
|
|
|
void applyGpsData();
|
2015-11-14 01:14:22 +00:00
|
|
|
void sendGpsData();
|
|
|
|
void clearGpsData();
|
2015-12-05 03:34:59 +00:00
|
|
|
void finishSetup();
|
2015-12-26 21:22:50 +00:00
|
|
|
void showMap(QString location);
|
2015-12-27 04:02:23 +00:00
|
|
|
QString getNumber(QString diveId);
|
|
|
|
QString getDate(QString diveId);
|
2015-11-11 20:34:56 +00:00
|
|
|
|
2015-06-04 10:29:50 +00:00
|
|
|
private:
|
2015-07-10 07:47:26 +00:00
|
|
|
QString m_cloudUserName;
|
|
|
|
QString m_cloudPassword;
|
2015-11-14 01:14:22 +00:00
|
|
|
QString m_ssrfGpsWebUserid;
|
2015-12-15 07:00:19 +00:00
|
|
|
QString m_startPageText;
|
2015-07-21 08:57:10 +00:00
|
|
|
bool m_saveCloudPassword;
|
2015-08-19 07:17:52 +00:00
|
|
|
QString m_logText;
|
2015-11-11 20:34:56 +00:00
|
|
|
bool m_locationServiceEnabled;
|
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;
|
|
|
|
QNetworkAccessManager *mgr;
|
2015-06-04 10:29:50 +00:00
|
|
|
|
|
|
|
signals:
|
2015-07-10 07:47:26 +00:00
|
|
|
void cloudUserNameChanged();
|
|
|
|
void cloudPasswordChanged();
|
2015-07-21 08:57:10 +00:00
|
|
|
void saveCloudPasswordChanged();
|
2015-11-11 20:34:56 +00:00
|
|
|
void locationServiceEnabledChanged();
|
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();
|
|
|
|
void distanceThresholdChanged();
|
2015-12-03 02:49:02 +00:00
|
|
|
void loadFromCloudChanged();
|
2015-12-15 07:00:19 +00:00
|
|
|
void startPageTextChanged();
|
2015-06-04 10:29:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|