qmlmapwidgethelper: maintain an instance of MapLocationModel

The idea here is that the QML code should be able to fetch a model
from the MapWidgetHelper instance which is instantiated inside the
QML code; fetch it in the lines of "mapHelper.model".

This way, updates at the backend would be reflected on the Map QML widget.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-17 18:02:37 +03:00 committed by Dirk Hohndel
parent 8b40490626
commit a50e9866d5
2 changed files with 9 additions and 1 deletions

View file

@ -1,12 +1,14 @@
// SPDX-License-Identifier: GPL-2.0
#include <QDebug>
#include "qmlmapwidgethelper.h"
#include "qmlmapwidgethelper.h"
#include "core/dive.h"
#include "core/divesite.h"
#include "qt-models/maplocationmodel.h"
MapWidgetHelper::MapWidgetHelper(QObject *parent) : QObject(parent)
{
m_mapLocationModel = new MapLocationModel(this);
}
void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)

View file

@ -4,12 +4,14 @@
#include <QObject>
class MapLocationModel;
struct dive_site;
class MapWidgetHelper : public QObject {
Q_OBJECT
Q_PROPERTY(QObject *map MEMBER m_map)
Q_PROPERTY(MapLocationModel *model MEMBER m_mapLocationModel NOTIFY modelChanged)
public:
explicit MapWidgetHelper(QObject *parent = NULL);
@ -18,6 +20,10 @@ public:
private:
QObject *m_map;
MapLocationModel *m_mapLocationModel;
signals:
void modelChanged();
};
#endif