mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Remove useless members of DiveItem
Just use the dive struct directly. Suggested-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5d4d40df91
commit
8a884d2cf7
1 changed files with 31 additions and 52 deletions
|
@ -294,29 +294,33 @@ void TankInfoModel::update()
|
||||||
class DiveItem
|
class DiveItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DiveItem(): number(0), when(), duration(), maxdepth(), rating(0),
|
explicit DiveItem(): dive() { parentItem = 0; }
|
||||||
temperature(), totalweight(), suit(QString()), sac(0),
|
|
||||||
otu(0), maxcns(0), location(QString()) { parentItem = 0; }
|
|
||||||
|
|
||||||
explicit DiveItem(struct dive *d, DiveItem *parent = 0);
|
explicit DiveItem(struct dive *d, DiveItem *parent = 0);
|
||||||
|
|
||||||
~DiveItem() { qDeleteAll(childlist); }
|
~DiveItem() { qDeleteAll(childlist); }
|
||||||
|
|
||||||
int diveNumber() const { return number; }
|
int diveNumber() const { return dive->number; }
|
||||||
const QString diveDateTime() const { return QString::fromUtf8(get_dive_date_string(when)); }
|
const QString diveDateTime() const { return QString::fromUtf8(get_dive_date_string(dive->when)); }
|
||||||
int diveDuration() const { return duration.seconds; }
|
int diveDuration() const { return dive->duration.seconds; }
|
||||||
int diveDepth() const { return maxdepth.mm; }
|
int diveDepth() const { return dive->maxdepth.mm; }
|
||||||
int diveSac() const { return sac; }
|
int diveSac() const { return dive->sac; }
|
||||||
int diveOtu() const { return otu; }
|
int diveOtu() const { return dive->otu; }
|
||||||
int diveMaxcns() const { return maxcns; }
|
int diveMaxcns() const { return dive->maxcns; }
|
||||||
int diveWeight() const { return totalweight.grams; }
|
|
||||||
|
int diveWeight() const
|
||||||
|
{
|
||||||
|
weight_t tw = { total_weight(dive) };
|
||||||
|
return tw.grams;
|
||||||
|
}
|
||||||
|
|
||||||
QString displayDuration() const;
|
QString displayDuration() const;
|
||||||
QString displayDepth() const;
|
QString displayDepth() const;
|
||||||
QString displayTemperature() const;
|
QString displayTemperature() const;
|
||||||
QString displayWeight() const;
|
QString displayWeight() const;
|
||||||
QString displaySac() const;
|
QString displaySac() const;
|
||||||
const QString& diveLocation() const { return location; }
|
const QString diveLocation() const { return dive->location; }
|
||||||
const QString& diveSuit() const { return suit; }
|
const QString diveSuit() const { return dive->suit; }
|
||||||
DiveItem *parent() const { return parentItem; }
|
DiveItem *parent() const { return parentItem; }
|
||||||
const QList<DiveItem *>& children() const { return childlist; }
|
const QList<DiveItem *>& children() const { return childlist; }
|
||||||
|
|
||||||
|
@ -326,40 +330,15 @@ public:
|
||||||
} /* parent = self */
|
} /* parent = self */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int number;
|
struct dive *dive;
|
||||||
timestamp_t when;
|
|
||||||
duration_t duration;
|
|
||||||
depth_t maxdepth;
|
|
||||||
int rating;
|
|
||||||
temperature_t temperature;
|
|
||||||
weight_t totalweight;
|
|
||||||
QString suit;
|
|
||||||
int sac;
|
|
||||||
int otu;
|
|
||||||
int maxcns;
|
|
||||||
QString location;
|
|
||||||
DiveItem *parentItem;
|
DiveItem *parentItem;
|
||||||
QList <DiveItem*> childlist;
|
QList <DiveItem*> childlist;
|
||||||
};
|
};
|
||||||
|
|
||||||
DiveItem::DiveItem(struct dive *d, DiveItem *p):
|
DiveItem::DiveItem(struct dive *d, DiveItem *p):
|
||||||
number(d->number),
|
dive(d),
|
||||||
rating(d->rating),
|
|
||||||
suit(d->suit),
|
|
||||||
sac(d->sac),
|
|
||||||
otu(d->otu),
|
|
||||||
maxcns(d->maxcns),
|
|
||||||
location(d->location),
|
|
||||||
parentItem(p)
|
parentItem(p)
|
||||||
{
|
{
|
||||||
this->when = d->when;
|
|
||||||
this->duration = d->duration;
|
|
||||||
this->maxdepth = d->maxdepth;
|
|
||||||
this->temperature = d->watertemp;
|
|
||||||
|
|
||||||
weight_t tw = { total_weight(d) };
|
|
||||||
this->totalweight = tw;
|
|
||||||
|
|
||||||
if (parentItem)
|
if (parentItem)
|
||||||
parentItem->addChild(this);
|
parentItem->addChild(this);
|
||||||
}
|
}
|
||||||
|
@ -369,11 +348,11 @@ QString DiveItem::displayDepth() const
|
||||||
const int scale = 1000;
|
const int scale = 1000;
|
||||||
QString fract, str;
|
QString fract, str;
|
||||||
if (get_units()->length == units::METERS) {
|
if (get_units()->length == units::METERS) {
|
||||||
fract = QString::number((unsigned)(maxdepth.mm % scale) / 10);
|
fract = QString::number((unsigned)(dive->maxdepth.mm % scale) / 10);
|
||||||
str = QString("%1.%2").arg((unsigned)(maxdepth.mm / scale)).arg(fract, 2, QChar('0'));
|
str = QString("%1.%2").arg((unsigned)(dive->maxdepth.mm / scale)).arg(fract, 2, QChar('0'));
|
||||||
}
|
}
|
||||||
if (get_units()->length == units::FEET) {
|
if (get_units()->length == units::FEET) {
|
||||||
str = QString::number(mm_to_feet(maxdepth.mm),'f',0);
|
str = QString::number(mm_to_feet(dive->maxdepth.mm),'f',0);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -382,8 +361,8 @@ QString DiveItem::displayDuration() const
|
||||||
{
|
{
|
||||||
int hrs, mins, secs;
|
int hrs, mins, secs;
|
||||||
|
|
||||||
secs = duration.seconds % 60;
|
secs = dive->duration.seconds % 60;
|
||||||
mins = duration.seconds / 60;
|
mins = dive->duration.seconds / 60;
|
||||||
hrs = mins / 60;
|
hrs = mins / 60;
|
||||||
mins -= hrs * 60;
|
mins -= hrs * 60;
|
||||||
|
|
||||||
|
@ -401,9 +380,9 @@ QString DiveItem::displayTemperature() const
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
if (get_units()->temperature == units::CELSIUS) {
|
if (get_units()->temperature == units::CELSIUS) {
|
||||||
str = QString::number(mkelvin_to_C(temperature.mkelvin), 'f', 1);
|
str = QString::number(mkelvin_to_C(dive->watertemp.mkelvin), 'f', 1);
|
||||||
} else {
|
} else {
|
||||||
str = QString::number(mkelvin_to_F(temperature.mkelvin), 'f', 1);
|
str = QString::number(mkelvin_to_F(dive->watertemp.mkelvin), 'f', 1);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -413,9 +392,9 @@ QString DiveItem::displaySac() const
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
if (get_units()->volume == units::LITER) {
|
if (get_units()->volume == units::LITER) {
|
||||||
str = QString::number(sac / 1000, 'f', 1);
|
str = QString::number(dive->sac / 1000, 'f', 1);
|
||||||
} else {
|
} else {
|
||||||
str = QString::number(ml_to_cuft(sac), 'f', 2);
|
str = QString::number(ml_to_cuft(dive->sac), 'f', 2);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -425,11 +404,11 @@ QString DiveItem::displayWeight() const
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
if (get_units()->weight == units::KG) {
|
if (get_units()->weight == units::KG) {
|
||||||
int gr = totalweight.grams % 1000;
|
int gr = diveWeight() % 1000;
|
||||||
int kg = totalweight.grams / 1000;
|
int kg = diveWeight() / 1000;
|
||||||
str = QString("%1.%2").arg(kg).arg((unsigned)(gr + 500) / 100);
|
str = QString("%1.%2").arg(kg).arg((unsigned)(gr + 500) / 100);
|
||||||
} else {
|
} else {
|
||||||
str = QString("%1").arg((unsigned)(grams_to_lbs(totalweight.grams) + 0.5));
|
str = QString("%1").arg((unsigned)(grams_to_lbs(diveWeight()) + 0.5));
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue