NodeModel Class Reference

Class for the model containing nodes. More...

#include <NodeModel.h>

List of all members.

Public Slots

void setSelected (const QString &name, bool selected)
 Selects or deselects the object with the given name.
void renameNode (const QString &oldName, const QString &newName)
 Gives the node with the given old name the given new name.
void changeParameter (const QString &name, const QString &parameterName, const QVariant &value)
 Changes the value of the parameter with the given name of the node with the given name to the given value.

Signals

void modified ()
 Signal that is emitted when the internal state of the node model has changed.
void clearSelectionRequested ()
 Signal that is emitted when the selection of nodes should be cleared.
void nodeSelected (Node *node)
 Signal that is emitted when the given node has been selected.
void nodeDeleted (const QString &name)
 Signal that is emitted when the node with the given name has been deleted.

Public Member Functions

 NodeModel ()
 Constructor of the NodeModel class.
 ~NodeModel ()
 Destructor of the NodeModel class.
void beginUpdate ()
 Sets an updating flag for the node model to prevent emitting redundant updated() signals.
void endUpdate ()
 Resets the updating flag for the node model and emits the updated() signal.
void beginSelectingAll ()
 Sets the m_selectingAll flag for the node model to prevent emitting redundant nodeSelected() signals.
void endSelectingAll (bool emitSignal=true)
 Resets the m_selectingAll flag for the node model and optionally emits the nodeSelected() signal for the last selected node.
NodecreateNode (const QString &typeName, const QString &name="", bool visible=true)
 Creates a node of the given type with the given name in the node model.
ConnectioncreateConnection (Parameter *sourceParameter, Parameter *targetParameter)
 Creates a connection.
NodegetNode (const QString &name) const
 Returns the node with the given name or 0 if no node with the given name can be found.
QList< Node * > getNodes (const QString &typeName="") const
 Returns a list of nodes of the given type name contained in the node model.
QList< Connection * > getConnections () const
 Returns a list of connections of the given type name contained in the node model.
QStringList getNodeNames (const QString &typeName="") const
 Returns the list of names of nodes of the given type name contained in the node model.
QStandardItem * getStandardItemNode (const QString &name) const
 Returns the standard item node with the given name or 0 if no item with the given name can be found.
QStandardItem * getStandardItemConnection (const QString &name) const
 Returns the standard item (connection) with the given name or 0 if no item with the given name can be found.
void setSelected (const QItemSelection &selection, bool selected)
 Sets the selection state of the items in the given selection to the given value.
void deleteNode (const QString &name)
 Deletes the node with the given name from the node model.
void deleteConnection (const QString &name)
 Deletes the connection with the given name from the node model.

Private Member Functions

QStandardItem * getCategoryItem (const QString &nodeCategory)
 Returns the category item that stands for nodes of the given node type.

Private Attributes

bool m_updating
 Flag that states whether a bigger update of the node model is taking place.
bool m_selectingAll
 Flag that states whether all nodes are currently being selected.
QMutex m_mutex
 The mutex to protect the node model data structure.
QMap< QString, Node * > m_nodeMap
 A map for referencing nodes by name.
QMap< QString, Connection * > m_connectionMap
 A map for referencing connections by name.
QMap< QString, QStandardItem * > m_standardItemNodeMap
 A map for referencing standard items by name.
QMap< QString, QStandardItem * > m_standardItemConnectionMap
 A map for referencing standard items by name.
QList< QStandardItem * > m_categoryItems
 The list of category items that appear as children of the model's root item.


Detailed Description

Class for the model containing nodes.

Inheritance Diagram

inline_dotgraph_9.dot
[legend]

Constructor & Destructor Documentation

NodeModel::NodeModel (  ) 

Constructor of the NodeModel class.

Constructors and Destructors.

NodeModel::~NodeModel (  ) 

Destructor of the NodeModel class.


Member Function Documentation

void NodeModel::beginUpdate (  ) 

Sets an updating flag for the node model to prevent emitting redundant updated() signals.

Public Functions.

Should be called to initiate a substantial update of the model.

See also:
endUpdate()
Sets an updating flag for the node model to prevent emitting redundant updated() signals.

Should be called to initiate a substantial update of the model.

See also:
endUpdate()

void NodeModel::endUpdate (  ) 

Resets the updating flag for the node model and emits the updated() signal.

Should be called when a substantial update of the model that was initiated by calling beginUpdate() has finished.

See also:
beginUpdate()

void NodeModel::beginSelectingAll (  ) 

Sets the m_selectingAll flag for the node model to prevent emitting redundant nodeSelected() signals.

Should be called before selecting all nodes in the node model.

See also:
endSelectingAll()

void NodeModel::endSelectingAll ( bool  emitSignal = true  ) 

Resets the m_selectingAll flag for the node model and optionally emits the nodeSelected() signal for the last selected node.

Should be called after selecting all nodes in the node model.

Parameters:
emitSignal Flag to control whether to emit the nodeSelected() signal.
See also:
beginSelectingAll()

Node * NodeModel::createNode ( const QString &  typeName,
const QString &  name = "",
bool  visible = true 
)

Creates a node of the given type with the given name in the node model.

Parameters:
typeName The name of the type of node to add to the model.
name The name to give to the node to add to the model.
visible Flag that controls whether the object represented by the node should appear in views.
Returns:
The new node or 0 if the node could not be created.

Connection * NodeModel::createConnection ( Parameter sourceParameter,
Parameter targetParameter 
)

Creates a connection.

Parameters:
sourceParameter The source parameter of the connection.
targetParameter The target parameter of the connection.
Returns:
The new connection or 0 if the connection could not be created.
Parameters:
typeName The name of the type of node to add to the model.
Returns:
The new connection or 0 if the connection could not be created.

Node * NodeModel::getNode ( const QString &  name  )  const

Returns the node with the given name or 0 if no node with the given name can be found.

Parameters:
name The name of the node to return.
Returns:
The node with the given name or 0.

QList< Node * > NodeModel::getNodes ( const QString &  typeName = ""  )  const

Returns a list of nodes of the given type name contained in the node model.

Parameters:
typeName The name of the type of nodes to return, or an empty string to return all nodes.
Returns:
A list of nodes of the given type name.

QList< Connection * > NodeModel::getConnections (  )  const

Returns a list of connections of the given type name contained in the node model.

Returns:
A list of connections.

QStringList NodeModel::getNodeNames ( const QString &  typeName = ""  )  const

Returns the list of names of nodes of the given type name contained in the node model.

Parameters:
typeName The name of the type of node names to return, or an empty string to return all node names.
Returns:
A list of names of nodes of the given type name.

QStandardItem * NodeModel::getStandardItemNode ( const QString &  name  )  const

Returns the standard item node with the given name or 0 if no item with the given name can be found.

Returns the standard item (node) with the given name or 0 if no item with the given name can be found.

Parameters:
name The name of the standard item to return.
Returns:
The item with the given name or 0.

QStandardItem * NodeModel::getStandardItemConnection ( const QString &  name  )  const

Returns the standard item (connection) with the given name or 0 if no item with the given name can be found.

Parameters:
name The name of the standard item to return.
Returns:
The item with the given name or 0.

void NodeModel::setSelected ( const QItemSelection &  selection,
bool  selected 
)

Sets the selection state of the items in the given selection to the given value.

Parameters:
selection The items to set the selection state for.
selected The selection state to set for the items.

void NodeModel::deleteNode ( const QString &  name  ) 

Deletes the node with the given name from the node model.

Parameters:
name The name of the node to delete from the node model.

void NodeModel::deleteConnection ( const QString &  name  ) 

Deletes the connection with the given name from the node model.

Parameters:
name The name of the connection to delete from the node model.

void NodeModel::setSelected ( const QString &  name,
bool  selected 
) [slot]

Selects or deselects the object with the given name.

Public Slots.

Parameters:
name The name of the object to select or deselect.
selected The new selected state for the object.
Selects or deselects the object with the given name.

Parameters:
name The name of the object to select or deselect.
selected The new selected state for the object.

void NodeModel::renameNode ( const QString &  oldName,
const QString &  newName 
) [slot]

Gives the node with the given old name the given new name.

Parameters:
oldName The old name of the scene object.
newName The new name of the scene object.

void NodeModel::changeParameter ( const QString &  name,
const QString &  parameterName,
const QVariant &  value 
) [slot]

Changes the value of the parameter with the given name of the node with the given name to the given value.

Changes the value of the parameter with the given name of the object with the given name to the given value.

Parameters:
name The name of the node for which to change the parameter.
parameterName The name of the parameter to change.
value The new value for the parameter.
name The name of the object for which to change the parameter.
parameterName The name of the parameter to change.
value The new value for the parameter.

void NodeModel::modified (  )  [signal]

Signal that is emitted when the internal state of the node model has changed.

void NodeModel::clearSelectionRequested (  )  [signal]

Signal that is emitted when the selection of nodes should be cleared.

void NodeModel::nodeSelected ( Node node  )  [signal]

Signal that is emitted when the given node has been selected.

Parameters:
node The node that was selected.

void NodeModel::nodeDeleted ( const QString &  name  )  [signal]

Signal that is emitted when the node with the given name has been deleted.

Parameters:
name The name of the node that was deleted.

QStandardItem * NodeModel::getCategoryItem ( const QString &  nodeCategory  )  [private]

Returns the category item that stands for nodes of the given node type.

Private Functions.

Parameters:
nodeCategory The category name of nodes that the category item stands for.
Returns:
The category item that stands for nodes of the given node type.
Returns the category item that stands for nodes of the given node type.

Parameters:
nodeCategory The category name of nodes that the category item stands for.
Returns:
The category item that stands for nodes of the given node type.


Member Data Documentation

bool NodeModel::m_updating [private]

Flag that states whether a bigger update of the node model is taking place.

See also:
beginUpdate(), endUpdate()

bool NodeModel::m_selectingAll [private]

Flag that states whether all nodes are currently being selected.

See also:
beginSelectingAll(), endSelectingAll(), setSelected()

QMutex NodeModel::m_mutex [private]

The mutex to protect the node model data structure.

QMap<QString, Node *> NodeModel::m_nodeMap [private]

A map for referencing nodes by name.

QMap<QString, Connection *> NodeModel::m_connectionMap [private]

A map for referencing connections by name.

QMap<QString, QStandardItem *> NodeModel::m_standardItemNodeMap [private]

A map for referencing standard items by name.

QMap<QString, QStandardItem *> NodeModel::m_standardItemConnectionMap [private]

A map for referencing standard items by name.

QList<QStandardItem *> NodeModel::m_categoryItems [private]

The list of category items that appear as children of the model's root item.


The documentation for this class was generated from the following files:

Generated on Wed Feb 24 15:01:01 2010 for Frapper by  doxygen 1.5.9