void ContextPrivate::renameNode( const QUuid &pUUID1, const QUuid &pUUID2 ) { if( pUUID1 == pUUID2 ) { return; } if( mNodeHash.contains( pUUID2 ) ) { qWarning() << "ContextPrivate::renameNode - mNodeHash.contains( pUUID2 )"; return; } NodeHash::iterator it = mNodeHash.find( pUUID1 ); if( it == mNodeHash.end() ) { qWarning() << "ContextPrivate::renameNode - !mNodeHash.contains( pUUID1 )"; return; } QSharedPointer<fugio::NodeInterface> Node = it.value(); mNodeHash.remove( pUUID1 ); mNodeHash.insert( pUUID2, Node ); if( mConnectIO.contains( pUUID1 ) ) { QUuid D = mConnectIO.take( pUUID1 ); mConnectIO.insert( pUUID2, D ); } if( mConnectOI.contains( pUUID1 ) ) { QList<QUuid> L = mConnectOI.values( pUUID1 ); for( QList<QUuid>::const_iterator it = L.begin() ; it != L.end() ; it++ ) { mConnectOI.remove( pUUID1, *it ); mConnectOI.insert( pUUID2, *it ); } } #if defined( QT_DEBUG ) && defined( DEBUG_CONNECTIONS ) qDebug() << "ContextPrivate::renameNode" << pUUID1 << pUUID2; #endif emit nodeRenamed( pUUID1, pUUID2 ); }
void ContextPrivate::onPinAdded( QSharedPointer<fugio::NodeInterface> pNode, QSharedPointer<fugio::PinInterface> pPin ) { registerPin( pPin ); ConnectionPair MapKey( pNode->name(), pPin->name() ); // DefaultMap::iterator DefaultIterator = mDefaultMap.find( MapKey ); // if( DefaultIterator != mDefaultMap.end() ) // { // pPin->setValue( DefaultIterator.value() ); // } for( ConnectionMap::iterator it = mConnectionMap.begin() ; it != mConnectionMap.end() ; it++ ) { if( pPin->direction() == PIN_OUTPUT && it.key() == MapKey ) { for( NodeHash::iterator NodeIterator = mNodeHash.begin() ; NodeIterator != mNodeHash.end() ; NodeIterator++ ) { QSharedPointer<fugio::NodeInterface> Node = NodeIterator.value(); if( Node->name() != it.value().first ) { continue; } QSharedPointer<fugio::PinInterface> Pin = Node->findPinByName( it.value().second ); if( Pin == 0 || Pin->direction() != PIN_INPUT ) { continue; } connectPins( pPin->globalId(), Pin->globalId() ); } break; } else if( pPin->direction() == PIN_INPUT && it.value() == MapKey ) { for( NodeHash::iterator NodeIterator = mNodeHash.begin() ; NodeIterator != mNodeHash.end() ; NodeIterator++ ) { QSharedPointer<fugio::NodeInterface> Node = *NodeIterator; if( Node->name() != it.key().first ) { continue; } QSharedPointer<fugio::PinInterface> Pin = Node->findPinByName( it.key().second ); if( Pin == 0 || Pin->direction() != PIN_OUTPUT ) { continue; } connectPins( pPin->globalId(), Pin->globalId() ); } break; } } emit pinAdded( pNode->uuid(), pPin->globalId() ); }
NodeHash::iterator LimitedNodeList::killNodeAtHashIterator(NodeHash::iterator& nodeItemToKill) { qDebug() << "Killed" << *nodeItemToKill.value(); emit nodeKilled(nodeItemToKill.value()); return _nodeHash.erase(nodeItemToKill); }