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 "DgmlAttributeDictionary.h"
10#include "DgmlAuxillaryDictionary.h"
11#include "DgmlElementDictionary.h"
12#include "GeoParser.h"
13#include "GeoSceneItem.h"
14#include "GeoSceneSection.h"
15
16namespace Marble
17{
18namespace dgml
19{
20DGML_DEFINE_TAG_HANDLER(Item)
21
22GeoNode *DgmlItemTagHandler::parse(GeoParser &parser) const
23{
24 // Check whether the tag is valid
25 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(dgmlTag_Item)));
26
27 QString name = parser.attribute(dgmlAttr_name).trimmed();
28 QString checkable = parser.attribute(dgmlAttr_checkable).toLower().trimmed();
29 QString connectTo = parser.attribute(dgmlAttr_connect).trimmed();
30 int spacing = parser.attribute(dgmlAttr_spacing).toInt();
31
32 GeoSceneItem *item = nullptr;
33
34 // Checking for parent item
35 GeoStackItem parentItem = parser.parentElement();
36 if (parentItem.represents(dgmlTag_Section)) {
37 item = new GeoSceneItem(name);
38 item->setCheckable(checkable == QString::fromLatin1(dgmlValue_true) || checkable == QString::fromLatin1(dgmlValue_on));
39 item->setConnectTo(connectTo);
40 item->setSpacing(spacing);
41 parentItem.nodeAs<GeoSceneSection>()->addItem(item);
42 }
43
44 return item;
45}
46
47}
48}
QString name(StandardAction 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 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.