Marble

KmlHotSpotTagHandler.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "KmlHotSpotTagHandler.h"
8
9#include "GeoDataHotSpot.h"
10#include "GeoDataIconStyle.h"
11#include "GeoParser.h"
12#include "KmlElementDictionary.h"
13
14namespace Marble
15{
16namespace kml
17{
18KML_DEFINE_TAG_HANDLER(hotSpot)
19
20GeoNode *KmlhotSpotTagHandler::parse(GeoParser &parser) const
21{
22 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(kmlTag_hotSpot)));
23
24 GeoStackItem parentItem = parser.parentElement();
25
26 if (parentItem.represents(kmlTag_IconStyle)) {
27 QPointF pf(parser.attribute("x").trimmed().toFloat(), parser.attribute("y").trimmed().toFloat());
28 QString xu = parser.attribute("xunits").trimmed();
29 QString yu = parser.attribute("yunits").trimmed();
30
31 GeoDataHotSpot::Units xunits;
32 GeoDataHotSpot::Units yunits;
33
34 if (xu == QLatin1StringView("pixels")) {
35 xunits = GeoDataHotSpot::Pixels;
36 } else if (xu == QLatin1StringView("insetPixels")) {
37 xunits = GeoDataHotSpot::InsetPixels;
38 } else {
39 xunits = GeoDataHotSpot::Fraction;
40 }
41
42 if (yu == QLatin1StringView("pixels")) {
43 yunits = GeoDataHotSpot::Pixels;
44 } else if (yu == QLatin1StringView("insetPixels")) {
45 yunits = GeoDataHotSpot::InsetPixels;
46 } else {
47 yunits = GeoDataHotSpot::Fraction;
48 }
49
50 parentItem.nodeAs<GeoDataIconStyle>()->setHotSpot(pf, xunits, yunits);
51 }
52 return nullptr;
53}
54
55}
56}
Binds a QML item to a specific geodetic location in screen coordinates.
QString trimmed() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.