• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.8.3 API Reference
  • KDE Home
  • Contact Us
 

syndication/atom

source.cpp
00001 /*
00002  * This file is part of the syndication library
00003  *
00004  * Copyright (C) 2006 Frank Osterfeld <osterfeld@kde.org>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "source.h"
00024 #include "category.h"
00025 #include "constants.h"
00026 #include "generator.h"
00027 #include "link.h"
00028 #include "person.h"
00029 #include "atomtools.h"
00030 
00031 #include <tools.h>
00032 
00033 #include <QtXml/QDomElement>
00034 #include <QtCore/QList>
00035 #include <QtCore/QString>
00036 
00037 namespace Syndication {
00038 namespace Atom {
00039 
00040 Source::Source() : ElementWrapper()
00041 {
00042 }
00043 
00044 Source::Source(const QDomElement& element) : ElementWrapper(element)
00045 {
00046 }
00047 
00048 QList<Person> Source::authors() const
00049 {
00050     QList<QDomElement> a = 
00051             elementsByTagNameNS(atom1Namespace(),
00052                                 QLatin1String("author"));
00053     QList<Person> list;
00054                                        
00055     QList<QDomElement>::ConstIterator it = a.constBegin();
00056     QList<QDomElement>::ConstIterator end = a.constEnd();
00057     
00058     
00059     for ( ; it != end; ++it)
00060     {
00061         list.append(Person(*it));
00062     }
00063         
00064     return list;
00065 }
00066 
00067 QList<Person> Source::contributors() const
00068 {
00069         QList<QDomElement> a = 
00070                 elementsByTagNameNS(atom1Namespace(),
00071                                     QLatin1String("contributor"));
00072     QList<Person> list;
00073                                        
00074     QList<QDomElement>::ConstIterator it = a.constBegin();
00075     QList<QDomElement>::ConstIterator end = a.constEnd();
00076     
00077     
00078     for ( ; it != end; ++it)
00079     {
00080         list.append(Person(*it));
00081     }
00082         
00083     return list;
00084 }
00085 
00086 QList<Category> Source::categories() const
00087 {
00088     QList<QDomElement> a = 
00089             elementsByTagNameNS(atom1Namespace(),
00090                                 QLatin1String("category"));
00091     QList<Category> list;
00092     
00093     QList<QDomElement>::ConstIterator it = a.constBegin();
00094     QList<QDomElement>::ConstIterator end = a.constEnd();
00095 
00096 
00097     for ( ; it != end; ++it)
00098     {
00099         list.append(Category(*it));
00100     }
00101 
00102     return list;
00103 }
00104 
00105 Generator Source::generator() const
00106 {
00107     return Generator(firstElementByTagNameNS(atom1Namespace(),
00108                      QLatin1String("generator")));
00109 }
00110 
00111 QString Source::icon() const
00112 {
00113     return extractElementTextNS(atom1Namespace(),
00114                                 QLatin1String("icon"));
00115 }
00116 
00117 QString Source::id() const
00118 {
00119     return extractElementTextNS(atom1Namespace(),
00120                                 QLatin1String("id"));
00121 }
00122 
00123 QList<Link> Source::links() const
00124 {
00125     QList<QDomElement> a = 
00126             elementsByTagNameNS(atom1Namespace(),
00127                                 QLatin1String("link"));
00128     QList<Link> list;
00129 
00130     QList<QDomElement>::ConstIterator it = a.constBegin();
00131     QList<QDomElement>::ConstIterator end = a.constEnd();
00132 
00133 
00134     for ( ; it != end; ++it)
00135     {
00136         list.append(Link(*it));
00137     }
00138 
00139     return list;
00140 }
00141 
00142 QString Source::logo() const
00143 {
00144     return extractElementTextNS(atom1Namespace(),
00145                                 QLatin1String("logo"));
00146 }
00147 
00148 QString Source::rights() const
00149 {
00150     return extractAtomText(*this, QLatin1String("rights"));
00151 }
00152 
00153 QString Source::subtitle() const
00154 {
00155     return extractAtomText(*this, QLatin1String("subtitle"));
00156 }
00157 
00158 QString Source::title() const
00159 {
00160     return extractAtomText(*this, QLatin1String("title"));
00161 }
00162 
00163 time_t Source::updated() const
00164 {
00165     QString upd = extractElementTextNS(atom1Namespace(),
00166                                        QLatin1String("updated"));
00167     return parseDate(upd, ISODate);
00168 }
00169 
00170 QString Source::debugInfo() const
00171 {
00172     QString info;
00173     info += QLatin1String("### Source: ###################\n");
00174     if (!title().isEmpty())
00175         info += QLatin1String("title: #") + title() + QLatin1String("#\n");
00176     if (!subtitle().isEmpty())
00177         info += QLatin1String("subtitle: #") + subtitle() + QLatin1String("#\n");
00178     if (!id().isEmpty())
00179         info += QLatin1String("id: #") + id() + QLatin1String("#\n");
00180 
00181     if (!rights().isEmpty())
00182         info += QLatin1String("rights: #") + rights() + QLatin1String("#\n");
00183     if (!icon().isEmpty())
00184         info += QLatin1String("icon: #") + icon() + QLatin1String("#\n");
00185     if (!logo().isEmpty())
00186         info += QLatin1String("logo: #") + logo() + QLatin1String("#\n");
00187     if (!generator().isNull())
00188         info += generator().debugInfo();
00189     
00190     
00191     QString dupdated = dateTimeToString(updated());
00192     if (!dupdated.isNull())
00193         info += QLatin1String("updated: #") + dupdated + QLatin1String("#\n");
00194     
00195     QList<Link> dlinks = links();
00196     QList<Link>::ConstIterator endlinks = dlinks.constEnd();
00197     for (QList<Link>::ConstIterator it = dlinks.constBegin(); it != endlinks; ++it)
00198         info += (*it).debugInfo();
00199     
00200     QList<Category> dcats = categories();
00201     QList<Category>::ConstIterator endcats = dcats.constEnd();
00202     for (QList<Category>::ConstIterator it = dcats.constBegin(); it != endcats; ++it)
00203         info += (*it).debugInfo();
00204 
00205     info += QLatin1String("### Authors: ###################\n");
00206     
00207     QList<Person> dauthors = authors();
00208     QList<Person>::ConstIterator endauthors = dauthors.constEnd();
00209     for (QList<Person>::ConstIterator it = dauthors.constBegin(); it != endauthors; ++it)
00210         info += (*it).debugInfo();
00211 
00212     info += QLatin1String("### Contributors: ###################\n");
00213     
00214     QList<Person> dcontri = contributors();
00215     QList<Person>::ConstIterator endcontri = dcontri.constEnd();
00216     for (QList<Person>::ConstIterator it = dcontri.constBegin(); it != endcontri; ++it)
00217         info += (*it).debugInfo();
00218     
00219     info += QLatin1String("### Source end ################\n");
00220 
00221     return info;
00222 }
00223 
00224 } // namespace Atom
00225 } //namespace Syndication
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:48:54 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

syndication/atom

Skip menu "syndication/atom"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Members
  • File List

kdepimlibs-4.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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