Marble

MarblePlacemarkModel.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <[email protected]>
4 // SPDX-FileCopyrightText: 2007 Inge Wallin <[email protected]>
5 //
6 
7 //
8 // MarblePlacemarkModel exposes the model for Placemarks
9 //
10 
11 #ifndef MARBLE_MARBLEPLACEMARKMODEL_H
12 #define MARBLE_MARBLEPLACEMARKMODEL_H
13 
14 
15 #include <QAbstractListModel>
16 #include <QModelIndex>
17 
18 #include "marble_export.h"
19 
20 namespace Marble
21 {
22 
23 class GeoDataCoordinates;
24 class GeoDataPlacemark;
25 
26 /**
27  * This class represents a model of all place marks which
28  * are currently available through a given PlacemarkManager.
29  */
30 class MARBLE_EXPORT MarblePlacemarkModel : public QAbstractListModel
31 {
32  friend class PlacemarkManager;
33 
34  Q_OBJECT
35 
36  Q_PROPERTY( int count READ rowCount NOTIFY countChanged )
37 
38  public:
39  /**
40  * The roles of the place marks.
41  */
42  enum Roles
43  {
44  GeoTypeRole = Qt::UserRole + 1, ///< The geo type (e.g. city or mountain)
45  DescriptionRole, ///< The description
46  CoordinateRole, ///< The GeoDataCoordinates coordinate
47  PopulationRole, ///< The population
48  AreaRole, ///< The area size
49  CountryCodeRole, ///< The country code
50  StateRole, ///< The state
51  VisualCategoryRole, ///< The category
52  StyleRole, ///< The style
53  PopularityIndexRole, ///< The popularity index
54  PopularityRole, ///< The popularity
55  ObjectPointerRole, ///< The pointer to a specific object
56  GmtRole, ///< The Greenwich Mean Time
57  DstRole, ///< The Daylight Saving Time
58  GeometryRole, ///< The GeoDataGeometry geometry
59  LongitudeRole, ///< The longitude in degree (for use in QML)
60  LatitudeRole, ///< The latitude in degree (for use in QML)
61  IconPathRole ///< Path to the image, if known
62  };
63 
64  /**
65  * Creates a new place mark model.
66  *
67  * @param parent The parent object.
68  */
69  explicit MarblePlacemarkModel( QObject *parent = nullptr );
70 
71  /**
72  * Destroys the place mark model.
73  */
74  ~MarblePlacemarkModel() override;
75 
76  void setPlacemarkContainer( QVector<GeoDataPlacemark*> *container );
77 
78  /**
79  * Return the number of Placemarks in the Model.
80  */
81  int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
82  int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
83 
84  /**
85  * Return the supported role names
86  */
87  QHash<int, QByteArray> roleNames() const override;
88 
89  /**
90  * Return the data according to the index.
91  *
92  * @param index the index of the data
93  * @param role which part of the data to return. @see Roles
94  */
95  QVariant data( const QModelIndex &index, int role ) const override;
96 
97  QModelIndexList approxMatch( const QModelIndex &start, int role,
98  const QVariant &value, int hits = 1,
100 
101  /**
102  * This method is used by the PlacemarkManager to add new
103  * place marks to the model.
104  */
105  void addPlacemarks( int start,
106  int length );
107 
108  /**
109  * This method is used by the PlacemarkManager to remove
110  * place marks from the model.
111  */
112  void removePlacemarks( const QString &containerName,
113  int start,
114  int length );
115 
116 Q_SIGNALS:
117  void countChanged();
118 
119  private:
120 
121  Q_DISABLE_COPY( MarblePlacemarkModel )
122  class Private;
123  Private* const d;
124  QHash<int, QByteArray> m_roleNames;
125 };
126 
127 }
128 
129 #endif
@ GeometryRole
The GeoDataGeometry geometry.
UserRole
@ LatitudeRole
The latitude in degree (for use in QML)
@ PopularityIndexRole
The popularity index.
Q_SCRIPTABLE Q_NOREPLY void start()
@ GmtRole
The Greenwich Mean Time.
@ ObjectPointerRole
The pointer to a specific object.
@ CoordinateRole
The GeoDataCoordinates coordinate.
Binds a QML item to a specific geodetic location in screen coordinates.
This class represents a model of all place marks which are currently available through a given Placem...
@ DstRole
The Daylight Saving Time.
Roles
The roles of the place marks.
typedef MatchFlags
@ LongitudeRole
The longitude in degree (for use in QML)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 04:10:37 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.