• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
MarbleControlBox.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  *
3  * Copyright 2004-2007 Torsten Rahn <tackat@kde.org>
4  * Copyright 2007 Inge Wallin <ingwa@kde.org>
5  * Copyright 2007 Thomas Zander <zander@kde.org>
6  * Copyright 2010 Bastian Holst <bastianholst@gmx.de>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 // Self
25 #include "MarbleControlBox.h"
26 
27 // Tabs
28 #include "CurrentLocationWidget.h"
29 #include "NavigationWidget.h"
30 #include "FileViewWidget.h"
31 #include "LegendWidget.h"
32 #include "MapViewWidget.h"
33 #include "RoutingWidget.h"
34 
35 // Marble
36 #include "MapThemeManager.h"
37 #include "MarbleGlobal.h"
38 #include "MarbleWidget.h"
39 #include "MarbleModel.h"
40 #include "GeoSceneDocument.h"
41 #include "GeoSceneHead.h"
42 #include "MarbleDebug.h"
43 
44 
45 namespace Marble
46 {
47 
48 class MarbleControlBoxPrivate
49 {
50  public:
51  MarbleControlBoxPrivate();
52 
53  MapThemeManager m_mapThemeManager;
54 
55  MarbleWidget *m_widget;
56 
57  NavigationWidget *m_navigationWidget;
58  LegendWidget *m_legendWidget;
59  MapViewWidget *m_mapViewWidget;
60 
61  CurrentLocationWidget *m_currentLocationWidget;
62 
63  FileViewWidget *m_fileViewWidget;
64 
65  RoutingWidget *m_routingWidget;
66 };
67 
68 MarbleControlBoxPrivate::MarbleControlBoxPrivate()
69  : m_widget( 0 ),
70  m_navigationWidget( 0 ),
71  m_legendWidget( 0 ),
72  m_mapViewWidget( 0 ),
73  m_currentLocationWidget( 0 ),
74  m_fileViewWidget( 0 ),
75  m_routingWidget( 0 )
76 {
77 }
78 
79 // ================================================================
80 
81 
82 MarbleControlBox::MarbleControlBox(QWidget *parent)
83  : QToolBox( parent ),
84  d( new MarbleControlBoxPrivate )
85 {
86  d->m_widget = 0;
87 
88  setFocusPolicy( Qt::NoFocus );
89 // setFocusProxy( d->uiWidget.searchLineEdit );
90 
91  // Iterate through all of the Side Widget values //
92  d->m_navigationWidget = new NavigationWidget( this );
93  addItem( d->m_navigationWidget, d->m_navigationWidget->windowTitle() );
94 
95  d->m_legendWidget = new LegendWidget( this );
96  addItem( d->m_legendWidget, d->m_legendWidget->windowTitle() );
97 
98  d->m_mapViewWidget = new MapViewWidget( this );
99  addItem( d->m_mapViewWidget, d->m_mapViewWidget->windowTitle() );
100 
101  d->m_fileViewWidget = new FileViewWidget( this );
102  addItem( d->m_fileViewWidget, d->m_fileViewWidget->windowTitle() );
103 
104  d->m_currentLocationWidget = new CurrentLocationWidget( this );
105 
106  addItem( d->m_currentLocationWidget, d->m_currentLocationWidget->windowTitle() );
107 
108  setCurrentIndex(0);
109 
110  //default
111  setCurrentLocationTabShown( true );
112  setFileViewTabShown( false );
113 
114  connect( d->m_mapViewWidget, SIGNAL(showMapWizard()), this, SIGNAL(showMapWizard()) );
115  connect( d->m_mapViewWidget, SIGNAL(showUploadDialog()), this, SIGNAL(showUploadDialog()) );
116  connect( d->m_mapViewWidget, SIGNAL(celestialBodyChanged(QString)),
117  d->m_navigationWidget, SLOT(clearSearch()) );
118  connect( d->m_navigationWidget, SIGNAL(searchFinished()), this, SIGNAL(searchFinished()) );
119 }
120 
121 MarbleControlBox::~MarbleControlBox()
122 {
123  delete d;
124 }
125 
126 void MarbleControlBox::setMarbleWidget(MarbleWidget *widget)
127 {
128  d->m_widget = widget;
129 
130  bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
131  if ( !smallScreen ) {
132  d->m_routingWidget = new RoutingWidget( widget, this );
133  addItem( d->m_routingWidget, tr( "Routing" ) );
134  }
135 
136  d->m_fileViewWidget->setMarbleWidget( widget );
137  d->m_legendWidget->setMarbleModel( widget->model() );
138  d->m_navigationWidget->setMarbleWidget( widget );
139  d->m_mapViewWidget->setMarbleWidget( widget, &d->m_mapThemeManager );
140  d->m_currentLocationWidget->setMarbleWidget( widget );
141 
142  connect( d->m_legendWidget, SIGNAL(propertyValueChanged(QString,bool)),
143  widget, SLOT(setPropertyValue(QString,bool)) );
144 
145  connect( d->m_widget, SIGNAL(themeChanged(QString)),
146  this, SLOT(selectTheme(QString)) );
147 }
148 
149 void MarbleControlBox::setWidgetTabShown( QWidget * widget,
150  int insertIndex, bool show,
151  QString &text )
152 {
153  int index = indexOf( widget );
154 
155  if( show ) {
156  if ( !(index >= 0) ){
157  if ( insertIndex < count() ) {
158  insertItem( insertIndex, widget, text );
159  } else {
160  insertItem( 3 ,widget, text );
161  }
162  widget->show();
163  }
164  } else {
165  if ( index >= 0 ) {
166  widget->hide();
167  removeItem( index );
168  }
169  }
170 }
171 
172 void MarbleControlBox::setNavigationTabShown( bool show )
173 {
174  QString title = tr( "Navigation" );
175  setWidgetTabShown( d->m_navigationWidget, 0, show, title);
176 }
177 
178 void MarbleControlBox::setLegendTabShown( bool show )
179 {
180  QString title = tr( "Legend" );
181  setWidgetTabShown( d->m_legendWidget, 1, show, title );
182 }
183 
184 void MarbleControlBox::setMapViewTabShown( bool show )
185 {
186  QString title = tr( "Map View" );
187  setWidgetTabShown( d->m_mapViewWidget, 2, show, title );
188 }
189 
190 void MarbleControlBox::setFileViewTabShown( bool show )
191 {
192  QString title = tr( "File View" );
193  setWidgetTabShown( d->m_fileViewWidget, 3, show, title );
194 }
195 
196 void MarbleControlBox::setCurrentLocationTabShown( bool show )
197 {
198  QString title = tr( "Current Location" );
199  setWidgetTabShown( d->m_currentLocationWidget, 4, show, title );
200  if ( d->m_widget && d->m_widget->mapTheme() ) {
201  bool enabled = d->m_widget->mapTheme()->head()->target() == "earth";
202  int locationIndex = indexOf( d->m_currentLocationWidget );
203  if ( locationIndex >= 0 ) {
204  setItemEnabled( locationIndex, enabled );
205  }
206  }
207 }
208 
209 void MarbleControlBox::setRoutingTabShown( bool show )
210 {
211  if ( d->m_routingWidget ) {
212  QString title = tr( "Routing" );
213  setWidgetTabShown( d->m_routingWidget, 5, show, title );
214  }
215 }
216 
217 void MarbleControlBox::selectTheme( const QString &theme )
218 {
219  Q_UNUSED( theme )
220 
221  if ( !d->m_widget )
222  return;
223 
224  QString selectedId = d->m_widget->mapTheme()->head()->target();
225  if ( d->m_routingWidget ) {
226  int routingIndex = indexOf( d->m_routingWidget );
227  setItemEnabled( routingIndex, selectedId == "earth" );
228  }
229  int locationIndex = indexOf( d->m_currentLocationWidget );
230  if ( locationIndex >= 0 ) {
231  setItemEnabled( locationIndex, selectedId == "earth" );
232  }
233 }
234 
235 void MarbleControlBox::setWorkOffline(bool offline)
236 {
237  d->m_widget->model()->setWorkOffline( offline );
238  if ( !offline ) {
239  d->m_widget->clearVolatileTileCache();
240  }
241 }
242 
243 CurrentLocationWidget * MarbleControlBox::currentLocationWidget()
244 {
245  return d->m_currentLocationWidget;
246 }
247 
248 void MarbleControlBox::search(const QString &searchTerm, SearchMode searchMode )
249 {
250  setCurrentWidget( d->m_navigationWidget );
251  d->m_navigationWidget->search( searchTerm, searchMode );
252 }
253 
254 }
255 
256 #include "MarbleControlBox.moc"
GeoSceneHead.h
Marble::SearchMode
SearchMode
Search mode: Global (worldwide) versus area (local, regional) search.
Definition: MarbleGlobal.h:183
QWidget
QToolBox::widget
QWidget * widget(int index) const
QToolBox::setCurrentIndex
void setCurrentIndex(int index)
QToolBox::addItem
int addItem(QWidget *w, const QString &text)
Marble::NavigationWidget
Definition: NavigationWidget.h:35
Marble::MarbleControlBox::setLegendTabShown
void setLegendTabShown(bool show)
Control whether the Legend tab is shown.
Definition: MarbleControlBox.cpp:178
QWidget::setFocusPolicy
void setFocusPolicy(Qt::FocusPolicy policy)
MarbleModel.h
This file contains the headers for MarbleModel.
Marble::MarbleControlBox::search
void search(const QString &searchTerm, SearchMode searchMode)
Brings the navigation tab to the front and initiates a search for the given term. ...
Definition: MarbleControlBox.cpp:248
MapThemeManager
Provides access to all map themes installed locally.
Definition: DeclarativeMapThemeManager.h:40
Marble::RoutingWidget
A widget consisting of input fields for places / routing destinations, a list view showing routing in...
Definition: RoutingWidget.h:35
Marble::MarbleControlBox::selectTheme
void selectTheme(const QString &)
Definition: MarbleControlBox.cpp:217
Marble::MapViewWidget
Definition: MapViewWidget.h:32
GeoSceneDocument.h
QToolBox::setCurrentWidget
void setCurrentWidget(QWidget *widget)
FileViewWidget.h
QToolBox::setItemEnabled
void setItemEnabled(int index, bool enabled)
MarbleDebug.h
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
MarbleControlBox.h
This file contains the header for MarbleControlBox.
CurrentLocationWidget.h
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:104
QToolBox::indexOf
int indexOf(QWidget *widget) const
Marble::MarbleControlBox::setMapViewTabShown
void setMapViewTabShown(bool show)
Control whether the Map View tab is shown.
Definition: MarbleControlBox.cpp:184
Marble::LegendWidget
Definition: LegendWidget.h:27
QWidget::enabled
enabled
Marble::CurrentLocationWidget
Definition: CurrentLocationWidget.h:30
NavigationWidget.h
Marble::MarbleWidget::model
MarbleModel * model()
Return the model that this view shows.
Definition: MarbleWidget.cpp:289
LegendWidget.h
QString
QWidget::hide
void hide()
MarbleGlobal.h
Marble::MarbleControlBox::searchFinished
void searchFinished()
Marble::MarbleGlobal::SmallScreen
Definition: MarbleGlobal.h:287
Marble::MarbleGlobal::getInstance
static MarbleGlobal * getInstance()
Definition: MarbleGlobal.cpp:37
Marble::MarbleControlBox::currentLocationWidget
CurrentLocationWidget * currentLocationWidget()
Provides access to the current location widget for session restoring.
Definition: MarbleControlBox.cpp:243
Marble::FileViewWidget
Definition: FileViewWidget.h:33
Marble::MarbleControlBox::setCurrentLocationTabShown
void setCurrentLocationTabShown(bool show)
Control whether the Current Location tab is shown.
Definition: MarbleControlBox.cpp:196
Marble::MarbleControlBox::setFileViewTabShown
void setFileViewTabShown(bool show)
Control whether the File View tab is shown.
Definition: MarbleControlBox.cpp:190
Marble::MarbleControlBox::MarbleControlBox
MarbleControlBox(QWidget *parent=0)
Construct a new MarbleControlBox.
Definition: MarbleControlBox.cpp:82
Marble::MarbleControlBox::setWorkOffline
void setWorkOffline(bool offline)
Toggle offline mode of download manager and runners.
Definition: MarbleControlBox.cpp:235
Marble::MarbleControlBox::showUploadDialog
void showUploadDialog()
Marble::MarbleControlBox::setNavigationTabShown
void setNavigationTabShown(bool show)
Control whether the Navigation tab is shown.
Definition: MarbleControlBox.cpp:172
QToolBox::removeItem
void removeItem(int index)
Marble::MarbleControlBox::setRoutingTabShown
void setRoutingTabShown(bool show)
Control whether the Routing tab is shown.
Definition: MarbleControlBox.cpp:209
RoutingWidget.h
QToolBox
Marble::MarbleGlobal::profiles
Profiles profiles() const
Definition: MarbleGlobal.cpp:48
MarbleWidget.h
This file contains the headers for MarbleWidget.
QWidget::show
void show()
MarbleWidget
Wraps a Marble::MarbleWidget, providing access to important properties and methods.
Definition: MarbleDeclarativeWidget.h:50
Marble::MarbleControlBox::showMapWizard
void showMapWizard()
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
MapViewWidget.h
QToolBox::count
int count() const
Marble::MarbleControlBox::setMarbleWidget
void setMarbleWidget(MarbleWidget *widget)
Set the MarbleWidget to be controlled by this widget.
Definition: MarbleControlBox.cpp:126
Marble::MarbleControlBox::~MarbleControlBox
~MarbleControlBox()
Definition: MarbleControlBox.cpp:121
MapThemeManager.h
QToolBox::insertItem
int insertItem(int index, QWidget *widget, const QString &text)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal