Frapper  1.0a
Public Slots | Signals | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Frapper::NodeModel Class Reference

Class for the model containing nodes. More...

#include <NodeModel.h>

Inheritance diagram for Frapper::NodeModel:
Inheritance graph
[legend]
Collaboration diagram for Frapper::NodeModel:
Collaboration graph
[legend]

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.
 
ConnectiongetConnection (const QString &name) const
 Returns a connection of the given 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.
 
QHash< QString, Node * > m_nodeMap
 A map for referencing nodes by name.
 
QHash< QString, Connection * > m_connectionMap
 A map for referencing connections by name.
 
QHash< QString, QStandardItem * > m_standardItemNodeMap
 A map for referencing standard items by name.
 
QHash< 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
dot_inline_dotgraph_7.png
[legend]

Constructor & Destructor Documentation

Frapper::NodeModel::NodeModel ( )

Constructor of the NodeModel class.

Constructors and Destructors.

Frapper::NodeModel::~NodeModel ( )

Destructor of the NodeModel class.

Member Function Documentation

void Frapper::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 Frapper::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 Frapper::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 Frapper::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
emitSignalFlag to control whether to emit the nodeSelected() signal.
See Also
beginSelectingAll()
Node * Frapper::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
typeNameThe name of the type of node to add to the model.
nameThe name to give to the node to add to the model.
visibleFlag 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 * Frapper::NodeModel::createConnection ( Parameter sourceParameter,
Parameter targetParameter 
)

Creates a connection.

Parameters
sourceParameterThe source parameter of the connection.
targetParameterThe target parameter of the connection.
Returns
The new connection or 0 if the connection could not be created.
Parameters
typeNameThe 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 * Frapper::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
nameThe name of the node to return.
Returns
The node with the given name or 0.
QList< Node * > Frapper::NodeModel::getNodes ( const QString &  typeName = "") const

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

Parameters
typeNameThe 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 * > Frapper::NodeModel::getConnections ( ) const

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

Returns
A list of connections.
Connection * Frapper::NodeModel::getConnection ( const QString &  name) const

Returns a connection of the given name contained in the node model.

name The name of the connection.

Returns
A list of connections.
QStringList Frapper::NodeModel::getNodeNames ( const QString &  typeName = "") const

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

Parameters
typeNameThe 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 * Frapper::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
nameThe name of the standard item to return.
Returns
The item with the given name or 0.
QStandardItem * Frapper::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
nameThe name of the standard item to return.
Returns
The item with the given name or 0.
void Frapper::NodeModel::setSelected ( const QItemSelection &  selection,
bool  selected 
)

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

Parameters
selectionThe items to set the selection state for.
selectedThe selection state to set for the items.
void Frapper::NodeModel::deleteNode ( const QString &  name)

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

Parameters
nameThe name of the node to delete from the node model.
void Frapper::NodeModel::deleteConnection ( const QString &  name)

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

Parameters
nameThe name of the connection to delete from the node model.
void Frapper::NodeModel::setSelected ( const QString &  name,
bool  selected 
)
slot

Selects or deselects the object with the given name.

Public Slots.

Parameters
nameThe name of the object to select or deselect.
selectedThe new selected state for the object.

Selects or deselects the object with the given name.

Parameters
nameThe name of the object to select or deselect.
selectedThe new selected state for the object.
void Frapper::NodeModel::renameNode ( const QString &  oldName,
const QString &  newName 
)
slot

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

Parameters
oldNameThe old name of the scene object.
newNameThe new name of the scene object.
void Frapper::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
nameThe name of the node for which to change the parameter.
parameterNameThe name of the parameter to change.
valueThe new value for the parameter.
nameThe name of the object for which to change the parameter.
parameterNameThe name of the parameter to change.
valueThe new value for the parameter.
void Frapper::NodeModel::modified ( )
signal

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

void Frapper::NodeModel::clearSelectionRequested ( )
signal

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

void Frapper::NodeModel::nodeSelected ( Node node)
signal

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

Parameters
nodeThe node that was selected.
void Frapper::NodeModel::nodeDeleted ( const QString &  name)
signal

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

Parameters
nameThe name of the node that was deleted.
QStandardItem * Frapper::NodeModel::getCategoryItem ( const QString &  nodeCategory)
private

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

Private Functions.

Parameters
nodeCategoryThe 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
nodeCategoryThe 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 Frapper::NodeModel::m_updating
private

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

See Also
beginUpdate(), endUpdate()
bool Frapper::NodeModel::m_selectingAll
private

Flag that states whether all nodes are currently being selected.

See Also
beginSelectingAll(), endSelectingAll(), setSelected()
QMutex Frapper::NodeModel::m_mutex
private

The mutex to protect the node model data structure.

QHash<QString, Node *> Frapper::NodeModel::m_nodeMap
private

A map for referencing nodes by name.

QHash<QString, Connection *> Frapper::NodeModel::m_connectionMap
private

A map for referencing connections by name.

QHash<QString, QStandardItem *> Frapper::NodeModel::m_standardItemNodeMap
private

A map for referencing standard items by name.

QHash<QString, QStandardItem *> Frapper::NodeModel::m_standardItemConnectionMap
private

A map for referencing standard items by name.

QList<QStandardItem *> Frapper::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: