kchart

KDFrameProfileSection.cpp

00001 /* -*- Mode: C++ -*-
00002    KDChart - a multi-platform charting engine
00003    */
00004 
00005 /****************************************************************************
00006  ** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB.  All rights reserved.
00007  **
00008  ** This file is part of the KDChart library.
00009  **
00010  ** This file may be distributed and/or modified under the terms of the
00011  ** GNU General Public License version 2 as published by the Free Software
00012  ** Foundation and appearing in the file LICENSE.GPL included in the
00013  ** packaging of this file.
00014  **
00015  ** Licensees holding valid commercial KDChart licenses may use this file in
00016  ** accordance with the KDChart Commercial License Agreement provided with
00017  ** the Software.
00018  **
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  ** See http://www.klaralvdalens-datakonsult.se/?page=products for
00023  **   information about KDChart Commercial License Agreements.
00024  **
00025  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
00026  ** licensing are not clear to you.
00027  **
00028  **********************************************************************/
00029 #include <KDFrameProfileSection.h>
00030 #include <KDXMLTools.h>
00031 
00032 KDFrameProfileSection::~KDFrameProfileSection()
00033 {
00034     // Intentionally left blank for now.
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() ) { // was really an element
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 == "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 }
KDE Home | KDE Accessibility Home | Description of Access Keys