summaryrefslogtreecommitdiffstats
path: root/kivio/kiviopart/kiviosdk/kivio_stencil_spawner_info.cpp
blob: 730e07ca38c3c3afff09354cba245b05c268d99c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * Kivio - Visual Modelling and Flowcharting
 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#include "kivio_stencil_spawner_info.h"
#include <tqdom.h>

#include <kglobal.h>
#include <klocale.h>

KivioStencilSpawnerInfo::KivioStencilSpawnerInfo()
{
    m_author = "Joe Bob";
    m_title  = "Untitled";
    m_id = "";
    m_desc   = "No desc";
    m_version = "1.0";
    m_web    = "http://kivio.sourceforge.net";
    m_email  = "landshark@ameritech.net";
    m_autoUpdate = "";
}

KivioStencilSpawnerInfo::~KivioStencilSpawnerInfo()
{
}

KivioStencilSpawnerInfo::KivioStencilSpawnerInfo( const TQString &auth, const TQString &tit, const TQString &_id, const TQString &des, const TQString &ver, const TQString &wb,
                                            const TQString &em, const TQString &au )
{
    m_author = auth;
    m_title = tit;
    m_id = _id;
    m_desc = des;
    m_version = ver;
    m_web = wb;
    m_email = em;
    m_autoUpdate = au;
}

bool KivioStencilSpawnerInfo::loadXML( const TQDomElement &e )
{
  TQDomNode node;
  TQDomElement nodeElement;
  TQString nodeName, origTitle, origDesc;
  m_title = "";
  m_desc = "";

  node = e.firstChild();
  while(!node.isNull())
  {
    nodeName = node.nodeName();

    nodeElement = node.toElement();

    if( nodeName.compare("Author")==0 )
    {
      m_author = nodeElement.attribute("data");
    }
    else if((nodeName.compare("Title")==0) && nodeElement.hasAttribute("lang"))
    {
      if(nodeElement.attribute("lang") == KGlobal::locale()->language()) {
        m_title = nodeElement.attribute("data");
      }
    }
    else if((nodeName.compare("Title")==0) && !nodeElement.hasAttribute("lang"))
    {
      origTitle = nodeElement.attribute("data");
    }
    else if( nodeName.compare("Id")==0 )
    {
      m_id = nodeElement.attribute("data");
    }
    else if((nodeName.compare("Description")==0) && nodeElement.hasAttribute("lang"))
    {
      if(nodeElement.attribute("lang") == KGlobal::locale()->language()) {
        m_desc = nodeElement.attribute("data");
      }
    }
    else if((nodeName.compare("Description")==0) && !nodeElement.hasAttribute("lang"))
    {
      origDesc = nodeElement.attribute("data");
    }
    else if( nodeName.compare("Version")==0 )
    {
      m_version = nodeElement.attribute("data");
    }
    else if( nodeName.compare("Web")==0 )
    {
      m_web = nodeElement.attribute("data");
    }
    else if( nodeName.compare("Email")==0 )
    {
      m_email = nodeElement.attribute("data");
    }
    else if( nodeName.compare("AutoUpdate")==0 )
    {
      m_autoUpdate = nodeElement.attribute("data");
    }
    
    if(m_title.isEmpty()) {
      m_title = i18n( "Stencils", origTitle.utf8());
    }
    
    if(m_desc.isEmpty()) {
      m_desc = i18n( "Stencils", origDesc.utf8());
    }

    node = node.nextSibling();
  }

  return true;
}