summaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models/divelistmodel.cpp')
-rw-r--r--qt-models/divelistmodel.cpp261
1 files changed, 9 insertions, 252 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index 7b7102f7b..1cec4bd20 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -1,249 +1,6 @@
#include "divelistmodel.h"
#include "helpers.h"
-MobileDive::MobileDive(dive *d)
-{
- m_thisDive = d;
- setDiveNumber(QString::number(d->number));
- setDiveId(QString::number(d->id));
-
- dive_trip *trip = d->divetrip;
-
- if(trip) {
- //trip is valid
- setTrip(trip->location);
- }
- setDate(d->when);
- setDateString(get_dive_date_string(d->when));
- setDepth(get_depth_string(d->maxdepth));
- setDuration(get_dive_duration_string(d->duration.seconds, "h:","min"));
-
- setupDiveTempDetails();
-
- weight_t tw = { total_weight(d) };
- setWeight(weight_string(tw.grams));
-
- setSuit(QString(d->suit));
- setCylinder(QString(d->cylinder[0].type.description));
- setSac(QString::number(d->sac));
- setLocation(get_dive_location(d));
- setNotes(d->notes);
- setBuddy(d->buddy);
- setDivemaster(d->divemaster);
-}
-
-QString MobileDive::dateString() const
-{
- return m_dateString;
-}
-
-void MobileDive::setDateString(const QString &date)
-{
- m_dateString = date;
-}
-
-timestamp_t MobileDive::date() const
-{
- return m_date;
-}
-
-void MobileDive::setDate(timestamp_t when)
-{
- m_date = when;
-}
-
-QString MobileDive::location() const
-{
- return m_location;
-}
-
-void MobileDive::setLocation(const QString &location)
-{
- m_location = location;
-}
-
-QString MobileDive::sac() const
-{
- return m_sac;
-}
-
-void MobileDive::setSac(const QString &sac)
-{
- m_sac = sac;
-}
-
-QString MobileDive::gas() const
-{
- return m_gas;
-}
-
-void MobileDive::setGas(const QString &gas)
-{
- m_gas = gas;
-}
-
-QString MobileDive::cylinder() const
-{
- return m_cylinder;
-}
-
-void MobileDive::setCylinder(const QString &cylinder)
-{
- m_cylinder = cylinder;
-}
-
-QString MobileDive::suit() const
-{
- return m_suit;
-}
-
-void MobileDive::setSuit(const QString &suit)
-{
- m_suit = suit;
-}
-
-QString MobileDive::weight() const
-{
- return m_weight;
-}
-
-void MobileDive::setWeight(const QString &weight)
-{
- m_weight = weight;
-}
-
-QString MobileDive::airtemp() const
-{
- return m_airtemp;
-}
-
-void MobileDive::setAirTemp(const QString &airtemp)
-{
- m_airtemp = airtemp;
-}
-
-QString MobileDive::duration() const
-{
- return m_duration;
-}
-
-void MobileDive::setDuration(const QString &duration)
-{
- m_duration = duration;
-}
-
-QString MobileDive::depth() const
-{
- return m_depth;
-}
-
-void MobileDive::setDepth(const QString &depth)
-{
- m_depth = depth;
-}
-
-QString MobileDive::rating() const
-{
- return m_rating;
-}
-
-void MobileDive::setRating(const QString &rating)
-{
- m_rating = rating;
-}
-
-dive *MobileDive::thisDive() const
-{
- return m_thisDive;
-}
-
-void MobileDive::setThisDive(dive *thisDive)
-{
- m_thisDive = thisDive;
-}
-
-QString MobileDive::diveNumber() const
-{
- return m_diveNumber;
-}
-
-void MobileDive::setDiveNumber(const QString &diveNumber)
-{
- m_diveNumber = diveNumber;
-}
-
-QString MobileDive::notes() const
-{
- return m_notes;
-}
-
-void MobileDive::setNotes(const QString &notes)
-{
- m_notes = notes;
-}
-
-QString MobileDive::trip() const
-{
- return m_trip;
-}
-
-void MobileDive::setTrip(const QString &trip)
-{
- m_trip = trip;
-}
-
-QString MobileDive::buddy() const
-{
- return m_buddy;
-}
-
-void MobileDive::setBuddy(const QString &buddy)
-{
- m_buddy = buddy;
-}
-
-QString MobileDive::divemaster() const
-{
- return m_divemaster;
-}
-
-void MobileDive::setDivemaster(const QString &divemaster)
-{
- m_divemaster = divemaster;
-}
-
-QString MobileDive::watertemp() const
-{
- return m_watertemp;
-}
-
-void MobileDive::setWatertemp(const QString &watertemp)
-{
- m_watertemp = watertemp;
-}
-
-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;
-}
-
-
-
-
-
-
-
-
DiveListModel *DiveListModel::m_instance = NULL;
DiveListModel::DiveListModel(QObject *parent) : QAbstractListModel(parent)
@@ -254,7 +11,7 @@ DiveListModel::DiveListModel(QObject *parent) : QAbstractListModel(parent)
void DiveListModel::addDive(dive *d)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
- m_dives.append(MobileDive(d));
+ m_dives.append(Dive(d));
endInsertRows();
}
@@ -268,26 +25,26 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
if(index.row() < 0 || index.row() > m_dives.count())
return QVariant();
- const MobileDive &dive = m_dives[index.row()];
+ const Dive &dive = m_dives[index.row()];
if (role == DiveNumberRole)
- return dive.diveNumber();
+ return dive.number();
else if (role == DiveTripRole)
return dive.trip();
else if (role == DiveDateRole)
- return (qlonglong)dive.date();
+ return (qlonglong)dive.timestamp();
else if (role == DiveDateStringRole)
- return dive.dateString();
+ return dive.date() + " " + dive.time();
else if (role == DiveRatingRole)
- return dive.rating();
+ return QString::number(dive.rating());
else if (role == DiveDepthRole)
return dive.depth();
else if (role == DiveDurationRole)
return dive.duration();
else if (role == DiveAirTemperatureRole)
- return dive.airtemp();
+ return dive.airTemp();
else if (role == DiveWaterTemperatureRole)
- return dive.watertemp();
+ return dive.waterTemp();
else if (role == DiveWeightRole)
return dive.weight();
else if (role == DiveSuitRole)
@@ -307,7 +64,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
else if (role == DiveMasterRole)
return dive.divemaster();
else if (role == DiveIdRole)
- return dive.diveId();
+ return QString::number(dive.id());
return QVariant();