mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: turn divecomputer list into std::vector<>
Since struct divecomputer is now fully C++ (i.e. cleans up after itself), we can simply turn the list of divecomputers into an std::vector<>. This makes the code quite a bit simpler, because the first divecomputer was actually a subobject. Yes, this makes the common case of a single divecomputer a little bit less efficient, but it really shouldn't matter. If it does, we can still write a special std::vector<>- like container that keeps the first element inline. This change makes pointers-to-divecomputers not stable. So always access the divecomputer via its index. As far as I can tell, most of the code already does this. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e237f29fb2
commit
284582d2e8
54 changed files with 738 additions and 893 deletions
|
@ -401,7 +401,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
if (get_o2(cyl.gasmix) + get_he(cyl.gasmix) > 1000)
|
||||
cyl.gasmix.he.permille = 1000 - get_o2(cyl.gasmix);
|
||||
pressure_t modpO2;
|
||||
if (d->dc.divemode == PSCR)
|
||||
if (d->dcs[0].divemode == PSCR)
|
||||
modpO2.mbar = prefs.decopo2 + (1000 - get_o2(cyl.gasmix)) * SURFACE_PRESSURE *
|
||||
prefs.o2consumption / prefs.decosac / prefs.pscr_ratio;
|
||||
else
|
||||
|
|
|
@ -70,7 +70,7 @@ void DivePlannerPointsModel::createSimpleDive(struct dive *dIn)
|
|||
clear_dive(d);
|
||||
d->id = dive_getUniqID();
|
||||
d->when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600;
|
||||
make_planner_dc(&d->dc);
|
||||
make_planner_dc(&d->dcs[0]);
|
||||
|
||||
clear();
|
||||
removeDeco();
|
||||
|
@ -818,7 +818,7 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_
|
|||
}
|
||||
}
|
||||
if (divemode == UNDEF_COMP_TYPE)
|
||||
divemode = get_dive_dc_const(d, dcNr)->divemode;
|
||||
divemode = get_dive_dc(d, dcNr)->divemode;
|
||||
|
||||
// add the new stop
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
|
|
|
@ -116,7 +116,7 @@ Stats::Stats() :
|
|||
|
||||
static void calculateDive(struct dive *dive, Stats &stats)
|
||||
{
|
||||
if (is_dc_planner(&dive->dc)) {
|
||||
if (is_dc_planner(&dive->dcs[0])) {
|
||||
stats.diveplans++;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -162,9 +162,9 @@ static int countPhotos(const struct dive *d)
|
|||
static QString displayDuration(const struct dive *d)
|
||||
{
|
||||
if (prefs.units.show_units_table)
|
||||
return get_dive_duration_string(d->duration.seconds, gettextFromC::tr("h"), gettextFromC::tr("min"), "", ":", d->dc.divemode == FREEDIVE);
|
||||
return get_dive_duration_string(d->duration.seconds, gettextFromC::tr("h"), gettextFromC::tr("min"), "", ":", d->dcs[0].divemode == FREEDIVE);
|
||||
else
|
||||
return get_dive_duration_string(d->duration.seconds, "", "", "", ":", d->dc.divemode == FREEDIVE);
|
||||
return get_dive_duration_string(d->duration.seconds, "", "", "", ":", d->dcs[0].divemode == FREEDIVE);
|
||||
}
|
||||
|
||||
static QString displayTemperature(const struct dive *d, bool units)
|
||||
|
@ -281,9 +281,9 @@ QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role)
|
|||
case MobileListModel::IdRole: return d->id;
|
||||
case MobileListModel::NumberRole: return d->number;
|
||||
case MobileListModel::LocationRole: return QString::fromStdString(get_dive_location(d));
|
||||
case MobileListModel::DepthRole: return get_depth_string(d->dc.maxdepth.mm, true, true);
|
||||
case MobileListModel::DepthRole: return get_depth_string(d->dcs[0].maxdepth.mm, true, true);
|
||||
case MobileListModel::DurationRole: return formatDiveDuration(d);
|
||||
case MobileListModel::DepthDurationRole: return QStringLiteral("%1 / %2").arg(get_depth_string(d->dc.maxdepth.mm, true, true),
|
||||
case MobileListModel::DepthDurationRole: return QStringLiteral("%1 / %2").arg(get_depth_string(d->dcs[0].maxdepth.mm, true, true),
|
||||
formatDiveDuration(d));
|
||||
case MobileListModel::RatingRole: return d->rating;
|
||||
case MobileListModel::VizRole: return d->visibility;
|
||||
|
@ -298,7 +298,7 @@ QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role)
|
|||
case MobileListModel::NotesRole: return formatNotes(d);
|
||||
case MobileListModel::GpsRole: return formatDiveGPS(d);
|
||||
case MobileListModel::GpsDecimalRole: return format_gps_decimal(d);
|
||||
case MobileListModel::NoDiveRole: return d->duration.seconds == 0 && d->dc.duration.seconds == 0;
|
||||
case MobileListModel::NoDiveRole: return d->duration.seconds == 0 && d->dcs[0].duration.seconds == 0;
|
||||
case MobileListModel::DiveSiteRole: return QVariant::fromValue(d->dive_site);
|
||||
case MobileListModel::CylinderRole: return formatGetCylinder(d).join(", ");
|
||||
case MobileListModel::GetCylinderRole: return formatGetCylinder(d);
|
||||
|
@ -363,7 +363,7 @@ QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role)
|
|||
case NOTES:
|
||||
return QString(d->notes);
|
||||
case DIVEMODE:
|
||||
return QString(divemode_text_ui[(int)d->dc.divemode]);
|
||||
return QString(divemode_text_ui[(int)d->dcs[0].divemode]);
|
||||
}
|
||||
break;
|
||||
case Qt::DecorationRole:
|
||||
|
@ -1780,6 +1780,6 @@ bool DiveTripModelList::lessThan(const QModelIndex &i1, const QModelIndex &i2) c
|
|||
case NOTES:
|
||||
return lessThanHelper(strCmp(d1->notes, d2->notes), row_diff);
|
||||
case DIVEMODE:
|
||||
return lessThanHelper((int)d1->dc.divemode - (int)d2->dc.divemode, row_diff);
|
||||
return lessThanHelper((int)d1->dcs[0].divemode - (int)d2->dcs[0].divemode, row_diff);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue