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 "MarbleDebug.h"
10
11#include "KmlElementDictionary.h"
12#include "GeoDataIconStyle.h"
13#include "GeoDataHotSpot.h"
14#include "GeoParser.h"
15
16namespace Marble
17{
18namespace kml
19{
20KML_DEFINE_TAG_HANDLER( hotSpot )
21
22GeoNode* KmlhotSpotTagHandler::parse( GeoParser& parser ) const
23{
24 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(kmlTag_hotSpot)));
25
26 GeoStackItem parentItem = parser.parentElement();
27
28 if ( parentItem.represents( kmlTag_IconStyle ) ) {
29 QPointF pf( parser.attribute( "x" ).trimmed().toFloat(),
30 parser.attribute( "y" ).trimmed().toFloat() );
31 QString xu = parser.attribute( "xunits" ).trimmed();
32 QString yu = parser.attribute( "yunits" ).trimmed();
33
34 GeoDataHotSpot::Units xunits;
35 GeoDataHotSpot::Units yunits;
36
37 if (xu == QLatin1String("pixels")) {
38 xunits = GeoDataHotSpot::Pixels;
39 } else if (xu == QLatin1String("insetPixels")) {
40 xunits = GeoDataHotSpot::InsetPixels;
41 } else {
42 xunits = GeoDataHotSpot::Fraction;
43 }
44
45 if (yu == QLatin1String("pixels")) {
46 yunits = GeoDataHotSpot::Pixels;
47 } else if (yu == QLatin1String("insetPixels")) {
48 yunits = GeoDataHotSpot::InsetPixels;
49 } else {
50 yunits = GeoDataHotSpot::Fraction;
51 }
52
53 parentItem.nodeAs<GeoDataIconStyle>()->setHotSpot( pf, xunits, yunits );
54 }
55 return nullptr;
56}
57
58}
59}
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 Jun 14 2024 11:54:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.