diff options
-rw-r--r-- | qt-ui/profile/divepixmapitem.cpp | 24 | ||||
-rw-r--r-- | qt-ui/profile/divepixmapitem.h | 11 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 2 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 3 |
4 files changed, 37 insertions, 3 deletions
diff --git a/qt-ui/profile/divepixmapitem.cpp b/qt-ui/profile/divepixmapitem.cpp index d27d77cba..b1942344e 100644 --- a/qt-ui/profile/divepixmapitem.cpp +++ b/qt-ui/profile/divepixmapitem.cpp @@ -1,5 +1,27 @@ #include "divepixmapitem.h" - +#include "animationfunctions.h" DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem() { } + +DivePictureItem::DivePictureItem(QObject *parent): DivePixmapItem(parent) +{ + setAcceptsHoverEvents(true); + setScale(0.2); +} + +void DivePictureItem::setPixmap(const QPixmap &pix) +{ + DivePixmapItem::setPixmap(pix); + setTransformOriginPoint(boundingRect().width()/2, boundingRect().height()/2); +} + +void DivePictureItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + Animations::scaleTo(this, 1.0); +} + +void DivePictureItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Animations::scaleTo(this, 0.2); +} diff --git a/qt-ui/profile/divepixmapitem.h b/qt-ui/profile/divepixmapitem.h index aa2563877..a0f542ea0 100644 --- a/qt-ui/profile/divepixmapitem.h +++ b/qt-ui/profile/divepixmapitem.h @@ -14,4 +14,15 @@ public: DivePixmapItem(QObject *parent = 0); }; +class DivePictureItem : public DivePixmapItem { + Q_OBJECT + Q_PROPERTY(qreal scale WRITE setScale READ scale) +public: + DivePictureItem(QObject *parent = 0); + void setPixmap(const QPixmap& pix); +protected: + void hoverEnterEvent(QGraphicsSceneHoverEvent *event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); +}; + #endif // DIVEPIXMAPITEM_H diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 92c368cb8..b2021fd8c 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -1309,7 +1309,7 @@ void ProfileWidget2::plotPictures() // information area. if (!pic->timestamp) continue; - DivePixmapItem *item = new DivePixmapItem(); + DivePictureItem *item = new DivePictureItem(); item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>()); // TODO: put the item in the correct place. use the pic.timestamp to find where it belongs on the dive. item->setPos(10 ,10); diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index a1ba7a23a..7d55fe5d0 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -43,6 +43,7 @@ class AbstractProfilePolygonItem; class DiveHandler; class QGraphicsSimpleTextItem; class QModelIndex; +class DivePictureItem; class ProfileWidget2 : public QGraphicsView { Q_OBJECT @@ -160,7 +161,7 @@ private: //specifics for ADD and PLAN QList<DiveHandler *> handles; QList<QGraphicsSimpleTextItem *> gases; - QList<DivePixmapItem*> pictures; + QList<DivePictureItem*> pictures; void repositionDiveHandlers(); int fixHandlerIndex(DiveHandler *activeHandler); friend class DiveHandler; |