diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-03-04 01:01:52 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-05-13 13:52:35 -0700 |
commit | 630862971fc314439dfa6d274474eb18e8f96711 (patch) | |
tree | 67eb3d7cbed81b4152a017a39f81d260f9cb02a9 /profile-widget/divepixmapitem.h | |
parent | e811c7306d210af17a6571e61f23496ce91fa4bc (diff) | |
download | subsurface-630862971fc314439dfa6d274474eb18e8f96711.tar.gz |
Dive pictures: remove close-button optimization
One close-button object was used for all dive pictures. This seems
like a brittle premature optimization and the pixmap is shared
anyway. Make the button a subobject of the dive picture object.
Change the object-hierarchy to be based on QGraphicsItem instead
of QObject. The QObject here is only used as a kludge to support
signals and properties (the latter are necessary for animations).
Remove a comment, which does not seem to be relevant after this
change.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget/divepixmapitem.h')
-rw-r--r-- | profile-widget/divepixmapitem.h | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/profile-widget/divepixmapitem.h b/profile-widget/divepixmapitem.h index b3fe3417a..16dbdf8fa 100644 --- a/profile-widget/divepixmapitem.h +++ b/profile-widget/divepixmapitem.h @@ -12,15 +12,33 @@ class DivePixmapItem : public QObject, public QGraphicsPixmapItem { Q_PROPERTY(qreal x WRITE setX READ x) Q_PROPERTY(qreal y WRITE setY READ y) public: - DivePixmapItem(QObject *parent = 0); + DivePixmapItem(QGraphicsItem *parent = 0); +}; + +class DiveButtonItem : public DivePixmapItem { + Q_OBJECT +public: + DiveButtonItem(QGraphicsItem *parent = 0); +protected: + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); +signals: + void clicked(); +}; + +class CloseButtonItem : public DiveButtonItem { + Q_OBJECT +public: + CloseButtonItem(QGraphicsItem *parent = 0); +public slots: + void hide(); + void show(); }; class DivePictureItem : public DivePixmapItem { Q_OBJECT Q_PROPERTY(qreal scale WRITE setScale READ scale) public: - DivePictureItem(QObject *parent = 0); - virtual ~DivePictureItem(); + DivePictureItem(QGraphicsItem *parent = 0); void setPixmap(const QPixmap& pix); public slots: void settingsChanged(); @@ -36,25 +54,7 @@ private: QString fileUrl; QGraphicsRectItem *canvas; QGraphicsRectItem *shadow; -}; - -class DiveButtonItem : public DivePixmapItem { - Q_OBJECT -public: - DiveButtonItem(QObject *parent = 0); -protected: - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); -signals: - void clicked(); -}; - -class CloseButtonItem : public DiveButtonItem { - Q_OBJECT -public: - CloseButtonItem(QObject *parent = 0); -public slots: - void hide(); - void show(); + DiveButtonItem *button; }; #endif // DIVEPIXMAPITEM_H |