Marble

DgmlIconTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Nikolas Zimmermann <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 // Own
8 #include "DgmlIconTagHandler.h"
9 
10 // Qt
11 #include <QColor>
12 
13 // Marble
14 #include "DgmlElementDictionary.h"
15 #include "DgmlAttributeDictionary.h"
16 #include "GeoParser.h"
17 #include "GeoSceneHead.h"
18 #include "GeoSceneIcon.h"
19 #include "GeoSceneItem.h"
20 
21 namespace Marble
22 {
23 namespace dgml
24 {
25 DGML_DEFINE_TAG_HANDLER(Icon)
26 
27 GeoNode* DgmlIconTagHandler::parse(GeoParser& parser) const
28 {
29  // Check whether the tag is valid
30  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(dgmlTag_Icon)));
31 
32  QString pixmapRelativePath = parser.attribute(dgmlAttr_pixmap).trimmed();
33 
34  QColor color;
35  color.setNamedColor(parser.attribute(dgmlAttr_color).trimmed());
36 
37  GeoSceneIcon *icon = nullptr;
38 
39  // Checking for parent item
40  GeoStackItem parentItem = parser.parentElement();
41  if (parentItem.represents(dgmlTag_Head)) {
42  icon = parentItem.nodeAs<GeoSceneHead>()->icon();
43  icon->setPixmap( pixmapRelativePath );
44  icon->setColor( color );
45  }
46  if (parentItem.represents(dgmlTag_Item)) {
47  icon = parentItem.nodeAs<GeoSceneItem>()->icon();
48  icon->setPixmap( pixmapRelativePath );
49  icon->setColor( color );
50  }
51 
52  return nullptr;
53 }
54 
55 }
56 }
void setNamedColor(const QString &name)
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 Thu Sep 21 2023 04:12:25 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.