@@ -241,7 +241,6 @@ extern "C"
241241{
242242#include < spatialite.h>
243243}
244- #include " spatialite/qgsspatialitesourceselect.h"
245244#include " spatialite/qgsnewspatialitelayerdialog.h"
246245#endif
247246
@@ -327,7 +326,7 @@ static void customSrsValidation_( QgsCoordinateReferenceSystem* srs )
327326{
328327 static QString authid = QString::null;
329328 QSettings mySettings;
330- QString myDefaultProjectionOption = mySettings.value ( " /Projections/defaultBehaviour" ).toString ();
329+ QString myDefaultProjectionOption = mySettings.value ( " /Projections/defaultBehaviour" , " prompt " ).toString ();
331330 if ( myDefaultProjectionOption == " prompt" )
332331 {
333332 // @note this class is not a descendent of QWidget so we cant pass
@@ -2346,62 +2345,17 @@ void QgisApp::addSpatiaLiteLayer()
23462345 }
23472346
23482347 // show the SpatiaLite dialog
2349-
2350- QgsSpatiaLiteSourceSelect *dbs = new QgsSpatiaLiteSourceSelect ( this );
2351-
2352- mMapCanvas ->freeze ();
2353-
2354- if ( dbs->exec () )
2348+ QDialog *dbs = dynamic_cast <QDialog*>( QgsProviderRegistry::instance ()->selectWidget ( QString ( " spatialite" ), this ) );
2349+ if ( !dbs )
23552350 {
2356- // Let render() do its own cursor management
2357- // QApplication::setOverrideCursor(Qt::WaitCursor);
2358-
2359-
2360- // repaint the canvas if it was covered by the dialog
2361-
2362- // add files to the map canvas
2363- QStringList tables = dbs->selectedTables ();
2364-
2365- QApplication::setOverrideCursor ( Qt::WaitCursor );
2366-
2367- // for each selected table, connect to the database and build a canvasitem for it
2368- QStringList::Iterator it = tables.begin ();
2369- while ( it != tables.end () )
2370- {
2371- // create the layer
2372- QgsDataSourceURI uri ( *it );
2373- QgsVectorLayer *layer = new QgsVectorLayer ( uri.uri (), uri.table (), " spatialite" );
2374- if ( layer->isValid () )
2375- {
2376- // register this layer with the central layers registry
2377- QgsMapLayerRegistry::instance ()->addMapLayer ( layer );
2378- }
2379- else
2380- {
2381- QgsDebugMsg (( *it ) + " is an invalid layer - not loaded" );
2382- QMessageBox::critical ( this , tr ( " Invalid Layer" ), tr ( " %1 is an invalid layer and cannot be loaded." ).arg ( *it ) );
2383- delete layer;
2384- }
2385- // qWarning("incrementing iterator");
2386- ++it;
2387- }
2388-
2389- QApplication::restoreOverrideCursor ();
2390-
2391- statusBar ()->showMessage ( mMapCanvas ->extent ().toString ( 2 ) );
2351+ QMessageBox::warning ( this , tr ( " SpatiaLite" ), tr ( " Cannot get SpatiaLite select dialog from provider." ) );
2352+ return ;
23922353 }
2354+ connect ( dbs , SIGNAL ( addDatabaseLayers ( QStringList const &, QString const & ) ),
2355+ this , SLOT ( addDatabaseLayers ( QStringList const &, QString const & ) ) );
2356+ dbs->exec ();
23932357 delete dbs;
23942358
2395- // update UI
2396- qApp->processEvents ();
2397-
2398- // draw the map
2399- mMapCanvas ->freeze ( false );
2400- mMapCanvas ->refresh ();
2401-
2402- // Let render() do its own cursor management
2403- // QApplication::restoreOverrideCursor();
2404-
24052359} // QgisApp::addSpatiaLiteLayer()
24062360#endif
24072361
0 commit comments