[Marble-commits] KDE/kdeedu/marble/src
Andrew Manson
g.real.ate at gmail.com
Thu Jul 23 17:04:05 CEST 2009
SVN commit 1001526 by mansona:
started work to be able to save OSM annotations as KML. The exact
final implementation might need to be discussed at lenght soon.
M +14 -0 lib/geodata/data/GeoDataPlacemark.cpp
M +24 -2 lib/geodata/data/GeoDataPlacemark.h
M +23 -13 plugins/render/osmannotate/OsmAnnotatePlugin.cpp
M +4 -1 plugins/render/osmannotate/OsmAnnotatePlugin.h
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPlacemark.cpp #1001525:1001526
@@ -20,6 +20,7 @@
// Qt
#include <QtCore/QDataStream>
#include <QtCore/QDebug>
+#include <QtXml/QXmlStreamWriter>
namespace Marble
{
@@ -189,7 +190,20 @@
p()->m_coordinate.pack( stream );
}
+QXmlStreamWriter& GeoDataPlacemark::pack( QXmlStreamWriter& stream ) const
+{
+ stream.writeStartElement( "placemark" );
+ stream.writeEndElement();
+ return stream;
+}
+
+QXmlStreamWriter& GeoDataPlacemark::operator <<( QXmlStreamWriter& stream ) const
+{
+ pack( stream );
+ return stream;
+}
+
void GeoDataPlacemark::unpack( QDataStream& stream )
{
detach();
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataPlacemark.h #1001525:1001526
@@ -16,6 +16,7 @@
#include <QtCore/QChar>
+class QXmlStreamWriter;
#include "GeoDataPoint.h"
#include "GeoDataLineString.h"
@@ -148,9 +149,30 @@
*/
void setCountryCode( const QString &code );
- // Serialize the Placemark to @p stream
+ /**
+ * Serialize the Placemark to a data stream. This is a binary serialisation
+ * and is deserialised using @see unpack()
+ * @param stream the QDataStream to serialise object to.
+ */
virtual void pack( QDataStream& stream ) const;
- // Unserialize the Placemark from @p stream
+
+ /**
+ * Serialise this Placemark to a XML stream writer @see QXmlStreamWriter in
+ * the Qt documentation for more info. This will output the XML
+ * representation of this Placemark. The default XML format is KML, to have
+ * other formats supported you need to create a subclass and overide this
+ * method.
+ * @param stream the XML Stream Reader to output to.
+ */
+ virtual QXmlStreamWriter& pack( QXmlStreamWriter& stream ) const;
+
+ virtual QXmlStreamWriter& operator <<( QXmlStreamWriter& stream ) const;
+
+ /**
+ * Deserialize the Placemark from a data stream. This has the opposite effect
+ * from @see pack()
+ * @param stream the QDataStream to deserialise from.
+ */
virtual void unpack( QDataStream& stream );
virtual bool isPlacemark() const { return true; }
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #1001525:1001526
@@ -82,16 +82,6 @@
void OsmAnnotatePlugin::initialize ()
{
-
- //Setup the model
- GeoDataCoordinates madrid( -13.7, 40.4, 0.0, GeoDataCoordinates::Degree );
- PlacemarkTextAnnotation* annon = new PlacemarkTextAnnotation();
-
- annon->setCoordinate(madrid);
-
- //FIXME memory leak withouth a model to do memory management
- model.append(annon);
-
widgetInitalised= false;
m_tmp_lineString = 0;
m_itemModel = 0;
@@ -224,6 +214,18 @@
}
}
+void OsmAnnotatePlugin::saveOsmFile()
+{
+ TmpGraphicsItem* item;
+ QListIterator<TmpGraphicsItem*> it(model);
+ while( it.hasNext() ) {
+ item = it.next();
+ qDebug() << "Saving item!";
+// implement the XML writer here
+// qDebug() << item;
+ }
+}
+
bool OsmAnnotatePlugin::eventFilter(QObject* watched, QEvent* event)
{
MarbleWidget* marbleWidget = (MarbleWidget*) watched;
@@ -252,9 +254,8 @@
//FIXME only repaint the new placemark
( ( MarbleWidget* ) watched)->repaint();
- //FIXME: enable a way to disable adding a placemark
- //using signals and slots
-// m_addPlacemark->setChecked( false );
+ emit placemarkAdded();
+
return true;
}
@@ -343,6 +344,7 @@
QAction* m_beginSeparator;
QAction* m_endSeparator;
QAction* m_loadOsmFile;
+ QAction* m_saveOsmFile;
QAction* m_enableInputAction;
m_addPlacemark = new QAction(this);
@@ -350,6 +352,8 @@
m_addPlacemark->setCheckable( true );
connect( m_addPlacemark, SIGNAL( toggled(bool)),
this, SLOT(setAddingPlacemark(bool)) );
+ connect( this, SIGNAL(placemarkAdded()) ,
+ m_addPlacemark, SLOT(toggle()) );
m_drawPolygon = new QAction( this );
m_drawPolygon->setText( "Draw Polygon" );
@@ -362,6 +366,11 @@
connect( m_loadOsmFile, SIGNAL(triggered()),
this, SLOT(loadOsmFile()) );
+ m_saveOsmFile = new QAction( this );
+ m_saveOsmFile->setText( "Save Osm File" );
+ connect( m_saveOsmFile, SIGNAL(triggered()),
+ this, SLOT(saveOsmFile()) );
+
m_beginSeparator = new QAction( this );
m_beginSeparator->setSeparator( true );
m_endSeparator = new QAction ( this );
@@ -381,6 +390,7 @@
group->addAction( m_addPlacemark );
group->addAction( m_drawPolygon );
group->addAction( m_loadOsmFile );
+ group->addAction( m_saveOsmFile );
group->addAction( m_endSeparator );
actions->append( initial );
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.h #1001525:1001526
@@ -37,7 +37,7 @@
class OsmAnnotatePlugin : public RenderPlugin
{
Q_OBJECT
- Q_INTERFACES( Marble::RenderPluginInterface )
+ Q_INTERFACES( Marble::RenderPluginInterface );
MARBLE_PLUGIN( OsmAnnotatePlugin )
public:
@@ -73,8 +73,11 @@
signals:
void redraw();
+ void placemarkAdded();
+
public slots:
void loadOsmFile();
+ void saveOsmFile();
void setAddingPlacemark( bool );
void setDrawingPolygon( bool );
More information about the Marble-commits
mailing list