Schim
operations.h
Go to the documentation of this file.
1 #ifndef OPERATION_H
3 #define OPERATION_H
4 
5 #include "ui/sheetscene.h"
6 #include "ui/objects/gobject.h"
7 #include "ui/objects/gline.h"
8 #include "ui/objects/grect.h"
9 #include "ui/objects/gtext.h"
10 
11 class QGraphicsSceneMouseEvent;
12 class QKeyEvent;
13 
22 class SceneOperation : public QObject
23 {
24  Q_OBJECT
25 public:
29  explicit SceneOperation(SheetScene *scene);
30  virtual ~SceneOperation();
31 
36  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
41  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
46  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
51  virtual void keyPressEvent(QKeyEvent *event);
58  virtual void cancel();
59 
60 signals:
64  void finished();
65 
66 protected:
67  SheetScene *scene{};
68  GObject *obj{};
69  int state = 0;
70 };
71 
76 {
77 public:
79 
80  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
81  void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
82 
83 private:
85  GLine *object() const;
86 };
87 
92 {
93 public:
95 
96  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
97  void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
98 
99  GRect *object() const;
100 };
101 
106 {
107  Q_OBJECT
108 public:
109  explicit OpInsertText(SheetScene *scene, GText *text = nullptr);
110 
111  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
112 
114  GText *object() const;
115 };
116 
122 {
123 public:
124  OpInsertComponent(SheetScene *scene, Component *obj);
125 
126  void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
127  void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
128 };
129 
130 #endif // OPERATION_H
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Process a mouseMoveEvent. The base implementation does nothing.
A scene operation that is triggered when the user wants to insert a rectangle.
Definition: operations.h:91
A specialized QGraphicsScene containing a sheet of paper.
Definition: sheetscene.h:27
virtual void keyPressEvent(QKeyEvent *event)
Process a keyPressEvent. The base implementation does nothing.
SceneOperation(SheetScene *scene)
Construct a scene operation in the specified scene.
A graphical text object that wraps a Text.
Definition: gtext.h:24
virtual void cancel()
Cancel the operation.
Model of an electrical component.
Definition: component.h:16
The base class of all objects represented in a graphical scene.
Definition: gobject.h:24
Graphical rectangle object that wraps a Rect.
Definition: grect.h:13
A scene operation that is triggered when the user wants to insert a line.
Definition: operations.h:75
A scene operation that is triggered when the user wants to insert a component.
Definition: operations.h:121
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Process a mouseReleaseEvent. The base implementation does nothing.
void finished()
Emitted when the operation has finished, either successfully or not.
The base class of all scene operations.
Definition: operations.h:22
A scene operation that is triggered when the user wants to insert a text.
Definition: operations.h:105
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Process a mousePressEvent. The base implementation does nothing.
Graphical line object that wraps a Line.
Definition: gline.h:15