summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-07-23 06:56:02 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-07-23 10:07:01 (GMT)
commit3471752a13dfb9ce4c368f6437911ed854f949d1 (patch)
tree668f9e61a39dfdc09630688e91cc6216ec33cd78
parent52144d888c6f4bcdcec4bcd258e1722160cb4f9e (diff)
Update bookmarks model when a different kml file is loaded
-rw-r--r--src/lib/marble/declarative/Bookmarks.cpp20
-rw-r--r--src/lib/marble/declarative/Bookmarks.h9
2 files changed, 20 insertions, 9 deletions
diff --git a/src/lib/marble/declarative/Bookmarks.cpp b/src/lib/marble/declarative/Bookmarks.cpp
index 19b2970..7645b5f 100644
--- a/src/lib/marble/declarative/Bookmarks.cpp
+++ b/src/lib/marble/declarative/Bookmarks.cpp
@@ -42,6 +42,12 @@ MarbleQuickItem *Bookmarks::map()
void Bookmarks::setMap( MarbleQuickItem* item )
{
m_marbleQuickItem = item;
+ if (item) {
+ connect(item->model()->bookmarkManager(), SIGNAL(bookmarksChanged()),
+ this, SLOT(updateBookmarkDocument()));
+ }
+ updateBookmarkDocument();
+ emit modelChanged();
}
bool Bookmarks::isBookmark( qreal longitude, qreal latitude ) const
@@ -125,15 +131,19 @@ void Bookmarks::removeBookmark( qreal longitude, qreal latitude )
}
}
-BookmarksModel *Bookmarks::model()
+void Bookmarks::updateBookmarkDocument()
{
- if ( !m_proxyModel && m_marbleQuickItem && m_marbleQuickItem->model()->bookmarkManager() ) {
+ if (m_marbleQuickItem) {
Marble::BookmarkManager* manager = m_marbleQuickItem->model()->bookmarkManager();
- Marble::GeoDataTreeModel* model = new Marble::GeoDataTreeModel( this );
- model->setRootDocument( manager->document() );
+ m_treeModel.setRootDocument( manager->document() );
+ }
+}
+BookmarksModel *Bookmarks::model()
+{
+ if ( !m_proxyModel && m_marbleQuickItem && m_marbleQuickItem->model()->bookmarkManager() ) {
KDescendantsProxyModel* flattener = new KDescendantsProxyModel( this );
- flattener->setSourceModel( model );
+ flattener->setSourceModel(&m_treeModel);
m_proxyModel = new BookmarksModel( this );
m_proxyModel->setFilterFixedString( Marble::GeoDataTypes::GeoDataPlacemarkType );
diff --git a/src/lib/marble/declarative/Bookmarks.h b/src/lib/marble/declarative/Bookmarks.h
index a31bcb9..869e7a2 100644
--- a/src/lib/marble/declarative/Bookmarks.h
+++ b/src/lib/marble/declarative/Bookmarks.h
@@ -13,6 +13,7 @@
#include <QObject>
#include <QSortFilterProxyModel>
+#include <GeoDataTreeModel.h>
namespace Marble {
@@ -43,7 +44,7 @@ class Bookmarks : public QObject
{
Q_OBJECT
- Q_PROPERTY( MarbleQuickItem* map READ map WRITE setMap NOTIFY mapChanged)
+ Q_PROPERTY( Marble::MarbleQuickItem* map READ map WRITE setMap NOTIFY mapChanged)
Q_PROPERTY( BookmarksModel* model READ model NOTIFY modelChanged )
public:
@@ -51,7 +52,7 @@ public:
MarbleQuickItem* map();
- void setMap(Marble::MarbleQuickItem *widget );
+ void setMap(MarbleQuickItem *widget );
BookmarksModel* model();
@@ -59,8 +60,8 @@ public:
public Q_SLOTS:
void addBookmark( qreal longitude, qreal latitude, const QString &name, const QString &folder );
-
void removeBookmark( qreal longitude, qreal latitude );
+ void updateBookmarkDocument();
Q_SIGNALS:
void mapChanged();
@@ -69,8 +70,8 @@ Q_SIGNALS:
private:
MarbleQuickItem* m_marbleQuickItem;
-
BookmarksModel* m_proxyModel;
+ GeoDataTreeModel m_treeModel;
};
}