File indexing completed on 2024-06-02 03:51:06
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com> 0004 // 0005 0006 #include "KmlStateTagHandler.h" 0007 0008 #include "MarbleDebug.h" 0009 0010 #include "KmlElementDictionary.h" 0011 #include "GeoDataItemIcon.h" 0012 #include "GeoDataParser.h" 0013 0014 namespace Marble 0015 { 0016 namespace kml 0017 { 0018 KML_DEFINE_TAG_HANDLER( state ) 0019 0020 GeoNode* KmlstateTagHandler::parse( GeoParser& parser ) const 0021 { 0022 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(kmlTag_state))); 0023 0024 GeoStackItem parentItem = parser.parentElement(); 0025 0026 GeoDataItemIcon::ItemIconStates itemIconState; 0027 0028 if ( parentItem.represents( kmlTag_ItemIcon ) ) 0029 { 0030 QString value = parser.readElementText().trimmed(); 0031 QStringList iconStateTextList = value.split(QLatin1Char(' ')); 0032 0033 for( const QString &value: iconStateTextList ) { 0034 if (value == QLatin1String("open")) { 0035 itemIconState |= GeoDataItemIcon::Open; 0036 } else if (value == QLatin1String("closed")) { 0037 itemIconState |= GeoDataItemIcon::Closed; 0038 } else if (value == QLatin1String("error")) { 0039 itemIconState |= GeoDataItemIcon::Error; 0040 } else if (value == QLatin1String("fetching0")) { 0041 itemIconState |= GeoDataItemIcon::Fetching0; 0042 } else if (value == QLatin1String("fetching1")) { 0043 itemIconState |= GeoDataItemIcon::Fetching1; 0044 } else if (value == QLatin1String("fetching2")) { 0045 itemIconState |= GeoDataItemIcon::Fetching2; 0046 } 0047 else { 0048 mDebug() << "Cannot parse state value" << value; 0049 } 0050 } 0051 0052 parentItem.nodeAs<GeoDataItemIcon>()->setState( itemIconState ); 0053 } 0054 return nullptr; 0055 } 0056 0057 } 0058 }