[Marble-commits] KDE/kdeedu/marble

Andrew Manson g.real.ate at gmail.com
Sun Aug 9 21:25:29 CEST 2009


SVN commit 1009341 by mansona:

More work on the KML writer, now outputting valid XML and KML that can be succesfully 
parserd again. Implementing CDATA for the description tag of GeoDataFeatures. Added some
Support for submitting CDash results. 


 M  +1 -1      CMakeLists.txt  
 A             CTestConfig.cmake  
 M  +11 -0     src/lib/geodata/data/GeoDataFeature.cpp  
 M  +12 -0     src/lib/geodata/data/GeoDataFeature.h  
 M  +4 -0      src/lib/geodata/data/GeoDataFeature_p.h  
 M  +1 -0      src/lib/geodata/handlers/kml/KmlDescriptionTagHandler.cpp  
 M  +1 -2      src/lib/geodata/writer/GeoWriter.cpp  
 M  +5 -1      src/lib/geodata/writers/kml/KmlPlacemarkTagWriter.cpp  
 M  +5 -0      src/lib/graphicsview/MarbleGraphicsItem.cpp  
 M  +5 -0      src/lib/graphicsview/MarbleGraphicsItem.h  
 M  +4 -0      tests/TestGeoDataWriter.cpp  
 A             tests/data/CDATATest.kml  
 M  +1 -1      tests/data/NewYork.kml  
 M  +1 -1      tests/data/NewYorkDocument.kml  


--- trunk/KDE/kdeedu/marble/CMakeLists.txt #1009340:1009341
@@ -31,7 +31,7 @@
 if( QTONLY )
     option( BUILD_MARBLE_TESTS "build marble tests if building QTONLY " ON )
     if( BUILD_MARBLE_TESTS )
-        enable_testing()
+        INCLUDE(CTest)
     endif( BUILD_MARBLE_TESTS )
 else( QTONLY )
     # for KDE builds this gets set in the kdeedu CMakeLists.txt
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataFeature.cpp #1009340:1009341
@@ -407,6 +407,17 @@
     d->m_description = value;
 }
 
+bool GeoDataFeature::descriptionIsCDATA() const
+{
+    return d->m_descriptionCDATA;
+}
+
+void GeoDataFeature::setDescriptionCDATA( bool cdata )
+{
+    detach();
+    d->m_descriptionCDATA = cdata;
+}
+
 QString GeoDataFeature::styleUrl() const
 {
     return d->m_styleUrl;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataFeature.h #1009340:1009341
@@ -179,6 +179,18 @@
     /// Set the description of this feature to @p value.
     void setDescription( const QString &value );
 
+    /**
+     * @brief test if the descirption is CDATA or not
+     * CDATA allows for special characters to be included in XML and also allows
+     * for other XML formats to be embedded in the XML without intefering with
+     * parser namespace.
+     * @return @true if the description should be treated as CDATA
+     *         @false if the description is a plain string
+     */
+    bool descriptionIsCDATA() const;
+    /// Set the description to be CDATA See: @see descriptionIsCDATA()
+    void setDescriptionCDATA( bool cdata );
+
     /// Return the styleUrl of the feature.
     QString styleUrl() const;
     /// Set the styleUrl of this feature to @p value.
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataFeature_p.h #1009340:1009341
@@ -25,6 +25,7 @@
     GeoDataFeaturePrivate() :
         m_name(),
         m_description(),
+        m_descriptionCDATA(),
         m_address(),
         m_phoneNumber(),
         m_styleUrl(),        
@@ -42,6 +43,7 @@
     GeoDataFeaturePrivate( const GeoDataFeaturePrivate& other ) :
         m_name( other.m_name ),
         m_description( other.m_description ),
+        m_descriptionCDATA( other.m_descriptionCDATA),
         m_address( other.m_address ),
         m_phoneNumber( other.m_phoneNumber ),
         m_styleUrl( other.m_styleUrl ),
@@ -60,6 +62,7 @@
     {
         m_name = other.m_name;
         m_description = other.m_description;
+        m_descriptionCDATA = other.m_descriptionCDATA;
         m_address = other.m_address;
         m_phoneNumber = other.m_phoneNumber;
         m_styleUrl = other.m_styleUrl;
@@ -95,6 +98,7 @@
 
     QString     m_name;         // Name of the feature. Is shown on screen
     QString     m_description;  // A longer textual description
+    bool        m_descriptionCDATA; // True if description should be considered CDATA
     QString     m_address;      // The address.  Optional
     QString     m_phoneNumber;  // Phone         Optional
     QString     m_styleUrl;     // styleUrl     Url#tag to a document wide style
--- trunk/KDE/kdeedu/marble/src/lib/geodata/handlers/kml/KmlDescriptionTagHandler.cpp #1009340:1009341
@@ -44,6 +44,7 @@
         QString description = parser.readElementText().trimmed();
         
         parentItem.nodeAs<GeoDataFeature>()->setDescription( description );
+        parentItem.nodeAs<GeoDataFeature>()->setDescriptionCDATA( parser.isCDATA() );
 #ifdef DEBUG_TAGS
         qDebug() << "Parsed <" << kmlTag_description << "> containing: " << description
                  << " parent item name: " << parentItem.qualifiedName().first;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writer/GeoWriter.cpp #1009340:1009341
@@ -28,9 +28,8 @@
 {
     setDevice( device );
     setAutoFormatting( true );
+    writeStartDocument();
 
-    writeDTD("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-
     //FIXME: write the starting tags. Possibly register a tag handler to do this
     // with a null string as the object name?
     GeoTagWriter::QualifiedName name( "", m_documentType );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/kml/KmlPlacemarkTagWriter.cpp #1009340:1009341
@@ -41,7 +41,11 @@
 
     if( !placemark.description().isEmpty() ) {
         writer.writeStartElement( "description" );
-        writer.writeCharacters( placemark.description() );
+        if( placemark.descriptionIsCDATA() ) {
+            writer.writeCDATA( placemark.description() );
+        } else {
+            writer.writeCharacters( placemark.description() );
+        }
         writer.writeEndElement();
     }
 
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/MarbleGraphicsItem.cpp #1009340:1009341
@@ -147,6 +147,11 @@
     return QRectF();
 }
 
+QList<QRectF> MarbleGraphicsItem::boundingRects() const
+{
+    return p()->boundingRects();
+}
+
 QSizeF MarbleGraphicsItem::size() const
 {
     return p()->m_size;
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/MarbleGraphicsItem.h #1009340:1009341
@@ -66,6 +66,11 @@
     QRectF containsRect( const QPointF& point ) const;
 
     /**
+     * @brief Used to get the set of screen bounding rects
+     */
+    QList<QRectF> boundingRects() const;
+
+    /**
      * Returns the layout of the MarbleGraphicsItem.
      */
     AbstractMarbleGraphicsLayout *layout() const;
--- trunk/KDE/kdeedu/marble/tests/TestGeoDataWriter.cpp #1009340:1009341
@@ -92,6 +92,7 @@
 //    This parser won't work because of the flaw that prevents single placemark files from loading
     QTest::newRow("New York") << parsers.value("NewYork.kml") << 1;
     QTest::newRow("New York Document") << parsers.value("NewYorkDocument.kml") << 2;
+    QTest::newRow("CDATATest") << parsers.value("CDATATest.kml") << 1;
 }
 
 void TestGeoDataWriter::countFeatures()
@@ -112,6 +113,7 @@
 
     QTest::newRow( "NewYork" ) << parsers.value("NewYork.kml");
     QTest::newRow( "NewYorkDocument") << parsers.value("NewYorkDocument.kml");
+    QTest::newRow("CDATATest") << parsers.value("CDATATest.kml");
 }
 
 void TestGeoDataWriter::saveFile()
@@ -139,6 +141,7 @@
 
     QTest::newRow("NewYork") << parsers.value( "NewYork.kml" ) ;
     QTest::newRow("NewYorkDocument") << parsers.value( "NewYorkDocument.kml" );
+    QTest::newRow("CDATATest") << parsers.value("CDATATest.kml");
 }
 
 void TestGeoDataWriter::saveAndLoad()
@@ -159,6 +162,7 @@
 
     GeoDataParser resultParser( GeoData_KML );
 
+    tempFile.reset();
     QVERIFY( resultParser.read( &tempFile ) );
 }
 
--- trunk/KDE/kdeedu/marble/tests/data/NewYork.kml #1009340:1009341
@@ -4,7 +4,7 @@
   <name>New York City</name>
   <description>New York City</description>
   <Point>
-    <coordinates>-74.006393,40.714172,0</coordinates>
+    <coordinates>-74.006393,40.714172</coordinates>
   </Point>
 </Placemark>
 </kml>
--- trunk/KDE/kdeedu/marble/tests/data/NewYorkDocument.kml #1009340:1009341
@@ -5,7 +5,7 @@
     <name>New York City</name>
     <description>New York City</description>
     <Point>
-      <coordinates>-74.006393,40.714172,0</coordinates>
+      <coordinates>-74.006393,40.714172</coordinates>
     </Point>
   </Placemark>
   <Placemark>


More information about the Marble-commits mailing list