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

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2012 Dennis Nienhüser <nienhueser@kde.org>
0004 //
0005 
0006 #include "GeoDataOverlay.h"
0007 #include "GeoDataOverlay_p.h"
0008 
0009 namespace Marble {
0010 
0011 GeoDataOverlay::GeoDataOverlay()
0012     : GeoDataFeature(new GeoDataOverlayPrivate)
0013 {
0014     // nothing to do
0015 }
0016 
0017 GeoDataOverlay::GeoDataOverlay(const GeoDataOverlay &other)
0018     : GeoDataFeature(other, new GeoDataOverlayPrivate(*other.d_func()))
0019 {
0020     // nothing to do
0021 }
0022 
0023 GeoDataOverlay::GeoDataOverlay(GeoDataOverlayPrivate *priv)
0024     : GeoDataFeature(priv)
0025 {
0026 }
0027 
0028 GeoDataOverlay::GeoDataOverlay(const GeoDataOverlay& other, GeoDataOverlayPrivate *priv)
0029     : GeoDataFeature(other, priv)
0030 {
0031 }
0032 
0033 GeoDataOverlay::~GeoDataOverlay()
0034 {
0035 }
0036 
0037 GeoDataOverlay &GeoDataOverlay::operator=( const GeoDataOverlay &other )
0038 {
0039     if (this != &other) {
0040         Q_D(GeoDataOverlay);
0041         *d = *other.d_func();
0042     }
0043 
0044     return *this;
0045 }
0046 
0047 QColor GeoDataOverlay::color() const
0048 {
0049     Q_D(const GeoDataOverlay);
0050     return d->m_color;
0051 }
0052 
0053 void GeoDataOverlay::setColor( const QColor &color )
0054 {
0055     Q_D(GeoDataOverlay);
0056     d->m_color = color;
0057 }
0058 
0059 int GeoDataOverlay::drawOrder() const
0060 {
0061     Q_D(const GeoDataOverlay);
0062     return d->m_drawOrder;
0063 }
0064 
0065 void GeoDataOverlay::setDrawOrder( int order )
0066 {
0067     Q_D(GeoDataOverlay);
0068     d->m_drawOrder = order;
0069 }
0070 
0071 QImage GeoDataOverlay::icon() const
0072 {
0073     Q_D(const GeoDataOverlay);
0074     if ( d->m_image.isNull() && !d->m_iconPath.isEmpty() ) {
0075         d->m_image = QImage( absoluteIconFile() );
0076     }
0077     return d->m_image;
0078 }
0079 
0080 void GeoDataOverlay::setIcon( const QImage &icon )
0081 {
0082     Q_D(GeoDataOverlay);
0083     d->m_image = icon;
0084 }
0085 
0086 void GeoDataOverlay::setIconFile( const QString &path )
0087 {
0088     Q_D(GeoDataOverlay);
0089     d->m_iconPath = path;
0090     d->m_image = QImage( path );
0091 }
0092 
0093 QString GeoDataOverlay::iconFile() const
0094 {
0095     Q_D(const GeoDataOverlay);
0096     return d->m_iconPath;
0097 }
0098 
0099 QString GeoDataOverlay::absoluteIconFile() const
0100 {
0101     Q_D(const GeoDataOverlay);
0102     return resolvePath( d->m_iconPath );
0103 }
0104 
0105 bool GeoDataOverlay::equals(const GeoDataOverlay& other) const
0106 {
0107     Q_D(const GeoDataOverlay);
0108     const GeoDataOverlayPrivate* const other_d = other.d_func();
0109 
0110     return GeoDataFeature::equals(other) &&
0111            d->m_drawOrder == other_d->m_drawOrder &&
0112            d->m_color == other_d->m_color &&
0113            d->m_iconPath == other_d->m_iconPath &&
0114            d->m_image == other_d->m_image;
0115 }
0116 
0117 }