aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-19 17:38:22 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-19 21:37:32 -0800
commit592ee31326115750bb9208d992164cb16221f6ec (patch)
treecb903bc1496453eee1bcfd2c47dbf90e07561eb1 /qt-ui/profile
parent9d2344d01b05dab1c1d5d59893b980366a041e17 (diff)
downloadsubsurface-592ee31326115750bb9208d992164cb16221f6ec.tar.gz
Fixed Temperature Text
This fixes temperature text replacing the old code with the new DiveTextItem. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/diveprofileitem.cpp17
-rw-r--r--qt-ui/profile/diveprofileitem.h1
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<DiveTextItem*> texts;
};
class DiveGasPressureItem : public AbstractProfilePolygonItem{