Skip to content

Commit dd03451

Browse files
committed
Move SpatiaLite source select dialog to provider.
1 parent 4ecaa12 commit dd03451

12 files changed

+568
-1056
lines changed

src/app/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,16 +321,12 @@ ENDIF (POSTGRES_FOUND)
321321

322322
IF (HAVE_SPATIALITE)
323323
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS}
324-
spatialite/qgsspatialitesourceselect.cpp
325324
spatialite/qgsnewspatialitelayerdialog.cpp
326325
spatialite/qgsspatialitesridsdialog.cpp
327-
spatialite/qgsspatialitetablemodel.cpp
328326
)
329327
SET (QGIS_APP_MOC_HDRS ${QGIS_APP_MOC_HDRS}
330-
spatialite/qgsspatialitesourceselect.h
331328
spatialite/qgsnewspatialitelayerdialog.h
332329
spatialite/qgsspatialitesridsdialog.h
333-
spatialite/qgsspatialitetablemodel.h
334330
)
335331
ENDIF (HAVE_SPATIALITE)
336332

src/app/qgisapp.cpp

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -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

Comments
 (0)