Marble

MarbleDBusInterface.cpp
1#include "MarbleDBusInterface.h"
2
3#include "MarbleWidget.h"
4#include "MarbleModel.h"
5#include "MapThemeManager.h"
6#include <GeoSceneDocument.h>
7#include <GeoSceneSettings.h>
8#include <GeoSceneProperty.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)),
36 this, SLOT(handleVisibleLatLonAltBoxChange()) );
37}
38
39MarbleDBusInterface::~MarbleDBusInterface()
40{
41 // nothing to do
42 // (an explicit destructor is required by QScopePointer)
43}
44
45QString MarbleDBusInterface::mapTheme() const
46{
47 return d->m_marbleWidget->mapThemeId();
48}
49
50QStringList MarbleDBusInterface::mapThemes() const
51{
52 MapThemeManager mapThemeManager;
53 return mapThemeManager.mapThemeIds();
54}
55
56int MarbleDBusInterface::tileLevel() const
57{
58 return d->m_marbleWidget->tileZoomLevel();
59}
60
61int MarbleDBusInterface::zoom() const
62{
63 return d->m_marbleWidget->zoom();
64}
65
66QPointF MarbleDBusInterface::center() const
67{
68 return d->m_currentCenter;
69}
70
71void MarbleDBusInterface::setMapTheme( const QString &mapTheme )
72{
73 d->m_marbleWidget->setMapThemeId( mapTheme );
74}
75
76void MarbleDBusInterface::setZoom(int zoom)
77{
78 d->m_marbleWidget->setZoom(zoom);
79}
80
81void MarbleDBusInterface::setPropertyEnabled(const QString &key, bool enabled )
82{
83 d->m_marbleWidget->setPropertyValue( key, enabled );
84}
85
86bool MarbleDBusInterface::isPropertyEnabled( const QString &key ) const
87{
88 bool value = false;
89 GeoSceneDocument const * const mapTheme = d->m_marbleWidget->model()->mapTheme();
90 if ( mapTheme ) {
91 mapTheme->settings()->propertyValue( key, value );
92 }
93
94 return value;
95}
96
97QStringList MarbleDBusInterface::properties() const
98{
100 GeoSceneDocument const * const mapTheme = d->m_marbleWidget->model()->mapTheme();
101 if ( mapTheme ) {
102 for( const GeoSceneProperty* property: mapTheme->settings()->allProperties() ) {
103 properties << property->name();
104 }
105 }
106 return properties;
107}
108
109void MarbleDBusInterface::setCenter( const QPointF &center ) const
110{
111 d->m_marbleWidget->centerOn( center.x(), center.y() );
112}
113
114void MarbleDBusInterface::handleVisibleLatLonAltBoxChange()
115{
116 QPointF const newCenter = QPointF( d->m_marbleWidget->centerLongitude(),
117 d->m_marbleWidget->centerLatitude() );
118 if ( newCenter != d->m_currentCenter ) {
119 d->m_currentCenter = newCenter;
120 emit centerChanged( d->m_currentCenter );
121 }
122}
123
124}
125
126#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 Fri Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.