Marble

DgmlLicenseTagHandler.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
4//
5
6#include "DgmlLicenseTagHandler.h"
7#include "GeoSceneLicense.h"
8
9#include "DgmlElementDictionary.h"
10#include "DgmlAttributeDictionary.h"
11#include "GeoParser.h"
12#include "GeoSceneHead.h"
13#include "MarbleDebug.h"
14
15namespace Marble
16{
17namespace dgml
18{
19DGML_DEFINE_TAG_HANDLER(License)
20
21GeoNode* DgmlLicenseTagHandler::parse( GeoParser& parser ) const
22{
23 // Check whether the tag is valid
24 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(dgmlTag_License)));
25
26 GeoStackItem parentItem = parser.parentElement();
27 if( parentItem.represents( dgmlTag_Head ) ) {
28 QString const attribution = parser.attribute(dgmlAttr_attribution).trimmed().toLower();
29 if (attribution == QLatin1String("never")) {
30 parentItem.nodeAs<GeoSceneHead>()->license()->setAttribution( GeoSceneLicense::Never );
31 } else if (attribution == QLatin1String("opt-in") || attribution == QLatin1String("optin")) {
32 parentItem.nodeAs<GeoSceneHead>()->license()->setAttribution( GeoSceneLicense::OptIn );
33 } else if (attribution.isEmpty() || attribution == QLatin1String("opt-out") || attribution == QLatin1String("optout")) {
34 parentItem.nodeAs<GeoSceneHead>()->license()->setAttribution( GeoSceneLicense::OptOut );
35 } else if (attribution == QLatin1String("always")) {
36 parentItem.nodeAs<GeoSceneHead>()->license()->setAttribution( GeoSceneLicense::Always );
37 } else {
38 mDebug() << "Unknown license attribution value " << attribution << ", falling back to 'opt-out'.";
39 parentItem.nodeAs<GeoSceneHead>()->license()->setAttribution( GeoSceneLicense::OptOut );
40 }
41 QString const shortLicense = parser.attribute( dgmlAttr_short ).trimmed();
42 parentItem.nodeAs<GeoSceneHead>()->license()->setShortLicense( shortLicense );
43 QString const fullLicense = parser.readElementText().trimmed();
44 parentItem.nodeAs<GeoSceneHead>()->license()->setLicense( fullLicense );
45 }
46
47 return nullptr;
48}
49
50}
51}
Binds a QML item to a specific geodetic location in screen coordinates.
bool isEmpty() 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.