Marble

DgmlSectionTagHandler.cpp
1/*
2 SPDX-FileCopyrightText: 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 SPDX-FileCopyrightText: 2008 Torsten Rahn <tackat@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "DgmlSectionTagHandler.h"
9
10#include "MarbleDebug.h"
11
12#include "DgmlAttributeDictionary.h"
13#include "DgmlAuxillaryDictionary.h"
14#include "DgmlElementDictionary.h"
15#include "GeoParser.h"
16#include "GeoSceneLegend.h"
17#include "GeoSceneSection.h"
18
19namespace Marble
20{
21namespace dgml
22{
23DGML_DEFINE_TAG_HANDLER(Section)
24
25GeoNode *DgmlSectionTagHandler::parse(GeoParser &parser) const
26{
27 // Check whether the tag is valid
28 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(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 == QString::fromLatin1(dgmlValue_true) || checkable == QString::fromLatin1(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 name(GameStandardAction id)
Binds a QML item to a specific geodetic location in screen coordinates.
QString fromLatin1(QByteArrayView str)
int toInt(bool *ok, int base) const const
QString toLower() const const
QString trimmed() const const
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.