Marble

DgmlMapTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2007 Nikolas Zimmermann <[email protected]>
3  SPDX-FileCopyrightText: 2008 Torsten Rahn <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #include "DgmlMapTagHandler.h"
9 
10 #include <QColor>
11 
12 #include "DgmlElementDictionary.h"
13 #include "DgmlAttributeDictionary.h"
14 #include "GeoParser.h"
15 #include "GeoSceneDocument.h"
16 #include "GeoSceneMap.h"
17 
18 namespace Marble
19 {
20 namespace dgml
21 {
22 DGML_DEFINE_TAG_HANDLER(Map)
23 
24 GeoNode* DgmlMapTagHandler::parse(GeoParser& parser) const
25 {
26  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(dgmlTag_Map)));
27 
28  QColor labelColor = parser.attribute(dgmlAttr_labelColor).trimmed();
29 
30  if ( !labelColor.isValid() )
31  labelColor = Qt::black;
32 
33  QColor highlightBrushColor = QColor ( parser.attribute(dgmlAttr_highlightBrush).trimmed() );
34  QColor highlightPenColor = QColor ( parser.attribute(dgmlAttr_highlightPen).trimmed() );
35 
36  GeoSceneMap* map = nullptr;
37 
38  // Checking for parent item
39  GeoStackItem parentItem = parser.parentElement();
40  if (parentItem.represents(dgmlTag_Document)) {
41  map = parentItem.nodeAs<GeoSceneDocument>()->map();
42  map->setBackgroundColor( QColor( parser.attribute( dgmlAttr_bgcolor ).trimmed() ) );
43  map->setLabelColor( labelColor );
44  map->setHighlightBrushColor( highlightBrushColor );
45  map->setHighlightPenColor( highlightPenColor );
46  }
47 
48  return map;
49 }
50 
51 }
52 }
Binds a QML item to a specific geodetic location in screen coordinates.
bool isValid() const const
QFuture< void > map(Sequence &sequence, MapFunctor function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.