• 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
  • localdatabase
LocalDatabaseRunner.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 2010 Torsten Rahn <rahn@kde.org>
9 // Copyright 2013 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
10 //
11 
12 #include "LocalDatabaseRunner.h"
13 
14 #include "MarbleModel.h"
15 #include "MarblePlacemarkModel.h"
16 #include "GeoDataFeature.h"
17 #include "GeoDataPlacemark.h"
18 #include "GeoDataCoordinates.h"
19 
20 #include "MarbleDebug.h"
21 #include <QString>
22 #include <QStringList>
23 #include <QVector>
24 
25 #include <QtDebug>
26 
27 namespace Marble
28 {
29 
30 LocalDatabaseRunner::LocalDatabaseRunner(QObject *parent) :
31  SearchRunner(parent)
32 {
33 }
34 
35 LocalDatabaseRunner::~LocalDatabaseRunner()
36 {
37 
38 }
39 
40 void LocalDatabaseRunner::search( const QString &searchTerm, const GeoDataLatLonAltBox &preferred )
41 {
42  QVector<GeoDataPlacemark*> vector;
43 
44  if (model()) {
45  const QAbstractItemModel * placemarkModel = model()->placemarkModel();
46 
47  if (placemarkModel) {
48  QModelIndexList resultList;
49  QModelIndex firstIndex = placemarkModel->index( 0, 0 );
50  resultList = placemarkModel->match( firstIndex,
51  Qt::DisplayRole, searchTerm, -1,
52  Qt::MatchStartsWith );
53 
54  foreach ( const QModelIndex& index, resultList )
55  {
56  if( !index.isValid() ) {
57  mDebug() << "invalid index!!!";
58  continue;
59  }
60  GeoDataPlacemark *placemark = dynamic_cast<GeoDataPlacemark*>(qvariant_cast<GeoDataObject*>( index.data( MarblePlacemarkModel::ObjectPointerRole )));
61  if ( placemark &&
62  ( preferred.isEmpty() || preferred.contains( placemark->coordinate() ) ) ) {
63  vector.append( new GeoDataPlacemark( *placemark ));
64  }
65  }
66  }
67  }
68 
69  emit searchFinished( vector );
70 }
71 
72 }
73 
74 #include "LocalDatabaseRunner.moc"
GeoDataCoordinates.h
Marble::GeoDataLatLonBox::isEmpty
virtual bool isEmpty() const
Indicates whether the bounding box is not initialised (and contains nothing).
Definition: GeoDataLatLonBox.cpp:768
Marble::LocalDatabaseRunner::search
virtual void search(const QString &searchTerm, const GeoDataLatLonAltBox &preferred)
Start a placemark search.
Definition: LocalDatabaseRunner.cpp:40
MarbleModel.h
This file contains the headers for MarbleModel.
Marble::GeoDataObject
A base class for all geodata objects.
Definition: GeoDataObject.h:48
Marble::SearchRunner::searchFinished
void searchFinished(QVector< GeoDataPlacemark * > result)
This is emitted to indicate that the runner has finished the placemark search.
Marble::GeoDataPlacemark::coordinate
GeoDataCoordinates coordinate(const QDateTime &dateTime=QDateTime(), bool *iconAtCoordinates=0) const
Return the coordinates of the placemark at time dateTime as a GeoDataCoordinates. ...
Definition: GeoDataPlacemark.cpp:78
Marble::GeoDataLatLonAltBox::contains
virtual bool contains(const GeoDataCoordinates &) const
Definition: GeoDataLatLonAltBox.cpp:171
QObject
Marble::MarblePlacemarkModel::ObjectPointerRole
The pointer to a specific object.
Definition: MarblePlacemarkModel.h:62
MarbleDebug.h
GeoDataFeature.h
Marble::LocalDatabaseRunner::LocalDatabaseRunner
LocalDatabaseRunner(QObject *parent=0)
Definition: LocalDatabaseRunner.cpp:30
MarblePlacemarkModel.h
GeoDataPlacemark.h
Marble::SearchRunner::model
const MarbleModel * model() const
Access to the currently used model, or null if no was set with.
Definition: SearchRunner.cpp:25
QAbstractItemModel
LocalDatabaseRunner.h
Marble::GeoDataPlacemark
a class representing a point of interest on the map
Definition: GeoDataPlacemark.h:54
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
Marble::SearchRunner
Definition: SearchRunner.h:30
Marble::GeoDataLatLonAltBox
A class that defines a 3D bounding box for geographic data.
Definition: GeoDataLatLonAltBox.h:49
Marble::LocalDatabaseRunner::~LocalDatabaseRunner
~LocalDatabaseRunner()
Definition: LocalDatabaseRunner.cpp:35
Marble::MarbleModel::placemarkModel
QAbstractItemModel * placemarkModel()
Definition: MarbleModel.cpp:417
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:51 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