mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add a MeanDepthItem that has 2 strings.
Dirk's implementation of the MeanDepth item was correct, but in order to add the 2 strings to it ( one at the begin, one at the end ) I had to put more stuff inside the ProfileWidget that's already packed with graphics items. So I created a new class MeanDepthItem that contains these 2 strings and will get updated whenever the value changes. I also fixed a math inconsistency where I changed RIGHT to LEFT. (wich fixed a few text-placements, and broke others.) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f22428b345
commit
2e2a87e619
5 changed files with 47 additions and 6 deletions
|
|
@ -7,6 +7,7 @@
|
|||
#include "dive.h"
|
||||
#include "profilegraphics.h"
|
||||
#include "preferences.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QPen>
|
||||
#include <QPainter>
|
||||
|
|
@ -384,7 +385,6 @@ void DiveCalculatedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsI
|
|||
QGraphicsPolygonItem::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
|
||||
void DiveReportedCeiling::modelDataChanged()
|
||||
{
|
||||
if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1)
|
||||
|
|
@ -425,3 +425,28 @@ void DiveReportedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsIte
|
|||
{
|
||||
QGraphicsPolygonItem::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
MeanDepthLine::MeanDepthLine()
|
||||
{
|
||||
leftText = new DiveTextItem(this);
|
||||
leftText->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||
leftText->setBrush(getColor(MEAN_DEPTH));
|
||||
rightText = new DiveTextItem(this);
|
||||
rightText->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
|
||||
rightText->setBrush(getColor(MEAN_DEPTH));
|
||||
leftText->setPos(0, 0);
|
||||
rightText->setPos(line().length(), 0);
|
||||
}
|
||||
|
||||
void MeanDepthLine::setLine(qreal x1, qreal y1, qreal x2, qreal y2)
|
||||
{
|
||||
QGraphicsLineItem::setLine(x1, y1, x2, y2);
|
||||
leftText->setPos(x1, 0);
|
||||
rightText->setPos(x2, 0);
|
||||
}
|
||||
|
||||
void MeanDepthLine::setMeanDepth(int value)
|
||||
{
|
||||
leftText->setText(get_depth_string(value, false, false));
|
||||
rightText->setText(get_depth_string(value, false, false));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue