Marble

KmlStateTagHandler.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 "KmlStateTagHandler.h"
7
8#include "MarbleDebug.h"
9
10#include "GeoDataItemIcon.h"
11#include "GeoDataParser.h"
12#include "KmlElementDictionary.h"
13
14namespace Marble
15{
16namespace kml
17{
18KML_DEFINE_TAG_HANDLER(state)
19
20GeoNode *KmlstateTagHandler::parse(GeoParser &parser) const
21{
22 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(kmlTag_state)));
23
24 GeoStackItem parentItem = parser.parentElement();
25
26 GeoDataItemIcon::ItemIconStates itemIconState;
27
28 if (parentItem.represents(kmlTag_ItemIcon)) {
29 QString value = parser.readElementText().trimmed();
30 QStringList iconStateTextList = value.split(QLatin1Char(' '));
31
32 for (const QString &value : iconStateTextList) {
33 if (value == QLatin1StringView("open")) {
34 itemIconState |= GeoDataItemIcon::Open;
35 } else if (value == QLatin1StringView("closed")) {
36 itemIconState |= GeoDataItemIcon::Closed;
37 } else if (value == QLatin1StringView("error")) {
38 itemIconState |= GeoDataItemIcon::Error;
39 } else if (value == QLatin1StringView("fetching0")) {
40 itemIconState |= GeoDataItemIcon::Fetching0;
41 } else if (value == QLatin1StringView("fetching1")) {
42 itemIconState |= GeoDataItemIcon::Fetching1;
43 } else if (value == QLatin1StringView("fetching2")) {
44 itemIconState |= GeoDataItemIcon::Fetching2;
45 } else {
46 mDebug() << "Cannot parse state value" << value;
47 }
48 }
49
50 parentItem.nodeAs<GeoDataItemIcon>()->setState(itemIconState);
51 }
52 return nullptr;
53}
54
55}
56}
Binds a QML item to a specific geodetic location in screen coordinates.
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString trimmed() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:37:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.