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

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • photo
FlickrParser.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2009 Bastian Holst <bastianholst@gmx.de>
9 //
10 
11 // Self
12 #include "FlickrParser.h"
13 
14 // Marble
15 #include "AbstractDataPluginItem.h"
16 #include "PhotoPluginItem.h"
17 
18 // Qt
19 #include <QByteArray>
20 
21 using namespace Marble;
22 
23 FlickrParser::FlickrParser( MarbleWidget *widget,
24  QList<PhotoPluginItem *> *list,
25  QObject *parent )
26  : m_marbleWidget( widget ),
27  m_list( list ),
28  m_parent( parent )
29 {
30 }
31 
32 bool FlickrParser::read( QByteArray data )
33 {
34  addData( data );
35 
36  while (!atEnd()) {
37  readNext();
38 
39  if (isStartElement()) {
40  if ( name() == "rsp" && attributes().value( "stat" ) == "ok" )
41  readFlickr();
42  else if ( name() == "rsp" )
43  raiseError( QObject::tr("Query failed") );
44  else
45  raiseError( QObject::tr("The file is not a valid Flickr answer.") );
46  }
47  }
48 
49  return !error();
50 }
51 
52 void FlickrParser::readUnknownElement()
53 {
54  Q_ASSERT( isStartElement() );
55 
56  while ( !atEnd() ) {
57  readNext();
58 
59  if ( isEndElement() )
60  break;
61 
62  if ( isStartElement() )
63  readUnknownElement();
64  }
65 }
66 
67 void FlickrParser::readFlickr()
68 {
69  Q_ASSERT( isStartElement()
70  && name() == "rsp"
71  && attributes().value( "stat" ) == "ok" );
72 
73  while( !atEnd() ) {
74  readNext();
75 
76  if( isEndElement() )
77  break;
78 
79  if( isStartElement() ) {
80  if( name() == "photos" )
81  readPhotos();
82  else
83  readUnknownElement();
84  }
85  }
86 }
87 
88 void FlickrParser::readPhotos()
89 {
90  Q_ASSERT( isStartElement()
91  && name() == "photos" );
92 
93  while( !atEnd() ) {
94  readNext();
95 
96  if( isEndElement() )
97  break;
98 
99  if( isStartElement() ) {
100  if( name() == "photo" )
101  readPhoto();
102  else
103  readUnknownElement();
104  }
105  }
106 }
107 
108 void FlickrParser::readPhoto()
109 {
110  Q_ASSERT( isStartElement()
111  && name() == "photo" );
112 
113  if( attributes().hasAttribute( "id" ) ) {
114  PhotoPluginItem *item = new PhotoPluginItem( m_marbleWidget, m_parent );
115  item->setId( attributes().value( "id" ).toString() );
116  item->setServer( attributes().value( "server" ).toString() );
117  item->setFarm( attributes().value( "farm" ).toString() );
118  item->setSecret( attributes().value( "secret" ).toString() );
119  item->setOwner( attributes().value( "owner" ).toString() );
120  item->setTitle( attributes().value( "title" ).toString() );
121  m_list->append( item );
122  }
123 
124  while( !atEnd() ) {
125  readNext();
126 
127  if( isEndElement() )
128  break;
129 
130  if( isStartElement() )
131  break;
132  }
133 }
Marble::PhotoPluginItem
Definition: PhotoPluginItem.h:29
Marble::AbstractDataPluginItem::setId
void setId(const QString &id)
Definition: AbstractDataPluginItem.cpp:86
Marble::PhotoPluginItem::setFarm
void setFarm(const QString &farm)
Definition: PhotoPluginItem.cpp:146
QObject
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:102
Marble::FlickrParser::FlickrParser
FlickrParser(Marble::MarbleWidget *widget, QList< PhotoPluginItem * > *list, QObject *parent)
Definition: FlickrParser.cpp:23
Marble::FlickrParser::read
bool read(QByteArray data)
Definition: FlickrParser.cpp:32
Marble::PhotoPluginItem::setServer
void setServer(const QString &server)
Definition: PhotoPluginItem.cpp:136
FlickrParser.h
Marble::PhotoPluginItem::setSecret
void setSecret(const QString &secret)
Definition: PhotoPluginItem.cpp:156
PhotoPluginItem.h
Marble::PhotoPluginItem::setOwner
void setOwner(const QString &owner)
Definition: PhotoPluginItem.cpp:166
AbstractDataPluginItem.h
Marble::PhotoPluginItem::setTitle
void setTitle(const QString &title)
Definition: PhotoPluginItem.cpp:176
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

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