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

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2007 Murad Tagirov <tmurad@gmail.com>
0004 // SPDX-FileCopyrightText: 2009 Patrick Spendrin <ps_ml@gmx.de>
0005 //
0006 
0007 
0008 #ifndef MARBLE_GEODATAFEATURE_H
0009 #define MARBLE_GEODATAFEATURE_H
0010 
0011 #include "GeoDataObject.h"
0012 
0013 #include "geodata_export.h"
0014 
0015 namespace Marble
0016 {
0017 
0018 // forward define all features we can find.
0019 class GeoDataRegion;
0020 class GeoDataAbstractView;
0021 
0022 class GeoDataStyle;
0023 class GeoDataStyleMap;
0024 
0025 class GeoDataExtendedData;
0026 
0027 class GeoDataTimeSpan;
0028 class GeoDataTimeStamp;
0029 
0030 class GeoDataFeaturePrivate;
0031 
0032 class GeoDataSnippet;
0033 
0034 /**
0035  * @short A base class for all geodata features
0036  *
0037  * GeoDataFeature is the base class for most geodata classes that
0038  * correspond to places on a map. It is never instantiated by itself,
0039  * but is always used as part of a derived class.
0040  *
0041  * @see GeoDataPlacemark
0042  * @see GeoDataContainer
0043  */
0044 class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
0045 {
0046  public:
0047     GeoDataFeature();
0048     /// Create a new GeoDataFeature with @p name as its name.
0049     explicit GeoDataFeature( const QString& name );
0050 
0051     GeoDataFeature( const GeoDataFeature& other );
0052 
0053     ~GeoDataFeature() override;
0054 
0055     GeoDataFeature& operator=( const GeoDataFeature& other );
0056 
0057     bool operator==(const GeoDataFeature &other) const;
0058     inline bool operator!=(const GeoDataFeature &other) const { return !(*this == other); }
0059 
0060     EnumFeatureId featureId() const;
0061 
0062     /**
0063      * @brief The name of the feature
0064      *
0065      * The name of the feature should be a short string. It is often
0066      * shown directly on the map and need therefore not take up much
0067      * space.
0068      *
0069      * @return The name of this feature
0070      */
0071     QString name() const;
0072     /**
0073      * @brief Set a new name for this feature
0074      * @param value  the new name
0075      */
0076     void setName( const QString &value );
0077 
0078     /**
0079      * @brief A short description of the feature.
0080      *
0081      * HTML markup is not supported.
0082      * @todo When the Snippet is not supplied, the first lines of description should be used.
0083      * @return The name of this feature
0084      */
0085     GeoDataSnippet snippet() const;
0086     /**
0087      * @brief Set a new name for this feature
0088      * @param value  the new name
0089      */
0090     void setSnippet( const GeoDataSnippet &value );
0091 
0092     /// Return the address of the feature
0093     QString address() const;
0094     /// Set the address of this feature to @p value.
0095     void setAddress( const QString &value);
0096 
0097     /// Return the phone number of the feature
0098     QString phoneNumber() const;
0099     /// Set the phone number of this feature to @p value.
0100     void setPhoneNumber( const QString &value );
0101 
0102     /// Return the text description of the feature.
0103     QString description() const;
0104     /// Set the description of this feature to @p value.
0105     void setDescription( const QString &value );
0106 
0107     /**
0108      * @brief test if the description is CDATA or not
0109      * CDATA allows for special characters to be included in XML and also allows
0110      * for other XML formats to be embedded in the XML without interfering with
0111      * parser namespace.
0112      * @return @c true if the description should be treated as CDATA
0113      *         @c false if the description is a plain string
0114      */
0115     bool descriptionIsCDATA() const;
0116     /// Set the description to be CDATA See: @see descriptionIsCDATA()
0117     void setDescriptionCDATA( bool cdata );
0118 
0119     /// Get the Abstract view of the feature
0120     const GeoDataAbstractView *abstractView() const;
0121     GeoDataAbstractView *abstractView();
0122     /// Set the abstract view of the feature
0123     void setAbstractView( GeoDataAbstractView *abstractView );
0124 
0125     /// Return the styleUrl of the feature.
0126     QString styleUrl() const;
0127     /// Set the styleUrl of this feature to @p value.
0128     void setStyleUrl( const QString &value );
0129 
0130     /// Return whether this feature is visible or not
0131     bool isVisible() const;
0132 
0133     /// Return whether this feature is visible or not in the context of its parenting
0134     bool isGloballyVisible() const;
0135 
0136     /**
0137      * @brief Set a new value for visibility
0138      * @param value  new value for the visibility
0139      *
0140      * This function sets the visibility, i.e. whether this feature
0141      * should be shown or not.  This can be changed either from a GUI
0142      * or through some action of the program.
0143      */
0144     void setVisible( bool value );
0145 
0146     /**
0147      * Return the timespan of the feature.
0148      */
0149     const GeoDataTimeSpan& timeSpan() const;
0150     GeoDataTimeSpan& timeSpan();
0151 
0152     /**
0153      * Set the timespan of the feature.
0154      * @param timeSpan new of timespan.
0155      */
0156     void setTimeSpan( const GeoDataTimeSpan &timeSpan );
0157 
0158     /**
0159      * Return the timestamp of the feature.
0160      */
0161     const GeoDataTimeStamp& timeStamp() const;
0162     GeoDataTimeStamp& timeStamp();
0163 
0164     /**
0165      * Set the timestamp of the feature.
0166      * @param timeStamp new of the timestamp.
0167      */
0168     void setTimeStamp( const GeoDataTimeStamp &timeStamp );
0169 
0170     /**
0171      * Return the style assigned to the placemark, or a default style if none has been set
0172      */
0173     QSharedPointer<const GeoDataStyle> style() const;
0174     /**
0175      * Return the style assigned to the placemark with setStyle (can be 0)
0176      */
0177     QSharedPointer<const GeoDataStyle> customStyle() const;
0178     /**
0179      * Sets the style of the placemark.
0180      * @param  style  the new style to be used.
0181      */
0182     void setStyle( const QSharedPointer<GeoDataStyle> &style );
0183 
0184     /**
0185      * Return the ExtendedData assigned to the feature.
0186      */
0187     GeoDataExtendedData& extendedData();
0188     const GeoDataExtendedData& extendedData() const;
0189 
0190     /**
0191      * Sets the ExtendedData of the feature.
0192      * @param  extendedData  the new ExtendedData to be used.
0193      */
0194     void setExtendedData( const GeoDataExtendedData& extendedData );
0195 
0196     /**
0197      * Return the region assigned to the placemark.
0198      */
0199     const GeoDataRegion& region() const;
0200     GeoDataRegion& region();
0201     /**
0202      * @brief Sets the region of the placemark.
0203      * @param region new value for the region
0204      *
0205      * The feature is only shown when the region if active.
0206      */
0207     void setRegion( const GeoDataRegion& region );
0208 
0209     /**
0210      * Return the role of the placemark.
0211      *
0212      * FIXME: describe roles here!
0213      */
0214     const QString role() const;
0215     /**
0216      * Sets the role of the placemark.
0217      * @param  role  the new role to be used.
0218      */
0219     void setRole( const QString &role );
0220 
0221     /**
0222      * @brief Return the popularity index of the placemark.
0223      *
0224      * The popularity index is a value which describes at which zoom
0225      * level the placemark will be shown.
0226      */
0227     int zoomLevel() const;
0228     /**
0229      * Sets the popularity @p index of the placemark.
0230      * @param  index  the new index to be used.
0231      */
0232     void setZoomLevel( int index );
0233 
0234     /**
0235      * Return the popularity of the feature.
0236      */
0237     qint64 popularity() const;
0238     /**
0239      * Sets the @p popularity of the feature.
0240      * @param  popularity  the new popularity value
0241      */
0242     void setPopularity( qint64 popularity );
0243 
0244     /**
0245      * Return a pointer to a GeoDataStyleMap object which represents the styleMap
0246      * of this feature. A styleMap is simply a QMap<QString,QString> which can connect
0247      * two styles with a keyword. This can be used to have a highlighted and a
0248      * normal style.
0249      * @see GeoDataStyleMap
0250      */
0251     const GeoDataStyleMap* styleMap() const;
0252     /**
0253      * Sets the styleMap of the feature
0254      */
0255     void setStyleMap( const GeoDataStyleMap* map );
0256 
0257     /// Duplicate into another equal instance
0258     virtual GeoDataFeature * clone() const = 0;
0259 
0260 
0261     /// Serialize the contents of the feature to @p stream.
0262     void pack( QDataStream& stream ) const override;
0263     /// Unserialize the contents of the feature from @p stream.
0264     void unpack( QDataStream& stream ) override;
0265 
0266  protected:
0267     // the d-pointer needs to be protected to be accessible from derived classes
0268     GeoDataFeaturePrivate* const d_ptr;
0269     explicit GeoDataFeature(GeoDataFeaturePrivate* dd);
0270     GeoDataFeature(const GeoDataFeature& other, GeoDataFeaturePrivate* dd);
0271 
0272     bool equals( const GeoDataFeature &other ) const;
0273     using GeoDataObject::equals;
0274 
0275  private:
0276     Q_DECLARE_PRIVATE(GeoDataFeature)
0277 };
0278 
0279 }
0280 
0281 #endif