Marble

MarbleDBusInterface.cpp
1#include "MarbleDBusInterface.h"
2
3#include "MapThemeManager.h"
4#include "MarbleModel.h"
5#include "MarbleWidget.h"
6#include <GeoSceneDocument.h>
7#include <GeoSceneProperty.h>
8#include <GeoSceneSettings.h>
9
10namespace Marble
11{
12
13class Q_DECL_HIDDEN MarbleDBusInterface::Private
14{
15public:
16 Private(MarbleWidget *widget);
17
18 MarbleWidget *m_marbleWidget;
19 QPointF m_currentCenter;
20};
21
22MarbleDBusInterface::Private::Private(MarbleWidget *widget)
23 : m_marbleWidget(widget)
24{
25 // nothing to do
26}
27
28MarbleDBusInterface::MarbleDBusInterface(MarbleWidget *widget)
29 : QDBusAbstractAdaptor(widget)
30 , d(new Private(widget))
31{
32 connect(widget, SIGNAL(themeChanged(QString)), this, SIGNAL(mapThemeChanged(QString)));
33 connect(widget, SIGNAL(tileLevelChanged(int)), this, SIGNAL(tileLevelChanged(int)));
34 connect(widget, SIGNAL(zoomChanged(int)), this, SIGNAL(zoomChanged(int)));
35 connect(widget, SIGNAL(visibleLatLonAltBoxChanged(GeoDataLatLonAltBox)), this, SLOT(handleVisibleLatLonAltBoxChange()));
36}
37
38MarbleDBusInterface::~MarbleDBusInterface()
39{
40 // nothing to do
41 // (an explicit destructor is required by QScopePointer)
42}
43
44QString MarbleDBusInterface::mapTheme() const
45{
46 return d->m_marbleWidget->mapThemeId();
47}
48
49QStringList MarbleDBusInterface::mapThemes() const
50{
51 MapThemeManager mapThemeManager;
52 return mapThemeManager.mapThemeIds();
53}
54
55int MarbleDBusInterface::tileLevel() const
56{
57 return d->m_marbleWidget->tileZoomLevel();
58}
59
60int MarbleDBusInterface::zoom() const
61{
62 return d->m_marbleWidget->zoom();
63}
64
65QPointF MarbleDBusInterface::center() const
66{
67 return d->m_currentCenter;
68}
69
70void MarbleDBusInterface::setMapTheme(const QString &mapTheme)
71{
72 d->m_marbleWidget->setMapThemeId(mapTheme);
73}
74
75void MarbleDBusInterface::setZoom(int zoom)
76{
77 d->m_marbleWidget->setZoom(zoom);
78}
79
80void MarbleDBusInterface::setPropertyEnabled(const QString &key, bool enabled)
81{
82 d->m_marbleWidget->setPropertyValue(key, enabled);
83}
84
85bool MarbleDBusInterface::isPropertyEnabled(const QString &key) const
86{
87 bool value = false;
88 GeoSceneDocument const *const mapTheme = d->m_marbleWidget->model()->mapTheme();
89 if (mapTheme) {
90 mapTheme->settings()->propertyValue(key, value);
91 }
92
93 return value;
94}
95
96QStringList MarbleDBusInterface::properties() const
97{
99 GeoSceneDocument const *const mapTheme = d->m_marbleWidget->model()->mapTheme();
100 if (mapTheme) {
101 for (const GeoSceneProperty *property : mapTheme->settings()->allProperties()) {
102 properties << property->name();
103 }
104 }
105 return properties;
106}
107
108void MarbleDBusInterface::setCenter(const QPointF &center) const
109{
110 d->m_marbleWidget->centerOn(center.x(), center.y());
111}
112
113void MarbleDBusInterface::handleVisibleLatLonAltBoxChange()
114{
115 QPointF const newCenter = QPointF(d->m_marbleWidget->centerLongitude(), d->m_marbleWidget->centerLatitude());
116 if (newCenter != d->m_currentCenter) {
117 d->m_currentCenter = newCenter;
118 Q_EMIT centerChanged(d->m_currentCenter);
119 }
120}
121
122}
123
124#include "moc_MarbleDBusInterface.cpp"
This file contains the headers for MarbleModel.
This file contains the headers for MarbleWidget.
Provides access to all map themes installed locally.
QStringList mapThemeIds() const
A list of all installed map theme ids, each entry has the form "planet/themeid/themeid....
KGuiItem properties()
Binds a QML item to a specific geodetic location in screen coordinates.
QTextStream & center(QTextStream &stream)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.