mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add more dive details to the DiveListModel
Add some more details to the model. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e4e6e896c1
commit
d613ed0105
2 changed files with 88 additions and 19 deletions
|
@ -17,13 +17,7 @@ Dive::Dive(dive *d)
|
||||||
setDepth(get_depth_string(d->maxdepth));
|
setDepth(get_depth_string(d->maxdepth));
|
||||||
setDuration(get_dive_duration_string(d->duration.seconds, "h:","min"));
|
setDuration(get_dive_duration_string(d->duration.seconds, "h:","min"));
|
||||||
|
|
||||||
if (!d->watertemp.mkelvin)
|
setupDiveTempDetails();
|
||||||
m_depth = "";
|
|
||||||
|
|
||||||
if (get_units()->temperature == units::CELSIUS)
|
|
||||||
m_depth = QString::number(mkelvin_to_C(d->watertemp.mkelvin), 'f', 1);
|
|
||||||
else
|
|
||||||
m_depth = QString::number(mkelvin_to_F(d->watertemp.mkelvin), 'f', 1);
|
|
||||||
|
|
||||||
weight_t tw = { total_weight(d) };
|
weight_t tw = { total_weight(d) };
|
||||||
setWeight(weight_string(tw.grams));
|
setWeight(weight_string(tw.grams));
|
||||||
|
@ -33,6 +27,8 @@ Dive::Dive(dive *d)
|
||||||
setSac(QString::number(d->sac));
|
setSac(QString::number(d->sac));
|
||||||
setLocation(get_dive_location(d));
|
setLocation(get_dive_location(d));
|
||||||
setNotes(d->notes);
|
setNotes(d->notes);
|
||||||
|
setBuddy(d->buddy);
|
||||||
|
setDivemaster(d->divemaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Dive::date() const
|
QString Dive::date() const
|
||||||
|
@ -98,14 +94,14 @@ void Dive::setWeight(const QString &weight)
|
||||||
{
|
{
|
||||||
m_weight = weight;
|
m_weight = weight;
|
||||||
}
|
}
|
||||||
QString Dive::temp() const
|
QString Dive::airtemp() const
|
||||||
{
|
{
|
||||||
return m_temp;
|
return m_airtemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dive::setTemp(const QString &temp)
|
void Dive::setAirTemp(const QString &airtemp)
|
||||||
{
|
{
|
||||||
m_temp = temp;
|
m_airtemp = airtemp;
|
||||||
}
|
}
|
||||||
QString Dive::duration() const
|
QString Dive::duration() const
|
||||||
{
|
{
|
||||||
|
@ -170,6 +166,53 @@ void Dive::setTrip(const QString &trip)
|
||||||
{
|
{
|
||||||
m_trip = trip;
|
m_trip = trip;
|
||||||
}
|
}
|
||||||
|
QString Dive::buddy() const
|
||||||
|
{
|
||||||
|
return m_buddy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dive::setBuddy(const QString &buddy)
|
||||||
|
{
|
||||||
|
m_buddy = buddy;
|
||||||
|
}
|
||||||
|
QString Dive::divemaster() const
|
||||||
|
{
|
||||||
|
return m_divemaster;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dive::setDivemaster(const QString &divemaster)
|
||||||
|
{
|
||||||
|
m_divemaster = divemaster;
|
||||||
|
}
|
||||||
|
QString Dive::watertemp() const
|
||||||
|
{
|
||||||
|
return m_watertemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dive::setWatertemp(const QString &watertemp)
|
||||||
|
{
|
||||||
|
m_watertemp = watertemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dive::setupDiveTempDetails()
|
||||||
|
{
|
||||||
|
const char *unit;
|
||||||
|
double d_airTemp, d_waterTemp;
|
||||||
|
|
||||||
|
d_airTemp = get_temp_units(m_thisDive->airtemp.mkelvin, &unit);
|
||||||
|
d_waterTemp = get_temp_units(m_thisDive->watertemp.mkelvin, &unit);
|
||||||
|
|
||||||
|
setAirTemp(QString::number(d_airTemp) + unit);
|
||||||
|
setWatertemp(QString::number(d_waterTemp) + unit);
|
||||||
|
|
||||||
|
if (!m_thisDive->airtemp.mkelvin)
|
||||||
|
setAirTemp("");
|
||||||
|
|
||||||
|
if (!m_thisDive->watertemp.mkelvin)
|
||||||
|
setWatertemp("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,8 +255,10 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
|
||||||
return dive.depth();
|
return dive.depth();
|
||||||
else if (role == DiveDurationRole)
|
else if (role == DiveDurationRole)
|
||||||
return dive.duration();
|
return dive.duration();
|
||||||
else if (role == DiveTemperatureRole)
|
else if (role == DiveAirTemperatureRole)
|
||||||
return dive.temp();
|
return dive.airtemp();
|
||||||
|
else if (role == DiveWaterTemperatureRole)
|
||||||
|
return dive.watertemp();
|
||||||
else if (role == DiveWeightRole)
|
else if (role == DiveWeightRole)
|
||||||
return dive.weight();
|
return dive.weight();
|
||||||
else if (role == DiveSuitRole)
|
else if (role == DiveSuitRole)
|
||||||
|
@ -228,6 +273,10 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
|
||||||
return dive.location();
|
return dive.location();
|
||||||
else if (role == DiveNotesRole)
|
else if (role == DiveNotesRole)
|
||||||
return dive.notes();
|
return dive.notes();
|
||||||
|
else if (role == DiveBuddyRole)
|
||||||
|
return dive.buddy();
|
||||||
|
else if (role == DiveMasterRole)
|
||||||
|
return dive.divemaster();
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,7 +291,8 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
|
||||||
roles[DiveRatingRole] = "rating";
|
roles[DiveRatingRole] = "rating";
|
||||||
roles[DiveDepthRole] = "depth";
|
roles[DiveDepthRole] = "depth";
|
||||||
roles[DiveDurationRole] = "duration";
|
roles[DiveDurationRole] = "duration";
|
||||||
roles[DiveTemperatureRole] = "temp";
|
roles[DiveAirTemperatureRole] = "airtemp";
|
||||||
|
roles[DiveWaterTemperatureRole] = "watertemp";
|
||||||
roles[DiveWeightRole] = "weight";
|
roles[DiveWeightRole] = "weight";
|
||||||
roles[DiveSuitRole] = "suit";
|
roles[DiveSuitRole] = "suit";
|
||||||
roles[DiveCylinderRole] = "cylinder";
|
roles[DiveCylinderRole] = "cylinder";
|
||||||
|
@ -250,6 +300,8 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
|
||||||
roles[DiveSacRole] = "sac";
|
roles[DiveSacRole] = "sac";
|
||||||
roles[DiveLocationRole] = "location";
|
roles[DiveLocationRole] = "location";
|
||||||
roles[DiveNotesRole] = "notes";
|
roles[DiveNotesRole] = "notes";
|
||||||
|
roles[DiveBuddyRole] = "buddy";
|
||||||
|
roles[DiveMasterRole] = "divemaster";
|
||||||
|
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ public:
|
||||||
QString weight() const;
|
QString weight() const;
|
||||||
void setWeight(const QString &weight);
|
void setWeight(const QString &weight);
|
||||||
|
|
||||||
QString temp() const;
|
QString airtemp() const;
|
||||||
void setTemp(const QString &temp);
|
void setAirTemp(const QString &airtemp);
|
||||||
|
|
||||||
QString duration() const;
|
QString duration() const;
|
||||||
void setDuration(const QString &duration);
|
void setDuration(const QString &duration);
|
||||||
|
@ -53,14 +53,26 @@ public:
|
||||||
QString trip() const;
|
QString trip() const;
|
||||||
void setTrip(const QString &trip);
|
void setTrip(const QString &trip);
|
||||||
|
|
||||||
|
QString buddy() const;
|
||||||
|
void setBuddy(const QString &buddy);
|
||||||
|
|
||||||
|
QString divemaster() const;
|
||||||
|
void setDivemaster(const QString &divemaster);
|
||||||
|
|
||||||
|
QString watertemp() const;
|
||||||
|
void setWatertemp(const QString &watertemp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setupDiveTempDetails();
|
||||||
|
|
||||||
QString m_diveNumber;
|
QString m_diveNumber;
|
||||||
QString m_trip;
|
QString m_trip;
|
||||||
QString m_date;
|
QString m_date;
|
||||||
QString m_rating;
|
QString m_rating;
|
||||||
QString m_depth;
|
QString m_depth;
|
||||||
QString m_duration;
|
QString m_duration;
|
||||||
QString m_temp;
|
QString m_airtemp;
|
||||||
|
QString m_watertemp;
|
||||||
QString m_weight;
|
QString m_weight;
|
||||||
QString m_suit;
|
QString m_suit;
|
||||||
QString m_cylinder;
|
QString m_cylinder;
|
||||||
|
@ -68,6 +80,8 @@ private:
|
||||||
QString m_sac;
|
QString m_sac;
|
||||||
QString m_location;
|
QString m_location;
|
||||||
QString m_notes;
|
QString m_notes;
|
||||||
|
QString m_buddy;
|
||||||
|
QString m_divemaster;
|
||||||
|
|
||||||
|
|
||||||
dive *m_thisDive;
|
dive *m_thisDive;
|
||||||
|
@ -85,14 +99,17 @@ public:
|
||||||
DiveRatingRole,
|
DiveRatingRole,
|
||||||
DiveDepthRole,
|
DiveDepthRole,
|
||||||
DiveDurationRole,
|
DiveDurationRole,
|
||||||
DiveTemperatureRole,
|
DiveWaterTemperatureRole,
|
||||||
|
DiveAirTemperatureRole,
|
||||||
DiveWeightRole,
|
DiveWeightRole,
|
||||||
DiveSuitRole,
|
DiveSuitRole,
|
||||||
DiveCylinderRole,
|
DiveCylinderRole,
|
||||||
DiveGasRole,
|
DiveGasRole,
|
||||||
DiveSacRole,
|
DiveSacRole,
|
||||||
DiveLocationRole,
|
DiveLocationRole,
|
||||||
DiveNotesRole
|
DiveNotesRole,
|
||||||
|
DiveBuddyRole,
|
||||||
|
DiveMasterRole
|
||||||
};
|
};
|
||||||
|
|
||||||
static DiveListModel *instance();
|
static DiveListModel *instance();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue