Frapper
1.0a
|
Class for the model containing nodes. More...
#include <NodeModel.h>
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 ¶meterName, 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. | |
Node * | 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. | |
Connection * | createConnection (Parameter *sourceParameter, Parameter *targetParameter) |
Creates a connection. | |
Node * | getNode (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. | |
Connection * | getConnection (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. | |
Frapper::NodeModel::NodeModel | ( | ) |
Constructor of the NodeModel class.
Constructors and Destructors.
Frapper::NodeModel::~NodeModel | ( | ) |
Destructor of the NodeModel class.
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.
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.
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.
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.
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.
emitSignal | Flag to control whether to emit the nodeSelected() signal. |
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.
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. |
Connection * Frapper::NodeModel::createConnection | ( | Parameter * | sourceParameter, |
Parameter * | targetParameter | ||
) |
Creates a connection.
sourceParameter | The source parameter of the connection. |
targetParameter | The target parameter of the connection. |
typeName | The name of the type of node to add to the model. |
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.
name | The name of the node to return. |
QList< Node * > Frapper::NodeModel::getNodes | ( | const QString & | typeName = "" | ) | const |
Returns a list of nodes of the given type name contained in the node model.
typeName | The name of the type of nodes to return, or an empty string to return all nodes. |
QList< Connection * > Frapper::NodeModel::getConnections | ( | ) | const |
Returns a list of connections of the given type name contained in the node model.
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.
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.
typeName | The name of the type of node names to return, or an empty string to return all node names. |
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.
name | The name of the standard item to return. |
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.
name | The name of the standard item to return. |
void Frapper::NodeModel::setSelected | ( | const QItemSelection & | selection, |
bool | selected | ||
) |
Sets the selection state of the items in the given selection to the given value.
selection | The items to set the selection state for. |
selected | The 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.
name | The 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.
name | The name of the connection to delete from the node model. |
|
slot |
Selects or deselects the object with the given name.
Public Slots.
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.
name | The name of the object to select or deselect. |
selected | The new selected state for the object. |
|
slot |
Gives the node with the given old name the given new name.
oldName | The old name of the scene object. |
newName | The new name of the scene object. |
|
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.
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. |
|
signal |
Signal that is emitted when the internal state of the node model has changed.
|
signal |
Signal that is emitted when the selection of nodes should be cleared.
|
signal |
Signal that is emitted when the given node has been selected.
node | The node that was selected. |
|
signal |
Signal that is emitted when the node with the given name has been deleted.
name | The name of the node that was deleted. |
|
private |
Returns the category item that stands for nodes of the given node type.
Private Functions.
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.
nodeCategory | The category name of nodes that the category item stands for. |
|
private |
Flag that states whether a bigger update of the node model is taking place.
|
private |
Flag that states whether all nodes are currently being selected.
|
private |
The mutex to protect the node model data structure.
|
private |
A map for referencing nodes by name.
|
private |
A map for referencing connections by name.
|
private |
A map for referencing standard items by name.
|
private |
A map for referencing standard items by name.
|
private |
The list of category items that appear as children of the model's root item.