diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-08-15 07:30:31 -0600 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-08-15 07:30:31 -0600 |
commit | e71119b40bac8d6dc33449e33329f235350b08f5 (patch) | |
tree | 318e48a393e4e14194c329f470e8b81b6c328ddb /qt-ui/profile/tankitem.cpp | |
parent | 5b14ed16accc39a1ed46f894404b10655576e386 (diff) | |
download | subsurface-e71119b40bac8d6dc33449e33329f235350b08f5.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/tankitem.cpp')
-rw-r--r-- | qt-ui/profile/tankitem.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
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); } |