File indexing completed on 2025-01-05 03:58:54

0001 /*
0002     SPDX-FileCopyrightText: 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
0003     SPDX-FileCopyrightText: 2007 Murad Tagirov <tmurad@gmail.com>
0004     SPDX-FileCopyrightText: 2009 Patrick Spendrin <ps_ml@gmx.de>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef MARBLE_GEODATADOCUMENT_H
0010 #define MARBLE_GEODATADOCUMENT_H
0011 
0012 #include <QMetaType>
0013 
0014 #include "digikam_export.h"
0015 
0016 #include "GeoDataContainer.h"
0017 #include "GeoDocument.h"
0018 #include "GeoDataStyle.h"
0019 
0020 namespace Marble
0021 {
0022 
0023 enum DocumentRole {
0024     UnknownDocument,
0025     MapDocument,
0026     UserDocument,
0027     TrackingDocument,
0028     SearchResultDocument
0029 };
0030 
0031 
0032 class GeoDataStyleMap;
0033 class GeoDataNetworkLinkControl;
0034 class GeoDataSchema;
0035 
0036 class GeoDataDocumentPrivate;
0037 
0038 /**
0039  * @short A container for Features, Styles and in the future Schemas.
0040  *
0041  * A GeoDataDocument is a container for features, styles, and
0042  * schemas. This element is required if your KML file uses schemas or
0043  * shared styles. It is recommended that all Styles be defined in a
0044  * Document, each with an id, and then later referenced by a
0045  * styleUrl for a given Feature or StyleMap.
0046  */
0047 class DIGIKAM_EXPORT GeoDataDocument : public GeoDocument,
0048                                        public GeoDataContainer
0049 {
0050 public:
0051     GeoDataDocument();
0052     GeoDataDocument( const GeoDataDocument& other );
0053     ~GeoDataDocument() override;
0054 
0055     GeoDataDocument& operator=(const GeoDataDocument& other);
0056 
0057     bool operator==( const GeoDataDocument &other ) const;
0058     bool operator!=( const GeoDataDocument &other ) const;
0059 
0060     const char* nodeType() const override;
0061 
0062     GeoDataFeature * clone() const override;
0063 
0064     /// Provides type information for downcasting a GeoData
0065     bool isGeoDataDocument() const override { return true; }
0066 
0067     DocumentRole documentRole() const;
0068     void setDocumentRole( DocumentRole role );
0069 
0070     QString property() const;
0071     void setProperty( const QString& property );
0072 
0073     /**
0074      * @brief The filename of the document
0075      *
0076      * The filename of the document is used internally to identify the files.
0077      * it should never be empty as this could lead to potential collisions.
0078      *
0079      * @return The filename of this document
0080      */
0081     QString fileName() const;
0082     /**
0083      * @brief Set a new file name for this document
0084      * @param value  the new name
0085      */
0086     void setFileName( const QString &value );
0087 
0088     /**
0089      * @brief The URI relative paths should be resolved against
0090      */
0091     QString baseUri() const;
0092 
0093     /**
0094      * @brief Change the URI for resolving relative paths.
0095      * See https://tools.ietf.org/html/rfc3986#section-5
0096      */
0097     void setBaseUri( const QString &baseUri );
0098 
0099     /**
0100      * @brief the NetworkLinkControl of the file
0101      */
0102     GeoDataNetworkLinkControl networkLinkControl() const;
0103 
0104     /**
0105      * @brief set the NetworkLinkControl of the file
0106      */
0107     void setNetworkLinkControl( const GeoDataNetworkLinkControl &networkLinkControl );
0108 
0109     /**
0110      * @brief Add a style to the style storage
0111      * @param style  the new style
0112      */
0113     void addStyle(const GeoDataStyle::Ptr &style);
0114 
0115     /**
0116      * @brief Add a style to the style storage
0117      * @param styleId  the new style
0118      */
0119     void removeStyle( const QString& styleId );
0120 
0121     /**
0122      * @brief Return a style in the style storage
0123      * @param styleId  the id of the style
0124      */
0125     GeoDataStyle::Ptr style( const QString& styleId );
0126     GeoDataStyle::ConstPtr style( const QString& styleId ) const;
0127 
0128     /**
0129     * @brief dump a Vector of all styles
0130     */
0131     QList<GeoDataStyle::Ptr> styles();
0132     QList<GeoDataStyle::ConstPtr> styles() const;
0133 
0134     /**
0135     * @brief Add a stylemap to the stylemap storage
0136     * @param map  the new stylemap
0137     */
0138     void addStyleMap( const GeoDataStyleMap& map );
0139 
0140     /**
0141     * @brief remove stylemap from storage
0142     * @param mapId the styleId of the styleMap to be removed
0143     */
0144     void removeStyleMap( const QString& mapId );
0145 
0146     /**
0147      * @brief Return a style in the style storage
0148      * @param styleId  the id of the style
0149      */
0150     GeoDataStyleMap& styleMap( const QString& styleId );
0151     GeoDataStyleMap styleMap( const QString& styleId ) const;
0152 
0153     /**
0154     * @brief dump a Vector of all stylemaps
0155     */
0156     QList<GeoDataStyleMap> styleMaps() const;
0157 
0158     /**
0159      * @brief Add a schema to simplemap storage
0160      * @param schema  the new schema
0161      */
0162     void addSchema( const GeoDataSchema& schema );
0163 
0164     /**
0165      * @brief remove a schema from schema storage
0166      * @param schemaId  the of schema to be removed
0167      */
0168     void removeSchema( const QString& schemaId );
0169 
0170     /**
0171      * @brief Returns a schema with id = schemaId form schema storage
0172      * @param schemaId  The id of schema to be returned
0173      */
0174     GeoDataSchema schema( const QString& schemaId ) const;
0175     GeoDataSchema &schema( const QString& schemaId );
0176 
0177     /**
0178      * @brief dump a vector of all schemas
0179      */
0180     QList<GeoDataSchema> schemas() const;
0181 
0182     // Serialize the Placemark to @p stream
0183     void pack( QDataStream& stream ) const override;
0184     // Unserialize the Placemark from @p stream
0185     void unpack( QDataStream& stream ) override;
0186 
0187 private:
0188     Q_DECLARE_PRIVATE(GeoDataDocument)
0189 };
0190 
0191 }
0192 Q_DECLARE_METATYPE(Marble::GeoDataDocument*)
0193 #endif