예제 #1
0
void OptionsWindow::saveNodeTypes( TreeItem* index )
{
	//nacitanie typov grafu
	Manager::GraphManager* manager = Manager::GraphManager::getInstance();
	QMap<qlonglong, Data::Type*>* types = manager->getActiveGraph()->getTypes();

	for ( int i=0; i < index->childCount(); i++ ) {
		TreeItem* root = index->child( i );
		//ak je root typov grafu
		if ( root->data( 0 ) == "Node Types" ) {
			//pre kazdy uloz data
			for ( int j=0; j< root->childCount(); j++ ) {
				TreeItem* item = root->child( j );
				Data::Type* type = types->value( item->data( 2 ).toLongLong() );
				QMap<QString, QString>* settings = type->getSettings();
				QList<QString> atributes = item->data( 1 ).toString().split( ";" );

				for ( int k=0; k<atributes.length(); k++ ) {
					QList<QString> atribute = atributes[k].split( "," );
					settings->insert( atribute[0],atribute[1] );
				}

			}
		}
	}


}
예제 #2
0
void TreeModel::addNodesToList(QList<TreeItem*> * parents)
{
	//vytvori sa nova korenova polozka pre typy uzlov
	QList<QVariant> * columnData = new QList<QVariant>();
	columnData->append("Node Types");
	TreeItem * nodeRoot = new TreeItem(*columnData,parents->last());
	parents->last()->appendChild(nodeRoot);

	//nacita sa zoznam typov uzlov
	Manager::GraphManager * manager = Manager::GraphManager::getInstance();
	QMap<qlonglong, Data::Type*> * nodes = manager->getActiveGraph()->getTypes();

	QMap<qlonglong, Data::Type*>::iterator iterator;	

	//typy uzlyovsa postupne prechadzaju
	for (iterator = nodes->begin(); iterator != nodes->end(); ++iterator)
	{
		//vytvori sa nova polozka a vlozi sa nazov polozky
		QString name = iterator.value()->getName();
		columnData = new QList<QVariant>();
		columnData->append(name);		
		
		//nacitaju sa data typu uzla
		Data::Type * node = static_cast<Data::Type*>(iterator.value());
		QMap<QString, QString> * settings = node->getSettings();
		QMap<QString, QString>::iterator settingsIterator;

		QString data;
		//postupne sa data zlozia
		for (settingsIterator = settings->begin(); settingsIterator != settings->end(); settingsIterator++)
		{
			if (settingsIterator != settings->begin())
				data.append(";");
			data.append(QString("%1,%2").arg(settingsIterator.key()).arg(settingsIterator.value()));
		}		
		
		//nakoniec sa data prilozia danemu typu uzla
		columnData->append(data);
		columnData->append(iterator.key());
		nodeRoot->appendChild(new TreeItem(*columnData,nodeRoot));
	}
}