• 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
  • runner
  • gpx
GpxRunner.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 2011 Thibaut Gridel <tgridel@free.fr>
9 
10 #include "GpxRunner.h"
11 
12 #include "GeoDataDocument.h"
13 #include "GpxParser.h"
14 
15 #include <QFile>
16 
17 namespace Marble
18 {
19 
20 GpxRunner::GpxRunner(QObject *parent) :
21  ParsingRunner(parent)
22 {
23 }
24 
25 GpxRunner::~GpxRunner()
26 {
27 }
28 
29 void GpxRunner::parseFile( const QString &fileName, DocumentRole role = UnknownDocument )
30 {
31  QFile file( fileName );
32  if ( !file.exists() ) {
33  qWarning( "File does not exist!" );
34  emit parsingFinished( 0 );
35  return;
36  }
37 
38  // Open file in right mode
39  file.open( QIODevice::ReadOnly );
40 
41  GpxParser parser;
42 
43  if ( !parser.read( &file ) ) {
44  emit parsingFinished( 0, parser.errorString() );
45  return;
46  }
47  GeoDocument* document = parser.releaseDocument();
48  Q_ASSERT( document );
49  GeoDataDocument* doc = static_cast<GeoDataDocument*>( document );
50  doc->setDocumentRole( role );
51  doc->setFileName( fileName );
52 
53  file.close();
54  emit parsingFinished( doc );
55 }
56 
57 }
58 
59 #include "GpxRunner.moc"
GeoDataDocument.h
Marble::GpxParser
Definition: GpxParser.h:17
QXmlStreamReader::errorString
QString errorString() const
Marble::GeoDataDocument
A container for Features, Styles and in the future Schemas.
Definition: GeoDataDocument.h:65
Marble::GeoDataDocument::setDocumentRole
void setDocumentRole(DocumentRole role)
Definition: GeoDataDocument.cpp:86
Marble::GpxRunner::~GpxRunner
~GpxRunner()
Definition: GpxRunner.cpp:25
GpxRunner.h
QFile::exists
bool exists() const
QFile
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::GpxRunner::parseFile
virtual void parseFile(const QString &fileName, DocumentRole role)
Start a file parsing.
Definition: GpxRunner.cpp:29
Marble::GeoParser::read
bool read(QIODevice *)
Main API for reading the XML document.
Definition: GeoParser.cpp:74
QObject
QString
QFile::open
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
Marble::ParsingRunner
Definition: ParsingRunner.h:23
QFile::close
virtual void close()
Marble::GeoDataDocument::setFileName
void setFileName(const QString &value)
Set a new file name for this document.
Definition: GeoDataDocument.cpp:106
Marble::GeoDocument
A shared base class between GeoDataDocument/GeoSourceDocument.
Definition: GeoDocument.h:42
GpxParser.h
Marble::DocumentRole
DocumentRole
Definition: GeoDataDocument.h:39
Marble::GpxRunner::GpxRunner
GpxRunner(QObject *parent=0)
Definition: GpxRunner.cpp:20
Marble::GeoParser::releaseDocument
GeoDocument * releaseDocument()
retrieve the parsed document and reset the parser If parsing was successful, retrieve the resulting d...
Definition: GeoParser.cpp:205
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