superkaramba
Go to the documentation of this file.
13 #include <QDomDocument>
18 #include <kio/netaccess.h>
31 if (!encoding.isEmpty()) {
32 codec = QTextCodec::codecForName(encoding.toAscii().constData());
34 codec = QTextCodec::codecForLocale();
36 codec = QTextCodec::codecForLocale();
49 if (KIO::NetAccess::download(KUrl(source), tmpFile, 0)) {
50 file.setFileName(tmpFile);
51 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
52 if (doc.setContent(&file)) {
55 qDebug(
"Error on building DOM");
58 qDebug(
"Error opening file");
61 qDebug(
"Error Downloading: %s", source.toAscii().constData());
77 QDomElement docElem = doc.documentElement();
78 QDomNode n = docElem.firstChild();
80 QDomNodeList links = docElem.elementsByTagName(
"link");
81 QDomNodeList displays;
82 if (format.contains(
"%d", Qt::CaseInsensitive) > 0) {
83 displays = docElem.elementsByTagName(
"description");
85 displays = docElem.elementsByTagName(
"title");
88 QRegExp rx(
"^http://", Qt::CaseInsensitive);
89 for (
int i = 1; i < displays.count(); ++i) {
90 QString dispTxt = displays.item(i).toElement().text();
91 QString linkTxt = links.item(i).toElement().text();
92 if ((rx.indexIn(dispTxt) == -1) && (rx.indexIn(linkTxt) != -1)) {
100 qDebug(
"Document Node was null!!");
106 KIO::NetAccess::removeTempFile(tmpFile);
virtual void setValue(int)
QList< QObject * > * objList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:20 by
doxygen 1.8.7 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.