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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • twitter
twitter/jsonparser.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 2008 Shashank Singh <shashank.personal@gmail.com>
9 //
10 
11 #include "jsonparser.h"
12 
13 jsonParser::jsonParser()
14 {
15  myEngine.setProcessEventsInterval(10);//this lets the gui remain responsive
16 }
17 
18 jsonParser::~jsonParser()
19 {
20 }
21 
22 twitterDataStructure jsonParser::parseObjectOnPosition(const QString &content , int requiredObjectPosition)
23 {
24  return dataStorage;
25 }
26 
27 QList <twitterDataStructure> jsonParser::parseAllObjects(const QString &content , int numberOfObjects)
28 {
29  QString temp = "var myJSONObject = { \"twitter\":" + content + "}";
30  int iterator = 0;//the count starts fom one
31  if (temp != "Twitter is down for database maintenance. It will return in about 30 minutes")
32  {
33  myEngine.evaluate(QString("function userName(k){return myJSONObject.twitter[k].user.name};"));
34  myEngine.evaluate(QString("function userLocation(k){return myJSONObject.twitter[k].user.location};"));
35  myEngine.evaluate(QString("function userText(k){return myJSONObject.twitter[k].text};"));
36 
37  myEngine.evaluate(temp);
38  while ((iterator) < numberOfObjects) {
39  myEngine.evaluate(QString("var a ="+QString::number(iterator) )).toString();
40  dataStorage.user=myEngine.evaluate(QString("userName(a)")).toString();
41  dataStorage.location=myEngine.evaluate(QString("userLocation(a)")).toString();
42  dataStorage.text=myEngine.evaluate(QString("userText(a)")).toString();
43 
44  parsedJsonOutput.insert(iterator , dataStorage);
45 
46  ++iterator;
47  }
48  }
49  else
50  {
51 //twitter is down :(
52  dataStorage.user="@Twitter Plugin";
53  dataStorage.location="Equator";
54  dataStorage.text="Twitter is down , Please try in 30 minutes " ;
55  parsedJsonOutput<<dataStorage;
56 
57  }
58  return parsedJsonOutput;
59 }
60 
61 googleMapDataStructure jsonParser::geoCodingAPIparseObject(QString content)
62 {
63  mDebug() << "in geoCodingAPIparseObject";
64  QString temp = "var myJSONObject = " + content;
65 
66  googleMapDataStructure returnStructure;
67  myEngine.evaluate("function lat(){return myJSONObject.Placemark[0].Point.coordinates[0]}");
68  myEngine.evaluate("function lon(){return myJSONObject.Placemark[0].Point.coordinates[1]}");
69  myEngine.evaluate(temp);
70 
71  returnStructure.lon = myEngine.evaluate("lon()").toNumber();
72  returnStructure.lat = myEngine.evaluate("lat()").toNumber();
73  mDebug() << "twitter lan lon text=" << returnStructure.lat << returnStructure.lon;
74  return returnStructure;
75 }
76 
77 
jsonparser.h
QScriptEngine::evaluate
QScriptValue evaluate(const QString &program, const QString &fileName, int lineNumber)
jsonParser::geoCodingAPIparseObject
googleMapDataStructure geoCodingAPIparseObject(QString content)
Definition: twitter/jsonparser.cpp:61
QScriptValue::toString
QString toString() const
jsonParser::~jsonParser
~jsonParser()
Definition: panoramio/jsonparser.cpp:20
QString::number
QString number(int n, int base)
googleMapDataStructure::lat
qreal lat
Definition: twitter/jsonparser.h:39
twitterDataStructure
This is a generic class built up for parsing Json that is JavaScript Object Notification FIXME: the c...
Definition: twitter/jsonparser.h:29
QString
QList< twitterDataStructure >
QScriptEngine::setProcessEventsInterval
void setProcessEventsInterval(int interval)
googleMapDataStructure::lon
qreal lon
Definition: twitter/jsonparser.h:40
QList::insert
void insert(int i, const T &value)
jsonParser::parseObjectOnPosition
panoramioDataStructure parseObjectOnPosition(const QString &content, int requiredObjectPosition)
Definition: panoramio/jsonparser.cpp:24
jsonParser::parseAllObjects
QList< panoramioDataStructure > parseAllObjects(const QString &content, int number)
Definition: panoramio/jsonparser.cpp:88
jsonParser::jsonParser
jsonParser()
Definition: panoramio/jsonparser.cpp:14
googleMapDataStructure
Definition: twitter/jsonparser.h:37
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:36
QScriptValue::toNumber
qsreal toNumber() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 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
  • 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