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 
10 namespace Marble
11 {
12 
13 class Q_DECL_HIDDEN MarbleDBusInterface::Private
14 {
15 public:
16  Private( MarbleWidget* widget );
17 
18  MarbleWidget* m_marbleWidget;
19  QPointF m_currentCenter;
20 };
21 
22 MarbleDBusInterface::Private::Private( MarbleWidget *widget ) :
23  m_marbleWidget( widget )
24 {
25  // nothing to do
26 }
27 
28 MarbleDBusInterface::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 
39 MarbleDBusInterface::~MarbleDBusInterface()
40 {
41  // nothing to do
42  // (an explicit destructor is required by QScopePointer)
43 }
44 
45 QString MarbleDBusInterface::mapTheme() const
46 {
47  return d->m_marbleWidget->mapThemeId();
48 }
49 
50 QStringList MarbleDBusInterface::mapThemes() const
51 {
52  MapThemeManager mapThemeManager;
53  return mapThemeManager.mapThemeIds();
54 }
55 
56 int MarbleDBusInterface::tileLevel() const
57 {
58  return d->m_marbleWidget->tileZoomLevel();
59 }
60 
61 int MarbleDBusInterface::zoom() const
62 {
63  return d->m_marbleWidget->zoom();
64 }
65 
66 QPointF MarbleDBusInterface::center() const
67 {
68  return d->m_currentCenter;
69 }
70 
71 void MarbleDBusInterface::setMapTheme( const QString &mapTheme )
72 {
73  d->m_marbleWidget->setMapThemeId( mapTheme );
74 }
75 
76 void MarbleDBusInterface::setZoom(int zoom)
77 {
78  d->m_marbleWidget->setZoom(zoom);
79 }
80 
81 void MarbleDBusInterface::setPropertyEnabled(const QString &key, bool enabled )
82 {
83  d->m_marbleWidget->setPropertyValue( key, enabled );
84 }
85 
86 bool 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 
97 QStringList 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 
109 void MarbleDBusInterface::setCenter( const QPointF &center ) const
110 {
111  d->m_marbleWidget->centerOn( center.x(), center.y() );
112 }
113 
114 void 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"
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....
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Binds a QML item to a specific geodetic location in screen coordinates.
KGuiItem properties()
QTextStream & center(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu May 26 2022 04:07:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.