CommentBlockView.hpp
1 #pragma once
2 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentViewConstants.hpp>
3 
4 #include <QGraphicsItem>
5 #include <QObject>
6 #include <QPointF>
7 
8 #include <verdigris>
9 namespace score
10 {
11 class TextItem;
12 }
13 
14 namespace Scenario
15 {
16 class CommentBlockPresenter;
17 class CommentBlockView final
18  : public QObject
19  , public QGraphicsItem
20 {
21 public:
22  CommentBlockView(CommentBlockPresenter& presenter, QGraphicsItem* parent);
23 
24  static const constexpr int Type = ItemType::Comment;
25  int type() const final override { return Type; }
26 
27  const CommentBlockPresenter& presenter() const { return m_presenter; }
28 
29  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
30  override;
31 
32  QRectF boundingRect() const override;
33 
34  void setHtmlContent(QString htmlText);
35 
36  void setSelected(bool);
37 
38 protected:
39  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
40  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
41  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
42  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* evt) override;
43 
44 private:
45  void focusOnText();
46  void focusOut();
47 
48  CommentBlockPresenter& m_presenter;
49 
50  score::TextItem* m_textItem{};
51 
52  QPointF m_clickedPoint{};
53  QPointF m_clickedScenePoint{};
54  bool m_selected{};
55 };
56 }
Definition: CommentBlockPresenter.hpp:23
Definition: CommentBlockView.hpp:20
Definition: TextItem.hpp:13
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Base toolkit upon which the software is built.
Definition: Application.cpp:90