mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									63c1a1b3e9
								
							
						
					
					
						commit
						caba6500d6
					
				
					 4 changed files with 24 additions and 9 deletions
				
			
		| 
						 | 
					@ -12,7 +12,7 @@
 | 
				
			||||||
DiveTextItem::DiveTextItem(QGraphicsItem* parent): QGraphicsItemGroup(parent),
 | 
					DiveTextItem::DiveTextItem(QGraphicsItem* parent): QGraphicsItemGroup(parent),
 | 
				
			||||||
	textBackgroundItem(NULL),
 | 
						textBackgroundItem(NULL),
 | 
				
			||||||
	textItem(NULL),
 | 
						textItem(NULL),
 | 
				
			||||||
	internalAlignFlags(0)
 | 
						internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	setFlag(ItemIgnoresTransformations);
 | 
						setFlag(ItemIgnoresTransformations);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -31,13 +31,18 @@ void DiveTextItem::setBrush(const QBrush& b)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DiveTextItem::setText(const QString& t)
 | 
					void DiveTextItem::setText(const QString& t)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	text = t;
 | 
						internalText = t;
 | 
				
			||||||
	updateText();
 | 
						updateText();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const QString& DiveTextItem::text()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return internalText;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DiveTextItem::updateText()
 | 
					void DiveTextItem::updateText()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if(!internalAlignFlags || text.isEmpty())
 | 
						if(internalText.isEmpty())
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	delete textItem;
 | 
						delete textItem;
 | 
				
			||||||
| 
						 | 
					@ -49,7 +54,7 @@ void DiveTextItem::updateText()
 | 
				
			||||||
	QPainterPath textPath;
 | 
						QPainterPath textPath;
 | 
				
			||||||
	qreal xPos = 0, yPos = 0;
 | 
						qreal xPos = 0, yPos = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QRectF rect = fm.boundingRect(text);
 | 
						QRectF rect = fm.boundingRect(internalText);
 | 
				
			||||||
	yPos = (internalAlignFlags & Qt::AlignTop) ? -rect.height() :
 | 
						yPos = (internalAlignFlags & Qt::AlignTop) ? -rect.height() :
 | 
				
			||||||
			(internalAlignFlags & Qt::AlignBottom) ? +rect.height() :
 | 
								(internalAlignFlags & Qt::AlignBottom) ? +rect.height() :
 | 
				
			||||||
	/*(internalAlignFlags & Qt::AlignVCenter  ? */ +rect.height() / 4;
 | 
						/*(internalAlignFlags & Qt::AlignVCenter  ? */ +rect.height() / 4;
 | 
				
			||||||
| 
						 | 
					@ -58,7 +63,7 @@ void DiveTextItem::updateText()
 | 
				
			||||||
		(internalAlignFlags & Qt::AlignHCenter) ?  -rect.width()/2 :
 | 
							(internalAlignFlags & Qt::AlignHCenter) ?  -rect.width()/2 :
 | 
				
			||||||
	 /* (internalAlignFlags & Qt::AlignRight) */ -rect.width();
 | 
						 /* (internalAlignFlags & Qt::AlignRight) */ -rect.width();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	textPath.addText( xPos, yPos, fnt, text);
 | 
						textPath.addText( xPos, yPos, fnt, internalText);
 | 
				
			||||||
	QPainterPathStroker stroker;
 | 
						QPainterPathStroker stroker;
 | 
				
			||||||
	stroker.setWidth(3);
 | 
						stroker.setWidth(3);
 | 
				
			||||||
	textBackgroundItem = new QGraphicsPathItem(stroker.createStroke(textPath), this);
 | 
						textBackgroundItem = new QGraphicsPathItem(stroker.createStroke(textPath), this);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,12 +18,13 @@ public:
 | 
				
			||||||
	void setBrush(const QBrush& brush);
 | 
						void setBrush(const QBrush& brush);
 | 
				
			||||||
	void animatedHide();
 | 
						void animatedHide();
 | 
				
			||||||
	void animateMoveTo(qreal x, qreal y);
 | 
						void animateMoveTo(qreal x, qreal y);
 | 
				
			||||||
 | 
						const QString& text();
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	void updateText();
 | 
						void updateText();
 | 
				
			||||||
	int internalAlignFlags;
 | 
						int internalAlignFlags;
 | 
				
			||||||
	QGraphicsPathItem *textBackgroundItem;
 | 
						QGraphicsPathItem *textBackgroundItem;
 | 
				
			||||||
	QGraphicsPathItem *textItem;
 | 
						QGraphicsPathItem *textItem;
 | 
				
			||||||
	QString text;
 | 
						QString internalText;
 | 
				
			||||||
	color_indice_t colorIndex;
 | 
						color_indice_t colorIndex;
 | 
				
			||||||
	QBrush brush;
 | 
						QBrush brush;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,7 @@
 | 
				
			||||||
#include "helpers.h"
 | 
					#include "helpers.h"
 | 
				
			||||||
#include "profile.h"
 | 
					#include "profile.h"
 | 
				
			||||||
#include "diveeventitem.h"
 | 
					#include "diveeventitem.h"
 | 
				
			||||||
 | 
					#include "divetextitem.h"
 | 
				
			||||||
#include <QStateMachine>
 | 
					#include <QStateMachine>
 | 
				
			||||||
#include <QSignalTransition>
 | 
					#include <QSignalTransition>
 | 
				
			||||||
#include <QPropertyAnimation>
 | 
					#include <QPropertyAnimation>
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
 | 
				
			||||||
	temperatureItem(NULL),
 | 
						temperatureItem(NULL),
 | 
				
			||||||
	gasPressureItem(NULL),
 | 
						gasPressureItem(NULL),
 | 
				
			||||||
	cartesianPlane(new DiveCartesianPlane()),
 | 
						cartesianPlane(new DiveCartesianPlane()),
 | 
				
			||||||
	meanDepth(new DiveLineItem())
 | 
						meanDepth(new DiveLineItem()),
 | 
				
			||||||
 | 
						diveComputerText(new DiveTextItem())
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	setScene(new QGraphicsScene());
 | 
						setScene(new QGraphicsScene());
 | 
				
			||||||
	scene()->setSceneRect(0, 0, 100, 100);
 | 
						scene()->setSceneRect(0, 0, 100, 100);
 | 
				
			||||||
| 
						 | 
					@ -92,10 +93,13 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
 | 
				
			||||||
	cartesianPlane->setLeftAxis(profileYAxis);
 | 
						cartesianPlane->setLeftAxis(profileYAxis);
 | 
				
			||||||
	scene()->addItem(cartesianPlane);
 | 
						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.
 | 
						// 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 <<
 | 
						QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis <<
 | 
				
			||||||
							timeAxis << depthController << timeController <<
 | 
												timeAxis << depthController << timeController <<
 | 
				
			||||||
							temperatureAxis << cylinderPressureAxis <<
 | 
												temperatureAxis << cylinderPressureAxis << diveComputerText <<
 | 
				
			||||||
							meanDepth;
 | 
												meanDepth;
 | 
				
			||||||
	Q_FOREACH(QGraphicsItem *item, stateItems) {
 | 
						Q_FOREACH(QGraphicsItem *item, stateItems) {
 | 
				
			||||||
		scene()->addItem(item);
 | 
							scene()->addItem(item);
 | 
				
			||||||
| 
						 | 
					@ -354,6 +358,9 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
 | 
				
			||||||
	gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
 | 
						gasPressureItem->setHorizontalDataColumn(DivePlotDataModel::TIME);
 | 
				
			||||||
	scene()->addItem(gasPressureItem);
 | 
						scene()->addItem(gasPressureItem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						diveComputerText->setText(currentdc->model);
 | 
				
			||||||
 | 
						diveComputerText->setPos(1 , sceneRect().height());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	emit startProfileState();
 | 
						emit startProfileState();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,7 @@
 | 
				
			||||||
#include "graphicsview-common.h"
 | 
					#include "graphicsview-common.h"
 | 
				
			||||||
#include "divelineitem.h"
 | 
					#include "divelineitem.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class DiveTextItem;
 | 
				
			||||||
class TemperatureAxis;
 | 
					class TemperatureAxis;
 | 
				
			||||||
class DiveEventItem;
 | 
					class DiveEventItem;
 | 
				
			||||||
struct DivePlotDataModel;
 | 
					struct DivePlotDataModel;
 | 
				
			||||||
| 
						 | 
					@ -81,6 +82,7 @@ private:
 | 
				
			||||||
	DiveGasPressureItem *gasPressureItem;
 | 
						DiveGasPressureItem *gasPressureItem;
 | 
				
			||||||
	DiveLineItem *meanDepth;
 | 
						DiveLineItem *meanDepth;
 | 
				
			||||||
	QList<DiveEventItem*> eventItems;
 | 
						QList<DiveEventItem*> eventItems;
 | 
				
			||||||
 | 
						DiveTextItem *diveComputerText;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue