File indexing completed on 2025-01-05 03:58:55
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2010 Harshit Jain <hjain.itbhu@gmail.com> 0004 // SPDX-FileCopyrightText: 2011 Niko Sams <niko.sams@gmail.com> 0005 // 0006 0007 #ifndef MARBLE_GEODATAEXTENDEDDATA_H 0008 #define MARBLE_GEODATAEXTENDEDDATA_H 0009 0010 #include "GeoDocument.h" 0011 #include "Serializable.h" 0012 0013 #include "digikam_export.h" 0014 #include <QHash> 0015 0016 namespace Marble 0017 { 0018 0019 class GeoDataSimpleArrayData; 0020 class GeoDataSchemaData; 0021 class GeoDataData; 0022 0023 class GeoDataExtendedDataPrivate; 0024 0025 /** 0026 * @short a class which allows to add custom data to KML Feature. 0027 * 0028 * @see GeoDataData 0029 */ 0030 class DIGIKAM_EXPORT GeoDataExtendedData : public GeoNode, public Serializable 0031 { 0032 public: 0033 GeoDataExtendedData(); 0034 GeoDataExtendedData( const GeoDataExtendedData& other ); 0035 ~GeoDataExtendedData() override; 0036 0037 /// Provides type information for downcasting a GeoNode 0038 const char* nodeType() const override; 0039 0040 /** 0041 * @brief assignment operator 0042 */ 0043 GeoDataExtendedData& operator=( const GeoDataExtendedData& other ); 0044 0045 bool operator==( const GeoDataExtendedData& other ) const; 0046 bool operator!=( const GeoDataExtendedData& other ) const; 0047 0048 /** 0049 * @brief return the value of GeoDataExtendedData associated with the given @p key 0050 */ 0051 GeoDataData value( const QString& key ) const; 0052 0053 /** 0054 * @brief add a data object to the GeoDataExtendedData with the @p key 0055 */ 0056 void addValue( const GeoDataData& data ); 0057 0058 /** 0059 * @since 0.26.0 0060 */ 0061 void removeKey(const QString &key); 0062 0063 /** 0064 * @brief return const Begin iterator for QHash 0065 */ 0066 QHash< QString, GeoDataData >::const_iterator constBegin( ) const; 0067 0068 /** 0069 * @brief return const End iterator for QHash 0070 */ 0071 0072 QHash< QString, GeoDataData >::const_iterator constEnd( ) const; 0073 0074 /** 0075 * @brief return size of QHash 0076 */ 0077 0078 int size( ) const; 0079 0080 /** 0081 * @brief return whether QHash is empty or not 0082 */ 0083 bool isEmpty( ) const; 0084 0085 /** 0086 * @brief Returns true if there exists a value for the given key 0087 */ 0088 bool contains( const QString &key ) const; 0089 0090 /** 0091 * @brief return value of GeoDataExtendedData object associated with the given @p key as a modifiable reference 0092 */ 0093 GeoDataData& valueRef( const QString& key ) const; 0094 0095 /** 0096 * @brief set SimpleArrayData for given @p key 0097 * 0098 * ExtendedData takes ownership of SimpleArrayData 0099 */ 0100 void setSimpleArrayData( const QString& key, GeoDataSimpleArrayData* values ); 0101 0102 /** 0103 * @brief return SimpleArrayData for given @p key, 0 pointer if none is set 0104 */ 0105 GeoDataSimpleArrayData* simpleArrayData( const QString& key ) const; 0106 0107 /** 0108 * @brief Adds a SchemaData @p schemaData element to schemaDataHash 0109 */ 0110 GeoDataSchemaData& schemaData( const QString& schemaUrl ) const; 0111 0112 /** 0113 * @brief Adds a SchemaData @p schemaData element to schemaDataHash 0114 */ 0115 void addSchemaData( const GeoDataSchemaData& schemaData ); 0116 0117 /** 0118 * @brief Removes a SchemaData element with schema url @p schemaUrl from schemaDataHash 0119 */ 0120 void removeSchemaData( const QString& schemaUrl ); 0121 0122 /** 0123 * @brief Dump a vector containing all SchemaData element 0124 */ 0125 QList< GeoDataSchemaData > schemaDataList() const; 0126 0127 /** 0128 * @brief Serialize the ExtendedData to a stream 0129 * @param stream the stream 0130 */ 0131 void pack( QDataStream& stream ) const override; 0132 0133 /** 0134 * @brief Unserialize the ExtendedData from a stream 0135 * @param stream the stream 0136 */ 0137 void unpack( QDataStream& stream ) override; 0138 0139 private: 0140 GeoDataExtendedDataPrivate * const d; 0141 }; 0142 0143 } 0144 0145 #endif