kchart
KDFrameProfileSection.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <KDFrameProfileSection.h>
00030 #include <KDXMLTools.h>
00031
00032 KDFrameProfileSection::~KDFrameProfileSection()
00033 {
00034
00035 }
00036
00037
00038 void KDFrameProfileSection::createFrameProfileSectionNode( QDomDocument& document,
00039 QDomNode& parent,
00040 const QString& elementName,
00041 const KDFrameProfileSection* section )
00042
00043 {
00044 QDomElement sectionElement = document.createElement( elementName );
00045 parent.appendChild( sectionElement );
00046 KDXML::createStringNode( document, sectionElement, "Direction",
00047 KDFrameProfileSection::directionToString( section->_direction ) );
00048 KDXML::createStringNode( document, sectionElement, "Curvature",
00049 KDFrameProfileSection::curvatureToString( section->_curvature ) );
00050 KDXML::createIntNode( document, sectionElement, "Width", section->_width );
00051 KDXML::createPenNode( document, sectionElement, "Style", section->_pen );
00052 }
00053
00054
00055 bool KDFrameProfileSection::readFrameProfileSectionNode( const QDomElement& element,
00056 KDFrameProfileSection* section )
00057 {
00058 bool ok = true;
00059 Direction tempDirection = DirPlain;
00060 Curvature tempCurvature = CvtPlain;
00061 int tempWidth;
00062 QPen tempPen;
00063 QDomNode node = element.firstChild();
00064 while( !node.isNull() ) {
00065 QDomElement element = node.toElement();
00066 if( !element.isNull() ) {
00067 QString tagName = element.tagName();
00068 if( tagName == "Direction" ) {
00069 QString value;
00070 ok = ok & KDXML::readStringNode( element, value );
00071 tempDirection = stringToDirection( value );
00072 } else if( tagName == "Curvature" ) {
00073 QString value;
00074 ok = ok & KDXML::readStringNode( element, value );
00075 tempCurvature = stringToCurvature( value );
00076 } else if( tagName == "Width" ) {
00077 ok = ok & KDXML::readIntNode( element, tempWidth );
00078 } else if( tagName == "Style" || tagName == "Pen" ) {
00079 ok = ok & KDXML::readPenNode( element, tempPen );
00080 } else {
00081 qDebug( "Unknown tag in frame" );
00082 }
00083 }
00084 node = node.nextSibling();
00085 }
00086
00087 if( ok ) {
00088 section->_direction = tempDirection;
00089 section->_curvature = tempCurvature;
00090 section->_width = tempWidth;
00091 section->_pen = tempPen;
00092 }
00093
00094 return ok;
00095 }
|