File indexing completed on 2025-01-05 03:59:22
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // 0006 0007 // 0008 // MarblePlacemarkModel exposes the model for Placemarks 0009 // 0010 0011 #ifndef MARBLE_MARBLEPLACEMARKMODEL_H 0012 #define MARBLE_MARBLEPLACEMARKMODEL_H 0013 0014 0015 #include <QAbstractListModel> 0016 #include <QModelIndex> 0017 0018 #include "digikam_export.h" 0019 0020 namespace Marble 0021 { 0022 0023 class GeoDataCoordinates; 0024 class GeoDataPlacemark; 0025 0026 /** 0027 * This class represents a model of all place marks which 0028 * are currently available through a given PlacemarkManager. 0029 */ 0030 class DIGIKAM_EXPORT MarblePlacemarkModel : public QAbstractListModel 0031 { 0032 friend class PlacemarkManager; 0033 0034 Q_OBJECT 0035 0036 Q_PROPERTY( int count READ rowCount NOTIFY countChanged ) 0037 0038 public: 0039 /** 0040 * The roles of the place marks. 0041 */ 0042 enum Roles 0043 { 0044 GeoTypeRole = Qt::UserRole + 1, ///< The geo type (e.g. city or mountain) 0045 DescriptionRole, ///< The description 0046 CoordinateRole, ///< The GeoDataCoordinates coordinate 0047 PopulationRole, ///< The population 0048 AreaRole, ///< The area size 0049 CountryCodeRole, ///< The country code 0050 StateRole, ///< The state 0051 VisualCategoryRole, ///< The category 0052 StyleRole, ///< The style 0053 PopularityIndexRole, ///< The popularity index 0054 PopularityRole, ///< The popularity 0055 ObjectPointerRole, ///< The pointer to a specific object 0056 GmtRole, ///< The Greenwich Mean Time 0057 DstRole, ///< The Daylight Saving Time 0058 GeometryRole, ///< The GeoDataGeometry geometry 0059 LongitudeRole, ///< The longitude in degree (for use in QML) 0060 LatitudeRole, ///< The latitude in degree (for use in QML) 0061 IconPathRole ///< Path to the image, if known 0062 }; 0063 0064 /** 0065 * Creates a new place mark model. 0066 * 0067 * @param parent The parent object. 0068 */ 0069 explicit MarblePlacemarkModel( QObject *parent = nullptr ); 0070 0071 /** 0072 * Destroys the place mark model. 0073 */ 0074 ~MarblePlacemarkModel() override; 0075 0076 void setPlacemarkContainer( QVector<GeoDataPlacemark*> *container ); 0077 0078 /** 0079 * Return the number of Placemarks in the Model. 0080 */ 0081 int rowCount( const QModelIndex &parent = QModelIndex() ) const override; 0082 int columnCount( const QModelIndex &parent = QModelIndex() ) const override; 0083 0084 /** 0085 * Return the supported role names 0086 */ 0087 QHash<int, QByteArray> roleNames() const override; 0088 0089 /** 0090 * Return the data according to the index. 0091 * 0092 * @param index the index of the data 0093 * @param role which part of the data to return. @see Roles 0094 */ 0095 QVariant data( const QModelIndex &index, int role ) const override; 0096 0097 QModelIndexList approxMatch( const QModelIndex &start, int role, 0098 const QVariant &value, int hits = 1, 0099 Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const; 0100 0101 /** 0102 * This method is used by the PlacemarkManager to add new 0103 * place marks to the model. 0104 */ 0105 void addPlacemarks( int start, 0106 int length ); 0107 0108 /** 0109 * This method is used by the PlacemarkManager to remove 0110 * place marks from the model. 0111 */ 0112 void removePlacemarks( const QString &containerName, 0113 int start, 0114 int length ); 0115 0116 Q_SIGNALS: 0117 void countChanged(); 0118 0119 private: 0120 0121 Q_DISABLE_COPY( MarblePlacemarkModel ) 0122 class Private; 0123 Private* const d; 0124 QHash<int, QByteArray> m_roleNames; 0125 }; 0126 0127 } 0128 0129 #endif