mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Random whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3c1a111404
commit
19e95efd6f
5 changed files with 92 additions and 97 deletions
|
@ -38,8 +38,7 @@ extern "C" int gitProgressCB(int percent)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMLManager::QMLManager() :
|
QMLManager::QMLManager() : m_locationServiceEnabled(false),
|
||||||
m_locationServiceEnabled(false),
|
|
||||||
m_verboseEnabled(false),
|
m_verboseEnabled(false),
|
||||||
m_loadFromCloud(false),
|
m_loadFromCloud(false),
|
||||||
reply(0),
|
reply(0),
|
||||||
|
@ -71,7 +70,7 @@ void QMLManager::finishSetup()
|
||||||
!same_string(prefs.cloud_storage_password, "") &&
|
!same_string(prefs.cloud_storage_password, "") &&
|
||||||
getCloudURL(url) == 0) {
|
getCloudURL(url) == 0) {
|
||||||
clear_dive_file_data();
|
clear_dive_file_data();
|
||||||
QByteArray fileNamePrt = QFile::encodeName(url);
|
QByteArray fileNamePrt = QFile::encodeName(url);
|
||||||
prefs.git_local_only = true;
|
prefs.git_local_only = true;
|
||||||
int error = parse_file(fileNamePrt.data());
|
int error = parse_file(fileNamePrt.data());
|
||||||
prefs.git_local_only = false;
|
prefs.git_local_only = false;
|
||||||
|
@ -84,7 +83,7 @@ void QMLManager::finishSetup()
|
||||||
struct dive *d;
|
struct dive *d;
|
||||||
process_dives(false, false);
|
process_dives(false, false);
|
||||||
DiveListModel::instance()->clear();
|
DiveListModel::instance()->clear();
|
||||||
for_each_dive(i, d) {
|
for_each_dive (i, d) {
|
||||||
DiveListModel::instance()->addDive(d);
|
DiveListModel::instance()->addDive(d);
|
||||||
}
|
}
|
||||||
appendTextToLog(QString("%1 dives loaded from cache").arg(i));
|
appendTextToLog(QString("%1 dives loaded from cache").arg(i));
|
||||||
|
@ -207,7 +206,7 @@ void QMLManager::provideAuth(QNetworkReply *reply, QAuthenticator *auth)
|
||||||
void QMLManager::handleSslErrors(const QList<QSslError> &errors)
|
void QMLManager::handleSslErrors(const QList<QSslError> &errors)
|
||||||
{
|
{
|
||||||
setStartPageText(tr("Cannot open cloud storage: Error creating https connection"));
|
setStartPageText(tr("Cannot open cloud storage: Error creating https connection"));
|
||||||
Q_FOREACH(QSslError e, errors) {
|
Q_FOREACH (QSslError e, errors) {
|
||||||
qDebug() << e.errorString();
|
qDebug() << e.errorString();
|
||||||
}
|
}
|
||||||
reply->abort();
|
reply->abort();
|
||||||
|
@ -253,7 +252,7 @@ void QMLManager::retrieveUserid()
|
||||||
void QMLManager::loadDiveProgress(int percent)
|
void QMLManager::loadDiveProgress(int percent)
|
||||||
{
|
{
|
||||||
QString text(tr("Loading dive list from cloud storage."));
|
QString text(tr("Loading dive list from cloud storage."));
|
||||||
while(percent > 0) {
|
while (percent > 0) {
|
||||||
text.append(".");
|
text.append(".");
|
||||||
percent -= 10;
|
percent -= 10;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +275,7 @@ void QMLManager::loadDivesWithValidCredentials()
|
||||||
setStartPageText(tr("Cloud storage error: %1").arg(errorString));
|
setStartPageText(tr("Cloud storage error: %1").arg(errorString));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray fileNamePrt = QFile::encodeName(url);
|
QByteArray fileNamePrt = QFile::encodeName(url);
|
||||||
if (check_git_sha(fileNamePrt.data()) == 0) {
|
if (check_git_sha(fileNamePrt.data()) == 0) {
|
||||||
qDebug() << "local cache was current, no need to modify dive list";
|
qDebug() << "local cache was current, no need to modify dive list";
|
||||||
appendTextToLog("Cloud sync shows local cache was current");
|
appendTextToLog("Cloud sync shows local cache was current");
|
||||||
|
@ -306,7 +305,7 @@ void QMLManager::loadDivesWithValidCredentials()
|
||||||
int i;
|
int i;
|
||||||
struct dive *d;
|
struct dive *d;
|
||||||
|
|
||||||
for_each_dive(i, d) {
|
for_each_dive (i, d) {
|
||||||
DiveListModel::instance()->addDive(d);
|
DiveListModel::instance()->addDive(d);
|
||||||
}
|
}
|
||||||
appendTextToLog(QString("%1 dives loaded").arg(i));
|
appendTextToLog(QString("%1 dives loaded").arg(i));
|
||||||
|
@ -320,15 +319,14 @@ void QMLManager::refreshDiveList()
|
||||||
int i;
|
int i;
|
||||||
struct dive *d;
|
struct dive *d;
|
||||||
DiveListModel::instance()->clear();
|
DiveListModel::instance()->clear();
|
||||||
for_each_dive(i, d) {
|
for_each_dive (i, d) {
|
||||||
DiveListModel::instance()->addDive(d);
|
DiveListModel::instance()->addDive(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the dive and return the notes field, stripped of the HTML junk
|
// update the dive and return the notes field, stripped of the HTML junk
|
||||||
QString QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
|
QString QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
|
||||||
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes)
|
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes)
|
||||||
{
|
{
|
||||||
struct dive *d = get_dive_by_uniq_id(diveId.toInt());
|
struct dive *d = get_dive_by_uniq_id(diveId.toInt());
|
||||||
// notes comes back as rich text - let's convert this into plain text
|
// notes comes back as rich text - let's convert this into plain text
|
||||||
|
@ -532,7 +530,6 @@ void QMLManager::downloadGpsData()
|
||||||
{
|
{
|
||||||
locationProvider->downloadFromServer();
|
locationProvider->downloadFromServer();
|
||||||
populateGpsData();
|
populateGpsData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMLManager::populateGpsData()
|
void QMLManager::populateGpsData()
|
||||||
|
@ -678,7 +675,8 @@ void QMLManager::showMap(QString location)
|
||||||
{
|
{
|
||||||
if (!location.isEmpty()) {
|
if (!location.isEmpty()) {
|
||||||
QString link = QString("https://www.google.com/maps/place/%1/@%2,5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0")
|
QString link = QString("https://www.google.com/maps/place/%1/@%2,5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0")
|
||||||
.arg(location).arg(location);
|
.arg(location)
|
||||||
|
.arg(location);
|
||||||
QDesktopServices::openUrl(link);
|
QDesktopServices::openUrl(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
|
|
||||||
#include "gpslocation.h"
|
#include "gpslocation.h"
|
||||||
|
|
||||||
class QMLManager : public QObject
|
class QMLManager : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString cloudUserName READ cloudUserName WRITE setCloudUserName NOTIFY cloudUserNameChanged)
|
Q_PROPERTY(QString cloudUserName READ cloudUserName WRITE setCloudUserName NOTIFY cloudUserNameChanged)
|
||||||
Q_PROPERTY(QString cloudPassword READ cloudPassword WRITE setCloudPassword NOTIFY cloudPasswordChanged)
|
Q_PROPERTY(QString cloudPassword READ cloudPassword WRITE setCloudPassword NOTIFY cloudPasswordChanged)
|
||||||
|
@ -57,7 +56,7 @@ public:
|
||||||
void setLogText(const QString &logText);
|
void setLogText(const QString &logText);
|
||||||
void appendTextToLog(const QString &newText);
|
void appendTextToLog(const QString &newText);
|
||||||
|
|
||||||
typedef void(QMLManager::*execute_function_type)();
|
typedef void (QMLManager::*execute_function_type)();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void savePreferences();
|
void savePreferences();
|
||||||
|
@ -72,7 +71,7 @@ public slots:
|
||||||
void loadDiveProgress(int percent);
|
void loadDiveProgress(int percent);
|
||||||
void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
|
void provideAuth(QNetworkReply *reply, QAuthenticator *auth);
|
||||||
QString commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
|
QString commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
|
||||||
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes);
|
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes);
|
||||||
void saveChanges();
|
void saveChanges();
|
||||||
QString addDive();
|
QString addDive();
|
||||||
void applyGpsData();
|
void applyGpsData();
|
||||||
|
|
|
@ -18,8 +18,7 @@ struct gpsTracker {
|
||||||
int idx;
|
int idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GpsLocation : QObject
|
class GpsLocation : QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent);
|
GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent);
|
||||||
|
|
|
@ -11,35 +11,34 @@ static QString EMPTY_DIVE_STRING = QStringLiteral("--");
|
||||||
|
|
||||||
static QString getFormattedWeight(struct dive *dive, unsigned int idx)
|
static QString getFormattedWeight(struct dive *dive, unsigned int idx)
|
||||||
{
|
{
|
||||||
weightsystem_t *weight = &dive->weightsystem[idx];
|
weightsystem_t *weight = &dive->weightsystem[idx];
|
||||||
if (!weight->description)
|
if (!weight->description)
|
||||||
return QString(EMPTY_DIVE_STRING);
|
return QString(EMPTY_DIVE_STRING);
|
||||||
QString fmt = QString(weight->description);
|
QString fmt = QString(weight->description);
|
||||||
fmt += ", " + get_weight_string(weight->weight, true);
|
fmt += ", " + get_weight_string(weight->weight, true);
|
||||||
return fmt;
|
return fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
|
static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
|
||||||
{
|
{
|
||||||
cylinder_t *cyl = &dive->cylinder[idx];
|
cylinder_t *cyl = &dive->cylinder[idx];
|
||||||
const char *desc = cyl->type.description;
|
const char *desc = cyl->type.description;
|
||||||
if (!desc && idx > 0)
|
if (!desc && idx > 0)
|
||||||
return QString(EMPTY_DIVE_STRING);
|
return QString(EMPTY_DIVE_STRING);
|
||||||
QString fmt = desc ? QString(desc) : QObject::tr("unknown");
|
QString fmt = desc ? QString(desc) : QObject::tr("unknown");
|
||||||
fmt += ", " + get_volume_string(cyl->type.size, true, 0);
|
fmt += ", " + get_volume_string(cyl->type.size, true, 0);
|
||||||
fmt += ", " + get_pressure_string(cyl->type.workingpressure, true);
|
fmt += ", " + get_pressure_string(cyl->type.workingpressure, true);
|
||||||
fmt += ", " + get_pressure_string(cyl->start, false) + " - " + get_pressure_string(cyl->end, true);
|
fmt += ", " + get_pressure_string(cyl->start, false) + " - " + get_pressure_string(cyl->end, true);
|
||||||
fmt += ", " + get_gas_string(cyl->gasmix);
|
fmt += ", " + get_gas_string(cyl->gasmix);
|
||||||
return fmt;
|
return fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiveObjectHelper::DiveObjectHelper(struct dive *d) :
|
DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_number(d->number),
|
||||||
m_number(d->number),
|
|
||||||
m_id(d->id),
|
m_id(d->id),
|
||||||
m_rating(d->rating),
|
m_rating(d->rating),
|
||||||
m_timestamp(d->when),
|
m_timestamp(d->when),
|
||||||
m_location(get_dive_location(d) ? QString::fromUtf8(get_dive_location(d)) : EMPTY_DIVE_STRING),
|
m_location(get_dive_location(d) ? QString::fromUtf8(get_dive_location(d)) : EMPTY_DIVE_STRING),
|
||||||
m_duration(get_dive_duration_string(d->duration.seconds, QObject::tr("h:"), QObject::tr("min"))),
|
m_duration(get_dive_duration_string(d->duration.seconds, QObject::tr("h:"), QObject::tr("min"))),
|
||||||
m_depth(get_depth_string(d->dc.maxdepth.mm, true, true)),
|
m_depth(get_depth_string(d->dc.maxdepth.mm, true, true)),
|
||||||
m_divemaster(d->divemaster ? d->divemaster : EMPTY_DIVE_STRING),
|
m_divemaster(d->divemaster ? d->divemaster : EMPTY_DIVE_STRING),
|
||||||
m_buddy(d->buddy ? d->buddy : EMPTY_DIVE_STRING),
|
m_buddy(d->buddy ? d->buddy : EMPTY_DIVE_STRING),
|
||||||
|
@ -68,7 +67,7 @@ DiveObjectHelper::DiveObjectHelper(struct dive *d) :
|
||||||
if (same_string(d->dc.model, "planned dive")) {
|
if (same_string(d->dc.model, "planned dive")) {
|
||||||
QTextDocument notes;
|
QTextDocument notes;
|
||||||
QString notesFormatted = m_notes;
|
QString notesFormatted = m_notes;
|
||||||
#define _NOTES_BR "\n"
|
#define _NOTES_BR "\n"
|
||||||
notesFormatted = notesFormatted.replace("<thead>", "<thead>" _NOTES_BR);
|
notesFormatted = notesFormatted.replace("<thead>", "<thead>" _NOTES_BR);
|
||||||
notesFormatted = notesFormatted.replace("<br>", "<br>" _NOTES_BR);
|
notesFormatted = notesFormatted.replace("<br>", "<br>" _NOTES_BR);
|
||||||
notesFormatted = notesFormatted.replace("<tr>", "<tr>" _NOTES_BR);
|
notesFormatted = notesFormatted.replace("<tr>", "<tr>" _NOTES_BR);
|
||||||
|
@ -76,7 +75,7 @@ DiveObjectHelper::DiveObjectHelper(struct dive *d) :
|
||||||
notes.setHtml(notesFormatted);
|
notes.setHtml(notesFormatted);
|
||||||
m_notes = notes.toPlainText();
|
m_notes = notes.toPlainText();
|
||||||
m_notes.replace(_NOTES_BR, "<br>");
|
m_notes.replace(_NOTES_BR, "<br>");
|
||||||
#undef _NOTES_BR
|
#undef _NOTES_BR
|
||||||
} else {
|
} else {
|
||||||
m_notes.replace("\n", "<br>");
|
m_notes.replace("\n", "<br>");
|
||||||
}
|
}
|
||||||
|
@ -213,7 +212,7 @@ QString DiveObjectHelper::sac() const
|
||||||
|
|
||||||
QStringList DiveObjectHelper::weights() const
|
QStringList DiveObjectHelper::weights() const
|
||||||
{
|
{
|
||||||
return m_weights;
|
return m_weights;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DiveObjectHelper::weight(int idx) const
|
QString DiveObjectHelper::weight(int idx) const
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
class DiveObjectHelper : public QObject {
|
class DiveObjectHelper : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int number READ number CONSTANT)
|
Q_PROPERTY(int number READ number CONSTANT)
|
||||||
Q_PROPERTY(int id READ id CONSTANT)
|
Q_PROPERTY(int id READ id CONSTANT)
|
||||||
Q_PROPERTY(int rating READ rating CONSTANT)
|
Q_PROPERTY(int rating READ rating CONSTANT)
|
||||||
|
@ -32,62 +32,62 @@ class DiveObjectHelper : public QObject {
|
||||||
Q_PROPERTY(QString maxcns READ maxcns CONSTANT)
|
Q_PROPERTY(QString maxcns READ maxcns CONSTANT)
|
||||||
Q_PROPERTY(QString otu READ otu CONSTANT)
|
Q_PROPERTY(QString otu READ otu CONSTANT)
|
||||||
public:
|
public:
|
||||||
DiveObjectHelper(struct dive *dive = NULL);
|
DiveObjectHelper(struct dive *dive = NULL);
|
||||||
~DiveObjectHelper();
|
~DiveObjectHelper();
|
||||||
int number() const;
|
int number() const;
|
||||||
int id() const;
|
int id() const;
|
||||||
int rating() const;
|
int rating() const;
|
||||||
QString date() const;
|
QString date() const;
|
||||||
timestamp_t timestamp() const;
|
timestamp_t timestamp() const;
|
||||||
QString time() const;
|
QString time() const;
|
||||||
QString location() const;
|
QString location() const;
|
||||||
QString gps() const;
|
QString gps() const;
|
||||||
QString duration() const;
|
QString duration() const;
|
||||||
QString depth() const;
|
QString depth() const;
|
||||||
QString divemaster() const;
|
QString divemaster() const;
|
||||||
QString buddy() const;
|
QString buddy() const;
|
||||||
QString airTemp() const;
|
QString airTemp() const;
|
||||||
QString waterTemp() const;
|
QString waterTemp() const;
|
||||||
QString notes() const;
|
QString notes() const;
|
||||||
QString tags() const;
|
QString tags() const;
|
||||||
QString gas() const;
|
QString gas() const;
|
||||||
QString sac() const;
|
QString sac() const;
|
||||||
QStringList weights() const;
|
QStringList weights() const;
|
||||||
QString weight(int idx) const;
|
QString weight(int idx) const;
|
||||||
QString suit() const;
|
QString suit() const;
|
||||||
QStringList cylinders() const;
|
QStringList cylinders() const;
|
||||||
QString cylinder(int idx) const;
|
QString cylinder(int idx) const;
|
||||||
QString trip() const;
|
QString trip() const;
|
||||||
QString maxcns() const;
|
QString maxcns() const;
|
||||||
QString otu() const;
|
QString otu() const;
|
||||||
private:
|
|
||||||
int m_number;
|
|
||||||
int m_id;
|
|
||||||
int m_rating;
|
|
||||||
QString m_date;
|
|
||||||
timestamp_t m_timestamp;
|
|
||||||
QString m_time;
|
|
||||||
QString m_location;
|
|
||||||
QString m_gps;
|
|
||||||
QString m_duration;
|
|
||||||
QString m_depth;
|
|
||||||
QString m_divemaster;
|
|
||||||
QString m_buddy;
|
|
||||||
QString m_airTemp;
|
|
||||||
QString m_waterTemp;
|
|
||||||
QString m_notes;
|
|
||||||
QString m_tags;
|
|
||||||
QString m_gas;
|
|
||||||
QString m_sac;
|
|
||||||
QStringList m_weights;
|
|
||||||
QString m_suit;
|
|
||||||
QStringList m_cylinders;
|
|
||||||
QString m_trip;
|
|
||||||
QString m_maxcns;
|
|
||||||
QString m_otu;
|
|
||||||
struct dive *m_dive;
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_number;
|
||||||
|
int m_id;
|
||||||
|
int m_rating;
|
||||||
|
QString m_date;
|
||||||
|
timestamp_t m_timestamp;
|
||||||
|
QString m_time;
|
||||||
|
QString m_location;
|
||||||
|
QString m_gps;
|
||||||
|
QString m_duration;
|
||||||
|
QString m_depth;
|
||||||
|
QString m_divemaster;
|
||||||
|
QString m_buddy;
|
||||||
|
QString m_airTemp;
|
||||||
|
QString m_waterTemp;
|
||||||
|
QString m_notes;
|
||||||
|
QString m_tags;
|
||||||
|
QString m_gas;
|
||||||
|
QString m_sac;
|
||||||
|
QStringList m_weights;
|
||||||
|
QString m_suit;
|
||||||
|
QStringList m_cylinders;
|
||||||
|
QString m_trip;
|
||||||
|
QString m_maxcns;
|
||||||
|
QString m_otu;
|
||||||
|
struct dive *m_dive;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(DiveObjectHelper*)
|
Q_DECLARE_METATYPE(DiveObjectHelper *)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue