Marble

DgmlItemTagHandler.cpp
1/*
2 SPDX-FileCopyrightText: 2007 Nikolas Zimmermann <zimmermann@kde.org>
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
18namespace Marble
19{
20namespace dgml
21{
22DGML_DEFINE_TAG_HANDLER(Item)
23
24GeoNode* 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 name(StandardShortcut id)
Binds a QML item to a specific geodetic location in screen coordinates.
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 Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.