Commit 77902db9 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Ensure bookmarks have a name and icon. Use StyleBuilder internally.

parent a306e47c
......@@ -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 ;
......
......@@ -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 );
......
......@@ -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;
};
}
......
......@@ -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)),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment