1 /* This file is part of the KDE Edu Library
2 Copyright (C) 2002 Scott Wheeler <wheeler@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA.
19 #include "keduvocdata.h"
25 ////////////////////////////////////////////////////////////////////////////////
26 // class KEduVocDataItem
27 ////////////////////////////////////////////////////////////////////////////////
31 KEduVocDataItem::KEduVocDataItem()
36 KEduVocDataItem::KEduVocDataItem(QDomElement
&entry
)
41 KEduVocDataItem::~KEduVocDataItem()
46 QString
KEduVocDataItem::originalText() const
51 QString
KEduVocDataItem::translatedText() const
58 QString
KEduVocDataItem::getText(const QString
&tagName
) const
60 if(!domElement
.isNull()) {
62 QDomNodeList list
= domElement
.elementsByTagName(tagName
);
64 if(list
.count() > 0) {
66 QDomElement element
= list
.item(0).toElement();
68 if(!element
.isNull()) {
69 return element
.text();
81 ////////////////////////////////////////////////////////////////////////////////
83 ////////////////////////////////////////////////////////////////////////////////
87 \fn KEduVocData::KEduVocData
89 KEduVocData::KEduVocData()
91 document
= new QDomDocument();
94 KEduVocDataItemList
KEduVocData::parse(const QString
&fileName
)
96 KEduVocDataItemList list
;
98 //QDomDocument document;
100 document
->setContent(&file
);
102 QDomNodeList entries
= document
->elementsByTagName("e");
104 // loop through the "e" (entry) tags looking for data
105 for(uint i
= 0 ; i
< entries
.count() ; i
++) {
107 // get an entry to operate on
108 QDomElement entry
= entries
.item(i
).toElement();
110 // if the "node" is in fact an element -- i.e. not null
111 if(!entry
.isNull()) {
112 KEduVocDataItem
item(entry
);
122 \fn KEduVocData::colWidth(int col)
124 int KEduVocData::colWidth(int col
)
126 if (!document
->isNull())
128 return document
-> documentElement().namedItem("e").namedItem("o").toElement().attribute("width", "250").toInt();
130 return document
-> documentElement().namedItem("e").namedItem("t").toElement().attribute("width", "250").toInt();
137 \fn KEduVocData::numRows()
139 int KEduVocData::numRows()
141 if (!document
->isNull())
142 return document
->documentElement().attribute("lines", "0").toInt();
149 \fn KEduVocData::language(int col)
151 QString
KEduVocData::language(int col
)
153 if (!document
->isNull())
155 return document
-> documentElement().namedItem("e").namedItem("o").toElement().attribute("l");
157 return document
-> documentElement().namedItem("e").namedItem("t").toElement().attribute("l");
159 return QString::null
;