[Marble-commits] KDE/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Tue Nov 9 21:04:16 CET 2010
SVN commit 1194761 by nienhueser:
Do not query runners (i.e. avoid starting threads) which cannot delivers results since their installation is incomplete. When no reverse geocoding plugin can be started, display the coordinate string as a fallback in the routing widget.
M +12 -1 lib/MarbleRunnerManager.cpp
M +5 -0 lib/RunnerPlugin.cpp
M +7 -0 lib/RunnerPlugin.h
M +4 -3 lib/routing/RoutingInputWidget.cpp
M +15 -0 plugins/runner/gosmore/GosmorePlugin.cpp
M +2 -0 plugins/runner/gosmore/GosmorePlugin.h
M +10 -0 plugins/runner/monav/MonavPlugin.cpp
M +2 -0 plugins/runner/monav/MonavPlugin.h
M +11 -0 plugins/runner/routino/RoutinoPlugin.cpp
M +1 -0 plugins/runner/routino/RoutinoPlugin.h
--- trunk/KDE/kdeedu/marble/src/lib/MarbleRunnerManager.cpp #1194760:1194761
@@ -85,6 +85,10 @@
continue;
}
+ if ( !plugin->canWork( capability ) ) {
+ continue;
+ }
+
if ( m_marbleModel && !plugin->supportsCelestialBody( m_marbleModel->planet()->id() ) )
{
continue;
@@ -118,7 +122,11 @@
runner->setModel( d->m_marbleModel );
QThreadPool::globalInstance()->start( new ReverseGeocodingTask( runner, coordinates ) );
}
+
+ if ( plugins.isEmpty() ) {
+ emit reverseGeocodingFinished( coordinates, GeoDataPlacemark() );
}
+}
void MarbleRunnerManager::findPlacemarks( const QString &searchTerm )
{
@@ -194,7 +202,10 @@
d->m_routeRequest = request;
QList<RunnerPlugin*> plugins = d->plugins( RunnerPlugin::Routing );
foreach( RunnerPlugin* plugin, plugins ) {
- if ( !profile.pluginSettings().contains( plugin->nameId() ) ) continue;
+ if ( !profile.pluginSettings().contains( plugin->nameId() ) ) {
+ continue;
+ }
+
MarbleAbstractRunner* runner = plugin->newRunner();
connect( runner, SIGNAL( routeCalculated( GeoDataDocument* ) ),
this, SLOT( addRoutingResult( GeoDataDocument* ) ) );
--- trunk/KDE/kdeedu/marble/src/lib/RunnerPlugin.cpp #1194760:1194761
@@ -159,6 +159,11 @@
return QHash< QString, QVariant >();
}
+bool RunnerPlugin::canWork( Capability capability ) const
+{
+ return supports( capability );
}
+}
+
#include "RunnerPlugin.moc"
--- trunk/KDE/kdeedu/marble/src/lib/RunnerPlugin.h #1194760:1194761
@@ -65,6 +65,13 @@
/** True if the plugin can execute its tasks without network access */
bool canWorkOffline() const;
+ /** Returns true if the plugin can execute a task for the given capability
+ * The default implementation returns true iff the plugin supports
+ * the given capability. This method can be overriden for example to
+ * indicate an incomplete installation.
+ */
+ virtual bool canWork( Capability capability ) const;
+
// Overridden methods with default implementations
virtual QString name() const;
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingInputWidget.cpp #1194760:1194761
@@ -398,10 +398,11 @@
emit targetValidityChanged( false );
}
-void RoutingInputWidget::retrieveReverseGeocodingResult( const GeoDataCoordinates &, const GeoDataPlacemark &placemark )
+void RoutingInputWidget::retrieveReverseGeocodingResult( const GeoDataCoordinates &coordinates, const GeoDataPlacemark &placemark )
{
- d->m_route->setName( d->m_index, placemark.address() );
- d->m_lineEdit->setText( placemark.address() );
+ QString description = placemark.address().isEmpty() ? coordinates.toString() : placemark.address();
+ d->m_route->setName( d->m_index, description );
+ d->m_lineEdit->setText( description );
d->m_lineEdit->setCursorPosition( 0 );
}
--- trunk/KDE/kdeedu/marble/src/plugins/runner/gosmore/GosmorePlugin.cpp #1194760:1194761
@@ -10,7 +10,11 @@
#include "GosmorePlugin.h"
#include "GosmoreRunner.h"
+#include "MarbleDirs.h"
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+
namespace Marble
{
@@ -30,8 +34,19 @@
return new GosmoreRunner;
}
+bool GosmorePlugin::canWork( Capability capability ) const
+{
+ if ( supports( capability ) ) {
+ QDir mapDir( MarbleDirs::localPath() + "/maps/earth/gosmore/" );
+ QFileInfo mapFile = QFileInfo ( mapDir, "gosmore.pak" );
+ return mapFile.exists();
+ } else {
+ return false;
}
+}
+}
+
Q_EXPORT_PLUGIN2( GosmorePlugin, Marble::GosmorePlugin )
#include "GosmorePlugin.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/runner/gosmore/GosmorePlugin.h #1194760:1194761
@@ -26,6 +26,8 @@
explicit GosmorePlugin( QObject *parent = 0 );
virtual MarbleAbstractRunner* newRunner() const;
+
+ virtual bool canWork( Capability capability ) const;
};
}
--- trunk/KDE/kdeedu/marble/src/plugins/runner/monav/MonavPlugin.cpp #1194760:1194761
@@ -240,8 +240,18 @@
d->loadMaps();
}
+bool MonavPlugin::canWork( Capability capability ) const
+{
+ if ( supports( capability ) ) {
+ d->initialize();
+ return !d->m_maps.isEmpty();
+ } else {
+ return false;
}
+}
+}
+
Q_EXPORT_PLUGIN2( MonavPlugin, Marble::MonavPlugin )
#include "MonavPlugin.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/runner/monav/MonavPlugin.h #1194760:1194761
@@ -33,6 +33,8 @@
virtual ConfigWidget *configWidget();
+ virtual bool canWork( Capability capability ) const;
+
QString mapDirectoryForRequest( RouteRequest* request ) const;
MonavMapsModel* installedMapsModel();
--- trunk/KDE/kdeedu/marble/src/plugins/runner/routino/RoutinoPlugin.cpp #1194760:1194761
@@ -10,6 +10,7 @@
#include "RoutinoPlugin.h"
#include "RoutinoRunner.h"
+#include "MarbleDirs.h"
#include "ui_RoutinoConfigWidget.h"
@@ -130,8 +131,18 @@
return result;
}
+bool RoutinoPlugin::canWork( Capability capability ) const
+{
+ if ( supports( capability ) ) {
+ QDir mapDir = QDir( MarbleDirs::localPath() + "/maps/earth/routino/" );
+ return mapDir.exists();
+ } else {
+ return false;
}
+}
+}
+
Q_EXPORT_PLUGIN2( RoutinoPlugin, Marble::RoutinoPlugin )
#include "RoutinoPlugin.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/runner/routino/RoutinoPlugin.h #1194760:1194761
@@ -36,6 +36,7 @@
QHash< QString, QVariant > templateSettings(RoutingProfilesModel::ProfileTemplate profileTemplate) const;
+ virtual bool canWork( Capability capability ) const;
};
}
More information about the Marble-commits
mailing list