Skip to content
Permalink
Browse files

Use proxy progress task for Oracle db table scan

  • Loading branch information
nyalldawson committed Aug 20, 2018
1 parent aa62f3a commit 6e9e0e8ba5686a804daaf1948171d5d8bd006a8e
Showing with 14 additions and 4 deletions.
  1. +12 −2 src/providers/oracle/qgsoraclesourceselect.cpp
  2. +2 −2 src/providers/oracle/qgsoraclesourceselect.h
@@ -29,6 +29,7 @@ email : jef at norbit dot de
#include "qgsvectorlayer.h"
#include "qgsoraclecolumntypethread.h"
#include "qgssettings.h"
#include "qgsproxyprogresstask.h"

#include <QFileDialog>
#include <QInputDialog>
@@ -516,15 +517,20 @@ void QgsOracleSourceSelect::on_btnConnect_clicked()
QgsOracleConn::restrictToSchema( cmbConnections->currentText() ),
uri.useEstimatedMetadata(),
cbxAllowGeometrylessTables->isChecked() );
mColumnTypeTask = new QgsProxyProgressTask( tr( "Scanning tables for %1" ).arg( cmbConnections->currentText() ) );
QgsApplication::taskManager()->addTask( mColumnTypeTask );

connect( mColumnTypeThread, &QgsOracleColumnTypeThread::setLayerType,
this, &QgsOracleSourceSelect::setLayerType );
connect( mColumnTypeThread, &QThread::finished,
this, &QgsOracleSourceSelect::columnThreadFinished );
connect( mColumnTypeThread, &QgsOracleColumnTypeThread::progress,
this, &QgsOracleSourceSelect::progress );
mColumnTypeTask, [ = ]( int i, int n )
{
mColumnTypeTask->setProxyProgress( 100.0 * static_cast< double >( i ) / n );
} );
connect( mColumnTypeThread, &QgsOracleColumnTypeThread::progressMessage,
this, &QgsOracleSourceSelect::progressMessage );
this, &QgsAbstractDataSourceWidget::progressMessage );

btnConnect->setText( tr( "Stop" ) );
mColumnTypeThread->start();
@@ -565,6 +571,10 @@ void QgsOracleSourceSelect::columnThreadFinished()

delete mColumnTypeThread;
mColumnTypeThread = nullptr;

mColumnTypeTask->finalize( true );
mColumnTypeTask = nullptr;

btnConnect->setText( tr( "Connect" ) );

finishList();
@@ -36,6 +36,7 @@ class QStringList;
class QgsOracleColumnTypeThread;
class QgisApp;
class QgsOracleSourceSelect;
class QgsProxyProgressTask;

class QgsOracleSourceSelectDelegate : public QItemDelegate
{
@@ -98,8 +99,6 @@ class QgsOracleSourceSelect : public QgsAbstractDataSourceWidget, private Ui::Qg

signals:
void addDatabaseLayers( QStringList const &layerPathList, QString const &providerKey );
void progress( int, int );
void progressMessage( QString );

public slots:
//! Determines the tables the user selected and closes the dialog
@@ -158,6 +157,7 @@ class QgsOracleSourceSelect : public QgsAbstractDataSourceWidget, private Ui::Qg
QStringList mColumnLabels;
// Our thread for doing long running queries
QgsOracleColumnTypeThread *mColumnTypeThread = nullptr;
QgsProxyProgressTask *mColumnTypeTask = nullptr;
QgsDataSourceUri mConnInfo;
QStringList mSelectedTables;
// Storage for the range of layer type icons

0 comments on commit 6e9e0e8

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