Marble

GeoDataItemIcon.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
4//
5
6#include "GeoDataItemIcon.h"
7#include "GeoDataTypes.h"
8
9#include <QString>
10#include <QImage>
11
12namespace Marble
13{
14
15class GeoDataItemIconPrivate
16{
17public:
18 GeoDataItemIconPrivate();
19
20 GeoDataItemIcon::ItemIconStates m_state;
21 QString m_iconPath;
22 QImage m_icon;
23};
24
25GeoDataItemIconPrivate::GeoDataItemIconPrivate() :
26 m_state(),
27 m_iconPath(),
28 m_icon()
29{
30}
31
32GeoDataItemIcon::GeoDataItemIcon() :
33 d( new GeoDataItemIconPrivate )
34{
35}
36
37GeoDataItemIcon::GeoDataItemIcon( const Marble::GeoDataItemIcon &other ) :
38 GeoDataObject(), d( new GeoDataItemIconPrivate( *other.d ) )
39{
40}
41
42GeoDataItemIcon &GeoDataItemIcon::operator=( const GeoDataItemIcon &other )
43{
44 GeoDataObject::operator=( other );
45 *d = *other.d;
46 return *this;
47}
48
49bool GeoDataItemIcon::operator==( const GeoDataItemIcon& other ) const
50{
51 return equals(other) &&
52 d->m_state == other.d->m_state &&
53 d->m_iconPath == other.d->m_iconPath &&
54 d->m_icon == other.d->m_icon;
55}
56
57bool GeoDataItemIcon::operator!=( const GeoDataItemIcon& other ) const
58{
59 return !this->operator==(other);
60}
61
62GeoDataItemIcon::~GeoDataItemIcon()
63{
64 delete d;
65}
66
67const char *GeoDataItemIcon::nodeType() const
68{
69 return GeoDataTypes::GeoDataItemIconType;
70}
71
72GeoDataItemIcon::ItemIconStates GeoDataItemIcon::state() const
73{
74 return d->m_state;
75}
76
77void GeoDataItemIcon::setState(ItemIconStates state)
78{
79 d->m_state = state;
80}
81
82void GeoDataItemIcon::setIcon( const QImage &icon )
83{
84 d->m_icon = icon;
85}
86
87QString GeoDataItemIcon::iconPath() const
88{
89 return d->m_iconPath;
90}
91
92void GeoDataItemIcon::setIconPath( const QString &path )
93{
94 d->m_iconPath = path;
95}
96
97QImage GeoDataItemIcon::icon() const
98{
99 if(!d->m_icon.isNull())
100 {
101 return d->m_icon;
102 }
103 else if(!d->m_iconPath.isEmpty())
104 {
105 d->m_icon = QImage(resolvePath(d->m_iconPath));
106 return d->m_icon;
107 }
108 else
109 {
110 return QImage();
111 }
112}
113
114}
QString path(const QString &relativePath)
bool equals(const QVariant &lhs, const QVariant &rhs)
Binds a QML item to a specific geodetic location in screen coordinates.
bool operator==(const QGraphicsApiFilter &reference, const QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:54:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.