aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-21 13:35:40 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-21 09:39:21 -0800
commit21d34db3a94e004affdaceb091382b251071d89d (patch)
treee1c4b1e26a66aa69b489d42363ce0c85741a497b
parent0a4e21a16813592031baf8ca90bc52418aa8965e (diff)
downloadsubsurface-21d34db3a94e004affdaceb091382b251071d89d.tar.gz
Simplfy the code for the cylinder pressure.
Instead of asking the data as we do on the generic models, use the internal knowledge of the class. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/profile/diveprofileitem.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 0715bc58b..f33ebeec7 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -226,22 +226,19 @@ void DiveGasPressureItem::modelDataChanged()
QPolygonF boundingPoly; // This is the "Whole Item", but a pressure can be divided in N Polygons.
polygons.clear();
- for (int i = 0; i < dataModel->rowCount(); i++) {
- int sPressure = dataModel->index(i, DivePlotDataModel::SENSOR_PRESSURE).data().toInt();
- int iPressure = dataModel->index(i, DivePlotDataModel::INTERPOLATED_PRESSURE).data().toInt();
- int cylIndex = dataModel->index(i, DivePlotDataModel::CYLINDERINDEX).data().toInt();
- int sec = dataModel->index(i, DivePlotDataModel::TIME).data().toInt();
- int mbar = sPressure ? sPressure : iPressure;
-
- if (cylIndex != last_index) {
+ for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
+ plot_data* entry = dataModel->data() + i;
+ int mbar = GET_PRESSURE(entry);
+
+ if (entry->cylinderindex != last_index) {
polygons.append(QPolygonF()); // this is the polygon that will be actually drawned on screen.
- last_index = cylIndex;
+ last_index = entry->cylinderindex;
}
if (!mbar) {
continue;
}
- QPointF point(hAxis->posAtValue(sec), vAxis->posAtValue(mbar));
+ QPointF point(hAxis->posAtValue(entry->sec), vAxis->posAtValue(mbar));
boundingPoly.push_back(point); // The BoundingRect
polygons.last().push_back(point); // The polygon thta will be plotted.
}