1 Index: marble-0.95+svn1213143/src/lib/CurrentLocationWidget.cpp
2 ===================================================================
3 --- marble-0.95+svn1213143.orig/src/lib/CurrentLocationWidget.cpp 2011-01-09 12:13:21.000000000 +0100
4 +++ marble-0.95+svn1213143/src/lib/CurrentLocationWidget.cpp 2011-01-09 12:15:22.000000000 +0100
7 #include "ui_CurrentLocationWidget.h"
9 +#include <QtCore/QDateTime>
10 +#include <QtGui/QFileDialog>
16 void updateRecenterComboBox( int centerMode );
17 void updateAutoZoomCheckBox( bool autoZoom );
18 void updateActivePositionProvider( PositionProviderPlugin* );
23 CurrentLocationWidget::CurrentLocationWidget( QWidget *parent, Qt::WindowFlags f )
26 d->m_locale = MarbleGlobal::getInstance()->locale();
28 - connect( d->m_currentLocationUi.recenterComboBox, SIGNAL ( highlighted( int ) ),
29 + connect( d->m_currentLocationUi.recenterComboBox, SIGNAL ( currentIndexChanged( int ) ),
30 this, SLOT( setRecenterMode( int ) ) );
32 connect( d->m_currentLocationUi.autoZoomCheckBox, SIGNAL( clicked( bool ) ),
33 this, SLOT( setAutoZoom( bool ) ) );
35 + bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
36 + d->m_currentLocationUi.positionTrackingComboBox->setVisible( !smallScreen );
37 + d->m_currentLocationUi.locationLabel->setVisible( !smallScreen );
40 CurrentLocationWidget::~CurrentLocationWidget()
42 QString html = "<p>No Position Tracking Plugin installed.</p>";
43 d->m_currentLocationUi.locationLabel->setText( html );
44 d->m_currentLocationUi.locationLabel->setEnabled ( true );
45 + d->m_currentLocationUi.showTrackCheckBox->setEnabled( false );
46 + d->m_currentLocationUi.saveTrackPushButton->setEnabled( false );
47 + d->m_currentLocationUi.clearTrackPushButton->setEnabled( false );
50 //disconnect CurrentLocation Signals
52 connect( d->m_widget->model()->positionTracking(),
53 SIGNAL( positionProviderPluginChanged( PositionProviderPlugin* ) ),
54 this, SLOT( updateActivePositionProvider( PositionProviderPlugin* ) ) );
55 + d->updateActivePositionProvider( d->m_widget->model()->positionTracking()->positionProviderPlugin() );
56 connect( d->m_currentLocationUi.positionTrackingComboBox, SIGNAL( currentIndexChanged( QString ) ),
57 this, SLOT( changePositionProvider( QString ) ) );
58 connect( d->m_currentLocationUi.locationLabel, SIGNAL( linkActivated( QString ) ),
60 this, SLOT( updateRecenterComboBox( int ) ) );
61 connect( d->m_adjustNavigation, SIGNAL( autoZoomToggled( bool ) ),
62 this, SLOT( updateAutoZoomCheckBox( bool ) ) );
63 + connect (d->m_currentLocationUi.showTrackCheckBox, SIGNAL( clicked(bool) ),
64 + d->m_widget->model()->positionTracking(), SLOT( setTrackVisible(bool) ));
65 + connect (d->m_currentLocationUi.showTrackCheckBox, SIGNAL( clicked(bool) ),
66 + d->m_widget, SLOT(repaint()));
67 + if ( d->m_widget->model()->positionTracking()->trackVisible() ) {
68 + d->m_currentLocationUi.showTrackCheckBox->setCheckState(Qt::Checked);
70 + connect ( d->m_currentLocationUi.saveTrackPushButton, SIGNAL( clicked(bool)),
71 + this, SLOT(saveTrack()));
72 + connect (d->m_currentLocationUi.clearTrackPushButton, SIGNAL( clicked(bool)),
73 + this, SLOT(clearTrack()));
76 void CurrentLocationWidgetPrivate::adjustPositionTrackingStatus( PositionProviderStatus status )
80 m_currentLocationUi.positionTrackingComboBox->blockSignals( false );
81 + m_currentLocationUi.recenterLabel->setEnabled( plugin );
82 + m_currentLocationUi.recenterComboBox->setEnabled( plugin );
83 + m_currentLocationUi.autoZoomCheckBox->setEnabled( plugin );
87 void CurrentLocationWidget::receiveGpsCoordinates( const GeoDataCoordinates &position, qreal speed )
89 html = html.arg( position.lonToString() ).arg( position.latToString() );
90 html = html.arg( distanceString ).arg( speedString + ' ' + unitString );
91 d->m_currentLocationUi.locationLabel->setText( html );
92 + d->m_currentLocationUi.showTrackCheckBox->setEnabled( true );
93 + d->m_currentLocationUi.saveTrackPushButton->setEnabled( true );
94 + d->m_currentLocationUi.clearTrackPushButton->setEnabled( true );
97 void CurrentLocationWidgetPrivate::changePositionProvider( const QString &provider )
99 bool hasProvider = ( provider != QObject::tr("Disabled") );
100 - m_currentLocationUi.recenterLabel->setEnabled( hasProvider );
101 - m_currentLocationUi.recenterComboBox->setEnabled( hasProvider );
102 - m_currentLocationUi.autoZoomCheckBox->setEnabled( hasProvider );
105 foreach( PositionProviderPlugin* plugin, m_positionProviderPlugins ) {
107 m_widget->centerOn(m_currentPosition, true);
110 +void CurrentLocationWidgetPrivate::saveTrack()
112 + static QString s_dirName = QDir::homePath();
113 + QString fileName = QFileDialog::getSaveFileName(m_widget, QObject::tr("Save Track"), // krazy:exclude=qclasses
114 + s_dirName.append('/' + QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss") + ".kml"),
115 + QObject::tr("KML File (*.kml)"));
117 + QFileInfo file( fileName );
118 + s_dirName = file.absolutePath();
119 + m_widget->model()->positionTracking()->saveTrack( fileName );
123 +void CurrentLocationWidgetPrivate::clearTrack()
125 + m_widget->model()->positionTracking()->clearTrack();
126 + m_widget->repaint();
127 + m_currentLocationUi.saveTrackPushButton->setEnabled( false );
128 + m_currentLocationUi.clearTrackPushButton->setEnabled( false );
133 #include "CurrentLocationWidget.moc"
134 Index: marble-0.95+svn1213143/src/lib/PositionTracking.cpp
135 ===================================================================
136 --- marble-0.95+svn1213143.orig/src/lib/PositionTracking.cpp 2011-01-09 12:13:21.000000000 +0100
137 +++ marble-0.95+svn1213143/src/lib/PositionTracking.cpp 2011-01-09 18:06:10.000000000 +0100
139 #include "GeoDataPlacemark.h"
140 #include "GeoDataStyle.h"
141 #include "GeoDataStyleMap.h"
142 +#include "GeoWriter.h"
143 +#include "KmlElementDictionary.h"
144 #include "AbstractProjection.h"
145 #include "FileManager.h"
146 #include "MarbleMath.h"
147 #include "MarbleDebug.h"
148 +#include "MarbleDirs.h"
149 #include "PositionProviderPlugin.h"
151 #include "PositionTracking_p.h"
153 +#include <QtCore/QFile>
155 using namespace Marble;
157 void PositionTrackingPrivate::setPosition( GeoDataCoordinates position,
159 d->m_document->setVisible( visible );
162 +bool PositionTracking::saveTrack(QString& fileName)
165 + if ( !fileName.isEmpty() )
167 + if ( !fileName.endsWith(".kml", Qt::CaseInsensitive) )
169 + fileName.append( ".kml" );
173 + //FIXME: a better way to do this?
174 + writer.setDocumentType( kml::kmlTag_nameSpace22 );
176 + QFileInfo fileInfo( fileName );
177 + QString name = fileInfo.baseName();
178 + GeoDataDocument document;
179 + document.setName( name );
180 + foreach( GeoDataStyle style, d->m_document->styles() ) {
181 + document.addStyle( style );
183 + foreach( GeoDataStyleMap map, d->m_document->styleMaps() ) {
184 + document.addStyleMap( map );
186 + GeoDataFeature *track = new GeoDataFeature( d->m_document->last() );
187 + track->setName( "Track " + name );
188 + document.append( track );
190 + QFile file( fileName );
191 + file.open( QIODevice::ReadWrite );
192 + return writer.write( &file, document );
197 void PositionTracking::clearTrack()
199 GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>(d->m_document->child(d->m_document->size()-1));
200 Index: marble-0.95+svn1213143/src/lib/PositionTracking.h
201 ===================================================================
202 --- marble-0.95+svn1213143.orig/src/lib/PositionTracking.h 2011-01-09 12:13:21.000000000 +0100
203 +++ marble-0.95+svn1213143/src/lib/PositionTracking.h 2011-01-09 12:13:35.000000000 +0100
205 void setTrackVisible ( bool visible );
208 + * Saves the track document to file
210 + bool saveTrack( QString& fileName );
213 * Removes all track segments which were recorded
216 Index: marble-0.95+svn1213143/src/lib/CurrentLocationWidget.h
217 ===================================================================
218 --- marble-0.95+svn1213143.orig/src/lib/CurrentLocationWidget.h 2011-01-09 12:13:21.000000000 +0100
219 +++ marble-0.95+svn1213143/src/lib/CurrentLocationWidget.h 2011-01-09 12:13:35.000000000 +0100
221 Q_PRIVATE_SLOT( d, void updateAutoZoomCheckBox( bool autoZoom ) )
223 Q_PRIVATE_SLOT( d, void updateActivePositionProvider( PositionProviderPlugin* ) )
225 + Q_PRIVATE_SLOT( d, void saveTrack() )
226 + Q_PRIVATE_SLOT( d, void clearTrack() )
230 Index: marble-0.95+svn1213143/src/lib/CurrentLocationWidget.ui
231 ===================================================================
232 --- marble-0.95+svn1213143.orig/src/lib/CurrentLocationWidget.ui 2011-01-09 12:13:21.000000000 +0100
233 +++ marble-0.95+svn1213143/src/lib/CurrentLocationWidget.ui 2011-01-09 12:13:42.000000000 +0100
238 - <height>190</height>
239 + <height>237</height>
242 <property name="windowTitle">
247 + <widget class="QCheckBox" name="showTrackCheckBox">
248 + <property name="enabled">
251 + <property name="text">
252 + <string>Show Track</string>
257 + <widget class="QPushButton" name="saveTrackPushButton">
258 + <property name="enabled">
261 + <property name="text">
262 + <string>Save Track</string>
267 + <widget class="QPushButton" name="clearTrackPushButton">
268 + <property name="enabled">
271 + <property name="text">
272 + <string>Clear Track</string>
277 <widget class="QLabel" name="locationLabel">
278 <property name="enabled">
284 + <spacer name="trackRecenterVerticalSpacer">
285 + <property name="orientation">
286 + <enum>Qt::Vertical</enum>
288 + <property name="sizeHint" stdset="0">
291 + <height>20</height>
297 <widget class="QLabel" name="recenterLabel">
298 <property name="enabled">
300 Index: marble-0.95+svn1213143/src/QtMainWindow.cpp
301 ===================================================================
302 --- marble-0.95+svn1213143.orig/src/QtMainWindow.cpp 2011-01-09 12:13:21.000000000 +0100
303 +++ marble-0.95+svn1213143/src/QtMainWindow.cpp 2011-01-09 12:13:42.000000000 +0100
305 #include <QtNetwork/QNetworkProxy>
307 #include "BookmarkInfoDialog.h"
308 +#include "CurrentLocationWidget.h"
309 //#include "EditBookmarkDialog.h"
310 #include "MapViewWidget.h"
311 #include "MarbleDirs.h"
313 m_osmEditAction( 0 ),
314 m_mapViewDialog( 0 ),
315 m_routingDialog( 0 ),
316 + m_trackingDialog( 0 ),
319 setUpdatesEnabled( false );
321 m_toggleRoutingTabAction = menuBar()->addAction( tr( "Routing" ) );
322 connect( m_toggleRoutingTabAction, SIGNAL( triggered( bool ) ),
323 this, SLOT( showRoutingDialog() ) );
324 + m_showTrackingDialogAction = menuBar()->addAction( tr( "Tracking" ) );
325 + connect( m_showTrackingDialogAction, SIGNAL( triggered()),
326 + this, SLOT( showTrackingDialog()) );
328 m_controlView->marbleControl()->setNavigationTabShown( false );
329 m_controlView->marbleControl()->setLegendTabShown( false );
330 @@ -1268,6 +1273,28 @@
331 m_routingDialog->activateWindow();
334 +void MainWindow::showTrackingDialog()
336 + if( !m_trackingDialog ) {
337 + m_trackingDialog = new QDialog( this );
338 + m_trackingDialog->setWindowTitle( tr( "Tracking - Marble" ) );
339 + CurrentLocationWidget *trackingWidget = new CurrentLocationWidget( m_trackingDialog );
340 + trackingWidget->setMarbleWidget( m_controlView->marbleWidget() );
342 + QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok, Qt::Vertical, m_trackingDialog );
343 + connect(buttonBox, SIGNAL( accepted() ), m_trackingDialog, SLOT( accept() ) );
345 + QHBoxLayout* layout = new QHBoxLayout;
346 + layout->addWidget( trackingWidget );
347 + layout->addWidget( buttonBox );
348 + m_trackingDialog->setLayout( layout );
349 + m_trackingDialog->resize( 640, 420 );
352 + m_trackingDialog->show();
353 + m_trackingDialog->raise();
354 + m_trackingDialog->activateWindow();
357 void MainWindow::updateMapEditButtonVisibility( const QString &mapTheme )
359 Index: marble-0.95+svn1213143/src/QtMainWindow.h
360 ===================================================================
361 --- marble-0.95+svn1213143.orig/src/QtMainWindow.h 2011-01-09 12:13:21.000000000 +0100
362 +++ marble-0.95+svn1213143/src/QtMainWindow.h 2011-01-09 12:13:42.000000000 +0100
364 void showMapViewDialog();
365 void showLegendTab( bool enabled );
366 void showRoutingDialog();
367 + void showTrackingDialog();
370 void setupZoomButtons();
372 QAction *m_showMapViewDialogAction;
373 QAction *m_toggleLegendTabAction;
374 QAction *m_toggleRoutingTabAction;
375 + QAction *m_showTrackingDialogAction;
377 QDialog *m_mapViewDialog;
378 QDialog *m_routingDialog;
379 + QDialog *m_trackingDialog;
381 RoutingWidget *m_routingWidget;