From 592ee31326115750bb9208d992164cb16221f6ec Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 19 Jan 2014 17:38:22 -0200 Subject: Fixed Temperature Text This fixes temperature text replacing the old code with the new DiveTextItem. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveprofileitem.cpp | 17 ++++++++++------- qt-ui/profile/diveprofileitem.h | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index b88ff6abb..03ad9c18e 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -120,6 +120,8 @@ void DiveTemperatureItem::modelDataChanged() if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1) return; + qDeleteAll(texts); + texts.clear(); // Ignore empty values. things do not look good with '0' as temperature in kelvin... QPolygonF poly; int last = -300, last_printed_temp = 0, sec = 0; @@ -159,9 +161,15 @@ void DiveTemperatureItem::createTextItem(int sec, int mkelvin) { double deg; const char *unit; - static text_render_options_t tro = {TEMP_TEXT_SIZE, TEMP_TEXT, LEFT, TOP}; + static text_render_options_t tro = {TEMP_TEXT_SIZE, TEMP_TEXT}; deg = get_temp_units(mkelvin, &unit); - plotText(&tro, QPointF(hAxis->posAtValue(sec), vAxis->posAtValue(mkelvin)), QString("%1%2").arg(deg, 0, 'f', 1).arg(unit), this); //"%.2g%s" + + DiveTextItem *text = new DiveTextItem(this); + text->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); + text->setBrush(getColor(TEMP_TEXT)); + text->setPos(QPointF(hAxis->posAtValue(sec), vAxis->posAtValue(mkelvin))); + text->setText(QString("%1%2").arg(deg, 0, 'f', 1).arg(unit)); + // text->setSize(TEMP_TEXT_SIZE); //TODO: TEXT SIZE! } void DiveTemperatureItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) @@ -217,8 +225,3 @@ void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte } } } - -QGraphicsItemGroup *plotText(text_render_options_t* tro, const QPointF& pos, const QString& text, QGraphicsItem *parent) -{ - -} diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index 2002c904a..89c18ff70 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -60,6 +60,7 @@ public: virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); private: void createTextItem(int seconds, int mkelvin); + QList texts; }; class DiveGasPressureItem : public AbstractProfilePolygonItem{ -- cgit v1.2.3-70-g09d2