• 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
  • runner
  • json
JsonRunner.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 2013 Ander Pijoan <ander.pijoan@deusto.es>
9 */
10 
11 #include "JsonRunner.h"
12 #include "JsonParser.h"
13 
14 #include "GeoDataDocument.h"
15 #include "MarbleDebug.h"
16 
17 #include <QFile>
18 #include <QFileInfo>
19 
20 namespace Marble
21 {
22 
23 JsonRunner::JsonRunner(QObject *parent) :
24  ParsingRunner(parent)
25 {
26 }
27 
28 JsonRunner::~JsonRunner()
29 {
30 }
31 
32 void JsonRunner::parseFile( const QString &fileName, DocumentRole role = UnknownDocument )
33 {
34  // Check file exists
35  QFile file( fileName );
36  if ( !file.exists() ) {
37  qWarning() << "File" << fileName << "does not exist!";
38  emit parsingFinished( 0 );
39  return;
40  }
41 
42  // Open file in right mode
43  file.open( QIODevice::ReadOnly );
44 
45  // Create parser
46  JsonParser parser;
47 
48  // Start parsing
49  if ( !parser.read( &file ) ) {
50  emit parsingFinished( 0, "Could not parse GeoJSON" );
51  return;
52  }
53 
54  GeoDataDocument* document = parser.releaseDocument();
55  file.close();
56  document->setDocumentRole( role );
57  document->setFileName( fileName );
58 
59  emit parsingFinished( document );
60 }
61 
62 }
63 
64 #include "JsonRunner.moc"
GeoDataDocument.h
Marble::GeoDataDocument
A container for Features, Styles and in the future Schemas.
Definition: GeoDataDocument.h:64
Marble::JsonParser::releaseDocument
GeoDataDocument * releaseDocument()
retrieve the parsed document and reset the parser If parsing was successful, retrieve the resulting d...
Definition: JsonParser.cpp:32
Marble::GeoDataDocument::setDocumentRole
void setDocumentRole(DocumentRole role)
Definition: GeoDataDocument.cpp:62
JsonParser.h
QObject
MarbleDebug.h
Marble::UnknownDocument
Definition: GeoDataDocument.h:40
Marble::ParsingRunner::parsingFinished
void parsingFinished(GeoDataDocument *document, const QString &error=QString())
File parsing is finished, result in the given document object.
Marble::JsonParser::read
bool read(QIODevice *)
parse the json file
Definition: JsonParser.cpp:39
JsonRunner.h
Marble::ParsingRunner
Definition: ParsingRunner.h:23
Marble::JsonRunner::~JsonRunner
~JsonRunner()
Definition: JsonRunner.cpp:28
Marble::GeoDataDocument::setFileName
void setFileName(const QString &value)
Set a new file name for this document.
Definition: GeoDataDocument.cpp:82
Marble::JsonRunner::JsonRunner
JsonRunner(QObject *parent=0)
Definition: JsonRunner.cpp:23
Marble::JsonParser
Definition: JsonParser.h:22
Marble::DocumentRole
DocumentRole
Definition: GeoDataDocument.h:39
Marble::JsonRunner::parseFile
virtual void parseFile(const QString &fileName, DocumentRole role)
Start a file parsing.
Definition: JsonRunner.cpp:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:50 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