Marble

DgmlLicenseTagHandler.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2012 Illya Kovalevskyy <[email protected]>
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 
15 namespace Marble
16 {
17 namespace dgml
18 {
19 DGML_DEFINE_TAG_HANDLER(License)
20 
21 GeoNode* 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 }
QString trimmed() const const
bool isEmpty() const const
Binds a QML item to a specific geodetic location in screen coordinates.
QString toLower() const const
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.