1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include "textitem.h" 29 #include <QGraphicsObject> 30 31 namespace ScxmlEditor { 32 33 namespace PluginInterface { 34 35 /** 36 * @brief The TagTextItem class provides the movable and editable text-item. 37 */ 38 class TagTextItem : public QGraphicsObject 39 { 40 Q_OBJECT 41 42 public: 43 explicit TagTextItem(QGraphicsItem *parent = nullptr); 44 type()45 int type() const override 46 { 47 return TagTextType; 48 } 49 50 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; 51 52 QRectF boundingRect() const override; 53 54 void setText(const QString &text); 55 void setDefaultTextColor(const QColor &col); 56 57 void resetMovePoint(const QPointF &p = QPointF(0, 0)); 58 QPointF movePoint() const; 59 60 protected: 61 void hoverEnterEvent(QGraphicsSceneHoverEvent *e) override; 62 void hoverMoveEvent(QGraphicsSceneHoverEvent *e) override; 63 void hoverLeaveEvent(QGraphicsSceneHoverEvent *e) override; 64 void mousePressEvent(QGraphicsSceneMouseEvent *e) override; 65 void mouseReleaseEvent(QGraphicsSceneMouseEvent *e) override; 66 67 signals: 68 void textChanged(); 69 void textReady(const QString &text); 70 void selected(bool sel); 71 void movePointChanged(); 72 73 private: 74 bool needIgnore(const QPointF sPos); 75 76 QPointF m_movePoint; 77 QPointF m_startPos; 78 TextItem *m_textItem; 79 }; 80 81 } // namespace PluginInterface 82 } // namespace ScxmlEditor 83