summaryrefslogtreecommitdiffstats
path: root/lib/util/domutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util/domutil.cpp')
-rw-r--r--lib/util/domutil.cpp156
1 files changed, 78 insertions, 78 deletions
diff --git a/lib/util/domutil.cpp b/lib/util/domutil.cpp
index b183717f..9f5d40c9 100644
--- a/lib/util/domutil.cpp
+++ b/lib/util/domutil.cpp
@@ -15,23 +15,23 @@
#include "domutil.h"
#include <kdebug.h>
-#include <qstringlist.h>
-#include <qfile.h>
+#include <tqstringlist.h>
+#include <tqfile.h>
-void DomUtil::makeEmpty( QDomElement& e )
+void DomUtil::makeEmpty( TQDomElement& e )
{
while( !e.firstChild().isNull() )
e.removeChild( e.firstChild() );
}
-QDomElement DomUtil::elementByPath(const QDomDocument &doc, const QString &path)
+TQDomElement DomUtil::elementByPath(const TQDomDocument &doc, const TQString &path)
{
- QStringList l = QStringList::split('/', path);
+ TQStringList l = TQStringList::split('/', path);
- QDomElement el;
+ TQDomElement el;
if(&doc) el = doc.documentElement();
- QStringList::ConstIterator it;
+ TQStringList::ConstIterator it;
for (it = l.begin(); it != l.end(); ++it) {
el = el.namedItem(*it).toElement();
}
@@ -40,9 +40,9 @@ QDomElement DomUtil::elementByPath(const QDomDocument &doc, const QString &path)
}
-QString DomUtil::readEntry(const QDomDocument &doc, const QString &path, const QString &defaultEntry)
+TQString DomUtil::readEntry(const TQDomDocument &doc, const TQString &path, const TQString &defaultEntry)
{
- QDomElement el = elementByPath(doc, path);
+ TQDomElement el = elementByPath(doc, path);
if (el.isNull())
return defaultEntry;
else
@@ -51,20 +51,20 @@ QString DomUtil::readEntry(const QDomDocument &doc, const QString &path, const Q
/// @todo consider whether it's okay to accept empty string == default value
/// if not use the below type
-///typedef pair<bool,QString> EltInfo;
+///typedef pair<bool,TQString> EltInfo;
-QString DomUtil::readEntryAux(const QDomDocument &doc, const QString &path)
+TQString DomUtil::readEntryAux(const TQDomDocument &doc, const TQString &path)
{
- QDomElement el = elementByPath(doc, path);
+ TQDomElement el = elementByPath(doc, path);
if (el.isNull())
- return QString::null;
+ return TQString::null;
else
return el.firstChild().toText().data();
}
-int DomUtil::readIntEntry(const QDomDocument &doc, const QString &path, int defaultEntry)
+int DomUtil::readIntEntry(const TQDomDocument &doc, const TQString &path, int defaultEntry)
{
- QString entry = readEntryAux(doc, path);
+ TQString entry = readEntryAux(doc, path);
if (entry.isNull())
return defaultEntry;
else
@@ -72,9 +72,9 @@ int DomUtil::readIntEntry(const QDomDocument &doc, const QString &path, int defa
}
-bool DomUtil::readBoolEntry(const QDomDocument &doc, const QString &path, bool defaultEntry)
+bool DomUtil::readBoolEntry(const TQDomDocument &doc, const TQString &path, bool defaultEntry)
{
- QString entry = readEntryAux(doc, path);
+ TQString entry = readEntryAux(doc, path);
if (entry.isNull())
return defaultEntry;
else
@@ -82,12 +82,12 @@ bool DomUtil::readBoolEntry(const QDomDocument &doc, const QString &path, bool d
}
-QStringList DomUtil::readListEntry(const QDomDocument &doc, const QString &path, const QString &tag)
+TQStringList DomUtil::readListEntry(const TQDomDocument &doc, const TQString &path, const TQString &tag)
{
- QStringList list;
+ TQStringList list;
- QDomElement el = elementByPath(doc, path);
- QDomElement subEl = el.firstChild().toElement();
+ TQDomElement el = elementByPath(doc, path);
+ TQDomElement subEl = el.firstChild().toElement();
while (!subEl.isNull()) {
if (subEl.tagName() == tag)
list << subEl.firstChild().toText().data();
@@ -98,17 +98,17 @@ QStringList DomUtil::readListEntry(const QDomDocument &doc, const QString &path,
}
-DomUtil::PairList DomUtil::readPairListEntry(const QDomDocument &doc, const QString &path, const QString &tag,
- const QString &firstAttr, const QString &secondAttr)
+DomUtil::PairList DomUtil::readPairListEntry(const TQDomDocument &doc, const TQString &path, const TQString &tag,
+ const TQString &firstAttr, const TQString &secondAttr)
{
PairList list;
- QDomElement el = elementByPath(doc, path);
- QDomElement subEl = el.firstChild().toElement();
+ TQDomElement el = elementByPath(doc, path);
+ TQDomElement subEl = el.firstChild().toElement();
while (!subEl.isNull()) {
if (subEl.tagName() == tag) {
- QString first = subEl.attribute(firstAttr);
- QString second = subEl.attribute(secondAttr);
+ TQString first = subEl.attribute(firstAttr);
+ TQString second = subEl.attribute(secondAttr);
list << Pair(first, second);
}
subEl = subEl.nextSibling().toElement();
@@ -117,12 +117,12 @@ DomUtil::PairList DomUtil::readPairListEntry(const QDomDocument &doc, const QStr
return list;
}
-QMap<QString, QString> DomUtil::readMapEntry(const QDomDocument &doc, const QString& path)
+TQMap<TQString, TQString> DomUtil::readMapEntry(const TQDomDocument &doc, const TQString& path)
{
- QMap<QString, QString> map;
+ TQMap<TQString, TQString> map;
- QDomElement el = elementByPath(doc, path);
- QDomElement subEl = el.firstChild().toElement();
+ TQDomElement el = elementByPath(doc, path);
+ TQDomElement subEl = el.firstChild().toElement();
while (!subEl.isNull()) {
map[subEl.tagName()] = subEl.firstChild().toText().data();
subEl = subEl.nextSibling().toElement();
@@ -131,9 +131,9 @@ QMap<QString, QString> DomUtil::readMapEntry(const QDomDocument &doc, const QStr
return map;
}
-QDomElement DomUtil::namedChildElement( QDomElement& el, const QString& name )
+TQDomElement DomUtil::namedChildElement( TQDomElement& el, const TQString& name )
{
- QDomElement child = el.namedItem( name ).toElement();
+ TQDomElement child = el.namedItem( name ).toElement();
if (child.isNull()) {
child = el.ownerDocument().createElement( name );
el.appendChild(child);
@@ -142,13 +142,13 @@ QDomElement DomUtil::namedChildElement( QDomElement& el, const QString& name )
}
-QDomElement DomUtil::createElementByPath(QDomDocument &doc, const QString &path)
+TQDomElement DomUtil::createElementByPath(TQDomDocument &doc, const TQString &path)
{
- QStringList l = QStringList::split('/', path);
+ TQStringList l = TQStringList::split('/', path);
- QDomElement el;
+ TQDomElement el;
if(&doc) el = doc.documentElement();
- QStringList::ConstIterator it;
+ TQStringList::ConstIterator it;
for (it = l.begin(); it != l.end(); ++it)
el = DomUtil::namedChildElement( el, *it );
@@ -159,16 +159,16 @@ QDomElement DomUtil::createElementByPath(QDomDocument &doc, const QString &path)
}
-void DomUtil::writeEntry(QDomDocument &doc, const QString &path, const QString &value)
+void DomUtil::writeEntry(TQDomDocument &doc, const TQString &path, const TQString &value)
{
- QDomElement el = createElementByPath(doc, path);
+ TQDomElement el = createElementByPath(doc, path);
el.appendChild(doc.createTextNode(value));
}
-void DomUtil::writeMapEntry(QDomDocument &doc, const QString &path, const QMap<QString, QString> &map)
+void DomUtil::writeMapEntry(TQDomDocument &doc, const TQString &path, const TQMap<TQString, TQString> &map)
{
- QString basePath( path + "/" );
- QMap<QString,QString>::ConstIterator it;
+ TQString basePath( path + "/" );
+ TQMap<TQString,TQString>::ConstIterator it;
for (it = map.begin(); it != map.end(); ++it)
{
kdDebug( 9010 ) << "writing " << basePath << ";" << it.key() << ";" << it.data() << endl;
@@ -177,65 +177,65 @@ void DomUtil::writeMapEntry(QDomDocument &doc, const QString &path, const QMap<Q
}
}
-void DomUtil::writeIntEntry(QDomDocument &doc, const QString &path, int value)
+void DomUtil::writeIntEntry(TQDomDocument &doc, const TQString &path, int value)
{
- writeEntry(doc, path, QString::number(value));
+ writeEntry(doc, path, TQString::number(value));
}
-void DomUtil::writeBoolEntry(QDomDocument &doc, const QString &path, bool value)
+void DomUtil::writeBoolEntry(TQDomDocument &doc, const TQString &path, bool value)
{
writeEntry(doc, path, value? "true" : "false");
}
-void DomUtil::writeListEntry(QDomDocument &doc, const QString &path, const QString &tag,
- const QStringList &value)
+void DomUtil::writeListEntry(TQDomDocument &doc, const TQString &path, const TQString &tag,
+ const TQStringList &value)
{
- QDomElement el = createElementByPath(doc, path);
+ TQDomElement el = createElementByPath(doc, path);
- QStringList::ConstIterator it;
+ TQStringList::ConstIterator it;
for (it = value.begin(); it != value.end(); ++it) {
- QDomElement subEl = doc.createElement(tag);
+ TQDomElement subEl = doc.createElement(tag);
subEl.appendChild(doc.createTextNode(*it));
el.appendChild(subEl);
}
}
-void DomUtil::writePairListEntry(QDomDocument &doc, const QString &path, const QString &tag,
- const QString &firstAttr, const QString &secondAttr,
+void DomUtil::writePairListEntry(TQDomDocument &doc, const TQString &path, const TQString &tag,
+ const TQString &firstAttr, const TQString &secondAttr,
const PairList &value)
{
- QDomElement el = createElementByPath(doc, path);
+ TQDomElement el = createElementByPath(doc, path);
PairList::ConstIterator it;
for (it = value.begin(); it != value.end(); ++it) {
- QDomElement subEl = doc.createElement(tag);
+ TQDomElement subEl = doc.createElement(tag);
subEl.setAttribute(firstAttr, (*it).first);
subEl.setAttribute(secondAttr, (*it).second);
el.appendChild(subEl);
}
}
-DomPath DomUtil::resolvPathStringExt(const QString pathstring)
+DomPath DomUtil::resolvPathStringExt(const TQString pathstring)
{
// parse path
unsigned int i;
- QStringList pathParts = QStringList::split('/',pathstring);
+ TQStringList pathParts = TQStringList::split('/',pathstring);
DomPath dompath;
for (i=0; i<pathParts.count(); i++)
{
- QStringList pathElemParts = QStringList::split('|',pathParts[i],TRUE);
+ TQStringList pathElemParts = TQStringList::split('|',pathParts[i],TRUE);
DomPathElement dompathelem;
dompathelem.tagName = pathElemParts[0].simplifyWhiteSpace();
if (pathElemParts.count()>1)
{
// handle attributes
- QStringList attrParts = QStringList::split(';',pathElemParts[1]);
+ TQStringList attrParts = TQStringList::split(';',pathElemParts[1]);
for (unsigned int j=0; j<attrParts.count(); j++)
{
- QStringList attribSet = QStringList::split('=',attrParts[j]);
+ TQStringList attribSet = TQStringList::split('=',attrParts[j]);
if (attribSet.count()<2)
continue;
DomAttribute domattribute;
@@ -256,12 +256,12 @@ DomPath DomUtil::resolvPathStringExt(const QString pathstring)
#define rightchild !wrongchild
-QDomElement DomUtil::elementByPathExt(QDomDocument &doc, const QString &pathstring)
+TQDomElement DomUtil::elementByPathExt(TQDomDocument &doc, const TQString &pathstring)
{
DomPath dompath = resolvPathStringExt(pathstring);
- QDomElement elem = doc.documentElement();
- QDomNodeList children;
- QDomElement nextElem = elem;
+ TQDomElement elem = doc.documentElement();
+ TQDomNodeList children;
+ TQDomElement nextElem = elem;
for (unsigned int j=0; j<dompath.count(); j++)
{
children = nextElem.childNodes();
@@ -271,15 +271,15 @@ QDomElement DomUtil::elementByPathExt(QDomDocument &doc, const QString &pathstri
for (unsigned int i=0; i<children.count(); i++)
{
wrongchild = false;
- QDomElement child = children.item(i).toElement();
- QString tag = child.tagName();
+ TQDomElement child = children.item(i).toElement();
+ TQString tag = child.tagName();
tag = dompathelement.tagName;
if (child.tagName() == dompathelement.tagName)
{
for (unsigned int k=0; k<dompathelement.attribute.count(); k++)
{
DomAttribute domattribute = dompathelement.attribute[k];
- QDomAttr domattr = child.attributeNode(domattribute.name);
+ TQDomAttr domattr = child.attributeNode(domattribute.name);
if (domattr.isNull() ||
domattr.value() != domattribute.value)
{
@@ -301,7 +301,7 @@ QDomElement DomUtil::elementByPathExt(QDomDocument &doc, const QString &pathstri
}
if (wrongchild)
{
- QDomElement nullDummy;
+ TQDomElement nullDummy;
nullDummy.clear();
return nullDummy;
}
@@ -310,9 +310,9 @@ QDomElement DomUtil::elementByPathExt(QDomDocument &doc, const QString &pathstri
}
-bool DomUtil::openDOMFile(QDomDocument &doc, QString filename)
+bool DomUtil::openDOMFile(TQDomDocument &doc, TQString filename)
{
- QFile file( filename );
+ TQFile file( filename );
if ( !file.open( IO_ReadOnly ) )
return false;
if ( !doc.setContent( &file ) ) {
@@ -323,23 +323,23 @@ bool DomUtil::openDOMFile(QDomDocument &doc, QString filename)
return true;
}
-bool DomUtil::saveDOMFile(QDomDocument &doc, QString filename)
+bool DomUtil::saveDOMFile(TQDomDocument &doc, TQString filename)
{
- QFile file( filename );
+ TQFile file( filename );
if ( !file.open( IO_ReadWrite | IO_Truncate ) )
return false;
- QTextStream t( &file );
+ TQTextStream t( &file );
t << doc.toString();
file.close();
return true;
}
-bool DomUtil::removeTextNodes(QDomDocument doc,QString pathExt)
+bool DomUtil::removeTextNodes(TQDomDocument doc,TQString pathExt)
{
- QDomElement elem = elementByPathExt(doc,pathExt);
+ TQDomElement elem = elementByPathExt(doc,pathExt);
if (elem.isNull())
return false;
- QDomNodeList children = elem.childNodes();
+ TQDomNodeList children = elem.childNodes();
for (unsigned int i=0;i<children.count();i++)
if (children.item(i).isText())
elem.removeChild(children.item(i));
@@ -347,9 +347,9 @@ bool DomUtil::removeTextNodes(QDomDocument doc,QString pathExt)
}
-bool DomUtil::appendText(QDomDocument doc, QString pathExt, QString text)
+bool DomUtil::appendText(TQDomDocument doc, TQString pathExt, TQString text)
{
- QDomElement elem = elementByPathExt(doc,pathExt);
+ TQDomElement elem = elementByPathExt(doc,pathExt);
if (elem.isNull())
return false;
elem.appendChild(doc.createTextNode(text));
@@ -357,7 +357,7 @@ bool DomUtil::appendText(QDomDocument doc, QString pathExt, QString text)
}
-bool DomUtil::replaceText(QDomDocument doc, QString pathExt, QString text)
+bool DomUtil::replaceText(TQDomDocument doc, TQString pathExt, TQString text)
{
if (removeTextNodes(doc,pathExt) &&
appendText(doc,pathExt,text))