summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGábor Péterffy <[email protected]>2015-07-18 20:15:42 +0200
committerDennis Nienhüser <[email protected]>2015-07-18 20:15:42 +0200
commit53375610b50c74a6c18353ff50f437f492bdebac (patch)
treea580c778162e0d26844ce761f689425fb0ff312e
parent632ed0c43b4fa1c43ada853c53e03a52aa24603a (diff)
More properties for MarbleQuickItem
REVIEW: 124297
-rw-r--r--examples/cpp/marbleQuick2/main.cpp2
-rw-r--r--src/lib/marble/MarbleQuickItem.cpp210
-rw-r--r--src/lib/marble/MarbleQuickItem.h78
3 files changed, 289 insertions, 1 deletions
diff --git a/examples/cpp/marbleQuick2/main.cpp b/examples/cpp/marbleQuick2/main.cpp
index 23ea1c2..dc63348 100644
--- a/examples/cpp/marbleQuick2/main.cpp
+++ b/examples/cpp/marbleQuick2/main.cpp
@@ -26,7 +26,7 @@ public:
{ //TODO: setters -> properties
map()->setSize(width(), height());
map()->setShowFrameRate(false);
- map()->setProjection(Spherical);
+ map()->setProjection(Marble::Spherical);
map()->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
map()->setShowAtmosphere(false);
map()->setShowCompass(false);
diff --git a/src/lib/marble/MarbleQuickItem.cpp b/src/lib/marble/MarbleQuickItem.cpp
index 6977fa0..e6757fd 100644
--- a/src/lib/marble/MarbleQuickItem.cpp
+++ b/src/lib/marble/MarbleQuickItem.cpp
@@ -191,6 +191,76 @@ namespace Marble
{
}
+ int MarbleQuickItem::mapWidth() const
+ {
+ return d->map()->width();
+ }
+
+ int MarbleQuickItem::mapHeight() const
+ {
+ return d->map()->height();
+ }
+
+ bool MarbleQuickItem::showFrameRate() const
+ {
+ return d->map()->showFrameRate();
+ }
+
+ MarbleQuickItem::Projection MarbleQuickItem::projection() const
+ {
+ return (Projection)d->map()->projection();
+ }
+
+ QString MarbleQuickItem::mapThemeId() const
+ {
+ return d->map()->mapThemeId();
+ }
+
+ bool MarbleQuickItem::showAtmosphere() const
+ {
+ return d->map()->showAtmosphere();
+ }
+
+ bool MarbleQuickItem::showCompass() const
+ {
+ return d->map()->showCompass();
+ }
+
+ bool MarbleQuickItem::showClouds() const
+ {
+ return d->map()->showClouds();
+ }
+
+ bool MarbleQuickItem::showCrosshairs() const
+ {
+ return d->map()->showCrosshairs();
+ }
+
+ bool MarbleQuickItem::showGrid() const
+ {
+ return d->map()->showGrid();
+ }
+
+ bool MarbleQuickItem::showOverviewMap() const
+ {
+ return d->map()->showOverviewMap();
+ }
+
+ bool MarbleQuickItem::showOtherPlaces() const
+ {
+ return d->map()->showOtherPlaces();
+ }
+
+ bool MarbleQuickItem::showScaleBar() const
+ {
+ return d->map()->showScaleBar();
+ }
+
+ bool MarbleQuickItem::showBackground() const
+ {
+ return d->map()->showBackground();
+ }
+
MarbleModel* MarbleQuickItem::model()
{
return d->model();
@@ -241,6 +311,146 @@ namespace Marble
d->zoomOut(mode);
}
+ void MarbleQuickItem::setMapWidth(int mapWidth)
+ {
+ if (d->map()->width() == mapWidth) {
+ return;
+ }
+
+ d->map()->setSize(mapWidth, mapHeight());
+ emit mapWidthChanged(mapWidth);
+ }
+
+ void MarbleQuickItem::setMapHeight(int mapHeight)
+ {
+ if (this->mapHeight() == mapHeight) {
+ return;
+ }
+
+ d->map()->setSize(mapWidth(), mapHeight);
+ emit mapHeightChanged(mapHeight);
+ }
+
+ void MarbleQuickItem::setShowFrameRate(bool showFrameRate)
+ {
+ if (this->showFrameRate() == showFrameRate) {
+ return;
+ }
+
+ d->map()->setShowFrameRate(showFrameRate);
+ emit showFrameRateChanged(showFrameRate);
+ }
+
+ void MarbleQuickItem::setProjection(Projection projection)
+ {
+ if (this->projection() == projection) {
+ return;
+ }
+
+ d->map()->setProjection((Marble::Projection)projection);
+ emit projectionChanged(projection);
+ }
+
+ void MarbleQuickItem::setMapThemeId(QString mapThemeId)
+ {
+ if (this->mapThemeId() == mapThemeId) {
+ return;
+ }
+
+ d->map()->setMapThemeId(mapThemeId);
+ emit mapThemeIdChanged(mapThemeId);
+ }
+
+ void MarbleQuickItem::setShowAtmosphere(bool showAtmosphere)
+ {
+ if (this->showAtmosphere() == showAtmosphere) {
+ return;
+ }
+
+ d->map()->setShowAtmosphere(showAtmosphere);
+ emit showAtmosphereChanged(showAtmosphere);
+ }
+
+ void MarbleQuickItem::setShowCompass(bool showCompass)
+ {
+ if (this->showCompass() == showCompass) {
+ return;
+ }
+
+ d->map()->setShowCompass(showCompass);
+ emit showCompassChanged(showCompass);
+ }
+
+ void MarbleQuickItem::setShowClouds(bool showClouds)
+ {
+ if (this->showClouds() == showClouds) {
+ return;
+ }
+
+ d->map()->setShowClouds(showClouds);
+ emit showCloudsChanged(showClouds);
+ }
+
+ void MarbleQuickItem::setShowCrosshairs(bool showCrosshairs)
+ {
+ if (this->showCrosshairs() == showCrosshairs) {
+ return;
+ }
+
+ d->map()->setShowCrosshairs(showCrosshairs);
+ emit showCrosshairsChanged(showCrosshairs);
+ }
+
+ void MarbleQuickItem::setShowGrid(bool showGrid)
+ {
+ if (this->showGrid() == showGrid) {
+ return;
+ }
+
+ d->map()->setShowGrid(showGrid);
+ emit showGridChanged(showGrid);
+ }
+
+ void MarbleQuickItem::setShowOverviewMap(bool showOverviewMap)
+ {
+ if (this->showOverviewMap() == showOverviewMap) {
+ return;
+ }
+
+ d->map()->setShowOverviewMap(showOverviewMap);
+ emit showOverviewMapChanged(showOverviewMap);
+ }
+
+ void MarbleQuickItem::setShowOtherPlaces(bool showOtherPlaces)
+ {
+ if (this->showOtherPlaces() == showOtherPlaces) {
+ return;
+ }
+
+ d->map()->setShowOtherPlaces(showOtherPlaces);
+ emit showOtherPlacesChanged(showOtherPlaces);
+ }
+
+ void MarbleQuickItem::setShowScaleBar(bool showScaleBar)
+ {
+ if (this->showScaleBar() == showScaleBar) {
+ return;
+ }
+
+ d->map()->setShowScaleBar(showScaleBar);
+ emit showScaleBarChanged(showScaleBar);
+ }
+
+ void MarbleQuickItem::setShowBackground(bool showBackground)
+ {
+ if (this->showBackground() == showBackground) {
+ return;
+ }
+
+ d->map()->setShowBackground(showBackground);
+ emit showBackgroundChanged(showBackground);
+ }
+
QObject *MarbleQuickItem::getEventFilter() const
{ //We would want to install the same event filter for abstract layer QuickItems such as PinchArea
return &d->m_inputHandler;
diff --git a/src/lib/marble/MarbleQuickItem.h b/src/lib/marble/MarbleQuickItem.h
index ce597df..b90e803 100644
--- a/src/lib/marble/MarbleQuickItem.h
+++ b/src/lib/marble/MarbleQuickItem.h
@@ -28,8 +28,38 @@ namespace Marble
{
Q_OBJECT
+ Q_ENUMS(Projection)
+
+ Q_PROPERTY(int mapWidth READ mapWidth WRITE setMapWidth NOTIFY mapWidthChanged)
+ Q_PROPERTY(int mapHeight READ mapHeight WRITE setMapHeight NOTIFY mapHeightChanged)
+ Q_PROPERTY(bool showFrameRate READ showFrameRate WRITE setShowFrameRate NOTIFY showFrameRateChanged)
+ Q_PROPERTY(Projection projection READ projection WRITE setProjection NOTIFY projectionChanged)
+ Q_PROPERTY(QString mapThemeId READ mapThemeId WRITE setMapThemeId NOTIFY mapThemeIdChanged)
+ Q_PROPERTY(bool showAtmosphere READ showAtmosphere WRITE setShowAtmosphere NOTIFY showAtmosphereChanged)
+ Q_PROPERTY(bool showCompass READ showCompass WRITE setShowCompass NOTIFY showCompassChanged)
+ Q_PROPERTY(bool showClouds READ showClouds WRITE setShowClouds NOTIFY showCloudsChanged)
+ Q_PROPERTY(bool showCrosshairs READ showCrosshairs WRITE setShowCrosshairs NOTIFY showCrosshairsChanged)
+ Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid NOTIFY showGridChanged)
+ Q_PROPERTY(bool showOverviewMap READ showOverviewMap WRITE setShowOverviewMap NOTIFY showOverviewMapChanged)
+ Q_PROPERTY(bool showOtherPlaces READ showOtherPlaces WRITE setShowOtherPlaces NOTIFY showOtherPlacesChanged)
+ Q_PROPERTY(bool showScaleBar READ showScaleBar WRITE setShowScaleBar NOTIFY showScaleBarChanged)
+ Q_PROPERTY(bool showBackground READ showBackground WRITE setShowBackground NOTIFY showBackgroundChanged)
+
public:
MarbleQuickItem(QQuickItem *parent = 0);
+
+ enum Projection{
+ Spherical = Marble::Spherical,
+ Equirectangular = Marble::Equirectangular,
+ Mercator = Marble::Mercator,
+ Gnomonic = Marble::Gnomonic,
+ Stereographic = Marble::Stereographic,
+ LambertAzimuthal = Marble::LambertAzimuthal,
+ AzimuthalEquidistant = Marble::AzimuthalEquidistant,
+ VerticalPerspective = Marble::VerticalPerspective
+ };
+
+
MarbleInputHandler *inputHandler();
int zoom() const;
@@ -42,6 +72,21 @@ namespace Marble
void zoomIn(FlyToMode mode = Automatic);
void zoomOut(FlyToMode mode = Automatic);
+ void setMapWidth(int mapWidth);
+ void setMapHeight(int mapHeight);
+ void setShowFrameRate(bool showFrameRate);
+ void setProjection(Projection projection);
+ void setMapThemeId(QString mapThemeId);
+ void setShowAtmosphere(bool showAtmosphere);
+ void setShowCompass(bool showCompass);
+ void setShowClouds(bool showClouds);
+ void setShowCrosshairs(bool showCrosshairs);
+ void setShowGrid(bool showGrid);
+ void setShowOverviewMap(bool showOverviewMap);
+ void setShowOtherPlaces(bool showOtherPlaces);
+ void setShowScaleBar(bool showScaleBar);
+ void setShowBackground(bool showBackground);
+
// QQuickPaintedItem interface
public:
void paint(QPainter *painter);
@@ -50,8 +95,41 @@ namespace Marble
public:
void classBegin();
void componentComplete();
+
+ public:
virtual bool layersEventFilter(QObject *o, QEvent *e);
+ int mapWidth() const;
+ int mapHeight() const;
+ bool showFrameRate() const;
+ Projection projection() const;
+ QString mapThemeId() const;
+ bool showAtmosphere() const;
+ bool showCompass() const;
+ bool showClouds() const;
+ bool showCrosshairs() const;
+ bool showGrid() const;
+ bool showOverviewMap() const;
+ bool showOtherPlaces() const;
+ bool showScaleBar() const;
+ bool showBackground() const;
+
+ signals:
+ void mapWidthChanged(int mapWidth);
+ void mapHeightChanged(int mapHeight);
+ void showFrameRateChanged(bool showFrameRate);
+ void projectionChanged(Projection projection);
+ void mapThemeIdChanged(QString mapThemeId);
+ void showAtmosphereChanged(bool showAtmosphere);
+ void showCompassChanged(bool showCompass);
+ void showCloudsChanged(bool showClouds);
+ void showCrosshairsChanged(bool showCrosshairs);
+ void showGridChanged(bool showGrid);
+ void showOverviewMapChanged(bool showOverviewMap);
+ void showOtherPlacesChanged(bool showOtherPlaces);
+ void showScaleBarChanged(bool showScaleBar);
+ void showBackgroundChanged(bool showBackground);
+
protected:
MarbleModel* model();
const MarbleModel* model() const;