Ejemplo n.º 1
0
void SystemClipboard::saveNode(const Node *node, const QString &name, bool)
{
	xml->beginSaveChildNode(node->typeName());
	xml->setName(name);
	xml->setPartialHint(false);

	node->save(*this);

	if ( !node->isFullyLoaded() )
	{
		// Persist sub nodes which have not been loaded. Each subnode has a unique name. If a node was previously
		// persisted and was not saved so far, we will read it back from the persistent store and store it again.

		// Get a list of sub nodes which have already been persisted.
		QStringList persistedChildren = xml->getChildrenNames();

		PersistedNode* persisted = node->model()->store()->loadCompleteNodeSubtree(node->model()->name(), node->persistentUnitId(), node->id());

		if (!persisted) throw FilePersistenceException("Could not load node subtree from old persistent store.");
		PersistedValue< QList<PersistedNode*> >* composite = dynamic_cast<PersistedValue< QList<PersistedNode*> >* > (persisted);
		if (!composite) throw FilePersistenceException("Partial loading of Value-type nodes (string, int, double) is not supported.");

		for(int i = 0; i<composite->value().size(); ++i)
		{
			if (!persistedChildren.contains(composite->value()[i]->name())) saveNodeFromOldStore(composite->value()[i]);
		}

		SAFE_DELETE(persisted);
	}

	xml->endSaveChildNode();
}
Ejemplo n.º 2
0
void SystemClipboard::saveNodeFromOldStore(PersistedNode* node)
{
	xml->beginSaveChildNode( node->type() );
	xml->setName(node->name());
	xml->setPartialHint( false );

	PersistedValue< QString >* string =  dynamic_cast< PersistedValue< QString >* > (node);
	if (string) xml->saveStringValue(string->value());
	else
	{
		PersistedValue< int >* integer =  dynamic_cast< PersistedValue< int >* > (node);
		if (integer) xml->saveIntValue( integer->value() );
		else
		{
			PersistedValue< double >* dbl =  dynamic_cast< PersistedValue< double >* > (node);
			if (dbl) xml->saveDoubleValue(dbl->value());
			else
			{
				PersistedValue< QList<PersistedNode*> >* composite =  dynamic_cast< PersistedValue< QList<PersistedNode*> >* > (node);
				if (composite)
				{
					for (int i = 0; i< composite->value().size(); ++i) saveNodeFromOldStore(composite->value()[i]);
				}
				else throw FilePersistenceException("Unknown PersistedNode type.");
			}
		}
	}

	xml->endSaveChildNode();
}
Ejemplo n.º 3
0
LoadedNode SystemClipboard::loadNode(Node* parent)
{
	if (!parent) throw FilePersistenceException("Can not load a not from clipboard without a parent.");

	LoadedNode node;
	node.name = xml->getName();
	node.node = Node::createNewNode(xml->getType(), parent, parent->model()->generateNextId(), *this, false);

	return node;
}
Ejemplo n.º 4
0
void NodeIdMap::setId(const Model::Node* node, NodeIdType id)
{
    QMap<const Model::Node*, NodeIdType>::const_iterator iter = map.find(node);
    if (iter != map.end())
    {
        if (*iter == id) return;
        else throw FilePersistenceException("Setting an inconsistent node id in NodeIdMap");
    }

    map.insert(node, id);
}
Ejemplo n.º 5
0
void SystemClipboard::next()
{
	if (xml->hasNext()) xml->loadNext();
	else throw FilePersistenceException("Could not find next clipboard element.");
}
Ejemplo n.º 6
0
PersistedNode* SystemClipboard::loadCompleteNodeSubtree(const QString&, NodeIdType, NodeIdType)
{
	throw FilePersistenceException("The loadCompleteNodeSubtree(...) method is not supported in the SystemClipboard store. This might indicate that an object only partially loaded itself, ignoring the provided partial hint.");
}
Ejemplo n.º 7
0
QList<LoadedNode> SystemClipboard::loadPartialNode(Node*)
{
	throw FilePersistenceException("The loadPartialNode(...) method is not supported in the SystemClipboard store. This might indicate that an object only partially loaded itself, ignoring the provided partial hint.");
}
Ejemplo n.º 8
0
Node* SystemClipboard::loadModel(::Model::Model*, const QString &)
{
	throw FilePersistenceException("The clipboard does not support the loadModel() method.");
}