Frapper  1.0a
NodeModel.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of FRAPPER
4 research.animationsinstitut.de
5 sourceforge.net/projects/frapper
6 
7 Copyright (c) 2008-2009 Filmakademie Baden-Wuerttemberg, Institute of Animation
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; version 2.1 of the License.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
21 -----------------------------------------------------------------------------
22 */
23 
33 
34 #ifndef NODEMODEL_H
35 #define NODEMODEL_H
36 
37 #include "FrapperPrerequisites.h"
38 #include <QtGui/QStandardItemModel>
39 #include <QtGui/QGraphicsItem>
40 #include <QtGui/QItemSelection>
41 #include <QtCore/QMutex>
42 #include "Node.h"
43 
44 namespace Frapper {
45 
67  class FRAPPER_CORE_EXPORT NodeModel : public QStandardItemModel
68  {
69 
70  Q_OBJECT
71 
72  public: // constructors and destructors
73 
77  NodeModel ();
78 
82  ~NodeModel ();
83 
84  public: // functions
85 
94  void beginUpdate ();
95 
105  void endUpdate ();
106 
115  void beginSelectingAll ();
116 
126  void endSelectingAll ( bool emitSignal = true);
127 
136  Node * createNode ( const QString &typeName, const QString &name = "", bool visible = true );
137 
145  Connection * createConnection ( Parameter *sourceParameter, Parameter *targetParameter );
146 
147 
155  Node * getNode ( const QString &name ) const;
156 
164  QList<Node *> getNodes ( const QString &typeName = "" ) const;
165 
172  QList<Connection *> getConnections () const;
173 
181  Connection * getConnection (const QString &name) const;
182 
190  QStringList getNodeNames ( const QString &typeName = "" ) const;
191 
199  QStandardItem * getStandardItemNode ( const QString &name ) const;
200 
208  QStandardItem * getStandardItemConnection ( const QString &name ) const;
209 
217  void setSelected ( const QItemSelection &selection, bool selected );
218 
224  void deleteNode ( const QString &name );
225 
231  void deleteConnection ( const QString &name );
232 
233 public slots:
234 
241  void setSelected ( const QString &name, bool selected );
242 
249  void renameNode ( const QString &oldName, const QString &newName );
250 
259  void changeParameter ( const QString &name, const QString &parameterName, const QVariant &value );
260 
261 signals: //
262 
267  void modified ();
268 
272  void clearSelectionRequested ();
273 
279  void nodeSelected ( Node *node );
280 
287  void nodeDeleted ( const QString &name );
288 
289  private: // functions
290 
297  QStandardItem * getCategoryItem ( const QString &nodeCategory );
298 
299  private: // data
300 
308 
315 
319  QMutex m_mutex;
320 
324  QHash<QString, Node *> m_nodeMap;
325 
329  QHash<QString, Connection *> m_connectionMap;
330 
334  QHash<QString, QStandardItem *> m_standardItemNodeMap;
335 
338  QHash<QString, QStandardItem *> m_standardItemConnectionMap;
339 
344  QList<QStandardItem *> m_categoryItems;
345 
346  };
347 
348 } // end namespace Frapper
349 
350 #endif