• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KNewStuff

xmlloader.cpp

Go to the documentation of this file.
00001 /*
00002     knewstuff3/xmlloader.cpp.
00003     Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
00004     Copyright (c) 2003 - 2007 Josef Spillner <spillner@kde.org>
00005     Copyright (c) 2009 Jeremy Whiting <jpwhiting@kde.org>
00006     Copyright (C) 2010 Frederik Gladhorn <gladhorn@kde.org>
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2.1 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00020 */
00021 
00022 #include "xmlloader.h"
00023 
00024 #include <QtCore/QByteArray>
00025 
00026 #include <kconfig.h>
00027 #include <kdebug.h>
00028 #include <kio/job.h>
00029 #include <klocale.h>
00030 
00031 namespace KNS3
00032 {
00033 
00034     XmlLoader::XmlLoader(QObject* parent)
00035             : QObject(parent)
00036     {
00037     }
00038 
00039     void XmlLoader::load(const KUrl &url)
00040     {
00041         m_jobdata.clear();
00042 
00043         kDebug(550) << "XmlLoader::load(): url: " << url;
00044 
00045         KIO::TransferJob *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
00046         connect(job, SIGNAL(result(KJob *)),
00047                 SLOT(slotJobResult(KJob *)));
00048         connect(job, SIGNAL(data(KIO::Job *, const QByteArray &)),
00049                 SLOT(slotJobData(KIO::Job *, const QByteArray &)));
00050     
00051         emit jobStarted(job);
00052     }
00053 
00054     void XmlLoader::slotJobData(KIO::Job *, const QByteArray &data)
00055     {
00056         kDebug(550) << "XmlLoader::slotJobData()";
00057 
00058         m_jobdata.append(data);
00059     }
00060 
00061     void XmlLoader::slotJobResult(KJob *job)
00062     {
00063         if (job->error()) {
00064             emit signalFailed();
00065             return;
00066         }
00067 /*
00068         kDebug(550) << "--Xml Loader-START--";
00069         kDebug(550) << QString::fromUtf8(m_jobdata);
00070         kDebug(550) << "--Xml Loader-END--";
00071 */
00072         QDomDocument doc;
00073         if (!doc.setContent(m_jobdata)) {
00074             emit signalFailed();
00075             return;
00076         }
00077         emit signalLoaded(doc);
00078     }
00079 
00080     QDomElement addElement(QDomDocument& doc, QDomElement& parent,
00081                                          const QString& tag, const QString& value)
00082     {
00083         QDomElement n = doc.createElement(tag);
00084         n.appendChild(doc.createTextNode(value));
00085         parent.appendChild(n);
00086 
00087         return n;
00088     }
00089 } // end KNS namespace
00090 
00091 #include "xmlloader.moc"

KNewStuff

Skip menu "KNewStuff"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal