Marble

DgmlDownloadUrlTagHandler.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Jens-Michael Hoffmann <jensmh@gmx.de>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7// Own
8#include "DgmlDownloadUrlTagHandler.h"
9
10// Qt
11#include <QUrl>
12#include <QUrlQuery>
13
14// Marble
15#include "DgmlAttributeDictionary.h"
16#include "DgmlElementDictionary.h"
17#include "GeoParser.h"
18#include "GeoSceneTileDataset.h"
19
20namespace Marble
21{
22namespace dgml
23{
24DGML_DEFINE_TAG_HANDLER(DownloadUrl)
25
26GeoNode *DgmlDownloadUrlTagHandler::parse(GeoParser &parser) const
27{
28 // Check whether the tag is valid
29 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(dgmlTag_DownloadUrl)));
30
31 // Checking for parent item
32 GeoStackItem parentItem = parser.parentElement();
33 if (!parentItem.represents(dgmlTag_Texture) && !parentItem.represents(dgmlTag_Vectortile))
34 return nullptr;
35
36 QUrl url;
37
38 // Attribute protocol, optional?
39 QString protocolStr = parser.attribute(dgmlAttr_protocol).trimmed();
40 if (!protocolStr.isEmpty())
41 url.setScheme(protocolStr);
42
43 // Attribute user, optional
44 const QString userStr = parser.attribute(dgmlAttr_user).trimmed();
45 if (!userStr.isEmpty())
46 url.setUserName(userStr);
47
48 // Attribute password, optional
49 const QString passwordStr = parser.attribute(dgmlAttr_password).trimmed();
50 if (!passwordStr.isEmpty())
51 url.setPassword(passwordStr);
52
53 // Attribute host, mandatory
54 const QString hostStr = parser.attribute(dgmlAttr_host).trimmed();
55 if (!hostStr.isEmpty())
56 url.setHost(hostStr);
57
58 // Attribute port, optional
59 const QString portStr = parser.attribute(dgmlAttr_port).trimmed();
60 if (!portStr.isEmpty())
61 url.setPort(portStr.toInt());
62
63 // Attribute path, mandatory
64 const QString pathStr = parser.attribute(dgmlAttr_path).trimmed();
65 if (!pathStr.isEmpty())
66 url.setPath(pathStr);
67
68 // Attribute query, optional
69 const QString queryStr = parser.attribute(dgmlAttr_query).trimmed();
70 if (!queryStr.isEmpty()) {
72 query.setQuery(queryStr);
73 url.setQuery(query);
74 }
75
76 parentItem.nodeAs<GeoSceneTileDataset>()->addDownloadUrl(url);
77 return nullptr;
78}
79
80}
81}
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
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
void setHost(const QString &host, ParsingMode mode)
void setPassword(const QString &password, ParsingMode mode)
void setPath(const QString &path, ParsingMode mode)
void setPort(int port)
void setQuery(const QString &query, ParsingMode mode)
void setScheme(const QString &scheme)
void setUserName(const QString &userName, ParsingMode mode)
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.