[Marble-commits] KDE/kdeedu/marble/src/lib
Dennis Nienhüser
earthwings at gentoo.org
Tue Jan 18 22:34:11 CET 2011
SVN commit 1215480 by nienhueser:
Export of bookmarks to .kml files
M +25 -0 BookmarkManagerDialog.cpp
M +2 -0 BookmarkManagerDialog.h
M +1 -1 BookmarkManagerDialog.ui
--- trunk/KDE/kdeedu/marble/src/lib/BookmarkManagerDialog.cpp #1215479:1215480
@@ -14,19 +14,25 @@
#include "BookmarkManager_p.h"
#include "FileManager.h"
#include "GeoDataCoordinates.h"
+#include "GeoDataDocument.h"
#include "GeoDataExtendedData.h"
#include "GeoDataFolder.h"
#include "GeoDataPlacemark.h"
#include "GeoDataPoint.h"
#include "GeoDataTreeModel.h"
#include "GeoDataTypes.h"
+#include "GeoWriter.h"
#include "kdescendantsproxymodel.h"
#include "MarbleDirs.h"
+#include "MarbleDebug.h"
#include "MarbleModel.h"
#include "MarbleDataFacade.h"
#include <QtCore/QPointer>
+#include <QtCore/QFile>
#include <QtGui/QSortFilterProxyModel>
+#include <QtGui/QFileDialog>
+#include <QtGui/QMessageBox>
namespace Marble {
@@ -233,6 +239,7 @@
connect( this, SIGNAL( accepted() ), SLOT( saveBookmarks() ) );
connect( this, SIGNAL( rejected() ), SLOT( discardChanges() ) );
+ connect( exportButton, SIGNAL( clicked() ), this, SLOT( exportBookmarks() ) );
}
BookmarkManagerDialog::~BookmarkManagerDialog()
@@ -245,6 +252,24 @@
d->m_manager->updateBookmarkFile();
}
+void BookmarkManagerDialog::exportBookmarks()
+{
+ QString fileName = QFileDialog::getSaveFileName( this, tr( "Export Bookmarks" ), // krazy:exclude=qclasses
+ QDir::homePath(), tr( "KML files (*.kml)" ) );
+
+ if ( !fileName.isEmpty() ) {
+ QFile file( fileName );
+ GeoWriter writer;
+ writer.setDocumentType( "http://earth.google.com/kml/2.2" );
+
+ if ( !file.open( QIODevice::ReadWrite ) || !writer.write( &file, d->m_manager->d->bookmarkDocument() ) ) {
+ mDebug() << "Could not write the bookmarks file" << fileName;
+ QString const text = tr( "Unable to save bookmarks. Please check that the file is writable." );
+ QMessageBox::warning( this, tr( "Bookmark Export - Marble" ), text );
}
+ }
+}
+}
+
#include "BookmarkManagerDialog.moc"
--- trunk/KDE/kdeedu/marble/src/lib/BookmarkManagerDialog.h #1215479:1215480
@@ -36,6 +36,8 @@
private Q_SLOTS:
void saveBookmarks();
+ void exportBookmarks();
+
private:
Q_PRIVATE_SLOT( d, void updateButtonState() );
--- trunk/KDE/kdeedu/marble/src/lib/BookmarkManagerDialog.ui #1215479:1215480
@@ -29,7 +29,7 @@
<item>
<widget class="QPushButton" name="exportButton">
<property name="enabled">
- <bool>false</bool>
+ <bool>true</bool>
</property>
<property name="text">
<string>Export Bookmarks....</string>
More information about the Marble-commits
mailing list