profile: set alignment and scale of DiveTextItem at construction

Alignment and scale of DiveTextItems are never changed. Therefore,
pass them at construction time. This makes things much easier
if we want to cache the rendered text [currently the text is
rerendered at every paint() event].

This also removes the "parent=0" default parameter of the
constructor, because inadvertently leaving out the last argument
led to a subtle bug.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-08-12 22:57:57 +02:00 committed by Dirk Hohndel
parent 5540471ce4
commit 2ebe6e3684
7 changed files with 39 additions and 57 deletions

View file

@ -14,10 +14,8 @@ class DiveTextItem : public QObject, public QGraphicsItemGroup {
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
public:
DiveTextItem(double dpr, QGraphicsItem *parent = 0);
DiveTextItem(double dpr, double scale, int alignFlags, QGraphicsItem *parent);
void setText(const QString &text);
void setAlignment(int alignFlags);
void setScale(double newscale);
void setBrush(const QBrush &brush);
const QString &text();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);