Marble

DgmlLayerTagHandler.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 "DgmlLayerTagHandler.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 "GeoSceneLayer.h"
17#include "GeoSceneMap.h"
18
19namespace Marble
20{
21namespace dgml
22{
23DGML_DEFINE_TAG_HANDLER(Layer)
24
25GeoNode *DgmlLayerTagHandler::parse(GeoParser &parser) const
26{
27 // Check whether the tag is valid
28 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(dgmlTag_Layer)));
29
30 QString name = parser.attribute(dgmlAttr_name).trimmed();
31 QString backend = parser.attribute(dgmlAttr_backend).toLower().trimmed();
32 QString role = parser.attribute(dgmlAttr_role).toLower().trimmed();
33
34 GeoSceneLayer *layer = nullptr;
35
36 // Checking for parent layer
37 GeoStackItem parentItem = parser.parentElement();
38 if (parentItem.represents(dgmlTag_Map)) {
39 layer = new GeoSceneLayer(name);
40 layer->setBackend(backend);
41 layer->setRole(role);
42 parentItem.nodeAs<GeoSceneMap>()->addLayer(layer);
43 }
44
45 return layer;
46}
47
48}
49}
QString name(StandardAction id)
Binds a QML item to a specific geodetic location in screen coordinates.
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 Mon Nov 18 2024 12:15:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.