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

marble

  • sources
  • kde-4.12
  • 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() : m_routingWidget(0)
69 {
70 }
71 
72 // ================================================================
73 
74 
75 MarbleControlBox::MarbleControlBox(QWidget *parent)
76  : QToolBox( parent ),
77  d( new MarbleControlBoxPrivate )
78 {
79  d->m_widget = 0;
80 
81  setFocusPolicy( Qt::NoFocus );
82 // setFocusProxy( d->uiWidget.searchLineEdit );
83 
84  // Iterate through all of the Side Widget values //
85  d->m_navigationWidget = new NavigationWidget( this );
86  addItem( d->m_navigationWidget, d->m_navigationWidget->windowTitle() );
87 
88  d->m_legendWidget = new LegendWidget( this );
89  addItem( d->m_legendWidget, d->m_legendWidget->windowTitle() );
90 
91  d->m_mapViewWidget = new MapViewWidget( this );
92  addItem( d->m_mapViewWidget, d->m_mapViewWidget->windowTitle() );
93 
94  d->m_fileViewWidget = new FileViewWidget( this );
95  addItem( d->m_fileViewWidget, d->m_fileViewWidget->windowTitle() );
96 
97  d->m_currentLocationWidget = new CurrentLocationWidget( this );
98 
99  addItem( d->m_currentLocationWidget, d->m_currentLocationWidget->windowTitle() );
100 
101  setCurrentIndex(0);
102 
103  //default
104  setCurrentLocationTabShown( true );
105  setFileViewTabShown( false );
106 
107  connect( d->m_mapViewWidget, SIGNAL(showMapWizard()), this, SIGNAL(showMapWizard()) );
108  connect( d->m_mapViewWidget, SIGNAL(showUploadDialog()), this, SIGNAL(showUploadDialog()) );
109  connect( d->m_mapViewWidget, SIGNAL(celestialBodyChanged(QString)),
110  d->m_navigationWidget, SLOT(clearSearch()) );
111  connect( d->m_navigationWidget, SIGNAL(searchFinished()), this, SIGNAL(searchFinished()) );
112 }
113 
114 MarbleControlBox::~MarbleControlBox()
115 {
116  delete d;
117 }
118 
119 void MarbleControlBox::setMarbleWidget(MarbleWidget *widget)
120 {
121  d->m_widget = widget;
122 
123  bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
124  if ( !smallScreen ) {
125  d->m_routingWidget = new RoutingWidget( widget, this );
126  addItem( d->m_routingWidget, tr( "Routing" ) );
127  }
128 
129  d->m_fileViewWidget->setMarbleWidget( widget );
130  d->m_legendWidget->setMarbleModel( widget->model() );
131  d->m_navigationWidget->setMarbleWidget( widget );
132  d->m_mapViewWidget->setMarbleWidget( widget, &d->m_mapThemeManager );
133  d->m_currentLocationWidget->setMarbleWidget( widget );
134 
135  connect( d->m_legendWidget, SIGNAL(propertyValueChanged(QString,bool)),
136  widget, SLOT(setPropertyValue(QString,bool)) );
137 
138  connect( d->m_widget, SIGNAL(themeChanged(QString)),
139  this, SLOT(selectTheme(QString)) );
140 }
141 
142 void MarbleControlBox::setWidgetTabShown( QWidget * widget,
143  int insertIndex, bool show,
144  QString &text )
145 {
146  int index = indexOf( widget );
147 
148  if( show ) {
149  if ( !(index >= 0) ){
150  if ( insertIndex < count() ) {
151  insertItem( insertIndex, widget, text );
152  } else {
153  insertItem( 3 ,widget, text );
154  }
155  widget->show();
156  }
157  } else {
158  if ( index >= 0 ) {
159  widget->hide();
160  removeItem( index );
161  }
162  }
163 }
164 
165 void MarbleControlBox::setNavigationTabShown( bool show )
166 {
167  QString title = tr( "Navigation" );
168  setWidgetTabShown( d->m_navigationWidget, 0, show, title);
169 }
170 
171 void MarbleControlBox::setLegendTabShown( bool show )
172 {
173  QString title = tr( "Legend" );
174  setWidgetTabShown( d->m_legendWidget, 1, show, title );
175 }
176 
177 void MarbleControlBox::setMapViewTabShown( bool show )
178 {
179  QString title = tr( "Map View" );
180  setWidgetTabShown( d->m_mapViewWidget, 2, show, title );
181 }
182 
183 void MarbleControlBox::setFileViewTabShown( bool show )
184 {
185  QString title = tr( "File View" );
186  setWidgetTabShown( d->m_fileViewWidget, 3, show, title );
187 }
188 
189 void MarbleControlBox::setCurrentLocationTabShown( bool show )
190 {
191  QString title = tr( "Current Location" );
192  setWidgetTabShown( d->m_currentLocationWidget, 4, show, title );
193  if ( d->m_widget && d->m_widget->mapTheme() ) {
194  bool enabled = d->m_widget->mapTheme()->head()->target() == "earth";
195  int locationIndex = indexOf( d->m_currentLocationWidget );
196  if ( locationIndex >= 0 ) {
197  setItemEnabled( locationIndex, enabled );
198  }
199  }
200 }
201 
202 void MarbleControlBox::setRoutingTabShown( bool show )
203 {
204  if ( d->m_routingWidget ) {
205  QString title = tr( "Routing" );
206  setWidgetTabShown( d->m_routingWidget, 5, show, title );
207  }
208 }
209 
210 void MarbleControlBox::selectTheme( const QString &theme )
211 {
212  Q_UNUSED( theme )
213 
214  if ( !d->m_widget )
215  return;
216 
217  QString selectedId = d->m_widget->mapTheme()->head()->target();
218  if ( d->m_routingWidget ) {
219  int routingIndex = indexOf( d->m_routingWidget );
220  setItemEnabled( routingIndex, selectedId == "earth" );
221  }
222  int locationIndex = indexOf( d->m_currentLocationWidget );
223  if ( locationIndex >= 0 ) {
224  setItemEnabled( locationIndex, selectedId == "earth" );
225  }
226 }
227 
228 void MarbleControlBox::setWorkOffline(bool offline)
229 {
230  d->m_widget->model()->setWorkOffline( offline );
231  if ( !offline ) {
232  d->m_widget->clearVolatileTileCache();
233  }
234 }
235 
236 CurrentLocationWidget * MarbleControlBox::currentLocationWidget()
237 {
238  return d->m_currentLocationWidget;
239 }
240 
241 void MarbleControlBox::search(const QString &searchTerm, SearchMode searchMode )
242 {
243  setCurrentWidget( d->m_navigationWidget );
244  d->m_navigationWidget->search( searchTerm, searchMode );
245 }
246 
247 }
248 
249 #include "MarbleControlBox.moc"
GeoSceneHead.h
Marble::SearchMode
SearchMode
Search mode: Global (worldwide) versus area (local, regional) search.
Definition: MarbleGlobal.h:179
QToolBox
Marble::NavigationWidget
Definition: NavigationWidget.h:35
Marble::MarbleControlBox::setLegendTabShown
void setLegendTabShown(bool show)
Control whether the Legend tab is shown.
Definition: MarbleControlBox.cpp:171
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:241
QWidget
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:210
Marble::MapViewWidget
Definition: MapViewWidget.h:32
GeoSceneDocument.h
FileViewWidget.h
MarbleDebug.h
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:102
Marble::MarbleControlBox::setMapViewTabShown
void setMapViewTabShown(bool show)
Control whether the Map View tab is shown.
Definition: MarbleControlBox.cpp:177
Marble::LegendWidget
Definition: LegendWidget.h:27
Marble::CurrentLocationWidget
Definition: CurrentLocationWidget.h:30
NavigationWidget.h
Marble::MarbleWidget::model
MarbleModel * model() const
Return the model that this view shows.
Definition: MarbleWidget.cpp:283
LegendWidget.h
MarbleGlobal.h
Marble::MarbleControlBox::searchFinished
void searchFinished()
Marble::MarbleGlobal::SmallScreen
Definition: MarbleGlobal.h:268
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:236
Marble::FileViewWidget
Definition: FileViewWidget.h:33
Marble::MarbleControlBox::setCurrentLocationTabShown
void setCurrentLocationTabShown(bool show)
Control whether the Current Location tab is shown.
Definition: MarbleControlBox.cpp:189
Marble::MarbleControlBox::setFileViewTabShown
void setFileViewTabShown(bool show)
Control whether the File View tab is shown.
Definition: MarbleControlBox.cpp:183
Marble::MarbleControlBox::MarbleControlBox
MarbleControlBox(QWidget *parent=0)
Construct a new MarbleControlBox.
Definition: MarbleControlBox.cpp:75
Marble::MarbleControlBox::setWorkOffline
void setWorkOffline(bool offline)
Toggle offline mode of download manager and runners.
Definition: MarbleControlBox.cpp:228
Marble::MarbleControlBox::showUploadDialog
void showUploadDialog()
Marble::MarbleControlBox::setNavigationTabShown
void setNavigationTabShown(bool show)
Control whether the Navigation tab is shown.
Definition: MarbleControlBox.cpp:165
Marble::MarbleControlBox::setRoutingTabShown
void setRoutingTabShown(bool show)
Control whether the Routing tab is shown.
Definition: MarbleControlBox.cpp:202
RoutingWidget.h
Marble::MarbleGlobal::profiles
Profiles profiles() const
Definition: MarbleGlobal.cpp:48
MarbleWidget.h
This file contains the headers for MarbleWidget.
MarbleWidget
Wraps a Marble::MarbleWidget, providing access to important properties and methods.
Definition: MarbleDeclarativeWidget.h:50
Marble::MarbleControlBox::showMapWizard
void showMapWizard()
MapViewWidget.h
Marble::MarbleControlBox::setMarbleWidget
void setMarbleWidget(MarbleWidget *widget)
Set the MarbleWidget to be controlled by this widget.
Definition: MarbleControlBox.cpp:119
Marble::MarbleControlBox::~MarbleControlBox
~MarbleControlBox()
Definition: MarbleControlBox.cpp:114
MapThemeManager.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:51 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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