map: add placeholder .cpp and .h files for the new map widget

The files are WIP and located in desktop-widgets, as these
would only be used by the desktop version.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-15 00:54:13 +03:00 committed by Dirk Hohndel
parent 762a9d2ec2
commit b083795233
2 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,27 @@
#include <QQmlContext>
#include <QDebug>
#include <QQuickItem>
#include "mapwidget.h"
MapWidget *MapWidget::m_instance = NULL;
MapWidget::MapWidget(QWidget *parent) : QQuickWidget(parent)
{
setSource(QUrl(QStringLiteral("qrc:/mapwidget-qml")));
setResizeMode(QQuickWidget::SizeRootObjectToView);
m_rootItem = qobject_cast<QQuickItem *>(rootObject());
}
MapWidget::~MapWidget()
{
m_instance = NULL;
}
MapWidget *MapWidget::instance()
{
if (m_instance == NULL)
m_instance = new MapWidget();
return m_instance;
}

View file

@ -0,0 +1,23 @@
#ifndef MAPWIDGET_H
#define MAPWIDGET_H
#include <QQuickWidget>
class QResizeEvent;
class QQuickItem;
class MapWidget : public QQuickWidget {
public:
MapWidget(QWidget *parent = NULL);
~MapWidget();
static MapWidget *instance();
private:
static MapWidget *m_instance;
QQuickItem *m_rootItem;
};
#endif // MAPWIDGET_H