summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile/divetextitem.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-21 10:48:26 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-21 09:38:46 -0800
commitcaba6500d63e6081565aebd9e872e48b049e5d03 (patch)
tree08038ec0647165ff208a9b8cc68f38a5b61f1267 /qt-ui/profile/divetextitem.cpp
parent63c1a1b3e9e631338bca59d45a21e67027799abc (diff)
downloadsubsurface-caba6500d63e6081565aebd9e872e48b049e5d03.tar.gz
Add the dive computer text.
Added the dive computer text on the bottom left side of the new Profile. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/divetextitem.cpp')
-rw-r--r--qt-ui/profile/divetextitem.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/qt-ui/profile/divetextitem.cpp b/qt-ui/profile/divetextitem.cpp
index 5ace46b5e..0bf071069 100644
--- a/qt-ui/profile/divetextitem.cpp
+++ b/qt-ui/profile/divetextitem.cpp
@@ -12,7 +12,7 @@
DiveTextItem::DiveTextItem(QGraphicsItem* parent): QGraphicsItemGroup(parent),
textBackgroundItem(NULL),
textItem(NULL),
- internalAlignFlags(0)
+ internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter)
{
setFlag(ItemIgnoresTransformations);
}
@@ -31,13 +31,18 @@ void DiveTextItem::setBrush(const QBrush& b)
void DiveTextItem::setText(const QString& t)
{
- text = t;
+ internalText = t;
updateText();
}
+const QString& DiveTextItem::text()
+{
+ return internalText;
+}
+
void DiveTextItem::updateText()
{
- if(!internalAlignFlags || text.isEmpty())
+ if(internalText.isEmpty())
return;
delete textItem;
@@ -49,7 +54,7 @@ void DiveTextItem::updateText()
QPainterPath textPath;
qreal xPos = 0, yPos = 0;
- QRectF rect = fm.boundingRect(text);
+ QRectF rect = fm.boundingRect(internalText);
yPos = (internalAlignFlags & Qt::AlignTop) ? -rect.height() :
(internalAlignFlags & Qt::AlignBottom) ? +rect.height() :
/*(internalAlignFlags & Qt::AlignVCenter ? */ +rect.height() / 4;
@@ -58,7 +63,7 @@ void DiveTextItem::updateText()
(internalAlignFlags & Qt::AlignHCenter) ? -rect.width()/2 :
/* (internalAlignFlags & Qt::AlignRight) */ -rect.width();
- textPath.addText( xPos, yPos, fnt, text);
+ textPath.addText( xPos, yPos, fnt, internalText);
QPainterPathStroker stroker;
stroker.setWidth(3);
textBackgroundItem = new QGraphicsPathItem(stroker.createStroke(textPath), this);