diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-12-22 21:25:32 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-01-10 15:57:39 -0800 |
commit | fccbed3ca9f6f3aa761fea1f4d2a0dfbf8a4c125 (patch) | |
tree | 3b4049dc4140d17c66c0d93d44cf390e7c089138 /profile-widget/profilewidget2.cpp | |
parent | 28f156e172b61df467d01e9a51d3ddad9ffd8409 (diff) | |
download | subsurface-fccbed3ca9f6f3aa761fea1f4d2a0dfbf8a4c125.tar.gz |
profile: collect dive-profile items in a vector
Collect all the created profile items in a dynamic vector.
This allows us to loop over them when adding them to the
scene, instead of addressing each item individually.
Hopefully, this will also allow for a more deterministic
repaint logic, without relying on signals.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/profilewidget2.cpp')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index dbfffebaf..cf9e3e997 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -102,6 +102,7 @@ T *ProfileWidget2::createItem(const DiveCartesianAxis &vAxis, int vColumn, int z T *res = new T(*dataModel, *timeAxis, DivePlotDataModel::TIME, vAxis, vColumn, std::forward<Args>(args)...); res->setZValue(static_cast<double>(z)); + profileItems.push_back(res); return res; } @@ -237,34 +238,19 @@ void ProfileWidget2::addItemsToScene() scene()->addItem(gasYAxis); scene()->addItem(temperatureAxis); scene()->addItem(timeAxis); - scene()->addItem(diveProfileItem); scene()->addItem(cylinderPressureAxis); - scene()->addItem(temperatureItem); - scene()->addItem(meanDepthItem); - scene()->addItem(gasPressureItem); // I cannot seem to figure out if an object that I find with itemAt() on the scene // is the object I am looking for - my guess is there's a simple way in Qt to do that // but nothing I tried worked. // so instead this adds a special magic key/value pair to the object to mark it diveComputerText->setData(SUBSURFACE_OBJ_DATA, SUBSURFACE_OBJ_DC_TEXT); scene()->addItem(diveComputerText); - scene()->addItem(reportedCeiling); scene()->addItem(tankItem); - scene()->addItem(pn2GasItem); - scene()->addItem(pheGasItem); - scene()->addItem(po2GasItem); - scene()->addItem(o2SetpointGasItem); - scene()->addItem(ccrsensor1GasItem); - scene()->addItem(ccrsensor2GasItem); - scene()->addItem(ccrsensor3GasItem); - scene()->addItem(ocpo2GasItem); #ifndef SUBSURFACE_MOBILE scene()->addItem(toolTipItem); - scene()->addItem(diveCeiling); scene()->addItem(decoModelParameters); scene()->addItem(percentageAxis); scene()->addItem(heartBeatAxis); - scene()->addItem(heartBeatItem); scene()->addItem(rulerItem); scene()->addItem(rulerItem->sourceNode()); scene()->addItem(rulerItem->destNode()); @@ -274,16 +260,9 @@ void ProfileWidget2::addItemsToScene() pen.setWidth(0); mouseFollowerHorizontal->setPen(pen); mouseFollowerVertical->setPen(pen); - - Q_FOREACH (DiveCalculatedTissue *tissue, allTissues) { - scene()->addItem(tissue); - } - Q_FOREACH (DivePercentageItem *percentage, allPercentages) { - scene()->addItem(percentage); - } - scene()->addItem(ambPressureItem); - scene()->addItem(gflineItem); #endif + for (AbstractProfilePolygonItem *item: profileItems) + scene()->addItem(item); } void ProfileWidget2::setupItemOnScene() |