diff options
author | Grace Karanja <gracie.karanja89@gmail.com> | 2015-07-13 13:06:45 +0300 |
---|---|---|
committer | Grace Karanja <gracie.karanja89@gmail.com> | 2015-07-17 19:12:39 +0300 |
commit | aae27629c4b6f524911f869694da27dcd2533adb (patch) | |
tree | c4afcdc45ad448a35e7faca10951b502a3a9ec14 | |
parent | 5d12723656c6643ff26f309442aa0b470f32d100 (diff) | |
download | subsurface-aae27629c4b6f524911f869694da27dcd2533adb.tar.gz |
QL UI: Add DiveId role to DiveListModel
This will be used when rendering the dive profile and also when
saving the dive changes.
Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
-rw-r--r-- | qt-models/divelistmodel.cpp | 14 | ||||
-rw-r--r-- | qt-models/divelistmodel.h | 7 |
2 files changed, 20 insertions, 1 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 0fb1cbbf9..8bb895fc8 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -5,6 +5,7 @@ MobileDive::MobileDive(dive *d) { m_thisDive = d; setDiveNumber(QString::number(d->number)); + setDiveId(QString::number(d->id)); dive_trip *trip = d->divetrip; @@ -216,6 +217,16 @@ void MobileDive::setupDiveTempDetails() setWatertemp(get_temperature_string(m_thisDive->watertemp, true)); setAirTemp(get_temperature_string(m_thisDive->airtemp, true)); } +QString MobileDive::diveId() const +{ + return m_diveId; +} + +void MobileDive::setDiveId(const QString &diveId) +{ + m_diveId = diveId; +} + @@ -283,6 +294,8 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const return dive.buddy(); else if (role == DiveMasterRole) return dive.divemaster(); + else if (role == DiveIdRole) + return dive.diveId(); return QVariant(); @@ -308,6 +321,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const roles[DiveNotesRole] = "notes"; roles[DiveBuddyRole] = "buddy"; roles[DiveMasterRole] = "divemaster"; + roles[DiveIdRole] = "id"; return roles; } diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index 68f0c6fa7..89f793bbc 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -62,6 +62,9 @@ public: QString watertemp() const; void setWatertemp(const QString &watertemp); + QString diveId() const; + void setDiveId(const QString &diveId); + private: void setupDiveTempDetails(); @@ -82,6 +85,7 @@ private: QString m_notes; QString m_buddy; QString m_divemaster; + QString m_diveId; dive *m_thisDive; @@ -109,7 +113,8 @@ public: DiveLocationRole, DiveNotesRole, DiveBuddyRole, - DiveMasterRole + DiveMasterRole, + DiveIdRole }; static DiveListModel *instance(); |