diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-02 18:45:10 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-01-10 15:57:39 -0800 |
commit | ea88f4729dcc6ec6df0dc25cb54494d07774dca8 (patch) | |
tree | efda582ba03f1c9f90b231036391fda3e097f81f /profile-widget/profilewidget2.cpp | |
parent | 975c123a30de95eafd9b3c2ce2a625a1d05a79dc (diff) | |
download | subsurface-ea88f4729dcc6ec6df0dc25cb54494d07774dca8.tar.gz |
profile: set model of profile items on construction
The profile items had a "setModel()" function to set
the DivePlotDataModel post creation. The model is never
changed. It does however mean that the model might be
null in a short period between construction and setting
the model.
To simplify reasoning about this code, set the model
in the constructor. To drive the point home that the
can never change and cannot be null, turn it into a
reference.
Yes, this is gratuitous bike-shedding, but it helps
me analysis the code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/profilewidget2.cpp')
-rw-r--r-- | profile-widget/profilewidget2.cpp | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 97cd6fe12..ecb26fc4b 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -111,29 +111,29 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), gasYAxis(new PartialGasPressureAxis(this)), temperatureAxis(new TemperatureAxis(this)), timeAxis(new TimeAxis(this)), - diveProfileItem(new DiveProfileItem()), - temperatureItem(new DiveTemperatureItem()), - meanDepthItem(new DiveMeanDepthItem()), + diveProfileItem(new DiveProfileItem(*dataModel)), + temperatureItem(new DiveTemperatureItem(*dataModel)), + meanDepthItem(new DiveMeanDepthItem(*dataModel)), cylinderPressureAxis(new DiveCartesianAxis(this)), - gasPressureItem(new DiveGasPressureItem()), + gasPressureItem(new DiveGasPressureItem(*dataModel)), diveComputerText(new DiveTextItem()), - reportedCeiling(new DiveReportedCeiling()), - pn2GasItem(new PartialPressureGasItem()), - pheGasItem(new PartialPressureGasItem()), - po2GasItem(new PartialPressureGasItem()), - o2SetpointGasItem(new PartialPressureGasItem()), - ccrsensor1GasItem(new PartialPressureGasItem()), - ccrsensor2GasItem(new PartialPressureGasItem()), - ccrsensor3GasItem(new PartialPressureGasItem()), - ocpo2GasItem(new PartialPressureGasItem()), + reportedCeiling(new DiveReportedCeiling(*dataModel)), + pn2GasItem(new PartialPressureGasItem(*dataModel)), + pheGasItem(new PartialPressureGasItem(*dataModel)), + po2GasItem(new PartialPressureGasItem(*dataModel)), + o2SetpointGasItem(new PartialPressureGasItem(*dataModel)), + ccrsensor1GasItem(new PartialPressureGasItem(*dataModel)), + ccrsensor2GasItem(new PartialPressureGasItem(*dataModel)), + ccrsensor3GasItem(new PartialPressureGasItem(*dataModel)), + ocpo2GasItem(new PartialPressureGasItem(*dataModel)), #ifndef SUBSURFACE_MOBILE - diveCeiling(new DiveCalculatedCeiling(this)), + diveCeiling(new DiveCalculatedCeiling(*dataModel, this)), decoModelParameters(new DiveTextItem()), heartBeatAxis(new DiveCartesianAxis(this)), - heartBeatItem(new DiveHeartrateItem()), + heartBeatItem(new DiveHeartrateItem(*dataModel)), percentageAxis(new DiveCartesianAxis(this)), - ambPressureItem(new DiveAmbPressureItem()), - gflineItem(new DiveGFLineItem()), + ambPressureItem(new DiveAmbPressureItem(*dataModel)), + gflineItem(new DiveGFLineItem(*dataModel)), mouseFollowerVertical(new DiveLineItem()), mouseFollowerHorizontal(new DiveLineItem()), rulerItem(new RulerItem2()), @@ -342,10 +342,10 @@ void ProfileWidget2::setupItemOnScene() decoModelParameters->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); setupItem(diveCeiling, profileYAxis, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1); for (int i = 0; i < 16; i++) { - DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue(this); + DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue(*dataModel, this); setupItem(tissueItem, profileYAxis, DivePlotDataModel::TISSUE_1 + i, DivePlotDataModel::TIME, 1 + i); allTissues.append(tissueItem); - DivePercentageItem *percentageItem = new DivePercentageItem(i); + DivePercentageItem *percentageItem = new DivePercentageItem(*dataModel, i); setupItem(percentageItem, percentageAxis, DivePlotDataModel::PERCENTAGE_1 + i, DivePlotDataModel::TIME, 1 + i); allPercentages.append(percentageItem); } @@ -542,7 +542,6 @@ void ProfileWidget2::setupItem(AbstractProfilePolygonItem *item, DiveCartesianAx { item->setHorizontalAxis(timeAxis); item->setVerticalAxis(vAxis); - item->setModel(dataModel); item->setVerticalDataColumn(vData); item->setHorizontalDataColumn(hData); item->setZValue(zValue); |