You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
2.7 KiB
112 lines
2.7 KiB
15 years ago
|
/* This file is part of the KDE Edu Library
|
||
|
Copyright (C) 2002 Scott Wheeler <wheeler@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2 as published by the Free Software Foundation.
|
||
|
|
||
|
This library 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
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "keduvocdata.h"
|
||
|
|
||
15 years ago
|
#include <tqfile.h>
|
||
15 years ago
|
|
||
|
#include <kdebug.h>
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
// class KEduVocDataItem
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
// public methods
|
||
|
|
||
|
KEduVocDataItem::KEduVocDataItem()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
15 years ago
|
KEduVocDataItem::KEduVocDataItem(TQDomElement &entry)
|
||
15 years ago
|
{
|
||
|
domElement = entry;
|
||
|
}
|
||
|
|
||
|
KEduVocDataItem::~KEduVocDataItem()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KEduVocDataItem::originalText() const
|
||
15 years ago
|
{
|
||
|
return getText("o");
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KEduVocDataItem::translatedText() const
|
||
15 years ago
|
{
|
||
|
return getText("t");
|
||
|
}
|
||
|
|
||
|
// protected methods
|
||
|
|
||
15 years ago
|
TQString KEduVocDataItem::getText(const TQString &tagName) const
|
||
15 years ago
|
{
|
||
|
if(!domElement.isNull()) {
|
||
|
|
||
15 years ago
|
TQDomNodeList list = domElement.elementsByTagName(tagName);
|
||
15 years ago
|
|
||
|
if(list.count() > 0) {
|
||
|
|
||
15 years ago
|
TQDomElement element = list.item(0).toElement();
|
||
15 years ago
|
|
||
|
if(!element.isNull()) {
|
||
|
return element.text();
|
||
|
}
|
||
|
else
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
else
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
else
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
// class KEduVocData
|
||
|
////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
// public static methods
|
||
|
|
||
15 years ago
|
KEduVocDataItemList KEduVocData::parse(const TQString &fileName)
|
||
15 years ago
|
{
|
||
|
KEduVocDataItemList list;
|
||
|
|
||
15 years ago
|
TQDomDocument document;
|
||
|
TQFile file(fileName);
|
||
15 years ago
|
document.setContent(&file);
|
||
|
|
||
15 years ago
|
TQDomNodeList entries = document.elementsByTagName("e");
|
||
15 years ago
|
|
||
|
// loop through the "e" (entry) tags looking for data
|
||
|
for(uint i = 0 ; i < entries.count() ; i++) {
|
||
|
|
||
|
// get an entry to operate on
|
||
15 years ago
|
TQDomElement entry = entries.item(i).toElement();
|
||
15 years ago
|
|
||
|
// if the "node" is in fact an element -- i.e. not null
|
||
|
if(!entry.isNull()) {
|
||
|
KEduVocDataItem item(entry);
|
||
|
list.append(item);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return list;
|
||
|
}
|