Marble

KmlDescriptionTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Patrick Spendrin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "KmlDescriptionTagHandler.h"
8 
9 #include "MarbleDebug.h"
10 
11 #include "KmlElementDictionary.h"
12 
13 #include "GeoDataFeature.h"
14 #include "GeoParser.h"
15 
16 namespace Marble
17 {
18 namespace kml
19 {
20 KML_DEFINE_TAG_HANDLER( description )
21 
22 GeoNode* KmldescriptionTagHandler::parse( GeoParser& parser ) const
23 {
24  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(kmlTag_description)));
25 
26  GeoStackItem parentItem = parser.parentElement();
27 
28  if( parentItem.is<GeoDataFeature>() ) {
29 
30  QString result;
31  bool finished = false;
32  bool isCDATA = false;
33  while( !finished ) {
34  switch ( parser.readNext() ) {
37  result.append( parser.text() );
38  if( parser.isCDATA() ) {
39  isCDATA = true;
40  }
41  break;
42  }
44  finished = true;
45  break;
48  break;
49  default:
50  finished = true;
51  break;
52  }
53  }
54 
55  QString description = result.trimmed();
56 
57  parentItem.nodeAs<GeoDataFeature>()->setDescription( description );
58  parentItem.nodeAs<GeoDataFeature>()->setDescriptionCDATA( isCDATA );
59  }
60 
61  return nullptr;
62 }
63 
64 }
65 }
QString trimmed() const const
Binds a QML item to a specific geodetic location in screen coordinates.
QString & append(QChar ch)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:27 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.