[Marble-commits] KDE/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Wed Sep 8 23:26:50 CEST 2010
SVN commit 1173176 by nienhueser:
Name and displayName are both attributes of GeoDataData, so add name. Fix tag writer using displayName to write name. Write displayName optionally. Add a convenience constructor to GeoDataData. Fixes empty name attributes being written for Data elements when displayName is not set.
RB: 5292
M +1 -4 lib/BookmarkInfoDialog.cpp
M +2 -7 lib/FileLoader.cpp
M +17 -0 lib/geodata/data/GeoDataData.cpp
M +15 -0 lib/geodata/data/GeoDataData.h
M +1 -0 lib/geodata/data/GeoDataData_p.h
M +2 -2 lib/geodata/data/GeoDataExtendedData.cpp
M +1 -1 lib/geodata/data/GeoDataExtendedData.h
M +4 -1 lib/geodata/handlers/kml/KmlDataTagHandler.cpp
M +4 -1 lib/geodata/writers/kml/KmlDataTagWriter.cpp
M +3 -4 plugins/runner/gosmore/GosmoreRunner.cpp
M +1 -3 plugins/runner/nominatim/OsmNominatimRunner.cpp
M +2 -1 plugins/runner/routino/RoutinoRunner.cpp
--- trunk/KDE/kdeedu/marble/src/lib/BookmarkInfoDialog.cpp #1173175:1173176
@@ -141,10 +141,7 @@
bookmark.setDescriptionCDATA( true );
bookmark.setCoordinate( m_widget->centerLongitude(), m_widget->centerLatitude(), 0, GeoDataPoint::Degree );
- GeoDataData data;
- data.setValue(true);
- data.setDisplayName("isBookmark");
- bookmark.extendedData().addValue("isBookmark",data );
+ bookmark.extendedData().addValue( GeoDataData( "isBookmark", true ) );
GeoDataLookAt *lookAt = new GeoDataLookAt( m_widget->lookAt() ) ;
bookmark.setLookAt( lookAt );
--- trunk/KDE/kdeedu/marble/src/lib/FileLoader.cpp #1173175:1173176
@@ -249,12 +249,9 @@
qint64 tmpint64;
qint8 tmpint8;
qint16 tmpint16;
- GeoDataData tmpdata;
while ( !in.atEnd() ) {
GeoDataPlacemark *mark = new GeoDataPlacemark;
- GeoDataData tmpgmt;
- GeoDataData tmpdst;
in >> tmpstr;
mark->setName( tmpstr );
in >> lon >> lat >> alt;
@@ -272,11 +269,9 @@
in >> tmpint64;
mark->setPopulation( tmpint64 );
in >> tmpint16;
- tmpgmt.setValue( QVariant( ( int ) tmpint16 ) );
- mark->extendedData().addValue("gmt", tmpgmt );
+ mark->extendedData().addValue( GeoDataData( "gmt", int( tmpint16 ) ) );
in >> tmpint8;
- tmpdst.setValue( QVariant( ( int ) tmpint8 ) );
- mark->extendedData().addValue("dst", tmpdst );
+ mark->extendedData().addValue( GeoDataData( "dst", int( tmpint8 ) ) );
m_document->append( mark );
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataData.cpp #1173175:1173176
@@ -40,6 +40,13 @@
return *this;
}
+GeoDataData::GeoDataData( const QString &name, const QVariant &value )
+ : d( new GeoDataDataPrivate )
+{
+ d->m_name = name;
+ d->m_value = value;
+}
+
QString GeoDataData::nodeType() const
{
return d->nodeType();
@@ -55,6 +62,16 @@
d->m_value = value;
}
+QString GeoDataData::name() const
+{
+ return d->m_name;
+}
+
+void GeoDataData::setName( const QString& name )
+{
+ d->m_name = name;
+}
+
QString GeoDataData::displayName() const
{
return d->m_displayName;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataData.h #1173175:1173176
@@ -27,6 +27,10 @@
{
public:
GeoDataData();
+
+ /** Convenience constructor that sets name and value directly */
+ GeoDataData( const QString &name, const QVariant &value );
+
GeoDataData( const GeoDataData& other );
virtual ~GeoDataData();
@@ -50,6 +54,17 @@
void setValue( const QVariant& value );
/**
+ * @brief return the name of data
+ */
+ QString name() const;
+
+ /**
+ * @brief set the name of data
+ * @param name the name to be set
+ */
+ void setName( const QString& name );
+
+ /**
* @brief return the displayName of data
*/
QString displayName() const;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataData_p.h #1173175:1173176
@@ -28,6 +28,7 @@
}
QVariant m_value;
+ QString m_name;
QString m_displayName;
};
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataExtendedData.cpp #1173175:1173176
@@ -54,9 +54,9 @@
return d->hash.value( key );
}
-void GeoDataExtendedData::addValue( const QString& key, const GeoDataData& data )
+void GeoDataExtendedData::addValue( const GeoDataData& data )
{
- d->hash.insert( key , data );
+ d->hash.insert( data.name(), data );
}
QHash< QString, GeoDataData >::const_iterator GeoDataExtendedData::constBegin( ) const
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataExtendedData.h #1173175:1173176
@@ -52,7 +52,7 @@
/**
* @brief add a data object to the GeoDataExtendedData with the @p key
*/
- void addValue( const QString& key, const GeoDataData& data );
+ void addValue( const GeoDataData& data );
/**
* @brief return const Begin iterator for QHash
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/kml/KmlDataTagHandler.cpp #1173175:1173176
@@ -38,10 +38,13 @@
#endif // DEBUG_TAGS
QString name = parser.attribute( "name" ).trimmed();
+ data.setName( name );
+ QString displayName = parser.attribute( "displayName" ).trimmed();
+ data.setDisplayName( displayName );
#ifdef DEBUG_TAGS
mDebug() << "attribute 'name':" << name;
#endif // DEBUG_TAGS
- parentItem.nodeAs< GeoDataExtendedData >()->addValue( name, data );
+ parentItem.nodeAs< GeoDataExtendedData >()->addValue( data );
return static_cast<GeoDataData*>( &parentItem.nodeAs<GeoDataExtendedData>()->valueRef( name ) );
} else {
return 0;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/kml/KmlDataTagWriter.cpp #1173175:1173176
@@ -30,7 +30,10 @@
const GeoDataData &data = static_cast<const GeoDataData&>( node );
writer.writeStartElement( kml::kmlTag_Data );
- writer.writeAttribute( "name", data.displayName() );
+ writer.writeAttribute( "name", data.name() );
+ if ( !data.displayName().isEmpty() ) {
+ writer.writeAttribute( "displayName", data.displayName() );
+ }
writer.writeElement( "value", data.value().toString() );
writer.writeEndElement();
--- trunk/KDE/kdeedu/marble/src/plugins/runner/gosmore/GosmoreRunner.cpp #1173175:1173176
@@ -134,8 +134,9 @@
GeoDataPlacemark* placemark = new GeoDataPlacemark( directions[i].instructionText() );
GeoDataExtendedData extendedData;
GeoDataData turnType;
+ turnType.setName( "turnType" );
turnType.setValue( qVariantFromValue<RoutingInstruction::TurnType>( directions[i].turnType() ) );
- extendedData.addValue( "turnType", turnType );
+ extendedData.addValue( turnType );
placemark->setExtendedData( extendedData );
Q_ASSERT( !directions[i].points().isEmpty() );
GeoDataLineString* geometry = new GeoDataLineString;
@@ -266,9 +267,7 @@
QString road = fields.last().trimmed();
placemark.setAddress( road );
GeoDataExtendedData extendedData;
- GeoDataData data;
- data.setValue( road );
- extendedData.addValue( "road", data );
+ extendedData.addValue( GeoDataData( "road", road ) );
placemark.setExtendedData( extendedData );
}
}
--- trunk/KDE/kdeedu/marble/src/plugins/runner/nominatim/OsmNominatimRunner.cpp #1173175:1173176
@@ -164,9 +164,7 @@
QDomNodeList child = node.item( 0 ).toElement().elementsByTagName( key );
if ( child.size() > 0 ) {
QString text = child.item( 0 ).toElement().text();
- GeoDataData data;
- data.setValue( text );
- extendedData->addValue( key, data );
+ extendedData->addValue( GeoDataData( key, text ) );
}
}
--- trunk/KDE/kdeedu/marble/src/plugins/runner/routino/RoutinoRunner.cpp #1173175:1173176
@@ -153,8 +153,9 @@
GeoDataPlacemark* placemark = new GeoDataPlacemark( directions[i].instructionText() );
GeoDataExtendedData extendedData;
GeoDataData turnType;
+ turnType.setName( "turnType" );
turnType.setValue( qVariantFromValue<RoutingInstruction::TurnType>( directions[i].turnType() ) );
- extendedData.addValue( "turnType", turnType );
+ extendedData.addValue( turnType );
placemark->setExtendedData( extendedData );
Q_ASSERT( !directions[i].points().isEmpty() );
GeoDataLineString* geometry = new GeoDataLineString;
More information about the Marble-commits
mailing list