Beispiel #1
0
void DrawPart::restoreFromItemData( const ItemData &itemData )
{
	Item::restoreFromItemData(itemData);
	
	const QStringMap::const_iterator stringEnd = itemData.dataString.end();
	for ( QStringMap::const_iterator it = itemData.dataString.begin(); it != stringEnd; ++it )
	{
		VariantDataMap::iterator vit = m_variantData.find(it.key());
		if ( vit == m_variantData.end() )
			continue;
		
		if ( vit.value()->type() == Variant::Type::PenStyle )
			setDataPenStyle( it.key(), idToPenStyle( it.value() ) );
		
		else if ( vit.value()->type() == Variant::Type::PenCapStyle )
			setDataPenCapStyle( it.key(), idToPenCapStyle( it.value() ) );
	}
}
Beispiel #2
0
void QmitkPythonSnippets::SaveStringMap(const QString &filename, const QmitkPythonSnippets::QStringMap &) const
{
  MITK_DEBUG("QmitkPythonSnippets") << "saving to xml file " << filename.toStdString();

  if( filename.isEmpty() )
  {
    MITK_WARN("QmitkPythonSnippets") << "empty auto save file path given. quit.";
    return;
  }

  QFile file(filename);
  file.open(QIODevice::WriteOnly);
  if( !file.isOpen() )
  {
    MITK_WARN("QmitkPythonSnippets") << "could not open file " << filename.toStdString() << " for writing";
    return;
  }
  QXmlStreamWriter xmlWriter(&file);

  xmlWriter.setAutoFormatting(true);
  xmlWriter.writeStartDocument();
  xmlWriter.writeStartElement(SNIPPETS_ROOT_XML_ELEMENT_NAME);

  QStringMap::const_iterator it = d->m_Snippets.begin();
  while( it != d->m_Snippets.end() )
  {

    {
      MITK_DEBUG("QmitkPythonSnippets") << "SNIPPETS_XML_ELEMENT_NAME " << SNIPPETS_XML_ELEMENT_NAME.toStdString();
      MITK_DEBUG("QmitkPythonSnippets") << "writing item " << it.key().toStdString();
    }

    xmlWriter.writeStartElement(SNIPPETS_XML_ELEMENT_NAME);

    xmlWriter.writeAttribute( "key", it.key() );
    xmlWriter.writeAttribute( "value", it.value() );

    xmlWriter.writeEndElement();

    ++it;
  }

  xmlWriter.writeEndDocument();
  if( file.isOpen() )
    file.close();

  {
    MITK_DEBUG("QmitkPythonSnippets") << "SaveStringMap successful ";
  }

}
Beispiel #3
0
void Item::restoreFromItemData( const ItemData &itemData )
{
	move( itemData.x, itemData.y );
	if ( canResize() )
		setSize( itemData.size );
	
	Item *parentItem = p_itemDocument->itemWithID( itemData.parentId );
	if (parentItem)
		setParentItem(parentItem);
	else
		m_baseZ = itemData.z;
	
	//BEGIN Restore data
	const QStringMap::const_iterator stringEnd = itemData.dataString.end();
	for ( QStringMap::const_iterator it = itemData.dataString.begin(); it != stringEnd; ++it )
	{
		if ( hasProperty(it.key()) )
			property( it.key() )->setValue( it.value() );
	}
	
	const DoubleMap::const_iterator numberEnd = itemData.dataNumber.end();
	for ( DoubleMap::const_iterator it = itemData.dataNumber.begin(); it != numberEnd; ++it )
	{
		if ( hasProperty(it.key()) )
			property( it.key() )->setValue( it.value() );
	}
	
	const QColorMap::const_iterator colorEnd = itemData.dataColor.end();
	for ( QColorMap::const_iterator it = itemData.dataColor.begin(); it != colorEnd; ++it )
	{
		if ( hasProperty(it.key()) )
			property( it.key() )->setValue( it.value() );
	}
	
	const BoolMap::const_iterator boolEnd = itemData.dataBool.end();
	for ( BoolMap::const_iterator it = itemData.dataBool.begin(); it != boolEnd; ++it )
	{
		if ( hasProperty(it.key()) )
			property( it.key() )->setValue( QVariant( it.value() /*, 0*/ ) );
	}
	
	const QBitArrayMap::const_iterator rawEnd = itemData.dataRaw.end();
	for ( QBitArrayMap::const_iterator it = itemData.dataRaw.begin(); it != rawEnd; ++it )
	{
		if ( hasProperty(it.key()) )
			property( it.key() )->setValue( it.value() );
	}
	//END Restore Data
}