aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--profile-widget/profilewidget2.cpp4
-rw-r--r--profile-widget/tankitem.cpp13
-rw-r--r--profile-widget/tankitem.h5
3 files changed, 7 insertions, 15 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index ae215e67a..a9d78f5ee 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -150,7 +150,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
mouseFollowerHorizontal(new DiveLineItem()),
rulerItem(new RulerItem2()),
#endif
- tankItem(new TankItem()),
+ tankItem(new TankItem(*timeAxis)),
shouldCalculateMaxTime(true),
shouldCalculateMaxDepth(true),
fontPrintScale(1.0)
@@ -318,8 +318,6 @@ void ProfileWidget2::setupItemOnScene()
diveComputerText->setAlignment(Qt::AlignRight | Qt::AlignTop);
diveComputerText->setBrush(getColor(TIME_TEXT, isGrayscale));
- tankItem->setHorizontalAxis(timeAxis);
-
#ifndef SUBSURFACE_MOBILE
rulerItem->setAxis(timeAxis, profileYAxis);
diff --git a/profile-widget/tankitem.cpp b/profile-widget/tankitem.cpp
index d87b1228b..849bab92c 100644
--- a/profile-widget/tankitem.cpp
+++ b/profile-widget/tankitem.cpp
@@ -7,7 +7,8 @@
static const qreal height = 3.0;
-TankItem::TankItem() :
+TankItem::TankItem(const DiveCartesianAxis &axis) :
+ hAxis(axis),
plotEndTime(-1)
{
QColor red(PERSIANRED1);
@@ -28,7 +29,6 @@ TankItem::TankItem() :
trimixGradient.setColorAt(1.0, red);
trimix = trimixGradient;
air = blue;
- hAxis = nullptr;
}
void TankItem::setData(struct plot_info *plotInfo, struct dive *d)
@@ -48,8 +48,8 @@ void TankItem::setData(struct plot_info *plotInfo, struct dive *d)
void TankItem::createBar(int startTime, int stopTime, struct gasmix gas)
{
- qreal x = hAxis->posAtValue(startTime);
- qreal w = hAxis->posAtValue(stopTime) - hAxis->posAtValue(startTime);
+ qreal x = hAxis.posAtValue(startTime);
+ qreal w = hAxis.posAtValue(stopTime) - hAxis.posAtValue(startTime);
// pick the right gradient, size, position and text
QGraphicsRectItem *rect = new QGraphicsRectItem(x, 0, w, height, this);
@@ -106,8 +106,3 @@ void TankItem::replot()
}
createBar(startTime, plotEndTime, gasmix);
}
-
-void TankItem::setHorizontalAxis(DiveCartesianAxis *horizontal)
-{
- hAxis = horizontal;
-}
diff --git a/profile-widget/tankitem.h b/profile-widget/tankitem.h
index f3e0c0238..fb94dc481 100644
--- a/profile-widget/tankitem.h
+++ b/profile-widget/tankitem.h
@@ -11,14 +11,13 @@
class TankItem : public QGraphicsRectItem
{
public:
- explicit TankItem();
- void setHorizontalAxis(DiveCartesianAxis *horizontal);
+ explicit TankItem(const DiveCartesianAxis &axis);
void setData(struct plot_info *plotInfo, struct dive *d);
private:
void createBar(int startTime, int stopTime, struct gasmix gas);
void replot();
- DiveCartesianAxis *hAxis;
+ const DiveCartesianAxis &hAxis;
int plotEndTime;
QBrush air, nitrox, oxygen, trimix;
QList<QGraphicsRectItem *> rects;