File indexing completed on 2025-01-05 03:59:11
0001 /* 0002 SPDX-FileCopyrightText: 2008 Torsten Rahn <rahn@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "GeoSceneSection.h" 0008 0009 #include "GeoSceneTypes.h" 0010 #include "GeoSceneItem.h" 0011 0012 #include "digikam_debug.h" 0013 0014 namespace Marble 0015 { 0016 0017 GeoSceneSection::GeoSceneSection( const QString& name ) 0018 : m_name( name ), 0019 m_checkable( false ), 0020 m_spacing( 12 ) 0021 { 0022 } 0023 0024 GeoSceneSection::~GeoSceneSection() 0025 { 0026 qDeleteAll( m_items ); 0027 } 0028 0029 const char* GeoSceneSection::nodeType() const 0030 { 0031 return GeoSceneTypes::GeoSceneSectionType; 0032 } 0033 0034 void GeoSceneSection::addItem( GeoSceneItem* item ) 0035 { 0036 // Remove any item that has the same name 0037 QVector<GeoSceneItem*>::iterator it = m_items.begin(); 0038 while (it != m_items.end()) { 0039 GeoSceneItem* currentItem = *it; 0040 if ( currentItem->name() == item->name() ) { 0041 delete currentItem; 0042 m_items.erase(it); 0043 break; 0044 } 0045 else { 0046 ++it; 0047 } 0048 } 0049 0050 if ( item ) { 0051 m_items.append( item ); 0052 } 0053 } 0054 0055 GeoSceneItem* GeoSceneSection::item( const QString& name ) 0056 { 0057 GeoSceneItem* item = nullptr; 0058 0059 QVector<GeoSceneItem*>::const_iterator it = m_items.constBegin(); 0060 QVector<GeoSceneItem*>::const_iterator end = m_items.constEnd(); 0061 for (; it != end; ++it) { 0062 if ( (*it)->name() == name ) { 0063 item = *it; 0064 break; 0065 } 0066 } 0067 0068 if ( !item ) { 0069 item = new GeoSceneItem( name ); 0070 addItem( item ); 0071 } 0072 0073 return item; 0074 } 0075 0076 QVector<GeoSceneItem*> GeoSceneSection::items() const 0077 { 0078 return m_items; 0079 } 0080 0081 QString GeoSceneSection::name() const 0082 { 0083 return m_name; 0084 } 0085 0086 QString GeoSceneSection::heading() const 0087 { 0088 return m_heading; 0089 } 0090 0091 void GeoSceneSection::setHeading( const QString& heading ) 0092 { 0093 m_heading = heading; 0094 } 0095 0096 bool GeoSceneSection::checkable() const 0097 { 0098 return m_checkable; 0099 } 0100 0101 void GeoSceneSection::setCheckable( bool checkable ) 0102 { 0103 m_checkable = checkable; 0104 } 0105 0106 QString GeoSceneSection::connectTo() const 0107 { 0108 return m_connectTo; 0109 } 0110 0111 void GeoSceneSection::setConnectTo( const QString& connectTo ) 0112 { 0113 m_connectTo = connectTo; 0114 } 0115 0116 int GeoSceneSection::spacing() const 0117 { 0118 return m_spacing; 0119 } 0120 0121 void GeoSceneSection::setSpacing( int spacing ) 0122 { 0123 m_spacing = spacing; 0124 } 0125 0126 QString GeoSceneSection::radio() const 0127 { 0128 return m_radio; 0129 } 0130 0131 void GeoSceneSection::setRadio( const QString& radio ) 0132 { 0133 m_radio = radio; 0134 } 0135 0136 }