[Marble-commits] KDE/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Sat Sep 11 15:27:24 CEST 2010
SVN commit 1174205 by nienhueser:
Use readSettings/writeSettings method names to be consistent with the rest. Activate route saving/restoring in the Qt and KDE applications on startup and shutdown. The settings are stored in routing/route.kml in the local marble path. Preferences are not stored as that would soon be outdated when the route profiles Niko Sams' is working on are committed.
Add a policy parameter to AlternativeRoutesModel::addRoute() to be able to override lazy appending of alternative routes.
M +7 -0 QtMainWindow.cpp
M +9 -1 lib/routing/AlternativeRoutesModel.cpp
M +10 -1 lib/routing/AlternativeRoutesModel.h
M +4 -3 lib/routing/RoutingManager.cpp
M +2 -2 lib/routing/RoutingManager.h
M +4 -1 lib/routing/RoutingModel.cpp
M +7 -0 marble_part.cpp
M +1 -1 plugins/runner/gosmore/GosmoreRunner.cpp
M +1 -1 plugins/runner/routino/RoutinoRunner.cpp
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.cpp #1174204:1174205
@@ -57,6 +57,7 @@
#include "BookmarkManager.h"
#include "NewFolderInfoDialog.h"
#include "GeoDataPlacemark.h"
+#include "routing/RoutingManager.h"
namespace
{
@@ -892,6 +893,9 @@
// The config dialog has to read settings.
m_configDialog->readSettings();
+
+ // Load previous route settings
+ m_controlView->marbleWidget()->model()->routingManager()->readSettings();
}
void MainWindow::writeSettings()
@@ -950,6 +954,9 @@
// The config dialog has to write settings.
m_configDialog->writeSettings();
+
+ // Store current route settings
+ m_controlView->marbleWidget()->model()->routingManager()->writeSettings();
}
void MainWindow::editSettings()
--- trunk/KDE/kdeedu/marble/src/lib/routing/AlternativeRoutesModel.cpp #1174204:1174205
@@ -327,8 +327,16 @@
d->m_restrainedRoutes.clear();
}
-void AlternativeRoutesModel::addRoute( GeoDataDocument* document )
+void AlternativeRoutesModel::addRoute( GeoDataDocument* document, WritePolicy policy )
{
+ if ( policy == Instant ) {
+ int affected = d->m_routes.size();
+ beginInsertRows( QModelIndex(), affected, affected );
+ d->m_routes.push_back( document );
+ endInsertRows();
+ return;
+ }
+
if ( d->m_routes.isEmpty() && d->m_restrainedRoutes.isEmpty() ) {
// First
int responseTime = d->m_responseTime.elapsed();
--- trunk/KDE/kdeedu/marble/src/lib/routing/AlternativeRoutesModel.h #1174204:1174205
@@ -35,6 +35,11 @@
Q_OBJECT
public:
+ enum WritePolicy {
+ Instant,
+ Lazy
+ };
+
/** Constructor */
explicit AlternativeRoutesModel( MarbleModel* model, QObject *parent = 0 );
@@ -62,8 +67,12 @@
/**
* Old data in the model is discarded, the parsed content of the provided document
* is used as the new model data and a model reset is done
+ * @param document The route to add
+ * @param policy In lazy mode (default), a short amount of time is waited for
+ * other addRoute() calls before adding the route to the model. Otherwise, the
+ * model is changed immediately.
*/
- void addRoute( GeoDataDocument* document );
+ void addRoute( GeoDataDocument* document, WritePolicy policy = Lazy );
void setCurrentRoute( int index );
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingManager.cpp #1174204:1174205
@@ -195,7 +195,7 @@
return d->m_adjustNavigation;
}
-void RoutingManager::saveSettings() const
+void RoutingManager::writeSettings() const
{
GeoWriter writer;
writer.setDocumentType( "http://earth.google.com/kml/2.2" );
@@ -225,7 +225,7 @@
file.close();
}
-void RoutingManager::restoreSettings()
+void RoutingManager::readSettings()
{
QFile file( d->stateFile() );
if ( !file.open( QIODevice::ReadOnly ) ) {
@@ -259,7 +259,8 @@
GeoDataDocument* route = dynamic_cast<GeoDataDocument*>(&container->last());
if ( route ) {
- routingModel()->setCurrentRoute( route );
+ alternativeRoutesModel()->addRoute( route, AlternativeRoutesModel::Instant );
+ alternativeRoutesModel()->setCurrentRoute( 0 );
} else {
mDebug() << "Expected a GeoDataDocument, didn't get one though";
}
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingManager.h #1174204:1174205
@@ -95,12 +95,12 @@
/**
* Saves the current route request and the current route to disk
*/
- void saveSettings() const;
+ void writeSettings() const;
/**
* Restores a previously saved route request and route from disk, if any
*/
- void restoreSettings();
+ void readSettings();
public Q_SLOTS:
/** Update the route */
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingModel.cpp #1174204:1174205
@@ -120,7 +120,10 @@
}
if ( placemark->extendedData().contains( "turnType" ) ) {
QVariant turnType = placemark->extendedData().value( "turnType" ).value();
- element.turnType = qVariantValue<RoutingInstruction::TurnType>( turnType );
+ // The enum value is converted to/from an int in the QVariant
+ // because only a limited set of data types can be serialized with QVariant's
+ // toString() method (which is used to serialize <ExtendedData>/<Data> values)
+ element.turnType = RoutingInstruction::TurnType( qVariantValue<int>( turnType ) );
}
element.instructionDistance = element.instructionPointSet.length( EARTH_RADIUS );
m_route.push_back( element );
--- trunk/KDE/kdeedu/marble/src/marble_part.cpp #1174204:1174205
@@ -75,6 +75,7 @@
#include "TileCoordsPyramid.h"
#include "ViewportParams.h"
#include "MarbleClock.h"
+#include "routing/RoutingManager.h"
// Marble non-library classes
#include "ControlView.h"
@@ -476,6 +477,9 @@
}
readPluginSettings();
+ // Load previous route settings
+ m_controlView->marbleWidget()->model()->routingManager()->readSettings();
+
disconnect( m_controlView->marbleWidget(), SIGNAL( pluginSettingsChanged() ),
this, SLOT( writePluginSettings() ) );
connect( m_controlView->marbleWidget(), SIGNAL( pluginSettingsChanged() ),
@@ -594,6 +598,9 @@
writeStatusBarSettings();
MarbleSettings::self()->writeConfig();
+
+ // Store current route settings
+ m_controlView->marbleWidget()->model()->routingManager()->writeSettings();
}
void MarblePart::writeStatusBarSettings()
--- trunk/KDE/kdeedu/marble/src/plugins/runner/gosmore/GosmoreRunner.cpp #1174204:1174205
@@ -135,7 +135,7 @@
GeoDataExtendedData extendedData;
GeoDataData turnType;
turnType.setName( "turnType" );
- turnType.setValue( qVariantFromValue<RoutingInstruction::TurnType>( directions[i].turnType() ) );
+ turnType.setValue( qVariantFromValue<int>( int( directions[i].turnType() ) ) );
extendedData.addValue( turnType );
placemark->setExtendedData( extendedData );
Q_ASSERT( !directions[i].points().isEmpty() );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/routino/RoutinoRunner.cpp #1174204:1174205
@@ -154,7 +154,7 @@
GeoDataExtendedData extendedData;
GeoDataData turnType;
turnType.setName( "turnType" );
- turnType.setValue( qVariantFromValue<RoutingInstruction::TurnType>( directions[i].turnType() ) );
+ turnType.setValue( qVariantFromValue<int>( int( directions[i].turnType() ) ) );
extendedData.addValue( turnType );
placemark->setExtendedData( extendedData );
Q_ASSERT( !directions[i].points().isEmpty() );
More information about the Marble-commits
mailing list