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 <QImage>
10#include <QString>
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()
39 , d(new GeoDataItemIconPrivate(*other.d))
40{
41}
42
43GeoDataItemIcon &GeoDataItemIcon::operator=(const GeoDataItemIcon &other)
44{
45 GeoDataObject::operator=(other);
46 *d = *other.d;
47 return *this;
48}
49
50bool GeoDataItemIcon::operator==(const GeoDataItemIcon &other) const
51{
52 return equals(other) && d->m_state == other.d->m_state && d->m_iconPath == other.d->m_iconPath && d->m_icon == other.d->m_icon;
53}
54
55bool GeoDataItemIcon::operator!=(const GeoDataItemIcon &other) const
56{
57 return !this->operator==(other);
58}
59
60GeoDataItemIcon::~GeoDataItemIcon()
61{
62 delete d;
63}
64
65const char *GeoDataItemIcon::nodeType() const
66{
67 return GeoDataTypes::GeoDataItemIconType;
68}
69
70GeoDataItemIcon::ItemIconStates GeoDataItemIcon::state() const
71{
72 return d->m_state;
73}
74
75void GeoDataItemIcon::setState(ItemIconStates state)
76{
77 d->m_state = state;
78}
79
80void GeoDataItemIcon::setIcon(const QImage &icon)
81{
82 d->m_icon = icon;
83}
84
85QString GeoDataItemIcon::iconPath() const
86{
87 return d->m_iconPath;
88}
89
90void GeoDataItemIcon::setIconPath(const QString &path)
91{
92 d->m_iconPath = path;
93}
94
95QImage GeoDataItemIcon::icon() const
96{
97 if (!d->m_icon.isNull()) {
98 return d->m_icon;
99 } else if (!d->m_iconPath.isEmpty()) {
100 d->m_icon = QImage(resolvePath(d->m_iconPath));
101 return d->m_icon;
102 } else {
103 return {};
104 }
105}
106
107}
QString path(const QString &relativePath)
bool equals(const QVariant &lhs, const QVariant &rhs)
bool operator==(const StyleDelim &l, const StyleDelim &r)
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.