kivio_stencil_spawner_info.cpp
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#include "kivio_stencil_spawner_info.h"
20#include <tqdom.h>
21
22#include <tdeglobal.h>
23#include <tdelocale.h>
24
25KivioStencilSpawnerInfo::KivioStencilSpawnerInfo()
26{
27 m_author = "Joe Bob";
28 m_title = "Untitled";
29 m_id = "";
30 m_desc = "No desc";
31 m_version = "1.0";
32 m_web = "http://kivio.sourceforge.net";
33 m_email = "landshark@ameritech.net";
34 m_autoUpdate = "";
35}
36
37KivioStencilSpawnerInfo::~KivioStencilSpawnerInfo()
38{
39}
40
41KivioStencilSpawnerInfo::KivioStencilSpawnerInfo( const TQString &auth, const TQString &tit, const TQString &_id, const TQString &des, const TQString &ver, const TQString &wb,
42 const TQString &em, const TQString &au )
43{
44 m_author = auth;
45 m_title = tit;
46 m_id = _id;
47 m_desc = des;
48 m_version = ver;
49 m_web = wb;
50 m_email = em;
51 m_autoUpdate = au;
52}
53
54bool KivioStencilSpawnerInfo::loadXML( const TQDomElement &e )
55{
56 TQDomNode node;
57 TQDomElement nodeElement;
58 TQString nodeName, origTitle, origDesc;
59 m_title = "";
60 m_desc = "";
61
62 node = e.firstChild();
63 while(!node.isNull())
64 {
65 nodeName = node.nodeName();
66
67 nodeElement = node.toElement();
68
69 if( nodeName.compare("Author")==0 )
70 {
71 m_author = nodeElement.attribute("data");
72 }
73 else if((nodeName.compare("Title")==0) && nodeElement.hasAttribute("lang"))
74 {
75 if(nodeElement.attribute("lang") == TDEGlobal::locale()->language()) {
76 m_title = nodeElement.attribute("data");
77 }
78 }
79 else if((nodeName.compare("Title")==0) && !nodeElement.hasAttribute("lang"))
80 {
81 origTitle = nodeElement.attribute("data");
82 }
83 else if( nodeName.compare("Id")==0 )
84 {
85 m_id = nodeElement.attribute("data");
86 }
87 else if((nodeName.compare("Description")==0) && nodeElement.hasAttribute("lang"))
88 {
89 if(nodeElement.attribute("lang") == TDEGlobal::locale()->language()) {
90 m_desc = nodeElement.attribute("data");
91 }
92 }
93 else if((nodeName.compare("Description")==0) && !nodeElement.hasAttribute("lang"))
94 {
95 origDesc = nodeElement.attribute("data");
96 }
97 else if( nodeName.compare("Version")==0 )
98 {
99 m_version = nodeElement.attribute("data");
100 }
101 else if( nodeName.compare("Web")==0 )
102 {
103 m_web = nodeElement.attribute("data");
104 }
105 else if( nodeName.compare("Email")==0 )
106 {
107 m_email = nodeElement.attribute("data");
108 }
109 else if( nodeName.compare("AutoUpdate")==0 )
110 {
111 m_autoUpdate = nodeElement.attribute("data");
112 }
113
114 if(m_title.isEmpty()) {
115 m_title = i18n( "Stencils", origTitle.utf8());
116 }
117
118 if(m_desc.isEmpty()) {
119 m_desc = i18n( "Stencils", origDesc.utf8());
120 }
121
122 node = node.nextSibling();
123 }
124
125 return true;
126}