[Marble-commits] KDE/kdeedu/marble
Thibaut Gridel
tgridel at free.fr
Sat Jul 17 00:35:56 CEST 2010
SVN commit 1150835 by tgridel:
GeoDataContainer: use append(GeoDataFeature*) instead of append(GeoDataFeature&)
M +0 -8 src/lib/geodata/data/GeoDataContainer.cpp
M +0 -5 src/lib/geodata/data/GeoDataContainer.h
M +4 -4 src/lib/geodata/handlers/gpx/GPXtrkTagHandler.cpp
M +3 -3 src/lib/geodata/handlers/gpx/GPXwptTagHandler.cpp
M +2 -2 src/lib/geodata/handlers/kml/KmlDocumentTagHandler.cpp
M +3 -5 src/lib/geodata/handlers/kml/KmlFolderTagHandler.cpp
M +4 -3 src/lib/geodata/handlers/kml/KmlMarblePlacemarkTagHandler.cpp
M +3 -2 src/lib/geodata/handlers/kml/KmlPlacemarkTagHandler.cpp
M +6 -6 src/lib/geodata/handlers/osm-namefinder/NamedTagHandler.cpp
M +2 -19 tests/TestGeoData.cpp
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataContainer.cpp #1150834:1150835
@@ -129,14 +129,6 @@
}
-void GeoDataContainer::append( const GeoDataFeature& other )
-{
- detach();
- GeoDataFeature *f = new GeoDataFeature(other);
- f->setParent(this);
- p()->m_vector.append( f );
-}
-
void GeoDataContainer::remove( int index )
{
detach();
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataContainer.h #1150834:1150835
@@ -99,11 +99,6 @@
void remove( int index );
/**
- * @brief add an element
- */
- void append( const GeoDataFeature& other );
-
- /**
* @brief size of the container
*/
int size() const;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/gpx/GPXtrkTagHandler.cpp #1150834:1150835
@@ -41,16 +41,16 @@
if (parentItem.represents(gpxTag_gpx))
{
GeoDataDocument* doc = parentItem.nodeAs<GeoDataDocument>();
- GeoDataPlacemark placemark;
+ GeoDataPlacemark *placemark = new GeoDataPlacemark;
GeoDataMultiGeometry multigeometry;
- placemark.setGeometry(multigeometry);
- placemark.setStyleUrl("#map-track");
+ placemark->setGeometry(multigeometry);
+ placemark->setStyleUrl("#map-track");
doc->append(placemark);
#ifdef DEBUG_TAGS
mDebug() << "Parsed <" << gpxTag_trk << "> trk: " << doc->size();
#endif
- return static_cast<GeoDataPlacemark*>(&doc->last());
+ return placemark;
}
mDebug() << "trk parsing with parentitem" << parentItem.qualifiedName();
return 0;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/gpx/GPXwptTagHandler.cpp #1150834:1150835
@@ -41,7 +41,7 @@
if (parentItem.represents(gpxTag_gpx))
{
GeoDataDocument* doc = parentItem.nodeAs<GeoDataDocument>();
- GeoDataPlacemark placemark;
+ GeoDataPlacemark *placemark = new GeoDataPlacemark;
QXmlStreamAttributes attributes = parser.attributes();
QStringRef tmp;
@@ -57,12 +57,12 @@
{
lon = tmp.toString().toFloat();
}
- placemark.setCoordinate(lat, lon);
+ placemark->setCoordinate(lat, lon);
doc->append(placemark);
#ifdef DEBUG_TAGS
mDebug() << "Parsed <" << gpxTag_wpt << "> waypoint: " << doc->size();
#endif
- return static_cast<GeoDataPlacemark*>(&doc->last());
+ return placemark;
}
mDebug() << "wpt parsing with parentitem" << parentItem.qualifiedName();
return 0;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/kml/KmlDocumentTagHandler.cpp #1150834:1150835
@@ -43,14 +43,14 @@
// this happens if there is a parent element to the Document tag. We can work around that and simply expect that
// the new Document tag works like a Folder
if( parentItem.represents( kmlTag_Folder ) || parentItem.represents( kmlTag_Document ) ) {
- GeoDataDocument document;
+ GeoDataDocument *document = new GeoDataDocument;
parentItem.nodeAs<GeoDataContainer>()->append( document );
#ifdef DEBUG_TAGS
mDebug() << "Parsed <" << kmlTag_Document << "> containing: " << &parentItem.nodeAs<GeoDataContainer>()->last()
<< " parent item name: " << parentItem.qualifiedName().first;
#endif // DEBUG_TAGS
- return static_cast<GeoDataDocument*>(&parentItem.nodeAs<GeoDataContainer>()->last());
+ return document;
}
else if ( parentItem.first.first == kmlTag_kml)
{
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/kml/KmlFolderTagHandler.cpp #1150834:1150835
@@ -38,19 +38,17 @@
{
Q_ASSERT(parser.isStartElement() && parser.isValidElement(kmlTag_Folder));
- GeoDataFolder folder;
-
GeoStackItem parentItem = parser.parentElement();
if ( parentItem.represents( kmlTag_Folder ) || parentItem.represents( kmlTag_Document ) ) {
- GeoDataFolder folder;
+ GeoDataFolder *folder = new GeoDataFolder;
GeoDataContainer *parentPtr = parentItem.nodeAs<GeoDataContainer>();
parentPtr->append( folder );
#ifdef DEBUG_TAGS
- mDebug() << "Parsed <" << kmlTag_Folder << "> containing: " << &parentItem.nodeAs<GeoDataContainer>()->last()
+ mDebug() << "Parsed <" << kmlTag_Folder << "> containing: " << folder
<< " parent item name: " << parentItem.qualifiedName().first;
#endif // DEBUG_TAGS
- return static_cast<GeoDataFolder*>(&parentPtr->last());
+ return folder;
} else {
return 0;
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/kml/KmlMarblePlacemarkTagHandler.cpp #1150834:1150835
@@ -41,17 +41,18 @@
{
Q_ASSERT( parser.isStartElement() && parser.isValidElement( kmlTag_MarblePlacemark ) );
- GeoDataPlacemark placemark;
GeoStackItem parentItem = parser.parentElement();
#ifdef DEBUG_TAGS
- mDebug() << "Parsed <" << kmlTag_MarblePlacemark << "> containing: " << &placemark
+ mDebug() << "Parsed <" << kmlTag_MarblePlacemark << ">"
<< " parent item name: " << parentItem.qualifiedName().first;
#endif // DEBUG_TAGS
if( parentItem.represents( kmlTag_Folder ) || parentItem.represents( kmlTag_Document ) ) {
+ GeoDataPlacemark *placemark = new GeoDataPlacemark;
parentItem.nodeAs<GeoDataContainer>()->append( placemark );
- return &parentItem.nodeAs<GeoDataContainer>()->last();
+ return placemark;
+
} else {
return 0;
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/kml/KmlPlacemarkTagHandler.cpp #1150834:1150835
@@ -40,7 +40,7 @@
{
Q_ASSERT( parser.isStartElement() && parser.isValidElement( kmlTag_Placemark ) );
- GeoDataPlacemark placemark;
+ GeoDataPlacemark *placemark = new GeoDataPlacemark;
GeoStackItem parentItem = parser.parentElement();
#ifdef DEBUG_TAGS
@@ -50,8 +50,9 @@
if( parentItem.represents( kmlTag_Folder ) || parentItem.represents( kmlTag_Document ) ) {
parentItem.nodeAs<GeoDataContainer>()->append( placemark );
- return static_cast<GeoDataPlacemark*>(&parentItem.nodeAs<GeoDataContainer>()->last());
+ return placemark;
} else {
+ delete placemark;
return 0;
}
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/osm-namefinder/NamedTagHandler.cpp #1150834:1150835
@@ -47,7 +47,7 @@
mDebug() << "parentItem:" << parentItem.qualifiedName().first;
// FIXME: better check tags before?
- GeoDataPlacemark named;
+ GeoDataPlacemark *named = new GeoDataPlacemark;
// FIXME: attribute type
// const ItemType type = getItemType( parser.attribute( attr_type ).trimmed() );
@@ -58,7 +58,7 @@
const QString idStr = parser.attribute( attr_id ).trimmed();
if ( !idStr.isEmpty() )
id = idStr.toInt();
- named.setId( id );
+ named->setId( id );
// attributes lat and lon
qreal lat = 0.0;
@@ -70,11 +70,11 @@
const QString lonStr = parser.attribute( attr_lon ).trimmed();
if ( !lonStr.isEmpty() )
lon = lonStr.toDouble();
- named.setCoordinate( GeoDataPoint( lon, lat, 0.0, GeoDataPoint::Degree, 0 ));
+ named->setCoordinate( GeoDataPoint( lon, lat, 0.0, GeoDataPoint::Degree, 0 ));
// attribute name
const QString name = parser.attribute( attr_name ).trimmed();
- named.setName( name );
+ named->setName( name );
// attribute rank
int rank = 0;
@@ -89,9 +89,9 @@
const QString zoomStr = parser.attribute( attr_zoom ).trimmed();
if ( !zoomStr.isEmpty() )
suggestedZoomLevel = zoomStr.toInt();
- named.setPopularityIndex( suggestedZoomLevel );
+ named->setPopularityIndex( suggestedZoomLevel );
- mDebug() << "parsed named:" << named.name() << " lon:" << lon << " lat:" << lat;
+ mDebug() << "parsed named:" << named->name() << " lon:" << lon << " lat:" << lat;
if ( parentItem.represents( tag_searchresults )) {
mDebug() << "added via parent searchresults";
--- trunk/KDE/kdeedu/marble/tests/TestGeoData.cpp #1150834:1150835
@@ -40,9 +40,9 @@
void TestGeoData::nodeTypeTest()
{
/// basic testing of nodeType
- GeoDataFolder folder;
+ GeoDataFolder *folder = new GeoDataFolder;
QString folderType(GeoDataTypes::GeoDataFolderType );
- QCOMPARE( folder.nodeType(), folderType );
+ QCOMPARE( folder->nodeType(), folderType );
/// testing the nodeType of an object appended to a container
GeoDataDocument document;
@@ -51,23 +51,6 @@
QCOMPARE( featureRef.nodeType(), folderType );
QCOMPARE( static_cast<GeoDataObject*>(&featureRef)->nodeType(), folderType );
- /// testing the nodeType of an object assigned to a super type object
- GeoDataFeature featureAssign;
- featureAssign = folder;
- QCOMPARE( featureAssign.nodeType(), folderType);
-
- /// testing the nodeType of an object copied into a super type object
- GeoDataFeature featureCopy( folder );
- QCOMPARE( featureCopy.nodeType(), folderType );
-
- /// testing the nodeType of an object assigned to a non shared data object
- GeoDataObject objectAssign;
- objectAssign = folder;
- QCOMPARE( objectAssign.nodeType(), folderType );
-
- /// testing the nodeType of an object copied to a non shared data object
- GeoDataObject objectCopy(folder);
- QCOMPARE( objectCopy.nodeType(), folderType );
}
void TestGeoData::parentingTest()
More information about the Marble-commits
mailing list