Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move SpatiaLite source select dialog to provider.
  • Loading branch information
wonder-sk committed Oct 31, 2011
1 parent 4ecaa12 commit dd03451
Show file tree
Hide file tree
Showing 12 changed files with 568 additions and 1,056 deletions.
4 changes: 0 additions & 4 deletions src/app/CMakeLists.txt
Expand Up @@ -321,16 +321,12 @@ ENDIF (POSTGRES_FOUND)

IF (HAVE_SPATIALITE)
SET (QGIS_APP_SRCS ${QGIS_APP_SRCS}
spatialite/qgsspatialitesourceselect.cpp
spatialite/qgsnewspatialitelayerdialog.cpp
spatialite/qgsspatialitesridsdialog.cpp
spatialite/qgsspatialitetablemodel.cpp
)
SET (QGIS_APP_MOC_HDRS ${QGIS_APP_MOC_HDRS}
spatialite/qgsspatialitesourceselect.h
spatialite/qgsnewspatialitelayerdialog.h
spatialite/qgsspatialitesridsdialog.h
spatialite/qgsspatialitetablemodel.h
)
ENDIF (HAVE_SPATIALITE)

Expand Down
60 changes: 7 additions & 53 deletions src/app/qgisapp.cpp
Expand Up @@ -241,7 +241,6 @@ extern "C"
{
#include <spatialite.h>
}
#include "spatialite/qgsspatialitesourceselect.h"
#include "spatialite/qgsnewspatialitelayerdialog.h"
#endif

Expand Down Expand Up @@ -2346,62 +2345,17 @@ void QgisApp::addSpatiaLiteLayer()
}

// show the SpatiaLite dialog

QgsSpatiaLiteSourceSelect *dbs = new QgsSpatiaLiteSourceSelect( this );

mMapCanvas->freeze();

if ( dbs->exec() )
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "spatialite" ), this ) );
if ( !dbs )
{
// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);


// repaint the canvas if it was covered by the dialog

// add files to the map canvas
QStringList tables = dbs->selectedTables();

QApplication::setOverrideCursor( Qt::WaitCursor );

// for each selected table, connect to the database and build a canvasitem for it
QStringList::Iterator it = tables.begin();
while ( it != tables.end() )
{
// create the layer
QgsDataSourceURI uri( *it );
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri(), uri.table(), "spatialite" );
if ( layer->isValid() )
{
// register this layer with the central layers registry
QgsMapLayerRegistry::instance()->addMapLayer( layer );
}
else
{
QgsDebugMsg(( *it ) + " is an invalid layer - not loaded" );
QMessageBox::critical( this, tr( "Invalid Layer" ), tr( "%1 is an invalid layer and cannot be loaded." ).arg( *it ) );
delete layer;
}
//qWarning("incrementing iterator");
++it;
}

QApplication::restoreOverrideCursor();

statusBar()->showMessage( mMapCanvas->extent().toString( 2 ) );
QMessageBox::warning( this, tr( "SpatiaLite" ), tr( "Cannot get SpatiaLite select dialog from provider." ) );
return;
}
connect( dbs , SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this , SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
dbs->exec();
delete dbs;

// update UI
qApp->processEvents();

// draw the map
mMapCanvas->freeze( false );
mMapCanvas->refresh();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

} // QgisApp::addSpatiaLiteLayer()
#endif

Expand Down

0 comments on commit dd03451

Please sign in to comment.