Marble

DgmlSectionTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Nikolas Zimmermann <[email protected]>
3  SPDX-FileCopyrightText: 2008 Torsten Rahn <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #include "DgmlSectionTagHandler.h"
9 
10 #include "MarbleDebug.h"
11 
12 #include "DgmlElementDictionary.h"
13 #include "DgmlAttributeDictionary.h"
14 #include "DgmlAuxillaryDictionary.h"
15 #include "GeoParser.h"
16 #include "GeoSceneLegend.h"
17 #include "GeoSceneSection.h"
18 
19 namespace Marble
20 {
21 namespace dgml
22 {
23 DGML_DEFINE_TAG_HANDLER(Section)
24 
25 GeoNode* DgmlSectionTagHandler::parse(GeoParser& parser) const
26 {
27  // Check whether the tag is valid
28  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(dgmlTag_Section)));
29 
30  QString name = parser.attribute(dgmlAttr_name);
31  QString checkable = parser.attribute(dgmlAttr_checkable).toLower().trimmed();
32  QString connectTo = parser.attribute(dgmlAttr_connect).trimmed();
33  QString radio = parser.attribute(dgmlAttr_radio);
34  int spacing = parser.attribute(dgmlAttr_spacing).toInt();
35 
36  GeoSceneSection* section = nullptr;
37 
38  // Checking for parent item
39  GeoStackItem parentItem = parser.parentElement();
40  if (parentItem.represents(dgmlTag_Legend)) {
41  section = new GeoSceneSection( name );
42  section->setCheckable( checkable == dgmlValue_true || checkable == dgmlValue_on );
43  section->setConnectTo( connectTo );
44  section->setSpacing( spacing );
45  section->setRadio( radio );
46  parentItem.nodeAs<GeoSceneLegend>()->addSection( section );
47  }
48 
49  return section;
50 }
51 
52 }
53 }
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
QString name(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Sep 25 2023 03:50:18 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.