mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Simplify DiveItem
The DiveItem constructor had 13 variables. By passing it the full dive we reduce that to 2. [Dirk Hohndel: changed to use "struct dive *" instead of just "dive *"] Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fde0f49df8
commit
5d4d40df91
1 changed files with 22 additions and 25 deletions
|
@ -63,7 +63,7 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
dive *d = get_dive(selected_dive);
|
struct dive *d = get_dive(selected_dive);
|
||||||
cylinder_t& cyl = d->cylinder[index.row()];
|
cylinder_t& cyl = d->cylinder[index.row()];
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
|
@ -297,8 +297,9 @@ public:
|
||||||
explicit DiveItem(): number(0), when(), duration(), maxdepth(), rating(0),
|
explicit DiveItem(): number(0), when(), duration(), maxdepth(), rating(0),
|
||||||
temperature(), totalweight(), suit(QString()), sac(0),
|
temperature(), totalweight(), suit(QString()), sac(0),
|
||||||
otu(0), maxcns(0), location(QString()) { parentItem = 0; }
|
otu(0), maxcns(0), location(QString()) { parentItem = 0; }
|
||||||
explicit DiveItem(int, timestamp_t, duration_t, depth_t, int, temperature_t,
|
|
||||||
weight_t, QString, int, int, int, QString, 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 number; }
|
||||||
|
@ -341,15 +342,24 @@ private:
|
||||||
QList <DiveItem*> childlist;
|
QList <DiveItem*> childlist;
|
||||||
};
|
};
|
||||||
|
|
||||||
DiveItem::DiveItem(int num, timestamp_t when, duration_t duration, depth_t maxdepth, int rating, temperature_t temp,
|
DiveItem::DiveItem(struct dive *d, DiveItem *p):
|
||||||
weight_t weight, QString su, int sac, int otu, int maxcns, QString loc, DiveItem *p):
|
number(d->number),
|
||||||
number(num), rating(rating), suit(su), sac(sac), otu(otu), maxcns(maxcns), location(loc), parentItem(p)
|
rating(d->rating),
|
||||||
|
suit(d->suit),
|
||||||
|
sac(d->sac),
|
||||||
|
otu(d->otu),
|
||||||
|
maxcns(d->maxcns),
|
||||||
|
location(d->location),
|
||||||
|
parentItem(p)
|
||||||
{
|
{
|
||||||
this->when = when;
|
this->when = d->when;
|
||||||
this->duration = duration;
|
this->duration = d->duration;
|
||||||
this->maxdepth = maxdepth;
|
this->maxdepth = d->maxdepth;
|
||||||
this->temperature = temp;
|
this->temperature = d->watertemp;
|
||||||
this->totalweight = weight;
|
|
||||||
|
weight_t tw = { total_weight(d) };
|
||||||
|
this->totalweight = tw;
|
||||||
|
|
||||||
if (parentItem)
|
if (parentItem)
|
||||||
parentItem->addChild(this);
|
parentItem->addChild(this);
|
||||||
}
|
}
|
||||||
|
@ -431,20 +441,7 @@ DiveTripModel::DiveTripModel(QObject *parent) : QAbstractItemModel(parent)
|
||||||
struct dive *d;
|
struct dive *d;
|
||||||
|
|
||||||
for_each_dive(i, d) {
|
for_each_dive(i, d) {
|
||||||
weight_t tw = {.grams = total_weight(d)};
|
new DiveItem(d, rootItem);
|
||||||
new DiveItem(d->number,
|
|
||||||
d->when,
|
|
||||||
d->duration,
|
|
||||||
d->maxdepth,
|
|
||||||
d->rating,
|
|
||||||
d->watertemp,
|
|
||||||
tw,
|
|
||||||
d->suit,
|
|
||||||
d->sac,
|
|
||||||
d->otu,
|
|
||||||
d->maxcns,
|
|
||||||
d->location,
|
|
||||||
rootItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue