tuchulcha  0.10.1
Graphical Workflow Configuration Editor
NodeHandler.h
Go to the documentation of this file.
1 /* Copyright (C) 2011 Jonathan Wuest
2 
3  This file is part of Tuchulcha.
4 
5  Tuchulcha is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Tuchulcha is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with Tuchulcha. If not, see <http://www.gnu.org/licenses/>.
17 */
23 #ifndef NODEHANDLER_H_
24 #define NODEHANDLER_H_
25 
26 #include <QGraphicsScene>
27 #include <QMap>
28 
29 class NodeProperty;
30 class ConnectionLine;
31 class Node;
32 class GraphModel;
33 
36 class NodeHandler: public QGraphicsScene {
37  Q_OBJECT
38 
39 public:
41 
44  NodeHandler(GraphModel* model, QObject* parent = 0);
45 
47  virtual ~NodeHandler() ;
48 
50 
55  void connectNodes(QString node0,QString prop0,QString node1,QString prop1);
56 
58  GraphModel* model();
59 
62 
65  bool load(QString fname);
66 
67 public slots:
69  void loadFromModel();
70 
72 
73  void saveFlowchart();
74 
76  void selectNode(QString name);
77 
79  void updateTooltip(QString comment);
80 
81 protected:
89  // \{
90  virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* event);
91  virtual void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
92  virtual void dropEvent(QGraphicsSceneDragDropEvent* event);
93  // \}
94 
96  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
97 
99 
106  virtual void keyPressEvent(QKeyEvent* keyEvent);
107 
109  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
110 
112  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
113 
115 
119  virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
120 
121 private:
123  void _deselectAllNodes();
124 
126  void setNodeActive();
127 
130 
133 
136 
139 
141  bool _addLine;
142 
144  QMap<QString,Node*> _nodeMap;
145 
146 signals:
148  void statusMessage(QString msg) const;
149 
152  void nodeTypeSelected(QString type) const;
153 };
154 
155 #endif /* NODEHANDLER_H_ */
This model wraps a ParameterFile instance and provides access to the data interpreted as a (directed)...
Definition: GraphModel.h:32
void setNodeActive()
sets the nodes active or inactive
Definition: NodeHandler.cpp:83
void _deselectAllNodes()
deselects all nodes
Definition: NodeHandler.cpp:61
QGraphicsItem that contains nodeproperties and draws the node.
Definition: Node.h:36
void selectNode(QString name)
select some node
Definition: NodeHandler.cpp:70
Node * _selectedNode
pointer to currently selected node (zero if none selected)
Definition: NodeHandler.h:135
void loadFromModel()
loads the scene from the set GraphModel
virtual void keyPressEvent(QKeyEvent *keyEvent)
handles key press events
void updateTooltip(QString comment)
update tooltip of selected node
ConnectionLine * _cline
buffered connection line for slot connection drawing
Definition: NodeHandler.h:129
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
handles mouse movement
NodeHandler(GraphModel *model, QObject *parent=0)
default constructor
Definition: NodeHandler.cpp:43
GraphModel * _model
current set GraphModel
Definition: NodeHandler.h:138
GraphModel * model()
get the current GraphModel
Line that connects two slots of two different nodes.
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
handles all mousebutton release events
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
context menu
QMap< QString, Node * > _nodeMap
map for node lookup
Definition: NodeHandler.h:144
void nodeTypeSelected(QString type) const
Send type of currently selected node.
bool _addLine
state of slot connection mode
Definition: NodeHandler.h:141
Property(/Parameter) of a node.
Definition: NodeProperty.h:35
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
handles mouse press events
Definition: NodeHandler.cpp:96
void saveFlowchart()
save flowchart to file
bool load(QString fname)
load the GraphModel from the given filename and calls loadFromModel to fill the scene ...
NodeProperty * _startProp
buffer that stores the slot connection start property
Definition: NodeHandler.h:132
QGraphicsScene that handles all drag&drop, node move and connect events.
Definition: NodeHandler.h:36
void statusMessage(QString msg) const
message to display on status bar
virtual ~NodeHandler()
default destructor
Definition: NodeHandler.cpp:56
void connectNodes(QString node0, QString prop0, QString node1, QString prop1)
connects two node with its slots: node0.prop0 to node1.prop1