From 305509ad5f0577de0a9b75311e78a01b19329515 Mon Sep 17 00:00:00 2001 From: Grace Karanja Date: Wed, 10 Jun 2015 21:38:14 +0300 Subject: Add dive notes to the divelistmodel Add the dive notes field into the DiveListModel class. Signed-off-by: Grace Karanja Signed-off-by: Dirk Hohndel --- qt-models/divelistmodel.cpp | 14 ++++++++++++++ qt-models/divelistmodel.h | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'qt-models') diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 1786c85e1..c1862b829 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -24,6 +24,7 @@ Dive::Dive(dive *d) setCylinder(QString(d->cylinder[0].type.description)); setSac(QString::number(d->sac)); setLocation(get_dive_location(d)); + setNotes(d->notes); } QString Dive::date() const @@ -143,6 +144,16 @@ void Dive::setDiveNumber(const QString &diveNumber) { m_diveNumber = diveNumber; } +QString Dive::notes() const +{ + return m_notes; +} + +void Dive::setNotes(const QString ¬es) +{ + m_notes = notes; +} + DiveListModel *DiveListModel::m_instance = NULL; @@ -195,6 +206,8 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const return dive.sac(); else if (role == DiveLocationRole) return dive.location(); + else if (role == DiveNotesRole) + return dive.notes(); return QVariant(); @@ -215,6 +228,7 @@ QHash DiveListModel::roleNames() const roles[DiveGasRole] = "gas"; roles[DiveSacRole] = "sac"; roles[DiveLocationRole] = "location"; + roles[DiveNotesRole] = "notes"; return roles; } diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index 96f16912a..307008cc1 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -47,6 +47,9 @@ public: QString diveNumber() const; void setDiveNumber(const QString &diveNumber); + QString notes() const; + void setNotes(const QString ¬es); + private: QString m_diveNumber; QString m_date; @@ -60,6 +63,7 @@ private: QString m_gas; QString m_sac; QString m_location; + QString m_notes; dive *m_thisDive; @@ -82,7 +86,8 @@ public: DiveCylinderRole, DiveGasRole, DiveSacRole, - DiveLocationRole + DiveLocationRole, + DiveNotesRole }; static DiveListModel *instance(); -- cgit v1.2.3-70-g09d2