Skip to content
Permalink
Browse files

Use a proxy task when scanning for postgres column types

  • Loading branch information
nyalldawson committed Aug 20, 2018
1 parent cea8b55 commit fd934d84a6b46c1cb3e0b742b33b03381c25ddff
Showing with 12 additions and 1 deletion.
  1. +9 −1 src/providers/postgres/qgspgsourceselect.cpp
  2. +3 −0 src/providers/postgres/qgspgsourceselect.h
@@ -28,6 +28,7 @@ email : sherman at mrcc.com
#include "qgsvectorlayer.h"
#include "qgscolumntypethread.h"
#include "qgssettings.h"
#include "qgsproxyprogresstask.h"

#include <QFileDialog>
#include <QInputDialog>
@@ -545,13 +546,18 @@ void QgsPgSourceSelect::btnConnect_clicked()
QApplication::setOverrideCursor( Qt::BusyCursor );

mColumnTypeThread = new QgsGeomColumnTypeThread( cmbConnections->currentText(), mUseEstimatedMetadata, cbxAllowGeometrylessTables->isChecked() );
mColumnTypeTask = new QgsProxyProgressTask( tr( "Scanning tables for %1" ).arg( cmbConnections->currentText() ) );
QgsApplication::taskManager()->addTask( mColumnTypeTask );

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

@@ -572,6 +578,8 @@ void QgsPgSourceSelect::columnThreadFinished()
delete mColumnTypeThread;
mColumnTypeThread = nullptr;
btnConnect->setText( tr( "Connect" ) );
mColumnTypeTask->finalize( true );
mColumnTypeTask = nullptr;

finishList();
}
@@ -36,6 +36,7 @@ class QStringList;
class QgsGeomColumnTypeThread;
class QgisApp;
class QgsPgSourceSelect;
class QgsProxyProgressTask;

class QgsPgSourceSelectDelegate : public QItemDelegate
{
@@ -138,6 +139,8 @@ class QgsPgSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsDbS
QStringList mColumnLabels;
// Our thread for doing long running queries
QgsGeomColumnTypeThread *mColumnTypeThread = nullptr;
QgsProxyProgressTask *mColumnTypeTask = nullptr;

QgsDataSourceUri mDataSrcUri;
QStringList mSelectedTables;
bool mUseEstimatedMetadata = false;

0 comments on commit fd934d8

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