Marble

KmlStateTagHandler.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <[email protected]>
4 //
5 
6 #include "KmlStateTagHandler.h"
7 
8 #include "MarbleDebug.h"
9 
10 #include "KmlElementDictionary.h"
11 #include "GeoDataItemIcon.h"
12 #include "GeoDataParser.h"
13 
14 namespace Marble
15 {
16 namespace kml
17 {
18 KML_DEFINE_TAG_HANDLER( state )
19 
20 GeoNode* KmlstateTagHandler::parse( GeoParser& parser ) const
21 {
22  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(kmlTag_state)));
23 
24  GeoStackItem parentItem = parser.parentElement();
25 
26  GeoDataItemIcon::ItemIconStates itemIconState;
27 
28  if ( parentItem.represents( kmlTag_ItemIcon ) )
29  {
30  QString value = parser.readElementText().trimmed();
31  QStringList iconStateTextList = value.split(QLatin1Char(' '));
32 
33  for( const QString &value: iconStateTextList ) {
34  if (value == QLatin1String("open")) {
35  itemIconState |= GeoDataItemIcon::Open;
36  } else if (value == QLatin1String("closed")) {
37  itemIconState |= GeoDataItemIcon::Closed;
38  } else if (value == QLatin1String("error")) {
39  itemIconState |= GeoDataItemIcon::Error;
40  } else if (value == QLatin1String("fetching0")) {
41  itemIconState |= GeoDataItemIcon::Fetching0;
42  } else if (value == QLatin1String("fetching1")) {
43  itemIconState |= GeoDataItemIcon::Fetching1;
44  } else if (value == QLatin1String("fetching2")) {
45  itemIconState |= GeoDataItemIcon::Fetching2;
46  }
47  else {
48  mDebug() << "Cannot parse state value" << value;
49  }
50  }
51 
52  parentItem.nodeAs<GeoDataItemIcon>()->setState( itemIconState );
53  }
54  return nullptr;
55 }
56 
57 }
58 }
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString trimmed() const const
Binds a QML item to a specific geodetic location in screen coordinates.
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Oct 3 2023 04:09:48 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.