Marble

GeoDataItemIcon.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <[email protected]>
4 //
5 
6 #include "GeoDataItemIcon.h"
7 #include "GeoDataTypes.h"
8 
9 #include <QString>
10 #include <QImage>
11 
12 namespace Marble
13 {
14 
15 class GeoDataItemIconPrivate
16 {
17 public:
18  GeoDataItemIconPrivate();
19 
20  GeoDataItemIcon::ItemIconStates m_state;
21  QString m_iconPath;
22  QImage m_icon;
23 };
24 
25 GeoDataItemIconPrivate::GeoDataItemIconPrivate() :
26  m_state(),
27  m_iconPath(),
28  m_icon()
29 {
30 }
31 
32 GeoDataItemIcon::GeoDataItemIcon() :
33  d( new GeoDataItemIconPrivate )
34 {
35 }
36 
37 GeoDataItemIcon::GeoDataItemIcon( const Marble::GeoDataItemIcon &other ) :
38  GeoDataObject(), d( new GeoDataItemIconPrivate( *other.d ) )
39 {
40 }
41 
42 GeoDataItemIcon &GeoDataItemIcon::operator=( const GeoDataItemIcon &other )
43 {
44  GeoDataObject::operator=( other );
45  *d = *other.d;
46  return *this;
47 }
48 
49 bool 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 
57 bool GeoDataItemIcon::operator!=( const GeoDataItemIcon& other ) const
58 {
59  return !this->operator==(other);
60 }
61 
62 GeoDataItemIcon::~GeoDataItemIcon()
63 {
64  delete d;
65 }
66 
67 const char *GeoDataItemIcon::nodeType() const
68 {
69  return GeoDataTypes::GeoDataItemIconType;
70 }
71 
72 GeoDataItemIcon::ItemIconStates GeoDataItemIcon::state() const
73 {
74  return d->m_state;
75 }
76 
77 void GeoDataItemIcon::setState(ItemIconStates state)
78 {
79  d->m_state = state;
80 }
81 
82 void GeoDataItemIcon::setIcon( const QImage &icon )
83 {
84  d->m_icon = icon;
85 }
86 
87 QString GeoDataItemIcon::iconPath() const
88 {
89  return d->m_iconPath;
90 }
91 
92 void GeoDataItemIcon::setIconPath( const QString &path )
93 {
94  d->m_iconPath = path;
95 }
96 
97 QImage 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 }
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
Binds a QML item to a specific geodetic location in screen coordinates.
QString path(const QString &relativePath)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.