Skip to content
Permalink
Browse files

oracle & postgres provider: show progress messages when scanning for …

…available geometry columns

postgres provider: stop using pg column sizes (fixes #7799)
oracle provider: skip dropped tables (fixes #7795)
  • Loading branch information
jef-n committed May 10, 2013
1 parent 4292976 commit 785114a52e667355990444f40518262ddae37ca5
@@ -2863,16 +2863,20 @@ void QgisApp::addDatabaseLayer()
QgsDebugMsg( "about to addRasterLayer" );

// TODO: QDialog for now, switch to QWidget in future
QDialog *pgs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "postgres" ), this ) );
if ( !pgs )
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "postgres", this ) );
if ( !dbs )
{
QMessageBox::warning( this, tr( "PostgreSQL" ), tr( "Cannot get PostgreSQL select dialog from provider." ) );
return;
}
connect( pgs , SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this , SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
pgs->exec();
delete pgs;
connect( dbs, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this, SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
connect( dbs, SIGNAL( progress( int, int ) ),
this, SLOT( showProgress( int, int ) ) );
connect( dbs, SIGNAL( progressMessage( QString ) ),
this, SLOT( showStatusMessage( QString ) ) );
dbs->exec();
delete dbs;
#endif
} // QgisApp::addDatabaseLayer()

@@ -2951,14 +2955,14 @@ void QgisApp::addSpatiaLiteLayer()
}

// show the SpatiaLite dialog
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "spatialite" ), this ) );
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "spatialite", this ) );
if ( !dbs )
{
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 & ) ) );
connect( dbs, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this, SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
dbs->exec();
delete dbs;
} // QgisApp::addSpatiaLiteLayer()
@@ -2972,14 +2976,14 @@ void QgisApp::addMssqlLayer()
}

// show the MSSQL dialog
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "mssql" ), this ) );
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "mssql", this ) );
if ( !dbs )
{
QMessageBox::warning( this, tr( "MSSQL" ), tr( "Cannot get MSSQL select dialog from provider." ) );
return;
}
connect( dbs , SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this , SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
connect( dbs, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this, SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
dbs->exec();
delete dbs;
#endif
@@ -2994,14 +2998,18 @@ void QgisApp::addOracleLayer()
}

// show the Oracle dialog
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "oracle" ), this ) );
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "oracle", this ) );
if ( !dbs )
{
QMessageBox::warning( this, tr( "Oracle" ), tr( "Cannot get Oracle select dialog from provider." ) );
return;
}
connect( dbs , SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this , SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
connect( dbs, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this, SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
connect( dbs, SIGNAL( progress( int, int ) ),
this, SLOT( showProgress( int, int ) ) );
connect( dbs, SIGNAL( progressMessage( QString ) ),
this, SLOT( showStatusMessage( QString ) ) );
dbs->exec();
delete dbs;
#endif
@@ -3023,8 +3031,8 @@ void QgisApp::addWmsLayer()
QMessageBox::warning( this, tr( "WMS" ), tr( "Cannot get WMS select dialog from provider." ) );
return;
}
connect( wmss , SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
this , SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
connect( wmss, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
this, SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
wmss->exec();
delete wmss;
}
@@ -3044,8 +3052,8 @@ void QgisApp::addWcsLayer()
QMessageBox::warning( this, tr( "WCS" ), tr( "Cannot get WCS select dialog from provider." ) );
return;
}
connect( wcss , SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
this , SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
connect( wcss, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
this, SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
wcss->exec();
delete wcss;
}
@@ -3071,8 +3079,8 @@ void QgisApp::addWfsLayer()
QMessageBox::warning( this, tr( "WFS" ), tr( "Cannot get WFS select dialog from provider." ) );
return;
}
connect( wfss , SIGNAL( addWfsLayer( QString, QString ) ),
this , SLOT( addWfsLayer( QString, QString ) ) );
connect( wfss, SIGNAL( addWfsLayer( QString, QString ) ),
this, SLOT( addWfsLayer( QString, QString ) ) );

//re-enable wfs with extent setting: pass canvas info to source select
wfss->setProperty( "MapExtent", mMapCanvas->extent().toString() );
@@ -513,6 +513,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cbxIdentifyResultsDocked->setChecked( settings.value( "/qgis/dockIdentifyResults", false ).toBool() );
cbxSnappingOptionsDocked->setChecked( settings.value( "/qgis/dockSnapping", false ).toBool() );
cbxAddPostgisDC->setChecked( settings.value( "/qgis/addPostgisDC", false ).toBool() );
cbxAddOracleDC->setChecked( settings.value( "/qgis/addOracleDC", false ).toBool() );
cbxAddNewLayersToCurrentGroup->setChecked( settings.value( "/qgis/addNewLayersToCurrentGroup", false ).toBool() );
cbxCreateRasterLegendIcons->setChecked( settings.value( "/qgis/createRasterLegendIcons", true ).toBool() );
cbxCopyWKTGeomFromTable->setChecked( settings.value( "/qgis/copyGeometryAsWKT", true ).toBool() );
@@ -1014,6 +1015,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() );
settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() );
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
settings.setValue( "/qgis/addOracleDC", cbxAddOracleDC->isChecked() );
settings.setValue( "/qgis/addNewLayersToCurrentGroup", cbxAddNewLayersToCurrentGroup->isChecked() );
bool createRasterLegendIcons = settings.value( "/qgis/createRasterLegendIcons", true ).toBool();
settings.setValue( "/qgis/createRasterLegendIcons", cbxCreateRasterLegendIcons->isChecked() );
@@ -45,7 +45,7 @@ void QgsOracleColumnTypeThread::run()

mStopped = false;

QgsDebugMsg( "retrieving supported layers - connection " + mName );
emit progressMessage( tr( "Retrieving tables of %1..." ).arg( mName ) );
QVector<QgsOracleLayerProperty> layerProperties;
if ( !conn->supportedLayers( layerProperties,
QgsOracleConn::geometryColumnsOnly( mName ),
@@ -56,10 +56,16 @@ void QgsOracleColumnTypeThread::run()
return;
}

int i = 0;
foreach ( QgsOracleLayerProperty layerProperty, layerProperties )
{
if ( !mStopped )
{
emit progress( i++, layerProperties.size() );
emit progressMessage( tr( "Scanning column %1.%2.%3..." )
.arg( layerProperty.ownerName )
.arg( layerProperty.tableName )
.arg( layerProperty.geometryColName ) );
conn->retrieveLayerTypes( layerProperty, mUseEstimatedMetadata );
}

@@ -73,5 +79,8 @@ void QgsOracleColumnTypeThread::run()
emit setLayerType( layerProperty );
}

emit progress( 0, 0 );
emit progressMessage( tr( "Table retrieval finished." ) );

conn->disconnect();
}
@@ -36,6 +36,8 @@ class QgsOracleColumnTypeThread : public QThread

signals:
void setLayerType( QgsOracleLayerProperty layerProperty );
void progress( int, int );
void progressMessage( QString );

public slots:
void stop();
@@ -188,13 +188,14 @@ bool QgsOracleConn::tableInfo( bool geometryColumnsOnly, bool userTablesOnly, bo

sql = QString( "SELECT %1,c.table_name,c.column_name,%2,t.table_name AS isview"
" FROM %3_%4 c"
" LEFT OUTER JOIN %3_tables t ON c.table_name=t.table_name%5%6" )
" LEFT OUTER JOIN %3_tables t ON c.table_name=t.table_name%5"
" WHERE %6" )
.arg( owner )
.arg( geometryColumnsOnly ? "c.srid" : "NULL AS srid" )
.arg( prefix )
.arg( geometryColumnsOnly ? "sdo_geom_metadata" : "tab_columns" )
.arg( userTablesOnly ? "" : " AND c.owner=t.owner" )
.arg( geometryColumnsOnly ? "" : " WHERE c.data_type='SDO_GEOMETRY'" );
.arg( geometryColumnsOnly ? "NOT t.dropped" : "c.data_type='SDO_GEOMETRY'" );

if ( allowGeometrylessTables )
{
@@ -202,11 +202,11 @@ QgsOracleSourceSelect::QgsOracleSourceSelect( QWidget *parent, Qt::WFlags fl, bo
//in search does not seem to work
mSearchColumnComboBox->setCurrentIndex( 2 );

restoreGeometry( settings.value( "/Windows/PgSourceSelect/geometry" ).toByteArray() );
restoreGeometry( settings.value( "/Windows/OracleSourceSelect/geometry" ).toByteArray() );

for ( int i = 0; i < mTableModel.columnCount(); i++ )
{
mTablesTreeView->setColumnWidth( i, settings.value( QString( "/Windows/PgSourceSelect/columnWidths/%1" ).arg( i ), mTablesTreeView->columnWidth( i ) ).toInt() );
mTablesTreeView->setColumnWidth( i, settings.value( QString( "/Windows/OracleSourceSelect/columnWidths/%1" ).arg( i ), mTablesTreeView->columnWidth( i ) ).toInt() );
}

//hide the search options by default
@@ -472,6 +472,10 @@ void QgsOracleSourceSelect::on_btnConnect_clicked()
this, SLOT( setLayerType( QgsOracleLayerProperty ) ) );
connect( mColumnTypeThread, SIGNAL( finished() ),
this, SLOT( columnThreadFinished() ) );
connect( mColumnTypeThread, SIGNAL( progress( int, int ) ),
this, SIGNAL( progress( int, int ) ) );
connect( mColumnTypeThread, SIGNAL( progressMessage( QString ) ),
this, SIGNAL( progressMessage( QString ) ) );

btnConnect->setText( tr( "Stop" ) );
mColumnTypeThread->start();
@@ -85,6 +85,8 @@ class QgsOracleSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
signals:
void addDatabaseLayers( QStringList const & layerPathList, QString const & providerKey );
void connectionsChanged();
void progress( int, int );
void progressMessage( QString );

public slots:
//! Determines the tables the user selected and closes the dialog
@@ -48,10 +48,13 @@ void QgsGeomColumnTypeThread::run()

mStopped = false;

int i = 0;
foreach ( QgsPostgresLayerProperty layerProperty, layerProperties )
{
if ( !mStopped )
{
emit progress( i++, layerProperties.size() );
emit progressMessage( tr( "Scanning PostgreSQL column %1.%2.%3..." ).arg( layerProperty.schemaName ).arg( layerProperty.tableName ).arg( layerProperty.geometryColName ) );
mConn->retrieveLayerTypes( layerProperty, mUseEstimatedMetadata );
}

@@ -36,6 +36,8 @@ class QgsGeomColumnTypeThread : public QThread

signals:
void setLayerType( QgsPostgresLayerProperty layerProperty );
void progress( int, int );
void progressMessage( QString );

public slots:
void addGeometryColumn( QgsPostgresLayerProperty layerProperty );
@@ -447,6 +447,8 @@ void QgsPgSourceSelect::on_btnConnect_clicked()
bool dontResolveType = QgsPostgresConn::dontResolveType( cmbConnections->currentText() );
bool allowGeometrylessTables = cbxAllowGeometrylessTables->isChecked();

emit progressMessage( tr( "Retrieving tables from %1..." ).arg( cmbConnections->currentText() ) );

QVector<QgsPostgresLayerProperty> layers;
if ( conn->supportedLayers( layers, searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables ) )
{
@@ -526,6 +528,9 @@ void QgsPgSourceSelect::finishList()
mTablesTreeView->sortByColumn( QgsPgTableModel::dbtmTable, Qt::AscendingOrder );
mTablesTreeView->sortByColumn( QgsPgTableModel::dbtmSchema, Qt::AscendingOrder );

emit progress( 0, 0 );
emit progressMessage( tr( "Table retrieval finished." ) );

if ( mTablesTreeView->model()->rowCount() == 0 )
QMessageBox::information( this,
tr( "Postgres/PostGIS Provider" ),
@@ -599,6 +604,10 @@ void QgsPgSourceSelect::addSearchGeometryColumn( QgsPostgresLayerProperty layerP
mColumnTypeThread, SLOT( addGeometryColumn( QgsPostgresLayerProperty ) ) );
connect( mColumnTypeThread, SIGNAL( finished() ),
this, SLOT( columnThreadFinished() ) );
connect( mColumnTypeThread, SIGNAL( progress( int, int ) ),
this, SIGNAL( progress( int, int ) ) );
connect( mColumnTypeThread, SIGNAL( progressMessage( QString ) ),
this, SIGNAL( progressMessage( QString ) ) );
}
}

@@ -75,6 +75,8 @@ class QgsPgSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
void addDatabaseLayers( QStringList const & layerPathList, QString const & providerKey );
void connectionsChanged();
void addGeometryColumn( QgsPostgresLayerProperty );
void progress( int, int );
void progressMessage( QString );

public slots:
//! Determines the tables the user selected and closes the dialog
@@ -1520,6 +1520,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxAddOracleDC">
<property name="text">
<string>Add Oracle layers with double click and select in extended mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

0 comments on commit 785114a

Please sign in to comment.
You can’t perform that action at this time.