summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-07-23 06:52:14 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-07-23 10:07:01 (GMT)
commit77902db9a1a00c0043e811afc97ef3f513c1ff4f (patch)
tree91b76bc7bda6f0f9b743d2c8fd35cfa1d9d75ee1
parenta306e47ceb7b48ca48a1a3b28d0caade6994a81c (diff)
Ensure bookmarks have a name and icon. Use StyleBuilder internally.
-rw-r--r--src/lib/marble/BookmarkManager.cpp17
-rw-r--r--src/lib/marble/BookmarkManager.h3
-rw-r--r--src/lib/marble/BookmarkManager_p.h2
-rw-r--r--src/lib/marble/MarbleMap.cpp3
4 files changed, 24 insertions, 1 deletions
diff --git a/src/lib/marble/BookmarkManager.cpp b/src/lib/marble/BookmarkManager.cpp
index dfbd7a8..44b9d82 100644
--- a/src/lib/marble/BookmarkManager.cpp
+++ b/src/lib/marble/BookmarkManager.cpp
@@ -21,6 +21,7 @@
#include "KmlElementDictionary.h"
#include "MarbleDebug.h"
#include "MarbleDirs.h"
+#include "StyleBuilder.h"
#include <QFile>
namespace Marble
@@ -29,7 +30,8 @@ namespace Marble
BookmarkManagerPrivate::BookmarkManagerPrivate( GeoDataTreeModel *treeModel ) :
m_treeModel( treeModel ),
m_bookmarkDocument( 0 ),
- m_bookmarkFileRelativePath( "bookmarks/bookmarks.kml" )
+ m_bookmarkFileRelativePath( "bookmarks/bookmarks.kml" ),
+ m_styleBuilder(nullptr)
{
resetBookmarkDocument();
}
@@ -134,6 +136,14 @@ void BookmarkManager::addBookmark( GeoDataContainer *container, const GeoDataPla
GeoDataPlacemark *bookmark = new GeoDataPlacemark( placemark );
bookmark->setVisualCategory( GeoDataDocument::Bookmark );
bookmark->setZoomLevel( 1 );
+ if (bookmark->name().isEmpty()) {
+ bookmark->setName(bookmark->coordinate().toString(GeoDataCoordinates::Decimal).trimmed());
+ }
+ if (d->m_styleBuilder && bookmark->style()->iconStyle().iconPath().isEmpty()) {
+ StyleParameters style;
+ style.feature = bookmark;
+ bookmark->setStyle(GeoDataStyle::Ptr(new GeoDataStyle(*d->m_styleBuilder->createStyle(style))));
+ }
d->m_treeModel->addFeature( container, bookmark );
updateBookmarkFile();
@@ -229,6 +239,11 @@ void BookmarkManager::removeAllBookmarks()
updateBookmarkFile();
}
+void BookmarkManager::setStyleBuilder(const StyleBuilder *styleBuilder)
+{
+ d->m_styleBuilder = styleBuilder;
+}
+
bool BookmarkManager::updateBookmarkFile()
{
QString absoluteLocalFilePath = MarbleDirs::localPath() + '/' + d->m_bookmarkFileRelativePath ;
diff --git a/src/lib/marble/BookmarkManager.h b/src/lib/marble/BookmarkManager.h
index bbfb841..e975402 100644
--- a/src/lib/marble/BookmarkManager.h
+++ b/src/lib/marble/BookmarkManager.h
@@ -27,6 +27,7 @@ namespace Marble
class GeoDataPlacemark;
class GeoDataFolder;
class GeoDataTreeModel;
+ class StyleBuilder;
/**
* This class is responsible for loading the
* book mark objects from the files and various
@@ -97,6 +98,8 @@ class MARBLE_EXPORT BookmarkManager : public QObject
*/
void removeAllBookmarks();
+ void setStyleBuilder(const StyleBuilder* styleBuilder);
+
public Q_SLOTS:
void setShowBookmarks( bool visible );
diff --git a/src/lib/marble/BookmarkManager_p.h b/src/lib/marble/BookmarkManager_p.h
index 64d8e99..ac53d91 100644
--- a/src/lib/marble/BookmarkManager_p.h
+++ b/src/lib/marble/BookmarkManager_p.h
@@ -19,6 +19,7 @@ namespace Marble
class GeoDataContainer;
class GeoDataDocument;
class GeoDataTreeModel;
+class StyleBuilder;
class BookmarkManagerPrivate
{
@@ -36,6 +37,7 @@ public:
GeoDataDocument *m_bookmarkDocument;
QString m_bookmarkFileRelativePath;
+ const StyleBuilder* m_styleBuilder;
};
}
diff --git a/src/lib/marble/MarbleMap.cpp b/src/lib/marble/MarbleMap.cpp
index b404eaa..fe4ea7f 100644
--- a/src/lib/marble/MarbleMap.cpp
+++ b/src/lib/marble/MarbleMap.cpp
@@ -69,6 +69,7 @@
#include "TileLoader.h"
#include "ViewParams.h"
#include "ViewportParams.h"
+#include "BookmarkManager.h"
namespace Marble
@@ -180,6 +181,8 @@ MarbleMapPrivate::MarbleMapPrivate( MarbleMap *parent, MarbleModel *model ) :
m_layerManager.addLayer( &m_placemarkLayer );
m_layerManager.addLayer( &m_customPaintLayer );
+ m_model->bookmarkManager()->setStyleBuilder(&m_styleBuilder);
+
QObject::connect( m_model, SIGNAL(themeChanged(QString)),
parent, SLOT(updateMapTheme()) );
QObject::connect( m_model->fileManager(), SIGNAL(fileAdded(QString)),