Skip to content

Commit 785114a

Browse files
committed
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)
1 parent 4292976 commit 785114a

12 files changed

+77
-26
lines changed

src/app/qgisapp.cpp

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,16 +2863,20 @@ void QgisApp::addDatabaseLayer()
28632863
QgsDebugMsg( "about to addRasterLayer" );
28642864

28652865
// TODO: QDialog for now, switch to QWidget in future
2866-
QDialog *pgs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "postgres" ), this ) );
2867-
if ( !pgs )
2866+
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "postgres", this ) );
2867+
if ( !dbs )
28682868
{
28692869
QMessageBox::warning( this, tr( "PostgreSQL" ), tr( "Cannot get PostgreSQL select dialog from provider." ) );
28702870
return;
28712871
}
2872-
connect( pgs , SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
2873-
this , SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
2874-
pgs->exec();
2875-
delete pgs;
2872+
connect( dbs, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
2873+
this, SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
2874+
connect( dbs, SIGNAL( progress( int, int ) ),
2875+
this, SLOT( showProgress( int, int ) ) );
2876+
connect( dbs, SIGNAL( progressMessage( QString ) ),
2877+
this, SLOT( showStatusMessage( QString ) ) );
2878+
dbs->exec();
2879+
delete dbs;
28762880
#endif
28772881
} // QgisApp::addDatabaseLayer()
28782882

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

29532957
// show the SpatiaLite dialog
2954-
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "spatialite" ), this ) );
2958+
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "spatialite", this ) );
29552959
if ( !dbs )
29562960
{
29572961
QMessageBox::warning( this, tr( "SpatiaLite" ), tr( "Cannot get SpatiaLite select dialog from provider." ) );
29582962
return;
29592963
}
2960-
connect( dbs , SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
2961-
this , SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
2964+
connect( dbs, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
2965+
this, SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
29622966
dbs->exec();
29632967
delete dbs;
29642968
} // QgisApp::addSpatiaLiteLayer()
@@ -2972,14 +2976,14 @@ void QgisApp::addMssqlLayer()
29722976
}
29732977

29742978
// show the MSSQL dialog
2975-
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "mssql" ), this ) );
2979+
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "mssql", this ) );
29762980
if ( !dbs )
29772981
{
29782982
QMessageBox::warning( this, tr( "MSSQL" ), tr( "Cannot get MSSQL select dialog from provider." ) );
29792983
return;
29802984
}
2981-
connect( dbs , SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
2982-
this , SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
2985+
connect( dbs, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
2986+
this, SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
29832987
dbs->exec();
29842988
delete dbs;
29852989
#endif
@@ -2994,14 +2998,18 @@ void QgisApp::addOracleLayer()
29942998
}
29952999

29963000
// show the Oracle dialog
2997-
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "oracle" ), this ) );
3001+
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "oracle", this ) );
29983002
if ( !dbs )
29993003
{
30003004
QMessageBox::warning( this, tr( "Oracle" ), tr( "Cannot get Oracle select dialog from provider." ) );
30013005
return;
30023006
}
3003-
connect( dbs , SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
3004-
this , SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
3007+
connect( dbs, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
3008+
this, SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
3009+
connect( dbs, SIGNAL( progress( int, int ) ),
3010+
this, SLOT( showProgress( int, int ) ) );
3011+
connect( dbs, SIGNAL( progressMessage( QString ) ),
3012+
this, SLOT( showStatusMessage( QString ) ) );
30053013
dbs->exec();
30063014
delete dbs;
30073015
#endif
@@ -3023,8 +3031,8 @@ void QgisApp::addWmsLayer()
30233031
QMessageBox::warning( this, tr( "WMS" ), tr( "Cannot get WMS select dialog from provider." ) );
30243032
return;
30253033
}
3026-
connect( wmss , SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
3027-
this , SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
3034+
connect( wmss, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
3035+
this, SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
30283036
wmss->exec();
30293037
delete wmss;
30303038
}
@@ -3044,8 +3052,8 @@ void QgisApp::addWcsLayer()
30443052
QMessageBox::warning( this, tr( "WCS" ), tr( "Cannot get WCS select dialog from provider." ) );
30453053
return;
30463054
}
3047-
connect( wcss , SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
3048-
this , SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
3055+
connect( wcss, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
3056+
this, SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
30493057
wcss->exec();
30503058
delete wcss;
30513059
}
@@ -3071,8 +3079,8 @@ void QgisApp::addWfsLayer()
30713079
QMessageBox::warning( this, tr( "WFS" ), tr( "Cannot get WFS select dialog from provider." ) );
30723080
return;
30733081
}
3074-
connect( wfss , SIGNAL( addWfsLayer( QString, QString ) ),
3075-
this , SLOT( addWfsLayer( QString, QString ) ) );
3082+
connect( wfss, SIGNAL( addWfsLayer( QString, QString ) ),
3083+
this, SLOT( addWfsLayer( QString, QString ) ) );
30763084

30773085
//re-enable wfs with extent setting: pass canvas info to source select
30783086
wfss->setProperty( "MapExtent", mMapCanvas->extent().toString() );

src/app/qgsoptions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
513513
cbxIdentifyResultsDocked->setChecked( settings.value( "/qgis/dockIdentifyResults", false ).toBool() );
514514
cbxSnappingOptionsDocked->setChecked( settings.value( "/qgis/dockSnapping", false ).toBool() );
515515
cbxAddPostgisDC->setChecked( settings.value( "/qgis/addPostgisDC", false ).toBool() );
516+
cbxAddOracleDC->setChecked( settings.value( "/qgis/addOracleDC", false ).toBool() );
516517
cbxAddNewLayersToCurrentGroup->setChecked( settings.value( "/qgis/addNewLayersToCurrentGroup", false ).toBool() );
517518
cbxCreateRasterLegendIcons->setChecked( settings.value( "/qgis/createRasterLegendIcons", true ).toBool() );
518519
cbxCopyWKTGeomFromTable->setChecked( settings.value( "/qgis/copyGeometryAsWKT", true ).toBool() );
@@ -1014,6 +1015,7 @@ void QgsOptions::saveOptions()
10141015
settings.setValue( "/qgis/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() );
10151016
settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() );
10161017
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
1018+
settings.setValue( "/qgis/addOracleDC", cbxAddOracleDC->isChecked() );
10171019
settings.setValue( "/qgis/addNewLayersToCurrentGroup", cbxAddNewLayersToCurrentGroup->isChecked() );
10181020
bool createRasterLegendIcons = settings.value( "/qgis/createRasterLegendIcons", true ).toBool();
10191021
settings.setValue( "/qgis/createRasterLegendIcons", cbxCreateRasterLegendIcons->isChecked() );

src/providers/oracle/qgsoraclecolumntypethread.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void QgsOracleColumnTypeThread::run()
4545

4646
mStopped = false;
4747

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

59+
int i = 0;
5960
foreach ( QgsOracleLayerProperty layerProperty, layerProperties )
6061
{
6162
if ( !mStopped )
6263
{
64+
emit progress( i++, layerProperties.size() );
65+
emit progressMessage( tr( "Scanning column %1.%2.%3..." )
66+
.arg( layerProperty.ownerName )
67+
.arg( layerProperty.tableName )
68+
.arg( layerProperty.geometryColName ) );
6369
conn->retrieveLayerTypes( layerProperty, mUseEstimatedMetadata );
6470
}
6571

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

82+
emit progress( 0, 0 );
83+
emit progressMessage( tr( "Table retrieval finished." ) );
84+
7685
conn->disconnect();
7786
}

src/providers/oracle/qgsoraclecolumntypethread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class QgsOracleColumnTypeThread : public QThread
3636

3737
signals:
3838
void setLayerType( QgsOracleLayerProperty layerProperty );
39+
void progress( int, int );
40+
void progressMessage( QString );
3941

4042
public slots:
4143
void stop();

src/providers/oracle/qgsoracleconn.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,14 @@ bool QgsOracleConn::tableInfo( bool geometryColumnsOnly, bool userTablesOnly, bo
188188

189189
sql = QString( "SELECT %1,c.table_name,c.column_name,%2,t.table_name AS isview"
190190
" FROM %3_%4 c"
191-
" LEFT OUTER JOIN %3_tables t ON c.table_name=t.table_name%5%6" )
191+
" LEFT OUTER JOIN %3_tables t ON c.table_name=t.table_name%5"
192+
" WHERE %6" )
192193
.arg( owner )
193194
.arg( geometryColumnsOnly ? "c.srid" : "NULL AS srid" )
194195
.arg( prefix )
195196
.arg( geometryColumnsOnly ? "sdo_geom_metadata" : "tab_columns" )
196197
.arg( userTablesOnly ? "" : " AND c.owner=t.owner" )
197-
.arg( geometryColumnsOnly ? "" : " WHERE c.data_type='SDO_GEOMETRY'" );
198+
.arg( geometryColumnsOnly ? "NOT t.dropped" : "c.data_type='SDO_GEOMETRY'" );
198199

199200
if ( allowGeometrylessTables )
200201
{

src/providers/oracle/qgsoraclesourceselect.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ QgsOracleSourceSelect::QgsOracleSourceSelect( QWidget *parent, Qt::WFlags fl, bo
202202
//in search does not seem to work
203203
mSearchColumnComboBox->setCurrentIndex( 2 );
204204

205-
restoreGeometry( settings.value( "/Windows/PgSourceSelect/geometry" ).toByteArray() );
205+
restoreGeometry( settings.value( "/Windows/OracleSourceSelect/geometry" ).toByteArray() );
206206

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

212212
//hide the search options by default
@@ -472,6 +472,10 @@ void QgsOracleSourceSelect::on_btnConnect_clicked()
472472
this, SLOT( setLayerType( QgsOracleLayerProperty ) ) );
473473
connect( mColumnTypeThread, SIGNAL( finished() ),
474474
this, SLOT( columnThreadFinished() ) );
475+
connect( mColumnTypeThread, SIGNAL( progress( int, int ) ),
476+
this, SIGNAL( progress( int, int ) ) );
477+
connect( mColumnTypeThread, SIGNAL( progressMessage( QString ) ),
478+
this, SIGNAL( progressMessage( QString ) ) );
475479

476480
btnConnect->setText( tr( "Stop" ) );
477481
mColumnTypeThread->start();

src/providers/oracle/qgsoraclesourceselect.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class QgsOracleSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase
8585
signals:
8686
void addDatabaseLayers( QStringList const & layerPathList, QString const & providerKey );
8787
void connectionsChanged();
88+
void progress( int, int );
89+
void progressMessage( QString );
8890

8991
public slots:
9092
//! Determines the tables the user selected and closes the dialog

src/providers/postgres/qgscolumntypethread.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ void QgsGeomColumnTypeThread::run()
4848

4949
mStopped = false;
5050

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

src/providers/postgres/qgscolumntypethread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class QgsGeomColumnTypeThread : public QThread
3636

3737
signals:
3838
void setLayerType( QgsPostgresLayerProperty layerProperty );
39+
void progress( int, int );
40+
void progressMessage( QString );
3941

4042
public slots:
4143
void addGeometryColumn( QgsPostgresLayerProperty layerProperty );

src/providers/postgres/qgspgsourceselect.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ void QgsPgSourceSelect::on_btnConnect_clicked()
447447
bool dontResolveType = QgsPostgresConn::dontResolveType( cmbConnections->currentText() );
448448
bool allowGeometrylessTables = cbxAllowGeometrylessTables->isChecked();
449449

450+
emit progressMessage( tr( "Retrieving tables from %1..." ).arg( cmbConnections->currentText() ) );
451+
450452
QVector<QgsPostgresLayerProperty> layers;
451453
if ( conn->supportedLayers( layers, searchGeometryColumnsOnly, searchPublicOnly, allowGeometrylessTables ) )
452454
{
@@ -526,6 +528,9 @@ void QgsPgSourceSelect::finishList()
526528
mTablesTreeView->sortByColumn( QgsPgTableModel::dbtmTable, Qt::AscendingOrder );
527529
mTablesTreeView->sortByColumn( QgsPgTableModel::dbtmSchema, Qt::AscendingOrder );
528530

531+
emit progress( 0, 0 );
532+
emit progressMessage( tr( "Table retrieval finished." ) );
533+
529534
if ( mTablesTreeView->model()->rowCount() == 0 )
530535
QMessageBox::information( this,
531536
tr( "Postgres/PostGIS Provider" ),
@@ -599,6 +604,10 @@ void QgsPgSourceSelect::addSearchGeometryColumn( QgsPostgresLayerProperty layerP
599604
mColumnTypeThread, SLOT( addGeometryColumn( QgsPostgresLayerProperty ) ) );
600605
connect( mColumnTypeThread, SIGNAL( finished() ),
601606
this, SLOT( columnThreadFinished() ) );
607+
connect( mColumnTypeThread, SIGNAL( progress( int, int ) ),
608+
this, SIGNAL( progress( int, int ) ) );
609+
connect( mColumnTypeThread, SIGNAL( progressMessage( QString ) ),
610+
this, SIGNAL( progressMessage( QString ) ) );
602611
}
603612
}
604613

0 commit comments

Comments
 (0)