• 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
  • apps
  • marble-ui
ControlView.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2006-2007 Torsten Rahn <tackat@kde.org>
9 // Copyright 2007 Inge Wallin <ingwa@kde.org>
10 //
11 
12 
13 #include "ControlView.h"
14 
15 #include <QLayout>
16 #include <QSplitter>
17 #include <QStringListModel>
18 #include <QPrintDialog>
19 #include <QPrintPreviewDialog>
20 #include <QPrinter>
21 #include <QPainter>
22 #include <QTextDocument>
23 #include <QPointer>
24 #include <QUrl>
25 #include <QDesktopServices>
26 #include <QNetworkAccessManager>
27 #include <QNetworkReply>
28 #include <QNetworkRequest>
29 #include <QProcess>
30 #include <QTimer>
31 #include <QFileInfo>
32 #include <QMessageBox>
33 #include <QMainWindow>
34 #include <QDockWidget>
35 #include <QShortcut>
36 #include <QMenu>
37 
38 #include "GeoSceneDocument.h"
39 #include "GeoSceneHead.h"
40 #include "MarbleWidget.h"
41 #include "MarbleDebug.h"
42 #include "MarbleModel.h"
43 #include "MarbleMap.h"
44 #include "MapThemeManager.h"
45 #include "PrintOptionsWidget.h"
46 #include "ViewportParams.h"
47 #include "ViewParams.h"
48 #include "routing/RoutingManager.h"
49 #include "routing/RoutingModel.h"
50 #include "routing/RouteRequest.h"
51 #include "routing/RoutingWidget.h"
52 #include "ExternalEditorDialog.h"
53 #include "CurrentLocationWidget.h"
54 #include "SearchWidget.h"
55 #include "MapViewWidget.h"
56 #include "FileViewWidget.h"
57 #include "LegendWidget.h"
58 #include "BookmarkManager.h"
59 #include "cloudsync/CloudSyncManager.h"
60 #include "cloudsync/BookmarkSyncManager.h"
61 #include "cloudsync/ConflictDialog.h"
62 #include "cloudsync/MergeItem.h"
63 
64 namespace Marble
65 {
66 
67 ControlView::ControlView( QWidget *parent )
68  : QWidget( parent ),
69  m_mapThemeManager( new MapThemeManager( this ) ),
70  m_searchDock( 0 ),
71  m_locationWidget( 0 ),
72  m_conflictDialog( 0 )
73 {
74  setWindowTitle( tr( "Marble - Virtual Globe" ) );
75 
76  resize( 680, 640 );
77 
78  m_marbleWidget = new MarbleWidget( this );
79  m_marbleWidget->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding,
80  QSizePolicy::MinimumExpanding ) );
81 
82  QVBoxLayout* layout = new QVBoxLayout;
83  layout->addWidget( m_marbleWidget );
84  layout->setMargin( 0 );
85  setLayout( layout );
86 
87  m_cloudSyncManager = new CloudSyncManager( this );
88  m_cloudSyncManager->routeSyncManager()->setRoutingManager( m_marbleWidget->model()->routingManager() );
89  BookmarkSyncManager* bookmarkSyncManager = m_cloudSyncManager->bookmarkSyncManager();
90  bookmarkSyncManager->setBookmarkManager( m_marbleWidget->model()->bookmarkManager() );
91  m_conflictDialog = new ConflictDialog( m_marbleWidget );
92  connect( bookmarkSyncManager, SIGNAL(mergeConflict(MergeItem*)), this, SLOT(showConflictDialog(MergeItem*)) );
93  connect( bookmarkSyncManager, SIGNAL(syncComplete()), m_conflictDialog, SLOT(stopAutoResolve()) );
94  connect( m_conflictDialog, SIGNAL(resolveConflict(MergeItem*)), bookmarkSyncManager, SLOT(resolveConflict(MergeItem*)) );
95 }
96 
97 ControlView::~ControlView()
98 {
99  // nothing to do
100 }
101 
102 QString ControlView::applicationVersion()
103 {
104  return "1.7.0 (stable version)";
105 }
106 
107 MapThemeManager *ControlView::mapThemeManager()
108 {
109  return m_mapThemeManager;
110 }
111 
112 void ControlView::zoomIn()
113 {
114  m_marbleWidget->zoomIn();
115 }
116 
117 void ControlView::zoomOut()
118 {
119  m_marbleWidget->zoomOut();
120 }
121 
122 void ControlView::moveLeft()
123 {
124  m_marbleWidget->moveLeft();
125 }
126 
127 void ControlView::moveRight()
128 {
129  m_marbleWidget->moveRight();
130 }
131 
132 void ControlView::moveUp()
133 {
134  m_marbleWidget->moveUp();
135 }
136 
137 void ControlView::moveDown()
138 {
139  m_marbleWidget->moveDown();
140 }
141 
142 QString ControlView::defaultMapThemeId() const
143 {
144  QStringList fallBackThemes;
145  fallBackThemes << "earth/srtm/srtm.dgml";
146  fallBackThemes << "earth/bluemarble/bluemarble.dgml";
147  fallBackThemes << "earth/openstreetmap/openstreetmap.dgml";
148 
149  const QStringList installedThemes = m_mapThemeManager->mapThemeIds();
150 
151  foreach(const QString &fallback, fallBackThemes) {
152  if (installedThemes.contains(fallback)) {
153  return fallback;
154  }
155  }
156 
157  if (installedThemes.size()) {
158  return installedThemes.first();
159  }
160 
161  return QString();
162 }
163 
164 void ControlView::printMapScreenShot( QPointer<QPrintDialog> printDialog)
165 {
166 #ifndef QT_NO_PRINTER
167  PrintOptionsWidget* printOptions = new PrintOptionsWidget( this );
168  bool const mapCoversViewport = m_marbleWidget->viewport()->mapCoversViewport();
169  printOptions->setBackgroundControlsEnabled( !mapCoversViewport );
170  bool hasLegend = m_marbleWidget->model()->legend() != 0;
171  printOptions->setLegendControlsEnabled( hasLegend );
172  bool hasRoute = marbleWidget()->model()->routingManager()->routingModel()->rowCount() > 0;
173  printOptions->setPrintRouteSummary( hasRoute );
174  printOptions->setPrintDrivingInstructions( hasRoute );
175  printOptions->setPrintDrivingInstructionsAdvice( hasRoute );
176  printOptions->setRouteControlsEnabled( hasRoute );
177  printDialog->setOptionTabs( QList<QWidget*>() << printOptions );
178 
179  if ( printDialog->exec() == QDialog::Accepted ) {
180  QTextDocument document;
181  QString text = "<html><head><title>Marble Printout</title></head><body>";
182  QPalette const originalPalette = m_marbleWidget->palette();
183  bool const wasBackgroundVisible = m_marbleWidget->showBackground();
184  bool const hideBackground = !mapCoversViewport && !printOptions->printBackground();
185  if ( hideBackground ) {
186  // Temporarily remove the black background and layers painting on it
187  m_marbleWidget->setShowBackground( false );
188  m_marbleWidget->setPalette( QPalette ( Qt::white ) );
189  m_marbleWidget->update();
190  }
191 
192  if ( printOptions->printMap() ) {
193  printMap( document, text, printDialog->printer() );
194  }
195 
196  if ( printOptions->printLegend() ) {
197  printLegend( document, text );
198  }
199 
200  if ( printOptions->printRouteSummary() ) {
201  printRouteSummary( document, text );
202  }
203 
204  if ( printOptions->printDrivingInstructions() ) {
205  printDrivingInstructions( document, text );
206  }
207 
208  if ( printOptions->printDrivingInstructionsAdvice() ) {
209  printDrivingInstructionsAdvice( document, text );
210  }
211 
212  text += "</body></html>";
213  document.setHtml( text );
214  document.print( printDialog->printer() );
215 
216  if ( hideBackground ) {
217  m_marbleWidget->setShowBackground( wasBackgroundVisible );
218  m_marbleWidget->setPalette( originalPalette );
219  m_marbleWidget->update();
220  }
221  }
222 #endif
223 }
224 
225 void ControlView::printPixmap( QPrinter * printer, const QPixmap& pixmap )
226 {
227 #ifndef QT_NO_PRINTER
228  QSize printSize = pixmap.size();
229  QRect mapPageRect = printer->pageRect();
230  printSize.scale( printer->pageRect().size(), Qt::KeepAspectRatio );
231  QPoint printTopLeft( ( mapPageRect.width() - printSize.width() ) / 2 ,
232  ( mapPageRect.height() - printSize.height() ) / 2 );
233  QRect mapPrintRect( printTopLeft, printSize );
234 
235  QPainter painter;
236  if (!painter.begin(printer))
237  return;
238  painter.drawPixmap( mapPrintRect, pixmap, pixmap.rect() );
239  painter.end();
240 #endif
241 }
242 
243 // QPointer is used because of issues described in http://www.kdedevelopers.org/node/3919
244 void ControlView::printPreview()
245 {
246 #ifndef QT_NO_PRINTER
247  QPrinter printer( QPrinter::HighResolution );
248 
249  QPointer<QPrintPreviewDialog> preview = new QPrintPreviewDialog( &printer, this );
250  preview->setWindowFlags ( Qt::Window );
251  preview->resize(640, 480);
252  connect( preview, SIGNAL(paintRequested(QPrinter*)), SLOT(paintPrintPreview(QPrinter*)) );
253  preview->exec();
254  delete preview;
255 #endif
256 }
257 
258 void ControlView::paintPrintPreview( QPrinter * printer )
259 {
260 #ifndef QT_NO_PRINTER
261  QPixmap mapPixmap = mapScreenShot();
262  printPixmap( printer, mapPixmap );
263 #endif
264 }
265 
266 void ControlView::printMap( QTextDocument &document, QString &text, QPrinter *printer )
267 {
268 #ifndef QT_NO_PRINTER
269  QPixmap image = mapScreenShot();
270 
271  if ( m_marbleWidget->viewport()->mapCoversViewport() ) {
272  // Paint a black frame. Looks better.
273  QPainter painter(&image);
274  painter.setPen( Qt::black );
275  painter.drawRect( 0, 0, image.width() - 2, image.height() - 2 );
276  }
277 
278  QString uri = "marble://screenshot.png";
279  document.addResource( QTextDocument::ImageResource, QUrl( uri ), QVariant( image) );
280  QString img = "<img src=\"%1\" width=\"%2\" align=\"center\">";
281  int width = qRound( printer->pageRect( QPrinter::Point ).width() );
282  text += img.arg( uri ).arg( width );
283 #endif
284 }
285 
286 void ControlView::printLegend( QTextDocument &document, QString &text )
287 {
288 #ifndef QT_NO_PRINTER
289  QTextDocument *legend = m_marbleWidget->model()->legend();
290  if ( legend ) {
291  legend->adjustSize();
292  QSize size = legend->size().toSize();
293  QSize imageSize = size + QSize( 4, 4 );
294  QImage image( imageSize, QImage::Format_ARGB32);
295  QPainter painter( &image );
296  painter.setRenderHint( QPainter::Antialiasing, true );
297  painter.drawRoundedRect( QRect( QPoint( 0, 0 ), size ), 5, 5 );
298  legend->drawContents( &painter );
299  document.addResource( QTextDocument::ImageResource, QUrl( "marble://legend.png" ), QVariant(image) );
300  QString img = "<p><img src=\"%1\" align=\"center\"></p>";
301  text += img.arg( "marble://legend.png" );
302  }
303 #endif
304 }
305 
306 void ControlView::printRouteSummary( QTextDocument &document, QString &text)
307 {
308 #ifndef QT_NO_PRINTER
309  RoutingModel* routingModel = m_marbleWidget->model()->routingManager()->routingModel();
310 
311  if ( !routingModel ) {
312  return;
313  }
314 
315  RouteRequest* routeRequest = m_marbleWidget->model()->routingManager()->routeRequest();
316  if ( routeRequest ) {
317  QString summary = "<h3>Route to %1: %2 %3</h3>";
318  QString destination;
319  if ( routeRequest->size() ) {
320  destination = routeRequest->name( routeRequest->size()-1 );
321  }
322 
323  QString label = "<p>%1 %2</p>";
324  qreal distance = routingModel->route().distance();
325  QString unit = distance > 1000 ? "km" : "m";
326  int precision = distance > 1000 ? 1 : 0;
327  if ( distance > 1000 ) {
328  distance /= 1000;
329  }
330  summary = summary.arg(destination).arg( distance, 0, 'f', precision ).arg( unit );
331  text += summary;
332 
333  text += "<table cellpadding=\"2\">";
334  QString pixmapTemplate = "marble://viaPoint-%1.png";
335  for ( int i=0; i<routeRequest->size(); ++i ) {
336  text += "<tr><td>";
337  QPixmap pixmap = routeRequest->pixmap(i);
338  QString pixmapResource = pixmapTemplate.arg( i );
339  document.addResource(QTextDocument::ImageResource,
340  QUrl( pixmapResource ), QVariant( pixmap ) );
341  QString myimg = "<img src=\"%1\">";
342  text += myimg.arg( pixmapResource );
343  text += "</td><td>";
344  text += routeRequest->name( i );
345  text += "</td></tr>";
346  }
347  text += "</table>";
348  }
349 #endif
350 }
351 
352 void ControlView::printDrivingInstructions( QTextDocument &document, QString &text )
353 {
354 #ifndef QT_NO_PRINTER
355  RoutingModel* routingModel = m_marbleWidget->model()->routingManager()->routingModel();
356 
357  if (!routingModel) {
358  return;
359  }
360 
361  GeoDataLineString total = routingModel->route().path();
362 
363  text += "<table cellpadding=\"4\">";
364  text += "<tr><th>No.</th><th>Distance</th><th>Instruction</th></tr>";
365  for ( int i=0; i<routingModel->rowCount(); ++i ) {
366  QModelIndex index = routingModel->index(i, 0);
367  GeoDataCoordinates coordinates = index.data( RoutingModel::CoordinateRole ).value<GeoDataCoordinates>();
368  GeoDataLineString accumulator;
369  for (int k=0; k<total.size(); ++k) {
370  accumulator << total.at(k);
371 
372  if (total.at(k) == coordinates)
373  break;
374  }
375 
376  if ( i%2 == 0 ) {
377  text += "<tr bgcolor=\"lightGray\"><td align=\"right\" valign=\"middle\">";
378  }
379  else {
380  text += "<tr><td align=\"right\" valign=\"middle\">";
381  }
382  text += QString::number( i+1 );
383  text += "</td><td align=\"right\" valign=\"middle\">";
384 
385  text += QString::number( accumulator.length( EARTH_RADIUS ) * METER2KM, 'f', 1 );
387  text += " km</td><td valign=\"middle\">";
388 
389  QPixmap instructionIcon = index.data( Qt::DecorationRole ).value<QPixmap>();
390  if ( !instructionIcon.isNull() ) {
391  QString uri = QString("marble://turnIcon%1.png").arg(i);
392  document.addResource( QTextDocument::ImageResource, QUrl( uri ), QVariant( instructionIcon ) );
393  text += QString("<img src=\"%1\">").arg(uri);
394  }
395 
396  text += routingModel->data( index ).toString();
397  text += "</td></tr>";
398  }
399  text += "</table>";
400 #endif
401 }
402 
403 void ControlView::printDrivingInstructionsAdvice( QTextDocument &, QString &text )
404 {
405 #ifndef QT_NO_PRINTER
406  text += "<p>" + tr( "The Marble development team wishes you a pleasant and safe journey." ) + "</p>";
407  text += "<p>" + tr( "Caution: Driving instructions may be incomplete or inaccurate." );
408  text += ' ' + tr( "Road construction, weather and other unforeseen variables can result in this suggested route not to be the most expedient or safest route to your destination." );
409  text += ' ' + tr( "Please use common sense while navigating." ) + "</p>";
410 #endif
411 }
412 
413 
414 void ControlView::launchExternalMapEditor()
415 {
416  QString editor = m_externalEditor;
417  if ( editor.isEmpty() ) {
418  QPointer<ExternalEditorDialog> dialog = new ExternalEditorDialog( this );
419  if( dialog->exec() == QDialog::Accepted ) {
420  editor = dialog->externalEditor();
421  if ( dialog->saveDefault() ) {
422  m_externalEditor = editor;
423  }
424  } else {
425  return;
426  }
427  }
428 
429  if ( editor == "josm" )
430  {
431  // JOSM, the java based editor
432  synchronizeWithExternalMapEditor( editor, "--download=%1,%4,%3,%2" );
433  }
434  else if ( editor == "merkaartor" )
435  {
436  // Merkaartor, a Qt based editor
437  QString argument = "osm://download/load_and_zoom?top=%1&right=%2&bottom=%3&left=%4";
438  synchronizeWithExternalMapEditor( editor, argument );
439  }
440  else {
441  // Potlatch, the flash based editor running at the osm main website
442  QString url = "http://www.openstreetmap.org/edit?lat=%1&lon=%2&zoom=%3";
443  qreal lat = m_marbleWidget->centerLatitude();
444  qreal lon = m_marbleWidget->centerLongitude();
445  int zoom = m_marbleWidget->tileZoomLevel();
446  url = url.arg( lat, 0, 'f', 8 ).arg( lon, 0, 'f', 8 ).arg( zoom );
447  QDesktopServices::openUrl( url );
448  }
449 }
450 
451 void ControlView::synchronizeWithExternalMapEditor( const QString &application, const QString &argument )
452 {
453  QTimer watchdog; // terminates network connection after a short timeout
454  watchdog.setSingleShot( true );
455  QEventLoop localEventLoop;
456  connect( &watchdog, SIGNAL(timeout()), &localEventLoop, SLOT(quit()) );
457  QNetworkAccessManager manager;
458  connect( &manager, SIGNAL(finished(QNetworkReply*)), &localEventLoop, SLOT(quit()) );
459 
460  // Wait at most two seconds for the local server to respond
461  QNetworkReply *reply = manager.get( QNetworkRequest( QUrl( "http://localhost:8111/") ) );
462  watchdog.start( 2000 );
463  localEventLoop.exec();
464 
465  GeoDataLatLonAltBox box = m_marbleWidget->viewport()->viewLatLonAltBox();
466  qreal north = box.north( GeoDataCoordinates::Degree );
467  qreal east = box.east( GeoDataCoordinates::Degree );
468  qreal south = box.south( GeoDataCoordinates::Degree );
469  qreal west = box.west( GeoDataCoordinates::Degree );
470 
471  if( watchdog.isActive() && reply->bytesAvailable() > 0 ) {
472  // The local server is alive. Tell it to download the current region
473  watchdog.stop();
474  QString serverUrl = "http://localhost:8111/load_and_zoom?top=%1&right=%2&bottom=%3&left=%4";
475  serverUrl = serverUrl.arg( north, 0, 'f', 8 ).arg( east, 0, 'f', 8 );
476  serverUrl = serverUrl.arg( south, 0, 'f', 8 ).arg( west, 0, 'f', 8 );
477  mDebug() << "Connecting to local server URL " << serverUrl;
478  manager.get( QNetworkRequest( QUrl( serverUrl ) ) );
479 
480  // Give it five seconds to process the request
481  watchdog.start( 5000 );
482  localEventLoop.exec();
483  } else {
484  // The local server is not alive. Start the application
485  QString applicationArgument = argument.arg( south, 0, 'f', 8 ).arg( east, 0, 'f', 8 );
486  applicationArgument = applicationArgument.arg( north, 0, 'f', 8 ).arg( west, 0, 'f', 8 );
487  mDebug() << "No local server found. Launching " << application << " with argument " << applicationArgument;
488  if ( !QProcess::startDetached( application, QStringList() << applicationArgument ) ) {
489  QString text = tr( "Unable to start the external editor. Check that %1 is installed or choose a different external editor in the settings dialog." );
490  text = text.arg( application );
491  QMessageBox::warning( this, tr( "Cannot start external editor" ), text );
492  }
493  }
494 }
495 
496 void ControlView::setExternalMapEditor( const QString &editor )
497 {
498  m_externalEditor = editor;
499 }
500 
501 QList<QAction*> ControlView::setupDockWidgets( QMainWindow *mainWindow )
502 {
503  Q_ASSERT( !m_searchDock && "Please create dock widgets just once" );
504 
505  mainWindow->setTabPosition( Qt::LeftDockWidgetArea, QTabWidget::North );
506  mainWindow->setTabPosition( Qt::RightDockWidgetArea, QTabWidget::North );
507 
508  QDockWidget* legendDock = new QDockWidget( tr( "Legend" ), this );
509  legendDock->setObjectName( "legendDock" );
510  legendDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
511  LegendWidget* legendWidget = new LegendWidget( this );
512  legendWidget->setMarbleModel( marbleModel() );
513  connect( legendWidget, SIGNAL(propertyValueChanged(QString,bool)),
514  marbleWidget(), SLOT(setPropertyValue(QString,bool)) );
515  legendDock->setWidget( legendWidget );
516 
517  bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
518  if ( smallScreen ) {
519  // Show only the legend as a dock widget on small screen, the others are dialogs
520  mainWindow->addDockWidget( Qt::LeftDockWidgetArea, legendDock );
521  return QList<QAction*>() << legendDock->toggleViewAction();
522  }
523 
524  QDockWidget *routingDock = new QDockWidget( tr( "Routing" ), mainWindow );
525  routingDock->setObjectName( "routingDock" );
526  routingDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
527  RoutingWidget* routingWidget = new RoutingWidget( marbleWidget(), mainWindow );
528  routingWidget->setRouteSyncManager( cloudSyncManager()->routeSyncManager() );
529  routingDock->setWidget( routingWidget );
530  mainWindow->addDockWidget( Qt::LeftDockWidgetArea, routingDock );
531 
532  QDockWidget *locationDock = new QDockWidget( tr( "Location" ), this );
533  locationDock->setObjectName( "locationDock" );
534  locationDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
535  m_locationWidget = new CurrentLocationWidget( this );
536  m_locationWidget->setMarbleWidget( marbleWidget() );
537  locationDock->setWidget( m_locationWidget );
538  mainWindow->addDockWidget( Qt::LeftDockWidgetArea, locationDock );
539 
540  m_searchDock = new QDockWidget( tr( "Search" ), this );
541  m_searchDock->setObjectName( "searchDock" );
542  m_searchDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
543  SearchWidget* searchWidget = new SearchWidget( this );
544  searchWidget->setMarbleWidget( marbleWidget() );
545  m_searchDock->setWidget( searchWidget );
546  mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_searchDock );
547 
548  mainWindow->tabifyDockWidget( m_searchDock, routingDock );
549  mainWindow->tabifyDockWidget( routingDock, locationDock );
550  m_searchDock->raise();
551 
552  QKeySequence searchSequence( Qt::CTRL + Qt::Key_F );
553  searchWidget->setToolTip( tr( "Search for cities, addresses, points of interest and more (%1)" ).arg( searchSequence.toString() ) );
554  QShortcut* searchShortcut = new QShortcut( mainWindow );
555  connect( searchShortcut, SIGNAL(activated()), this, SLOT(showSearch()) );
556 
557  QDockWidget *mapViewDock = new QDockWidget( tr( "Map View" ), this );
558  mapViewDock->setObjectName( "mapViewDock" );
559  mapViewDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
560  MapViewWidget* mapViewWidget = new MapViewWidget( this );
561  mapViewWidget->setMarbleWidget( marbleWidget(), m_mapThemeManager );
562  connect( mapViewWidget, SIGNAL(showMapWizard()), this, SIGNAL(showMapWizard()) );
563  connect( mapViewWidget, SIGNAL(showUploadDialog()), this, SIGNAL(showUploadDialog()) );
564  connect( mapViewWidget, SIGNAL(mapThemeDeleted()), this, SIGNAL(mapThemeDeleted()) );
565  mapViewDock->setWidget( mapViewWidget );
566  mainWindow->addDockWidget( Qt::LeftDockWidgetArea, mapViewDock );
567 
568  QDockWidget *fileViewDock = new QDockWidget( tr( "Files" ), this );
569  fileViewDock->setObjectName( "fileViewDock" );
570  fileViewDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
571  FileViewWidget* fileViewWidget = new FileViewWidget( this );
572  fileViewWidget->setMarbleWidget( marbleWidget() );
573  fileViewDock->setWidget( fileViewWidget );
574  mainWindow->addDockWidget( Qt::LeftDockWidgetArea, fileViewDock );
575  fileViewDock->hide();
576 
577  mainWindow->addDockWidget( Qt::LeftDockWidgetArea, legendDock );
578  mainWindow->tabifyDockWidget( mapViewDock, legendDock );
579  mapViewDock->raise();
580 
581  QList<QAction*> panelActions;
582  panelActions << routingDock->toggleViewAction();
583  panelActions << locationDock->toggleViewAction();
584  panelActions << m_searchDock->toggleViewAction();
585  panelActions << mapViewDock->toggleViewAction();
586  panelActions << fileViewDock->toggleViewAction();
587  panelActions << legendDock->toggleViewAction();
588  return panelActions;
589 }
590 
591 CurrentLocationWidget *ControlView::currentLocationWidget()
592 {
593  return m_locationWidget;
594 }
595 
596 void ControlView::setWorkOffline( bool offline )
597 {
598  marbleWidget()->model()->setWorkOffline( offline );
599  if ( !offline ) {
600  marbleWidget()->clearVolatileTileCache();
601  }
602 }
603 
604 CloudSyncManager *ControlView::cloudSyncManager()
605 {
606  return m_cloudSyncManager;
607 }
608 
609 QString ControlView::externalMapEditor() const
610 {
611  return m_externalEditor;
612 }
613 
614 void ControlView::addGeoDataFile( QString filename )
615 {
616  QFileInfo const file( filename );
617  if ( file.exists() ) {
618  m_marbleWidget->model()->addGeoDataFile( file.absoluteFilePath() );
619  } else {
620  qWarning() << "File" << filename << "does not exist, cannot open it.";
621  }
622 }
623 
624 void ControlView::showSearch()
625 {
626  if ( !m_searchDock ) {
627  return;
628  }
629 
630  m_searchDock->show();
631  m_searchDock->raise();
632  m_searchDock->widget()->setFocus();
633 }
634 
635 void ControlView::showConflictDialog( MergeItem *item )
636 {
637  Q_ASSERT( m_conflictDialog );
638  m_conflictDialog->setMergeItem( item );
639  m_conflictDialog->open();
640 }
641 
642 }
643 
644 #include "ControlView.moc"
Marble::ControlView::showMapWizard
void showMapWizard()
Marble::MarbleWidget::tileZoomLevel
int tileZoomLevel() const
Definition: MarbleWidget.cpp:372
GeoSceneHead.h
Marble::ControlView::defaultMapThemeId
QString defaultMapThemeId() const
Returns a default map theme: earth/srtm/srtm.dgml if installed, any other theme id if earth/srtm/srtm...
Definition: ControlView.cpp:142
Marble::ControlView::printMapScreenShot
void printMapScreenShot(QPointer< QPrintDialog > dialog)
Definition: ControlView.cpp:164
QPainter
Marble::BookmarkSyncManager::setBookmarkManager
void setBookmarkManager(BookmarkManager *manager)
Definition: BookmarkSyncManager.cpp:254
Marble::ControlView::showUploadDialog
void showUploadDialog()
RoutingModel.h
Marble::MarbleWidget::moveUp
void moveUp(FlyToMode mode=Automatic)
Move up by the moveStep.
Definition: MarbleWidget.cpp:718
Marble::ConflictDialog
Definition: ConflictDialog.h:22
Marble::ControlView::launchExternalMapEditor
void launchExternalMapEditor()
Start the configured external map editor (or update it if it is already running)
Definition: ControlView.cpp:414
Marble::ControlView::mapThemeManager
MapThemeManager * mapThemeManager()
Definition: ControlView.cpp:107
Marble::PrintOptionsWidget::setRouteControlsEnabled
void setRouteControlsEnabled(bool enabled)
Definition: PrintOptionsWidget.cpp:82
MarbleModel.h
This file contains the headers for MarbleModel.
Marble::PrintOptionsWidget::setPrintDrivingInstructions
void setPrintDrivingInstructions(bool print)
Definition: PrintOptionsWidget.cpp:67
Marble::PrintOptionsWidget::printLegend
bool printLegend() const
Definition: PrintOptionsWidget.cpp:42
QWidget
Marble::ControlView::mapThemeDeleted
void mapThemeDeleted()
Marble::MarbleWidget::moveDown
void moveDown(FlyToMode mode=Automatic)
Move down by the moveStep.
Definition: MarbleWidget.cpp:723
Marble::RoutingWidget
A widget consisting of input fields for places / routing destinations, a list view showing routing in...
Definition: RoutingWidget.h:35
Marble::ControlView::printPixmap
void printPixmap(QPrinter *printer, const QPixmap &pixmap)
Definition: ControlView.cpp:225
Marble::ViewportParams::viewLatLonAltBox
const GeoDataLatLonAltBox & viewLatLonAltBox() const
Definition: ViewportParams.cpp:305
ExternalEditorDialog.h
Marble::MapViewWidget
Definition: MapViewWidget.h:32
GeoSceneDocument.h
Marble::RoutingModel::route
const Route & route() const
Definition: RoutingModel.cpp:416
Marble::ControlView::zoomIn
void zoomIn()
Definition: ControlView.cpp:112
Marble::RoutingModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Overload of QAbstractListModel.
Definition: RoutingModel.cpp:158
FileViewWidget.h
Marble::RouteSyncManager::setRoutingManager
void setRoutingManager(RoutingManager *routingManager)
Definition: RouteSyncManager.cpp:84
Marble::ExternalEditorDialog
Definition: ExternalEditorDialog.h:25
Marble::MarbleWidget::moveLeft
void moveLeft(FlyToMode mode=Automatic)
Move left by the moveStep.
Definition: MarbleWidget.cpp:707
Marble::ControlView::cloudSyncManager
CloudSyncManager * cloudSyncManager()
Definition: ControlView.cpp:604
MarbleDebug.h
Marble::GeoDataCoordinates::Degree
Definition: GeoDataCoordinates.h:66
BookmarkManager.h
CurrentLocationWidget.h
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:102
Marble::RoutingManager::routingModel
RoutingModel * routingModel()
Provides access to the routing model which contains a list of routing instructions describing steps t...
Definition: RoutingManager.cpp:260
Marble::RoutingManager::routeRequest
RouteRequest * routeRequest()
Returns the current route request.
Definition: RoutingManager.cpp:270
SearchWidget.h
ViewParams.h
This file contains the headers for ViewParameters.
Marble::LegendWidget
Definition: LegendWidget.h:27
Marble::ControlView::applicationVersion
static QString applicationVersion()
Returns the version of the Marble applications (which differs from the Marble library version)...
Definition: ControlView.cpp:102
Marble::GeoDataLatLonBox::north
qreal north(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the northern boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:93
PrintOptionsWidget.h
Marble::GeoDataLatLonBox::east
qreal east(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the eastern boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:135
Marble::ControlView::moveDown
void moveDown()
Definition: ControlView.cpp:137
Marble::CloudSyncManager::bookmarkSyncManager
BookmarkSyncManager bookmarkSyncManager
Definition: CloudSyncManager.h:37
MarbleMap.h
This file contains the headers for MarbleMap.
Marble::MarbleModel::addGeoDataFile
void addGeoDataFile(const QString &filename)
Handle file loading into the treeModel.
Definition: MarbleModel.cpp:655
RoutingManager.h
Marble::CurrentLocationWidget
Definition: CurrentLocationWidget.h:30
Marble::ControlView::moveLeft
void moveLeft()
Definition: ControlView.cpp:122
Marble::MarbleWidget::centerLongitude
qreal centerLongitude() const
Return the longitude of the center point.
Definition: MarbleWidget.cpp:776
Marble::PrintOptionsWidget::printDrivingInstructions
bool printDrivingInstructions() const
Definition: PrintOptionsWidget.cpp:62
Marble::EARTH_RADIUS
const qreal EARTH_RADIUS
Definition: MarbleGlobal.h:238
Marble::imageSize
const QSize imageSize(28, 28)
Marble::MarbleModel::setWorkOffline
void setWorkOffline(bool workOffline)
Definition: MarbleModel.cpp:689
Marble::MarbleModel::routingManager
RoutingManager * routingManager()
Definition: MarbleModel.cpp:605
Marble::PrintOptionsWidget::printRouteSummary
bool printRouteSummary() const
Definition: PrintOptionsWidget.cpp:52
Marble::ControlView::moveUp
void moveUp()
Definition: ControlView.cpp:132
Marble::ControlView::externalMapEditor
QString externalMapEditor() const
Returns the editor used to launch a map editor application.
Definition: ControlView.cpp:609
Marble::ControlView::paintPrintPreview
void paintPrintPreview(QPrinter *printer)
Definition: ControlView.cpp:258
Marble::ViewportParams::mapCoversViewport
bool mapCoversViewport() const
Definition: ViewportParams.cpp:398
Marble::CloudSyncManager::routeSyncManager
RouteSyncManager routeSyncManager
Definition: CloudSyncManager.h:38
Marble::MarbleWidget::zoomOut
void zoomOut(FlyToMode mode=Automatic)
Zoom out by the amount zoomStep.
Definition: MarbleWidget.cpp:590
Marble::MarbleWidget::model
MarbleModel * model() const
Return the model that this view shows.
Definition: MarbleWidget.cpp:283
LegendWidget.h
Marble::ConflictDialog::setMergeItem
void setMergeItem(MergeItem *item)
Definition: ConflictDialog.cpp:32
Marble::MarbleWidget::setShowBackground
void setShowBackground(bool visible)
Definition: MarbleWidget.cpp:1058
Marble::PrintOptionsWidget::setPrintDrivingInstructionsAdvice
void setPrintDrivingInstructionsAdvice(bool print)
Definition: PrintOptionsWidget.cpp:92
Marble::PrintOptionsWidget::printMap
bool printMap() const
Definition: PrintOptionsWidget.cpp:22
Marble::PrintOptionsWidget::printBackground
bool printBackground() const
Definition: PrintOptionsWidget.cpp:32
Marble::ControlView::mapScreenShot
QPixmap mapScreenShot()
Definition: ControlView.h:72
Marble::PrintOptionsWidget::setBackgroundControlsEnabled
void setBackgroundControlsEnabled(bool enabled)
Definition: PrintOptionsWidget.cpp:72
Marble::PrintOptionsWidget::setLegendControlsEnabled
void setLegendControlsEnabled(bool enabled)
Definition: PrintOptionsWidget.cpp:77
Marble::METER2KM
const qreal METER2KM
Definition: MarbleGlobal.h:205
Marble::GeoDataLineString::at
GeoDataCoordinates & at(int pos)
Returns a reference to the coordinates of a node at a given position. This method detaches the return...
Definition: GeoDataLineString.cpp:139
Marble::MarbleWidget::viewport
ViewportParams * viewport()
Definition: MarbleWidget.cpp:289
Marble::MergeItem
Definition: MergeItem.h:23
ConflictDialog.h
Marble::MarbleWidget::zoomIn
void zoomIn(FlyToMode mode=Automatic)
Zoom in by the amount zoomStep.
Definition: MarbleWidget.cpp:575
Marble::ControlView::moveRight
void moveRight()
Definition: ControlView.cpp:127
Marble::ControlView::marbleWidget
MarbleWidget * marbleWidget() const
Definition: ControlView.h:59
Marble::RouteRequest::name
QString name(int index) const
Definition: RouteRequest.cpp:268
ViewportParams.h
This file contains the headers for ViewportParams.
Marble::MarbleGlobal::SmallScreen
Definition: MarbleGlobal.h:268
Marble::MarbleGlobal::getInstance
static MarbleGlobal * getInstance()
Definition: MarbleGlobal.cpp:37
Marble::FileViewWidget
Definition: FileViewWidget.h:33
Marble::RoutingWidget::setRouteSyncManager
void setRouteSyncManager(RouteSyncManager *manager)
Definition: RoutingWidget.cpp:630
Marble::GeoDataLatLonBox::west
qreal west(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the western boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:156
Marble::ControlView::printPreview
void printPreview()
Definition: ControlView.cpp:244
Marble::ControlView::~ControlView
virtual ~ControlView()
Definition: ControlView.cpp:97
Marble::ConflictDialog::open
void open()
Definition: ConflictDialog.cpp:42
Marble::MapThemeManager
The class that handles map themes that are locally available .
Definition: MapThemeManager.h:48
Marble::MapViewWidget::setMarbleWidget
void setMarbleWidget(MarbleWidget *widget, MapThemeManager *mapThemeManager)
Set a MarbleWidget associated to this widget.
Definition: MapViewWidget.cpp:394
Marble::ControlView::setExternalMapEditor
void setExternalMapEditor(const QString &editor)
Change the editor to launch via.
Definition: ControlView.cpp:496
QMainWindow
RoutingWidget.h
MergeItem.h
Marble::GeoDataLatLonBox::south
qreal south(GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian) const
Get the southern boundary of the bounding box.
Definition: GeoDataLatLonBox.cpp:114
Marble::MarbleModel::bookmarkManager
BookmarkManager * bookmarkManager()
return instance of BookmarkManager
Definition: MarbleModel.cpp:206
Marble::MarbleGlobal::profiles
Profiles profiles() const
Definition: MarbleGlobal.cpp:48
Marble::PrintOptionsWidget
Definition: PrintOptionsWidget.h:23
Marble::MarbleModel::legend
QTextDocument * legend()
Definition: MarbleModel.cpp:645
Marble::ControlView::setWorkOffline
void setWorkOffline(bool workOffline)
Definition: ControlView.cpp:596
MarbleWidget.h
This file contains the headers for MarbleWidget.
RouteRequest.h
Marble::ControlView::addGeoDataFile
void addGeoDataFile(QString filename)
Definition: ControlView.cpp:614
Marble::PrintOptionsWidget::printDrivingInstructionsAdvice
bool printDrivingInstructionsAdvice() const
Definition: PrintOptionsWidget.cpp:87
Marble::RoutingModel::CoordinateRole
Definition: RoutingModel.h:42
ControlView.h
Marble::MarbleWidget::showBackground
bool showBackground() const
Definition: MarbleWidget.cpp:522
Marble::ControlView::zoomOut
void zoomOut()
Definition: ControlView.cpp:117
Marble::Route::path
const GeoDataLineString & path() const
Definition: Route.cpp:66
Marble::MapThemeManager::mapThemeIds
QStringList mapThemeIds() const
Returns a list of all locally available map theme IDs.
Definition: MapThemeManager.cpp:138
Marble::ControlView::ControlView
ControlView(QWidget *=0)
Definition: ControlView.cpp:67
Marble::MarbleWidget::clearVolatileTileCache
void clearVolatileTileCache()
Definition: MarbleWidget.cpp:1087
Marble::ControlView::currentLocationWidget
CurrentLocationWidget * currentLocationWidget()
Definition: ControlView.cpp:591
Marble::SearchWidget::setMarbleWidget
void setMarbleWidget(MarbleWidget *widget)
Definition: SearchWidget.cpp:117
Marble::SearchWidget
Definition: SearchWidget.h:24
MapViewWidget.h
Marble::ControlView::marbleModel
MarbleModel * marbleModel()
Definition: ControlView.h:60
Marble::CloudSyncManager
Definition: CloudSyncManager.h:25
CloudSyncManager.h
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
Marble::GeoDataLatLonAltBox
A class that defines a 3D bounding box for geographic data.
Definition: GeoDataLatLonAltBox.h:49
Marble::CurrentLocationWidget::setMarbleWidget
void setMarbleWidget(MarbleWidget *widget)
Set a MarbleWidget associated to this widget.
Definition: CurrentLocationWidget.cpp:104
BookmarkSyncManager.h
MapThemeManager.h
Marble::BookmarkSyncManager
Definition: BookmarkSyncManager.h:26
Marble::MarbleWidget::moveRight
void moveRight(FlyToMode mode=Automatic)
Move right by the moveStep.
Definition: MarbleWidget.cpp:712
Marble::ControlView::setupDockWidgets
QList< QAction * > setupDockWidgets(QMainWindow *mainWindow)
Definition: ControlView.cpp:501
Marble::LegendWidget::setMarbleModel
void setMarbleModel(MarbleModel *model)
Set a MarbleWidget associated to this widget.
Definition: LegendWidget.cpp:49
Marble::FileViewWidget::setMarbleWidget
void setMarbleWidget(MarbleWidget *widget)
Definition: FileViewWidget.cpp:73
Marble::PrintOptionsWidget::setPrintRouteSummary
void setPrintRouteSummary(bool print)
Definition: PrintOptionsWidget.cpp:57
Marble::MarbleWidget::centerLatitude
qreal centerLatitude() const
Return the latitude of the center point.
Definition: MarbleWidget.cpp:771
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 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