NCL Composer  0.1.5
 All Classes Functions Variables Pages
qnstgraphicsentity.h
1 #ifndef QNSTGRAPHICSENTITY_H
2 #define QNSTGRAPHICSENTITY_H
3 
4 #include <QAction>
5 #include <QFileDialog>
6 
7 #include <QDebug>
8 
9 #include "qnstentity.h"
10 #include "qncggraphicsentity.h"
11 
12 #include "qnstmenu.h"
13 
14 class QnstMenu;
15 
16 //
17 // ATTENTION: This code needs a refactoring.
18 //
19 
21 {
22 Q_OBJECT
23 
24 public:
26 
28 
29  QnstGraphicsEntity* getnstGraphicsParent() const;
30 
31  void setnstGraphicsParent(QnstGraphicsEntity* parent);
32 
33  void addAngle(QString uid, int angle);
34 
35  void removeAngle(QString uid, int angle);
36 
37  QSet<QnstGraphicsEntity*> getnstGraphicsEntities();
38 
39  void addnstGraphicsEntity(QnstGraphicsEntity* entity);
40 
41  void removenstGraphicsEntity(QnstGraphicsEntity* entity);
42 
43  bool hasMouseHover();
44 
45  void setMouseHover(bool hover);
46 
47  virtual void setnstId(const QString &id);
48 
49  virtual void updateToolTip() {}
50 
51  virtual void setProperties(const QMap <QString, QString> &properties);
52 
53  virtual void getProperties(QMap <QString, QString> &properties);
54 
55  virtual void adjust(bool avoidCollision = false) = 0;
56 
57 signals:
58  void entityAdded(QnstGraphicsEntity* entity);
59 
60  void entityRemoved(QnstGraphicsEntity* entity);
61 
62  void entityChanged(QnstGraphicsEntity* entity);
63 
64  void entityAboutToChange(QnstGraphicsEntity* entity,
65  QMap<QString, QString> properties);
66 
67  void entitySelected(QnstGraphicsEntity* entity);
68 
69  void undoRequested();
70 
71  void redoRequested();
72 
73  void cutRequested();
74 
75  void copyRequested();
76 
77  void pasteRequested();
78 
79  void deleteRequested();
80 
81  void exportRequested();
82 
83  void zoominRequested();
84 
85  void zoomoutRequested();
86 
87  void zoomresetRequested();
88 
89  void fullscreenRequested();
90 
91 protected:
92  virtual void draw(QPainter* painter) = 0;
93 
94  virtual void delineate(QPainterPath* painter) const = 0;
95 
96  virtual void move(QGraphicsSceneMouseEvent* event) = 0;
97 
98  virtual void resize(QGraphicsSceneMouseEvent* event) = 0;
99 
100  virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
101 
102  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
103 
104  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
105 
106 protected slots:
107  void requestEntityChange();
108 
109  void requestEntityPreparation(QMap<QString, QString> properties);
110 
111  void requestEntitySelection();
112 
113  virtual bool createEntity(Qnst::EntityType type);
114 
115 public:
116  QnstMenu* menu;
117  bool isDraggable();
118  void setDraggable(bool isDraggable);
119  void setError(bool hasError);
120  void setErrorMsg(QString erroMsg);
121 
122 private:
123  bool draggable;
124  QnstGraphicsEntity* parent;
125 
126  QSet<QnstGraphicsEntity*> entities;
127 
128 protected:
129  bool hover, hasError;
130  QString erroMsg;
131  QString dropsrc;
132 };
133 
134 #endif // QNSTGRAPHICSENTITY_H