@@ -241,7 +241,6 @@ extern "C"
241
241
{
242
242
#include < spatialite.h>
243
243
}
244
- #include " spatialite/qgsspatialitesourceselect.h"
245
244
#include " spatialite/qgsnewspatialitelayerdialog.h"
246
245
#endif
247
246
@@ -2346,62 +2345,17 @@ void QgisApp::addSpatiaLiteLayer()
2346
2345
}
2347
2346
2348
2347
// 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 )
2355
2350
{
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 ;
2392
2353
}
2354
+ connect ( dbs , SIGNAL ( addDatabaseLayers ( QStringList const &, QString const & ) ),
2355
+ this , SLOT ( addDatabaseLayers ( QStringList const &, QString const & ) ) );
2356
+ dbs->exec ();
2393
2357
delete dbs;
2394
2358
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
-
2405
2359
} // QgisApp::addSpatiaLiteLayer()
2406
2360
#endif
2407
2361
0 commit comments