diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profile/divetextitem.cpp | 15 | ||||
-rw-r--r-- | qt-ui/profile/divetextitem.h | 3 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 13 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 2 |
4 files changed, 24 insertions, 9 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); diff --git a/qt-ui/profile/divetextitem.h b/qt-ui/profile/divetextitem.h index 6771d91d3..774693c0c 100644 --- a/qt-ui/profile/divetextitem.h +++ b/qt-ui/profile/divetextitem.h @@ -18,12 +18,13 @@ public: void setBrush(const QBrush& brush); void animatedHide(); void animateMoveTo(qreal x, qreal y); + const QString& text(); private: void updateText(); int internalAlignFlags; QGraphicsPathItem *textBackgroundItem; QGraphicsPathItem *textItem; - QString text; + QString internalText; color_indice_t colorIndex; QBrush brush; }; diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 6fc5dd565..34b87ad78 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -7,7 +7,7 @@ #include "helpers.h" #include "profile.h" #include "diveeventitem.h" - +#include "divetextitem.h" #include <QStateMachine> #include <QSignalTransition> #include <QPropertyAnimation> @@ -37,7 +37,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : temperatureItem(NULL), gasPressureItem(NULL), cartesianPlane(new DiveCartesianPlane()), - meanDepth(new DiveLineItem()) + meanDepth(new DiveLineItem()), + diveComputerText(new DiveTextItem()) { setScene(new QGraphicsScene()); scene()->setSceneRect(0, 0, 100, 100); @@ -92,10 +93,13 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : cartesianPlane->setLeftAxis(profileYAxis); scene()->addItem(cartesianPlane); + diveComputerText->setAlignment(Qt::AlignLeft | Qt::AlignTop); + diveComputerText->setBrush(getColor(TIME_TEXT)); + // insert in the same way it's declared on the Enum. This is needed so we don't use an map. QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis << timeAxis << depthController << timeController << - temperatureAxis << cylinderPressureAxis << + temperatureAxis << cylinderPressureAxis << diveComputerText << meanDepth; Q_FOREACH(QGraphicsItem *item, stateItems) { scene()->addItem(item); @@ -354,6 +358,9 @@ void ProfileWidget2::plotDives(QList<dive*> dives) gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME); scene()->addItem(gasPressureItem); + diveComputerText->setText(currentdc->model); + diveComputerText->setPos(1 , sceneRect().height()); + emit startProfileState(); } diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 7f6d77319..7a24008d7 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -16,6 +16,7 @@ #include "graphicsview-common.h" #include "divelineitem.h" +class DiveTextItem; class TemperatureAxis; class DiveEventItem; struct DivePlotDataModel; @@ -81,6 +82,7 @@ private: DiveGasPressureItem *gasPressureItem; DiveLineItem *meanDepth; QList<DiveEventItem*> eventItems; + DiveTextItem *diveComputerText; }; #endif |