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 ////////////////////////////////////////////////////////////////////////////////
85 // public static methods
87 KEduVocDataItemList
KEduVocData::parse(const QString
&fileName
)
89 KEduVocDataItemList list
;
91 QDomDocument document
;
93 document
.setContent(&file
);
95 QDomNodeList entries
= document
.elementsByTagName("e");
97 // loop through the "e" (entry) tags looking for data
98 for(uint i
= 0 ; i
< entries
.count() ; i
++) {
100 // get an entry to operate on
101 QDomElement entry
= entries
.item(i
).toElement();
103 // if the "node" is in fact an element -- i.e. not null
104 if(!entry
.isNull()) {
105 KEduVocDataItem
item(entry
);