From e71119b40bac8d6dc33449e33329f235350b08f5 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 15 Aug 2014 07:30:31 -0600 Subject: TankBar: use the itemPos as intended Which actually makes the code much clearer as now the object is at the correct spot on the canvas and the positions inside are relative to that. No more magic gradiants starting at "92" Signed-off-by: Dirk Hohndel --- qt-ui/profile/tankitem.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'qt-ui/profile/tankitem.cpp') diff --git a/qt-ui/profile/tankitem.cpp b/qt-ui/profile/tankitem.cpp index 2db64da32..399306d2c 100644 --- a/qt-ui/profile/tankitem.cpp +++ b/qt-ui/profile/tankitem.cpp @@ -11,19 +11,18 @@ TankItem::TankItem(QObject *parent) : dive(0), pInfo(0) { - yPos = 92; height = 3; QColor red(PERSIANRED1); QColor blue(AIR_BLUE); QColor yellow(NITROX_YELLOW); QColor green(NITROX_GREEN); - QLinearGradient nitroxGradient(QPointF(0, yPos), QPointF(0, yPos + height)); + QLinearGradient nitroxGradient(QPointF(0, 0), QPointF(0, height)); nitroxGradient.setColorAt(0.0, green); nitroxGradient.setColorAt(0.49, green); nitroxGradient.setColorAt(0.5, yellow); nitroxGradient.setColorAt(1.0, yellow); nitrox = nitroxGradient; - QLinearGradient trimixGradient(QPointF(0, yPos), QPointF(0, yPos + height)); + QLinearGradient trimixGradient(QPointF(0, 0), QPointF(0, height)); trimixGradient.setColorAt(0.0, green); trimixGradient.setColorAt(0.49, green); trimixGradient.setColorAt(0.5, red); @@ -44,7 +43,7 @@ void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, str void TankItem::createBar(qreal x, qreal w, struct gasmix *gas) { // pick the right gradient, size, position and text - QGraphicsRectItem *rect = new QGraphicsRectItem(x, yPos, w, height, this); + QGraphicsRectItem *rect = new QGraphicsRectItem(x, 0, w, height, this); if (gasmix_is_air(gas)) rect->setBrush(air); else if (gas->he.permille) @@ -55,7 +54,7 @@ void TankItem::createBar(qreal x, qreal w, struct gasmix *gas) DiveTextItem *label = new DiveTextItem(rect); label->setText(gasname(gas)); label->setBrush(Qt::black); - label->setPos(x, yPos); + label->setPos(x + 1, 0); label->setAlignment(Qt::AlignBottom | Qt::AlignRight); label->setZValue(101); } -- cgit v1.2.3-70-g09d2