File indexing completed on 2024-04-28 15:15:33

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de>
0004 //
0005 
0006 #ifndef MARBLE_ABSTRACTDATAPLUGINITEM_H
0007 #define MARBLE_ABSTRACTDATAPLUGINITEM_H
0008 
0009 #include <QObject>
0010 #include <QString>
0011 #include <QHash>
0012 
0013 #include "BillboardGraphicsItem.h"
0014 #include "marble_export.h"
0015 
0016 class QAction;
0017 
0018 namespace Marble
0019 {
0020 
0021 class AbstractDataPluginItemPrivate;
0022 
0023 class MARBLE_EXPORT AbstractDataPluginItem : public QObject, public BillboardGraphicsItem
0024 {
0025     Q_OBJECT
0026 
0027     Q_PROPERTY( QString identifier READ id WRITE setId NOTIFY idChanged )
0028     Q_PROPERTY( bool favorite READ isFavorite WRITE setFavorite NOTIFY favoriteChanged )
0029     Q_PROPERTY( bool sticky READ isSticky WRITE setSticky NOTIFY stickyChanged )
0030 
0031  public:
0032     explicit AbstractDataPluginItem( QObject *parent = nullptr );
0033     ~AbstractDataPluginItem() override;
0034 
0035     /**
0036      * Returns the item's tool tip.
0037      */
0038     QString toolTip() const;
0039 
0040     /**
0041      * Set the tool tip for the item.
0042      */
0043     void setToolTip( const QString& toolTip );
0044 
0045     QString id() const;
0046     void setId( const QString& id );
0047 
0048     bool isFavorite() const;
0049     virtual void setFavorite( bool favorite );
0050 
0051     bool isSticky() const;
0052     void setSticky( bool sticky );
0053 
0054     /**
0055      * @brief Set the settings of the item.
0056      * This is usually called automatically before painting. If you reimplement this it would be
0057      * useful to check for changes before copying.
0058      */
0059     virtual void setSettings( const QHash<QString, QVariant>& settings );
0060 
0061     /**
0062      * Returns the action of this specific item.
0063      */
0064     virtual QAction *action();
0065 
0066     virtual bool initialized() const = 0;
0067 
0068     virtual void addDownloadedFile( const QString& url, const QString& type );
0069 
0070     virtual bool operator<( const AbstractDataPluginItem *other ) const = 0;
0071 
0072     virtual QList<QAction*> actions();
0073 
0074  Q_SIGNALS:
0075     void updated();
0076     void idChanged();
0077     void favoriteChanged( const QString& id, bool favorite );
0078     void stickyChanged();
0079 
0080  public Q_SLOTS:
0081    void toggleFavorite();
0082 
0083  private:
0084     friend class AbstractDataPluginModel;
0085 
0086     /**
0087      * Returning the angular resolution of the viewport when the item was added to it the last
0088      * time.
0089      */
0090     qreal addedAngularResolution() const;
0091     void setAddedAngularResolution( qreal resolution );
0092 
0093     AbstractDataPluginItemPrivate * const d;
0094 };
0095 
0096 } // Marble namespace
0097 
0098 #endif