Marble

MarbleModel.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2005-2007 Torsten Rahn <[email protected]>
4 // SPDX-FileCopyrightText: 2007 Inge Wallin <[email protected]>
5 // SPDX-FileCopyrightText: 2010-2013 Bernhard Beschow <[email protected]>
6 //
7 
8 //
9 // MarbleModel is the data store and index class for the MarbleWidget.
10 //
11 
12 #ifndef MARBLE_MARBLEMODEL_H
13 #define MARBLE_MARBLEMODEL_H
14 
15 
16 /** @file
17  * This file contains the headers for MarbleModel
18  *
19  * @author Torsten Rahn <[email protected]>
20  * @author Inge Wallin <[email protected]>
21  */
22 
23 
24 
25 #include "marble_export.h"
26 
27 #include <QObject>
28 #include <QString>
29 
30 #include "MarbleGlobal.h"
31 
33 class QAbstractItemModel;
34 class QTextDocument;
35 class QDateTime;
36 
37 namespace Marble
38 {
39 
40 class GeoDataPlacemark;
41 class GeoPainter;
42 class MeasureTool;
43 class PositionTracking;
44 class HttpDownloadManager;
45 class MarbleModelPrivate;
46 class MarbleClock;
47 class SunLocator;
48 class TileCreator;
49 class PluginManager;
50 class GeoDataCoordinates;
51 class GeoDataTreeModel;
52 class GeoSceneDocument;
53 class Planet;
54 class RoutingManager;
55 class BookmarkManager;
56 class FileManager;
57 class ElevationModel;
58 
59 /**
60  * @short The data model (not based on QAbstractModel) for a MarbleWidget.
61  *
62  * This class provides a data storage and indexer that can be
63  * displayed in a MarbleWidget. It contains 3 different datatypes:
64  * <b>tiles</b> which provide the background, <b>vectors</b> which
65  * provide things like country borders and coastlines and
66  * <b>placemarks</b> which can show points of interest, such as
67  * cities, mountain tops or the poles.
68  *
69  * The <b>tiles</b> provide the background of the image and can be for
70  * instance height and depth fields, magnetic strength, topographic
71  * data or anything else that is area based.
72  *
73  * The <b>vectors</b> provide things like country borders and
74  * coastlines. They are stored in separate files and can be added or
75  * removed at anytime.
76  *
77  * The <b>placemarks</b> contain points of interest, such as cities,
78  * mountain tops or the poles. These are sorted by size (for cities)
79  * and category (capitals, other important cities, less important
80  * cities, etc) and are displayed with different color or shape like
81  * square or round.
82  *
83  * @see MarbleWidget
84  */
85 
86 class MARBLE_EXPORT MarbleModel : public QObject
87 {
88  friend class MarbleModelPrivate;
89 
90  Q_OBJECT
91 
92  Q_PROPERTY( QString mapThemeId READ mapThemeId WRITE setMapThemeId NOTIFY themeChanged )
93  Q_PROPERTY( bool workOffline READ workOffline WRITE setWorkOffline NOTIFY workOfflineChanged )
94 
95  public:
96  /**
97  * @brief Construct a new MarbleModel.
98  * @param parent the parent widget
99  */
100  explicit MarbleModel( QObject *parent = nullptr );
101  ~MarbleModel() override;
102 
103  /**
104  * @brief Return the list of Placemarks as a QAbstractItemModel *
105  * @return a list of all Placemarks in the MarbleModel.
106  */
107  GeoDataTreeModel *treeModel();
108  const GeoDataTreeModel *treeModel() const;
109 
110  QAbstractItemModel *groundOverlayModel();
111  const QAbstractItemModel *groundOverlayModel() const;
112 
113  QAbstractItemModel *placemarkModel();
114  const QAbstractItemModel *placemarkModel() const;
115 
116  QItemSelectionModel *placemarkSelectionModel();
117 
118  /**
119  * @brief Return the name of the current map theme.
120  * @return the identifier of the current MapTheme.
121  * To ensure that a unique identifier is being used the theme does NOT
122  * get represented by its name but the by relative location of the file
123  * that specifies the theme:
124  *
125  * Example:
126  * maptheme = "earth/bluemarble/bluemarble.dgml"
127  */
128  QString mapThemeId() const;
129 
130  GeoSceneDocument *mapTheme();
131  const GeoSceneDocument *mapTheme() const;
132  void setMapTheme( GeoSceneDocument * document );
133 
134  /**
135  * @brief Set a new map theme to use.
136  * @param mapThemeId the identifier of the new map theme
137  *
138  * This function sets the map theme, i.e. combination of tile set
139  * and color scheme to use. If the map theme is not previously
140  * used, some basic tiles are created and a progress dialog is
141  * shown.
142  *
143  * The ID of the new maptheme. To ensure that a unique
144  * identifier is being used the theme does NOT get represented by its
145  * name but the by relative location of the file that specifies the theme:
146  *
147  * Example:
148  * maptheme = "earth/bluemarble/bluemarble.dgml"
149  */
150  void setMapThemeId( const QString &mapThemeId );
151 
152  /**
153  * @brief get the home point
154  * @param lon the longitude of the home point.
155  * @param lat the latitude of the home point.
156  * @param zoom the default zoom level of the home point.
157  */
158  void home( qreal &lon, qreal &lat, int& zoom ) const;
159  /**
160  * @brief Set the home point
161  * @param lon the longitude of the new home point.
162  * @param lat the latitude of the new home point.
163  * @param zoom the default zoom level for the new home point.
164  */
165  void setHome( qreal lon, qreal lat, int zoom = 1050 );
166  /**
167  * @brief Set the home point
168  * @param homePoint the new home point.
169  * @param zoom the default zoom level for the new home point.
170  */
171  void setHome( const GeoDataCoordinates& homePoint, int zoom = 1050 );
172 
173  /**
174  * @brief Return the downloadmanager to load missing tiles
175  * @return the HttpDownloadManager instance.
176  */
177  HttpDownloadManager *downloadManager();
178  const HttpDownloadManager *downloadManager() const;
179 
180 
181  /**
182  * @brief Handle file loading into the treeModel
183  * @param filename the file to load
184  */
185  void addGeoDataFile( const QString& filename );
186 
187  /**
188  * @brief Handle raw data loading into the treeModel
189  * @param data the raw data to load
190  * @param key the name to remove this raw data later
191  */
192  void addGeoDataString( const QString& data, const QString& key = QLatin1String("data") );
193 
194  /**
195  * @brief Remove the file or raw data from the treeModel
196  * @param key either the file name or the key for raw data
197  */
198  void removeGeoData( const QString& key );
199 
200  FileManager *fileManager();
201 
202  PositionTracking *positionTracking() const;
203 
204  qreal planetRadius() const;
205  QString planetName() const;
206  QString planetId() const;
207 
208  MarbleClock *clock();
209  const MarbleClock *clock() const;
210 
211  SunLocator *sunLocator();
212  const SunLocator *sunLocator() const;
213 
214  /**
215  * @brief Returns the limit in kilobytes of the persistent (on hard disc) tile cache.
216  * @return the limit of persistent tile cache in kilobytes.
217  */
218  quint64 persistentTileCacheLimit() const;
219 
220  /**
221  * @brief Returns the limit of the volatile (in RAM) tile cache.
222  * @return the cache limit in kilobytes
223  */
224  quint64 volatileTileCacheLimit() const;
225 
226  const PluginManager* pluginManager() const;
227 
228  PluginManager* pluginManager();
229 
230  /**
231  * @brief Returns the planet object for the current map.
232  * @return the planet object for the current map
233  */
234  const Planet *planet() const;
235 
236  RoutingManager* routingManager();
237  const RoutingManager* routingManager() const;
238 
239  void setClockDateTime( const QDateTime& datetime );
240 
241  QDateTime clockDateTime() const;
242 
243  int clockSpeed() const;
244 
245  void setClockSpeed( int speed );
246 
247  void setClockTimezone( int timeInSec );
248 
249  int clockTimezone() const;
250 
251  /**
252  * return instance of BookmarkManager
253  */
254  BookmarkManager *bookmarkManager();
255 
256  QTextDocument * legend();
257 
258  /**
259  * @brief Uses the given text document as the new content of the legend
260  * Any previous legend content is overwritten. MarbleModel takes ownership
261  * of the passed document.
262  */
263  void setLegend( QTextDocument * document );
264 
265  bool workOffline() const;
266 
267  void setWorkOffline( bool workOffline );
268 
269  ElevationModel* elevationModel();
270  const ElevationModel* elevationModel() const;
271 
272  /**
273  * Returns the placemark being tracked by this model or 0 if no
274  * placemark is currently tracked.
275  * @see setTrackedPlacemark(), trackedPlacemarkChanged()
276  */
277  const GeoDataPlacemark *trackedPlacemark() const;
278 
279  public Q_SLOTS:
280  void clearPersistentTileCache();
281 
282  /**
283  * @brief Set the limit of the persistent (on hard disc) tile cache.
284  * @param kiloBytes The limit in kilobytes, 0 means no limit.
285  */
286  void setPersistentTileCacheLimit( quint64 kiloBytes );
287 
288  /**
289  * @brief Change the placemark tracked by this model
290  * @see trackedPlacemark(), trackedPlacemarkChanged()
291  */
292  void setTrackedPlacemark( const GeoDataPlacemark *placemark );
293 
294  void updateProperty( const QString &property, bool value );
295 
296  Q_SIGNALS:
297 
298  /**
299  * @brief Signal that the MarbleModel has started to create a new set of tiles.
300  * @param name name of the set
301  * @param description the set description
302  */
303  void creatingTilesStart( TileCreator*, const QString& name, const QString& description );
304 
305  /**
306  * @brief Signal that the map theme has changed, and to which theme.
307  * @param mapTheme the identifier of the new map theme.
308  * @see mapTheme
309  * @see setMapTheme
310  */
311  void themeChanged( const QString &mapTheme );
312 
313  void workOfflineChanged();
314 
315  /**
316  * @brief Emitted when the placemark tracked by this model has changed
317  * @see setTrackedPlacemark(), trackedPlacemark()
318  */
319  void trackedPlacemarkChanged( const GeoDataPlacemark *placemark );
320 
321  /** @brief Emitted when the home location is changed
322  * @see home(), setHome()
323  */
324  void homeChanged( const GeoDataCoordinates &newHomePoint );
325 
326  private:
327  Q_DISABLE_COPY( MarbleModel )
328 
329  Q_PRIVATE_SLOT( d, void assignFillColors( const QString &filePath ) )
330 
331  void addDownloadPolicies( const GeoSceneDocument *mapTheme );
332  MarbleModelPrivate * const d;
333 };
334 
335 }
336 
337 #endif
A 3d point representation.
Delegates data retrieval and model updates to the appropriate routing provider.
This class manages scheduled downloads.
This class is responsible for loading the book mark objects from the files and various book mark oper...
The representation of GeoData in a model This class represents all available data given by kml-data f...
The class that handles Marble's plugins.
Definition: PluginManager.h:39
Binds a QML item to a specific geodetic location in screen coordinates.
a class representing a point of interest on the map
This class is responsible for loading the different files into Geodata model.
Definition: FileManager.h:32
The data model (not based on QAbstractModel) for a MarbleWidget.
Definition: MarbleModel.h:86
A container for features parsed from the DGML file.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:06:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.