kivio

kivio_stencil_spawner_info.cpp

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 #include "kivio_stencil_spawner_info.h"
00020 #include <qdom.h>
00021 
00022 #include <kglobal.h>
00023 #include <klocale.h>
00024 
00025 KivioStencilSpawnerInfo::KivioStencilSpawnerInfo()
00026 {
00027     m_author = "Joe Bob";
00028     m_title  = "Untitled";
00029     m_id = "";
00030     m_desc   = "No desc";
00031     m_version = "1.0";
00032     m_web    = "http://kivio.sourceforge.net";
00033     m_email  = "landshark@ameritech.net";
00034     m_autoUpdate = "";
00035 }
00036 
00037 KivioStencilSpawnerInfo::~KivioStencilSpawnerInfo()
00038 {
00039 }
00040 
00041 KivioStencilSpawnerInfo::KivioStencilSpawnerInfo( const QString &auth, const QString &tit, const QString &_id, const QString &des, const QString &ver, const QString &wb,
00042                                             const QString &em, const QString &au )
00043 {
00044     m_author = auth;
00045     m_title = tit;
00046     m_id = _id;
00047     m_desc = des;
00048     m_version = ver;
00049     m_web = wb;
00050     m_email = em;
00051     m_autoUpdate = au;
00052 }
00053 
00054 bool KivioStencilSpawnerInfo::loadXML( const QDomElement &e )
00055 {
00056   QDomNode node;
00057   QDomElement nodeElement;
00058   QString nodeName, origTitle, origDesc;
00059   m_title = "";
00060   m_desc = "";
00061 
00062   node = e.firstChild();
00063   while(!node.isNull())
00064   {
00065     nodeName = node.nodeName();
00066 
00067     nodeElement = node.toElement();
00068 
00069     if( nodeName.compare("Author")==0 )
00070     {
00071       m_author = nodeElement.attribute("data");
00072     }
00073     else if((nodeName.compare("Title")==0) && nodeElement.hasAttribute("lang"))
00074     {
00075       if(nodeElement.attribute("lang") == KGlobal::locale()->language()) {
00076         m_title = nodeElement.attribute("data");
00077       }
00078     }
00079     else if((nodeName.compare("Title")==0) && !nodeElement.hasAttribute("lang"))
00080     {
00081       origTitle = nodeElement.attribute("data");
00082     }
00083     else if( nodeName.compare("Id")==0 )
00084     {
00085       m_id = nodeElement.attribute("data");
00086     }
00087     else if((nodeName.compare("Description")==0) && nodeElement.hasAttribute("lang"))
00088     {
00089       if(nodeElement.attribute("lang") == KGlobal::locale()->language()) {
00090         m_desc = nodeElement.attribute("data");
00091       }
00092     }
00093     else if((nodeName.compare("Description")==0) && !nodeElement.hasAttribute("lang"))
00094     {
00095       origDesc = nodeElement.attribute("data");
00096     }
00097     else if( nodeName.compare("Version")==0 )
00098     {
00099       m_version = nodeElement.attribute("data");
00100     }
00101     else if( nodeName.compare("Web")==0 )
00102     {
00103       m_web = nodeElement.attribute("data");
00104     }
00105     else if( nodeName.compare("Email")==0 )
00106     {
00107       m_email = nodeElement.attribute("data");
00108     }
00109     else if( nodeName.compare("AutoUpdate")==0 )
00110     {
00111       m_autoUpdate = nodeElement.attribute("data");
00112     }
00113     
00114     if(m_title.isEmpty()) {
00115       m_title = i18n( "Stencils", origTitle.utf8());
00116     }
00117     
00118     if(m_desc.isEmpty()) {
00119       m_desc = i18n( "Stencils", origDesc.utf8());
00120     }
00121 
00122     node = node.nextSibling();
00123   }
00124 
00125   return true;
00126 }
KDE Home | KDE Accessibility Home | Description of Access Keys