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

KNewStuff

  • sources
  • kde-4.12
  • kdelibs
  • knewstuff
  • knewstuff3
  • core
xmlloader.cpp
Go to the documentation of this file.
1 /*
2  knewstuff3/xmlloader.cpp.
3  Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4  Copyright (c) 2003 - 2007 Josef Spillner <spillner@kde.org>
5  Copyright (c) 2009 Jeremy Whiting <jpwhiting@kde.org>
6  Copyright (C) 2010 Frederik Gladhorn <gladhorn@kde.org>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include "xmlloader.h"
23 
24 #include <QtCore/QByteArray>
25 
26 #include <kconfig.h>
27 #include <kdebug.h>
28 #include <kio/job.h>
29 #include <klocale.h>
30 
31 namespace KNS3
32 {
33 
34  XmlLoader::XmlLoader(QObject* parent)
35  : QObject(parent)
36  {
37  }
38 
39  void XmlLoader::load(const KUrl &url)
40  {
41  m_jobdata.clear();
42 
43  kDebug(550) << "XmlLoader::load(): url: " << url;
44 
45  KIO::TransferJob *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
46  connect(job, SIGNAL(result(KJob*)),
47  SLOT(slotJobResult(KJob*)));
48  connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
49  SLOT(slotJobData(KIO::Job*,QByteArray)));
50 
51  emit jobStarted(job);
52  }
53 
54  void XmlLoader::slotJobData(KIO::Job *, const QByteArray &data)
55  {
56  kDebug(550) << "XmlLoader::slotJobData()";
57 
58  m_jobdata.append(data);
59  }
60 
61  void XmlLoader::slotJobResult(KJob *job)
62  {
63  if (job->error()) {
64  emit signalFailed();
65  return;
66  }
67 /*
68  kDebug(550) << "--Xml Loader-START--";
69  kDebug(550) << QString::fromUtf8(m_jobdata);
70  kDebug(550) << "--Xml Loader-END--";
71 */
72  QDomDocument doc;
73  if (!doc.setContent(m_jobdata)) {
74  emit signalFailed();
75  return;
76  }
77  emit signalLoaded(doc);
78  }
79 
80  QDomElement addElement(QDomDocument& doc, QDomElement& parent,
81  const QString& tag, const QString& value)
82  {
83  QDomElement n = doc.createElement(tag);
84  n.appendChild(doc.createTextNode(value));
85  parent.appendChild(n);
86 
87  return n;
88  }
89 } // end KNS namespace
90 
91 #include "xmlloader.moc"
KNS3::XmlLoader::signalLoaded
void signalLoaded(const QDomDocument &)
Indicates that the list of providers has been successfully loaded.
kdebug.h
KIO::HideProgressInfo
kconfig.h
KNS3::XmlLoader::load
void load(const KUrl &url)
Starts asynchronously loading the xml document from the specified URL.
Definition: xmlloader.cpp:39
KIO::get
TransferJob * get(const KUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
QString
QObject
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
klocale.h
xmlloader.h
KNS3::XmlLoader::slotJobResult
void slotJobResult(KJob *)
Definition: xmlloader.cpp:61
KUrl
KNS3::addElement
QDomElement addElement(QDomDocument &doc, QDomElement &parent, const QString &tag, const QString &value)
Definition: xmlloader.cpp:80
job.h
KIO::Job
KIO::NoReload
KNS3::XmlLoader::signalFailed
void signalFailed()
KIO::TransferJob
KNS3::XmlLoader::jobStarted
void jobStarted(KJob *)
KNS3::XmlLoader::slotJobData
void slotJobData(KIO::Job *, const QByteArray &)
Definition: xmlloader.cpp:54
KJob
KNS3::XmlLoader::XmlLoader
XmlLoader(QObject *parent)
Constructor.
Definition: xmlloader.cpp:34
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KNewStuff

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal