diff options
Diffstat (limited to 'subsurface-core/subsurface-qt')
-rw-r--r-- | subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 43 | ||||
-rw-r--r-- | subsurface-core/subsurface-qt/DiveObjectHelper.h | 112 |
2 files changed, 77 insertions, 78 deletions
diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp index c82a4a96e..7db882da2 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp @@ -11,35 +11,34 @@ static QString EMPTY_DIVE_STRING = QStringLiteral("--"); static QString getFormattedWeight(struct dive *dive, unsigned int idx) { - weightsystem_t *weight = &dive->weightsystem[idx]; - if (!weight->description) - return QString(EMPTY_DIVE_STRING); - QString fmt = QString(weight->description); - fmt += ", " + get_weight_string(weight->weight, true); - return fmt; + weightsystem_t *weight = &dive->weightsystem[idx]; + if (!weight->description) + return QString(EMPTY_DIVE_STRING); + QString fmt = QString(weight->description); + fmt += ", " + get_weight_string(weight->weight, true); + return fmt; } static QString getFormattedCylinder(struct dive *dive, unsigned int idx) { - cylinder_t *cyl = &dive->cylinder[idx]; - const char *desc = cyl->type.description; - if (!desc && idx > 0) - return QString(EMPTY_DIVE_STRING); - QString fmt = desc ? QString(desc) : QObject::tr("unknown"); - fmt += ", " + get_volume_string(cyl->type.size, true, 0); - fmt += ", " + get_pressure_string(cyl->type.workingpressure, true); - fmt += ", " + get_pressure_string(cyl->start, false) + " - " + get_pressure_string(cyl->end, true); - fmt += ", " + get_gas_string(cyl->gasmix); - return fmt; + cylinder_t *cyl = &dive->cylinder[idx]; + const char *desc = cyl->type.description; + if (!desc && idx > 0) + return QString(EMPTY_DIVE_STRING); + QString fmt = desc ? QString(desc) : QObject::tr("unknown"); + fmt += ", " + get_volume_string(cyl->type.size, true, 0); + fmt += ", " + get_pressure_string(cyl->type.workingpressure, true); + fmt += ", " + get_pressure_string(cyl->start, false) + " - " + get_pressure_string(cyl->end, true); + fmt += ", " + get_gas_string(cyl->gasmix); + return fmt; } -DiveObjectHelper::DiveObjectHelper(struct dive *d) : - m_number(d->number), +DiveObjectHelper::DiveObjectHelper(struct dive *d) : m_number(d->number), m_id(d->id), m_rating(d->rating), m_timestamp(d->when), 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_divemaster(d->divemaster ? d->divemaster : 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")) { QTextDocument notes; QString notesFormatted = m_notes; - #define _NOTES_BR "\n" +#define _NOTES_BR "\n" notesFormatted = notesFormatted.replace("<thead>", "<thead>" _NOTES_BR); notesFormatted = notesFormatted.replace("<br>", "<br>" _NOTES_BR); notesFormatted = notesFormatted.replace("<tr>", "<tr>" _NOTES_BR); @@ -76,7 +75,7 @@ DiveObjectHelper::DiveObjectHelper(struct dive *d) : notes.setHtml(notesFormatted); m_notes = notes.toPlainText(); m_notes.replace(_NOTES_BR, "<br>"); - #undef _NOTES_BR +#undef _NOTES_BR } else { m_notes.replace("\n", "<br>"); } @@ -213,7 +212,7 @@ QString DiveObjectHelper::sac() const QStringList DiveObjectHelper::weights() const { -return m_weights; + return m_weights; } QString DiveObjectHelper::weight(int idx) const diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.h b/subsurface-core/subsurface-qt/DiveObjectHelper.h index 2833cd30c..5f6cdf60b 100644 --- a/subsurface-core/subsurface-qt/DiveObjectHelper.h +++ b/subsurface-core/subsurface-qt/DiveObjectHelper.h @@ -7,7 +7,7 @@ #include <QStringList> class DiveObjectHelper : public QObject { - Q_OBJECT + Q_OBJECT Q_PROPERTY(int number READ number CONSTANT) Q_PROPERTY(int id READ id 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 otu READ otu CONSTANT) public: - DiveObjectHelper(struct dive *dive = NULL); - ~DiveObjectHelper(); - int number() const; - int id() const; - int rating() const; - QString date() const; - timestamp_t timestamp() const; - QString time() const; - QString location() const; - QString gps() const; - QString duration() const; - QString depth() const; - QString divemaster() const; - QString buddy() const; - QString airTemp() const; - QString waterTemp() const; - QString notes() const; - QString tags() const; - QString gas() const; - QString sac() const; - QStringList weights() const; - QString weight(int idx) const; - QString suit() const; - QStringList cylinders() const; - QString cylinder(int idx) const; - QString trip() const; - QString maxcns() 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; + DiveObjectHelper(struct dive *dive = NULL); + ~DiveObjectHelper(); + int number() const; + int id() const; + int rating() const; + QString date() const; + timestamp_t timestamp() const; + QString time() const; + QString location() const; + QString gps() const; + QString duration() const; + QString depth() const; + QString divemaster() const; + QString buddy() const; + QString airTemp() const; + QString waterTemp() const; + QString notes() const; + QString tags() const; + QString gas() const; + QString sac() const; + QStringList weights() const; + QString weight(int idx) const; + QString suit() const; + QStringList cylinders() const; + QString cylinder(int idx) const; + QString trip() const; + QString maxcns() 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; }; -Q_DECLARE_METATYPE(DiveObjectHelper*) + Q_DECLARE_METATYPE(DiveObjectHelper *) #endif |