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 "DgmlElementDictionary.h"
14#include "DgmlAttributeDictionary.h"
15#include "DgmlAuxillaryDictionary.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(QLatin1String(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)
46 && parentItem.nodeAs<GeoSceneLayer>()->backend() == dgmlValue_texture ) {
47
48 texture = new GeoSceneTextureTileDataset( name );
49 texture->setExpire( expire );
50 parentItem.nodeAs<GeoSceneLayer>()->addDataset( texture );
51 }
52
53 return texture;
54}
55
56}
57}
QString name(StandardShortcut id)
Binds a QML item to a specific geodetic location in screen coordinates.
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 May 3 2024 11:49:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.