Marble

DgmlTextureTagHandler.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 "DgmlTextureTagHandler.h"
8
9#include <limits>
10
11#include "MarbleDebug.h"
12
13#include "DgmlAttributeDictionary.h"
14#include "DgmlAuxillaryDictionary.h"
15#include "DgmlElementDictionary.h"
16#include "GeoParser.h"
17#include "GeoSceneLayer.h"
18#include "GeoSceneTextureTileDataset.h"
19
20namespace Marble
21{
22namespace dgml
23{
24DGML_DEFINE_TAG_HANDLER(Texture)
25
26GeoNode *DgmlTextureTagHandler::parse(GeoParser &parser) const
27{
28 // Check whether the tag is valid
29 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(dgmlTag_Texture)));
30
31 const QString name = parser.attribute(dgmlAttr_name).trimmed();
32
33 const QString expireStr = parser.attribute(dgmlAttr_expire).trimmed();
34 int expire = std::numeric_limits<int>::max();
35 if (!expireStr.isEmpty())
36 expire = expireStr.toInt();
37
38 GeoSceneTileDataset *texture = nullptr;
39
40 // Checking for parent item
41 GeoStackItem parentItem = parser.parentElement();
42
43 // Check parent type and make sure that the dataSet type
44 // matches the backend of the parent layer
45 if (parentItem.represents(dgmlTag_Layer) && parentItem.nodeAs<GeoSceneLayer>()->backend() == QString::fromLatin1(dgmlValue_texture)) {
46 texture = new GeoSceneTextureTileDataset(name);
47 texture->setExpire(expire);
48 parentItem.nodeAs<GeoSceneLayer>()->addDataset(texture);
49 }
50
51 return texture;
52}
53
54}
55}
QString name(StandardAction id)
Binds a QML item to a specific geodetic location in screen coordinates.
QString fromLatin1(QByteArrayView str)
bool isEmpty() const const
int toInt(bool *ok, int base) const const
QString trimmed() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:52:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.