/**
 * Create new leaf nodes by copying the children of <code>parent</code>
 * TODO: Should let parent be const, but setting its index property to be able to rebuild the edge structure.
 * Do that in a preparation step instead.
 */
void TreeData::readFromSubNetwork(NodeBase* parent)
{
	// Clone all nodes
	unsigned int numNodes = parent->childDegree();
	reserveNodeCount(numNodes);
	unsigned int i = 0;
	for (NodeBase::sibling_iterator childIt(parent->begin_child()), endIt(parent->end_child());
			childIt != endIt; ++childIt, ++i)
	{
		addNewNode(*childIt); // New node copies the data from the other
		childIt->index = i; // Set index to its place in this subnetwork to be able to find edge target below
	}

	// Clone edges
	for (NodeBase::sibling_iterator childIt(parent->begin_child()), endIt(parent->end_child());
			childIt != endIt; ++childIt)
	{
		NodeBase& node = *childIt;
		for (NodeBase::edge_iterator outEdgeIt(node.begin_outEdge()), endIt(node.end_outEdge());
				outEdgeIt != endIt; ++outEdgeIt)
		{
			EdgeType edge = **outEdgeIt;
			// If neighbour node is within the same cluster, add the link to this subnetwork.
			if (edge.target.parent == parent)
			{
				addEdge(node.index, edge.target.index, edge.data.weight, edge.data.flow);
			}
			// else flow out of sub-network
		}
	}
}
Example #2
0
void KXMLGUIClient::prepareXMLUnplug( QWidget * )
{
  actionCollection()->prepareXMLUnplug();
  QPtrListIterator<KXMLGUIClient> childIt( d->m_children );
  for (; childIt.current(); ++childIt )
    childIt.current()->actionCollection()->prepareXMLUnplug();
}
Example #3
0
void KXMLGUIClient::endXMLPlug()
{
  actionCollection()->endXMLPlug();
  QPtrListIterator<KXMLGUIClient> childIt( d->m_children );
  for (; childIt.current(); ++childIt )
    childIt.current()->actionCollection()->endXMLPlug();
}
Example #4
0
void KXMLGUIClient::beginXMLPlug( QWidget *w )
{
  actionCollection()->beginXMLPlug( w );
  QPtrListIterator<KXMLGUIClient> childIt( d->m_children );
  for (; childIt.current(); ++childIt )
    childIt.current()->actionCollection()->beginXMLPlug( w );
}
Example #5
0
KAction *KXMLGUIClient::action( const char *name ) const
{
  KAction* act = actionCollection()->action( name );
  if ( !act ) {
    QPtrListIterator<KXMLGUIClient> childIt( d->m_children );
    for (; childIt.current(); ++childIt ) {
      act = childIt.current()->actionCollection()->action( name );
      if ( act )
        break;
    }
  }
  return act;
}
KABCResourceItem* ResourceSelection::findSubResourceItem( KABC::ResourceABC *resource,
                                                          const QString &subResource )
{
  QTreeWidgetItemIterator parentIt( mListView );
  for ( ; *parentIt; ++parentIt ) {
    if ( static_cast<KABCResourceItem*>(*parentIt)->resource() != resource )
      continue;

    QTreeWidgetItemIterator childIt( *parentIt );
    for ( ; *childIt; ++childIt ) {
      KABCResourceItem *item = static_cast<KABCResourceItem*>(*childIt);
      if ( item->resourceIdentifier() == subResource )
        return item;
    }
  }

  return 0;
}