bool KivioBaseTargetStencil::loadProperties( const QDomElement &e ) { QDomNode node; QDomElement nodeE; QString nodeName; node = e.firstChild(); while( !node.isNull() ) { nodeName = node.nodeName(); nodeE = node.toElement(); if( nodeName == "KivioFillStyle" ) { m_pFillStyle->loadXML( node.toElement() ); } else if( nodeName == "KivioLineStyle" ) { m_pLineStyle->loadXML( node.toElement() ); } else if( nodeName == "KivioTextStyle" ) { m_pTextStyle->loadXML( node.toElement() ); } else if( nodeName == "KivioTargetList" ) { loadTargets( node.toElement() ); } else if( nodeName == "CustomData" ) { loadCustom( node.toElement() ); } else if( nodeName == "Geometry" ) { m_x = XmlReadFloat( nodeE, "x", 0.0f ); m_y = XmlReadFloat( nodeE, "y", 0.0f ); m_w = XmlReadFloat( nodeE, "w", 72.0f ); m_h = XmlReadFloat( nodeE, "h", 72.0f ); } node = node.nextSibling(); } return true; }
bool KivioLineStyle::loadXML( const QDomElement &e ) { m_color = XmlReadColor( e, "color", QColor(0,0,0) ); m_width = XmlReadFloat( e, "width", 1.0f ); m_capStyle = XmlReadInt( e, "capStyle", Qt::RoundCap ); m_joinStyle = XmlReadInt( e, "joinStyle", Qt::RoundJoin ); m_style = XmlReadInt( e, "pattern", Qt::SolidLine ); return true; }
/** * Loads a shape of type line-array. * * @param e The element to load from. * @returns A newly allocated KivioShape, or NULL on error. */ KivioShape *KivioShape::loadShapeLineArray( const QDomElement &e ) { KivioShape *pShape = NULL; KivioPoint *pPoint = NULL; QDomNode node; QString nodeName; QDomElement lineElement; // Create the new shape to load into pShape = new KivioShape(); // Load the type, name, and lineWidth properties pShape->m_shapeData.m_shapeType = KivioShapeData::kstLineArray; pShape->m_shapeData.m_name = XmlReadString( e, "name", "" ); // Iterate through the nodes loading the various items node = e.firstChild(); while( !node.isNull() ) { nodeName = node.nodeName(); // The line array is made up of pairs of points if( nodeName == "Line" ) { lineElement = node.toElement(); // Allocate a new point, load it, and store it in the list pPoint = new KivioPoint( XmlReadFloat( lineElement, "x1", 0.0f ), XmlReadFloat( lineElement, "y1", 0.0f ) ); pShape->m_shapeData.m_pOriginalPointList->append( pPoint ); pPoint = new KivioPoint( XmlReadFloat( lineElement, "x2", 0.0f ), XmlReadFloat( lineElement, "y2", 0.0f ) ); pShape->m_shapeData.m_pOriginalPointList->append( pPoint ); pPoint = NULL; } else if( nodeName == "KivioLineStyle" ) { pShape->m_shapeData.m_pLineStyle->loadXML( node.toElement() ); } node = node.nextSibling(); } return pShape; }
/** * Loads a shape of type textbox. * * @param e The element to load from. * @returns A newly allocated KivioShape, or NULL on error. */ KivioShape *KivioShape::loadShapeTextBox( const QDomElement &e ) { KivioShape *pShape = NULL; QDomNode node; QString nodeName; KivioTextStyle ts; QString name; // Create the new shape to load into pShape = new KivioShape(); // Load the type and name pShape->m_shapeData.setShapeType(KivioShapeData::kstTextBox); pShape->m_shapeData.setName( XmlReadString( e, "name", "" ) ); pShape->m_shapeData.setTextColor(XmlReadColor(e,"color",QColor(0,0,0))); pShape->m_shapeData.m_position.set( XmlReadFloat( e, "x", 0.0f ), XmlReadFloat( e, "y", 0.0f ) ); pShape->m_shapeData.m_dimensions.set( XmlReadFloat( e, "w", 72.0f ), XmlReadFloat( e, "h", 72.0f ) ); // Now look for the KivioTextStyle node = e.firstChild(); while( !node.isNull() ) { nodeName = node.nodeName(); if( nodeName == "KivioTextStyle" ) { ts.loadXML( node.toElement() ); pShape->m_shapeData.setTextStyle( &ts ); } node = node.nextSibling(); } // QString text = XmlReadString( e, "text", "" ); // pShape->m_shapeData.setText( text ); return pShape; }
/** * Loads a shape of type rectangle. * * @param e The element to load from. * @returns A newly allocated KivioShape, or NULL on error. */ KivioShape *KivioShape::loadShapeRectangle( const QDomElement &e ) { KivioShape *pShape = NULL; QDomNode node; QString nodeName; // Create the new shape to load into pShape = new KivioShape(); // Load the type, name, and lineWidth properties pShape->m_shapeData.m_shapeType = KivioShapeData::kstRectangle; pShape->m_shapeData.m_name = XmlReadString( e, "name", "" ); pShape->m_shapeData.m_position.set( XmlReadFloat( e, "x", 0.0f ), XmlReadFloat( e, "y", 0.0f ) ); pShape->m_shapeData.m_dimensions.set( XmlReadFloat( e, "w", 72.0f ), XmlReadFloat( e, "h", 72.0f ) ); // Iterate through the nodes loading the various items node = e.firstChild(); while( !node.isNull() ) { nodeName = node.nodeName(); // Read the fill style if( nodeName == "KivioFillStyle" ) { pShape->m_shapeData.m_pFillStyle->loadXML( node.toElement() ); } else if( nodeName == "KivioLineStyle" ) { pShape->m_shapeData.m_pLineStyle->loadXML( node.toElement() ); } node = node.nextSibling(); } return pShape; }