Marble

KmlHotSpotTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Patrick Spendrin <[email protected]>
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 
16 namespace Marble
17 {
18 namespace kml
19 {
20 KML_DEFINE_TAG_HANDLER( hotSpot )
21 
22 GeoNode* 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 }
QString trimmed() const const
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Oct 4 2023 04:09:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.