File indexing completed on 2024-05-12 03:50:10

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