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
|
@ -213,7 +213,7 @@ static bool ppGraphsEnabled(const struct divecomputer *dc, bool simplified)
|
|||
// Update visibility of non-interactive chart features according to preferences
|
||||
void ProfileScene::updateVisibility(bool diveHasHeartBeat, bool simplified)
|
||||
{
|
||||
const struct divecomputer *currentdc = get_dive_dc_const(d, dc);
|
||||
const struct divecomputer *currentdc = get_dive_dc(d, dc);
|
||||
if (!currentdc)
|
||||
return;
|
||||
bool ppGraphs = ppGraphsEnabled(currentdc, simplified);
|
||||
|
@ -291,7 +291,7 @@ struct VerticalAxisLayout {
|
|||
|
||||
void ProfileScene::updateAxes(bool diveHasHeartBeat, bool simplified)
|
||||
{
|
||||
const struct divecomputer *currentdc = get_dive_dc_const(d, dc);
|
||||
const struct divecomputer *currentdc = get_dive_dc(d, dc);
|
||||
if (!currentdc)
|
||||
return;
|
||||
|
||||
|
@ -428,7 +428,7 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
|||
decoModelParameters->set(QString("GF %1/%2").arg(diveplan.gflow).arg(diveplan.gfhigh), getColor(PRESSURE_TEXT));
|
||||
}
|
||||
|
||||
const struct divecomputer *currentdc = get_dive_dc_const(d, dc);
|
||||
const struct divecomputer *currentdc = get_dive_dc(d, dc);
|
||||
if (!currentdc || currentdc->samples.empty()) {
|
||||
clear();
|
||||
return;
|
||||
|
|
|
@ -534,7 +534,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
|||
// figure out if we are ontop of the dive computer name in the profile
|
||||
QGraphicsItem *sceneItem = itemAt(mapFromGlobal(event->globalPos()));
|
||||
if (isDiveTextItem(sceneItem, profileScene->diveComputerText)) {
|
||||
const struct divecomputer *currentdc = get_dive_dc_const(d, dc);
|
||||
const struct divecomputer *currentdc = get_dive_dc(d, dc);
|
||||
if (!currentdc->deviceid && dc == 0 && number_of_computers(d) == 1)
|
||||
// nothing to do, can't rename, delete or reorder
|
||||
return;
|
||||
|
@ -580,7 +580,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
|||
m.addAction(tr("Add bookmark"), [this, seconds]() { addBookmark(seconds); });
|
||||
m.addAction(tr("Split dive into two"), [this, seconds]() { splitDive(seconds); });
|
||||
|
||||
divemode_loop loop(*get_dive_dc_const(d, dc));
|
||||
divemode_loop loop(*get_dive_dc(d, dc));
|
||||
divemode_t divemode = loop.next(seconds);
|
||||
QMenu *changeMode = m.addMenu(tr("Change divemode"));
|
||||
if (divemode != OC)
|
||||
|
@ -648,7 +648,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
|||
}
|
||||
m2->addAction(tr("All event types"), this, &ProfileWidget2::unhideEventTypes);
|
||||
}
|
||||
const struct divecomputer *currentdc = get_dive_dc_const(d, dc);
|
||||
const struct divecomputer *currentdc = get_dive_dc(d, dc);
|
||||
if (currentdc && std::any_of(currentdc->events.begin(), currentdc->events.end(),
|
||||
[] (auto &ev) { return ev.hidden; }))
|
||||
m.addAction(tr("Unhide individually hidden events of this dive"), this, &ProfileWidget2::unhideEvents);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue