Marble

DgmlItemTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Nikolas Zimmermann <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "DgmlItemTagHandler.h"
8 
9 #include "MarbleDebug.h"
10 
11 #include "DgmlElementDictionary.h"
12 #include "DgmlAttributeDictionary.h"
13 #include "DgmlAuxillaryDictionary.h"
14 #include "GeoParser.h"
15 #include "GeoSceneSection.h"
16 #include "GeoSceneItem.h"
17 
18 namespace Marble
19 {
20 namespace dgml
21 {
22 DGML_DEFINE_TAG_HANDLER(Item)
23 
24 GeoNode* DgmlItemTagHandler::parse(GeoParser& parser) const
25 {
26  // Check whether the tag is valid
27  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(dgmlTag_Item)));
28 
29  QString name = parser.attribute(dgmlAttr_name).trimmed();
30  QString checkable = parser.attribute(dgmlAttr_checkable).toLower().trimmed();
31  QString connectTo = parser.attribute(dgmlAttr_connect).trimmed();
32  int spacing = parser.attribute(dgmlAttr_spacing).toInt();
33 
34  GeoSceneItem *item = nullptr;
35 
36  // Checking for parent item
37  GeoStackItem parentItem = parser.parentElement();
38  if (parentItem.represents(dgmlTag_Section)) {
39  item = new GeoSceneItem( name );
40  item->setCheckable( checkable == dgmlValue_true || checkable == dgmlValue_on );
41  item->setConnectTo( connectTo );
42  item->setSpacing( spacing );
43  parentItem.nodeAs<GeoSceneSection>()->addItem( item );
44  }
45 
46  return item;
47 }
48 
49 }
50 }
QString trimmed() const const
int toInt(bool *ok, int base) const const
Binds a QML item to a specific geodetic location in screen coordinates.
QString toLower() const const
const char * name(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.