#ifndef TAGITEM_H #define TAGITEM_H #include "sqlitebackend.h" #include class TagItem : public QGraphicsSimpleTextItem { public: TagItem(const Tag &tag); TagItem() : valid(false) {}; enum { Type = UserType + 1 }; int type() const override { return Type; } bool isValid() { return valid; } void tagUpdated(const Tag &tag); Tag tag() { return m_tag; } virtual QRectF boundingRect() const override; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; virtual QPainterPath shape() const override; protected: QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) override; virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; private: Tag m_tag; bool valid; QMargins m_margins; bool dragAboveThreshold = false; }; #endif // TAGITEM_H