[Marble-commits] KDE/kdeedu/marble
Utku Aydın
utkuaydin34 at gmail.com
Sat Jan 8 23:54:17 CET 2011
SVN commit 1212989 by aydin:
Add settings tag writers
M +25 -0 src/lib/MapWizard.cpp
M +6 -0 src/lib/geodata/scene/GeoSceneProperty.cpp
M +1 -0 src/lib/geodata/scene/GeoSceneProperty.h
M +11 -0 src/lib/geodata/scene/GeoSceneSettings.cpp
M +1 -0 src/lib/geodata/scene/GeoSceneSettings.h
M +4 -0 src/lib/geodata/writers/dgml/DgmlDocumentTagWriter.cpp
M +1 -3 src/lib/geodata/writers/dgml/DgmlHeadTagWriter.cpp
M +1 -3 src/lib/geodata/writers/dgml/DgmlLayerTagWriter.cpp
M +1 -3 src/lib/geodata/writers/dgml/DgmlMapTagWriter.cpp
A src/lib/geodata/writers/dgml/DgmlSettingsTagWriter.cpp [License: LGPL]
A src/lib/geodata/writers/dgml/DgmlSettingsTagWriter.h [License: LGPL]
M +4 -6 src/lib/geodata/writers/dgml/DgmlTextureTagWriter.cpp
M +44 -0 tests/TestGeoSceneWriter.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MapWizard.cpp #1212988:1212989
@@ -21,6 +21,8 @@
#include "GeoSceneMap.h"
#include "GeoSceneLayer.h"
#include "GeoSceneTexture.h"
+#include "GeoSceneSettings.h"
+#include "GeoSceneProperty.h"
#include <QtCore/QDir>
#include <QtCore/QFile>
@@ -832,6 +834,29 @@
GeoSceneMap *map = document->map();
map->addLayer( layer );
+
+ GeoSceneSettings *settings = document->settings();
+
+ GeoSceneProperty *coorGrid = new GeoSceneProperty( "coordinate-grid" );
+ coorGrid->setValue( true );
+ coorGrid->setAvailable( true );
+ settings->addProperty( coorGrid );
+
+ GeoSceneProperty *overviewmap = new GeoSceneProperty( "overviewmap" );
+ overviewmap->setValue( true );
+ overviewmap->setAvailable( true );
+ settings->addProperty( overviewmap );
+
+ GeoSceneProperty *compass = new GeoSceneProperty( "compass" );
+ compass->setValue( true );
+ compass->setAvailable( true );
+ settings->addProperty( compass );
+
+ GeoSceneProperty *scalebar = new GeoSceneProperty( "scalebar" );
+ scalebar->setValue( true );
+ scalebar->setAvailable( true );
+ settings->addProperty( scalebar );
+
return document;
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneProperty.cpp #1212988:1212989
@@ -22,6 +22,7 @@
#include "GeoSceneProperty.h"
#include "MarbleDebug.h"
+#include "GeoSceneTypes.h"
namespace Marble
{
@@ -34,6 +35,11 @@
{
}
+const char* GeoSceneProperty::nodeType() const
+{
+ return GeoSceneTypes::GeoScenePropertyType;
+}
+
QString GeoSceneProperty::name() const
{
return m_name;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneProperty.h #1212988:1212989
@@ -43,6 +43,7 @@
public:
explicit GeoSceneProperty( const QString& name );
+ virtual const char* nodeType() const;
QString name() const;
bool available() const;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneSettings.cpp #1212988:1212989
@@ -25,6 +25,7 @@
#include "GeoSceneProperty.h"
#include "GeoSceneGroup.h"
+#include "GeoSceneTypes.h"
namespace Marble
{
@@ -41,6 +42,11 @@
/// The hash table holding all the properties in the settings.
QVector<GeoSceneProperty*> m_properties;
QVector<GeoSceneGroup*> m_groups;
+
+ const char* nodeType() const
+ {
+ return GeoSceneTypes::GeoSceneSettingsType;
+ }
};
@@ -54,6 +60,11 @@
delete d;
}
+const char* GeoSceneSettings::nodeType() const
+{
+ return d->nodeType();
+}
+
bool GeoSceneSettings::propertyAvailable( const QString& name, bool& available ) const
{
QVector<GeoSceneProperty*>::const_iterator it = d->m_properties.constBegin();
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneSettings.h #1212988:1212989
@@ -49,6 +49,7 @@
public:
GeoSceneSettings();
virtual ~GeoSceneSettings();
+ virtual const char* nodeType() const;
/**
* @brief Get the availability of a property across groups
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlDocumentTagWriter.cpp #1212988:1212989
@@ -14,6 +14,7 @@
#include "GeoSceneDocument.h"
#include "GeoSceneHead.h"
#include "GeoSceneMap.h"
+#include "GeoSceneSettings.h"
#include "DgmlElementDictionary.h"
namespace Marble
@@ -34,6 +35,9 @@
const GeoSceneMap *map = static_cast<const GeoSceneMap*>( document->map() );
writeElement( map, writer );
+ const GeoSceneSettings *settings = static_cast<const GeoSceneSettings*>( document->settings() );
+ writeElement( settings, writer );
+
writer.writeEndDocument();
return true;
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlHeadTagWriter.cpp #1212988:1212989
@@ -20,11 +20,9 @@
namespace Marble
{
-static GeoTagWriterRegistrar s_writerData( GeoTagWriter::QualifiedName( GeoSceneTypes::GeoSceneHeadType,
- dgml::dgmlTag_nameSpace20 ),
+static GeoTagWriterRegistrar s_writerHead( GeoTagWriter::QualifiedName( GeoSceneTypes::GeoSceneHeadType, dgml::dgmlTag_nameSpace20 ),
new DgmlHeadTagWriter() );
-
bool DgmlHeadTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
{
const GeoSceneHead *head = static_cast<const GeoSceneHead*>( node );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlLayerTagWriter.cpp #1212988:1212989
@@ -18,11 +18,9 @@
namespace Marble
{
-static GeoTagWriterRegistrar s_writerData( GeoTagWriter::QualifiedName( GeoSceneTypes::GeoSceneLayerType,
- dgml::dgmlTag_nameSpace20 ),
+static GeoTagWriterRegistrar s_writerLayer( GeoTagWriter::QualifiedName( GeoSceneTypes::GeoSceneLayerType, dgml::dgmlTag_nameSpace20 ),
new DgmlLayerTagWriter() );
-
bool DgmlLayerTagWriter::write(const GeoNode *node, GeoWriter& writer) const
{
const GeoSceneLayer *layer = static_cast<const GeoSceneLayer*>( node );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlMapTagWriter.cpp #1212988:1212989
@@ -19,11 +19,9 @@
namespace Marble
{
-static GeoTagWriterRegistrar s_writerData( GeoTagWriter::QualifiedName( GeoSceneTypes::GeoSceneMapType,
- dgml::dgmlTag_nameSpace20 ),
+static GeoTagWriterRegistrar s_writerMap( GeoTagWriter::QualifiedName( GeoSceneTypes::GeoSceneMapType, dgml::dgmlTag_nameSpace20 ),
new DgmlMapTagWriter() );
-
bool DgmlMapTagWriter::write(const GeoNode *node, GeoWriter& writer) const
{
const GeoSceneMap *map = static_cast<const GeoSceneMap*>( node );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/writers/dgml/DgmlTextureTagWriter.cpp #1212988:1212989
@@ -19,11 +19,9 @@
namespace Marble
{
-static GeoTagWriterRegistrar s_writerData( GeoTagWriter::QualifiedName( GeoSceneTypes::GeoSceneTextureType,
- dgml::dgmlTag_nameSpace20 ),
+static GeoTagWriterRegistrar s_writerTexture( GeoTagWriter::QualifiedName( GeoSceneTypes::GeoSceneTextureType, dgml::dgmlTag_nameSpace20 ),
new DgmlTextureTagWriter() );
-
bool DgmlTextureTagWriter::write(const GeoNode *node, GeoWriter& writer) const
{
const GeoSceneTexture *texture = static_cast<const GeoSceneTexture*>( node );
@@ -53,9 +51,9 @@
for( int i = 0; i < texture->downloadUrls().size(); ++i )
{
QString protocol = texture->downloadUrls().at(i).toString().left( texture->downloadUrls().at(i).toString().indexOf( ':' ) );
- QString host = QString( texture->downloadUrls().at(i).encodedHost() );
- QString path = QString( texture->downloadUrls().at(i).encodedPath() );
- QString query = QString( texture->downloadUrls().at(i).encodedQuery() );
+ QString host = QString( texture->downloadUrls().at(i).host() );
+ QString path = QString( texture->downloadUrls().at(i).path() );
+ QString query = QUrl::fromEncoded( texture->downloadUrls().at(i).encodedQuery() ).toString();
writer.writeStartElement( dgml::dgmlTag_DownloadUrl );
writer.writeAttribute( "protocol", protocol );
--- trunk/KDE/kdeedu/marble/tests/TestGeoSceneWriter.cpp #1212988:1212989
@@ -20,7 +20,11 @@
#include "GeoSceneMap.h"
#include "GeoSceneLayer.h"
#include "GeoSceneTexture.h"
+#include "GeoSceneSettings.h"
+#include "GeoSceneProperty.h"
+
#include "GeoWriter.h"
+#include "GeoSceneParser.h"
using namespace Marble;
@@ -68,12 +72,52 @@
GeoSceneMap* map = document->map();
map->addLayer( layer );
+ GeoSceneSettings *settings = document->settings();
+
+ GeoSceneProperty *coorGrid = new GeoSceneProperty( "coordinate-grid" );
+ coorGrid->setValue( true );
+ coorGrid->setAvailable( true );
+ settings->addProperty( coorGrid );
+
+ GeoSceneProperty *overviewmap = new GeoSceneProperty( "overviewmap" );
+ overviewmap->setValue( true );
+ overviewmap->setAvailable( true );
+ settings->addProperty( overviewmap );
+
+ GeoSceneProperty *compass = new GeoSceneProperty( "compass" );
+ compass->setValue( true );
+ compass->setAvailable( true );
+ settings->addProperty( compass );
+
+ GeoSceneProperty *scalebar = new GeoSceneProperty( "scalebar" );
+ scalebar->setValue( true );
+ scalebar->setAvailable( true );
+ settings->addProperty( scalebar );
+
QTemporaryFile tempFile;
tempFile.open();
GeoWriter writer;
writer.setDocumentType( "http://edu.kde.org/marble/dgml/2.0" );
QVERIFY( writer.write( &tempFile, document ) );
+
+ //Parser and verify
+ GeoSceneParser* parser = new GeoSceneParser( GeoScene_DGML );
+ tempFile.reset();
+ QVERIFY( parser->read( &tempFile ) );
+
+ GeoSceneDocument *document2 = static_cast<GeoSceneDocument*>( parser->activeDocument() );
+ QTemporaryFile tempFile2;
+ tempFile2.open();
+ GeoWriter writer2;
+ writer2.setDocumentType( "http://edu.kde.org/marble/dgml/2.0" );
+ QVERIFY( writer2.write( &tempFile2, document2 ) );
+
+ tempFile.reset();
+ QTextStream file( &tempFile );
+ tempFile2.reset();
+ QTextStream file2( &tempFile2 );
+ QCOMPARE( file.readAll().simplified(), file2.readAll().simplified() );
}
QTEST_MAIN( TestGeoSceneWriter )
More information about the Marble-commits
mailing list