Skip to content
Permalink
Browse files

[oracle] Don't report import failures when user has cancelled import

On behalf of Faunalia, sponsored by ENEL
  • Loading branch information
nyalldawson committed Jul 6, 2016
1 parent 82be399 commit a31a1d3f13101a906de88bd71981c61526ccb1ae
Showing with 17 additions and 3 deletions.
  1. +17 −3 src/providers/oracle/qgsoracledataitems.cpp
@@ -216,13 +216,15 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction

qApp->setOverrideCursor( Qt::WaitCursor );

QProgressDialog *progress = new QProgressDialog( tr( "Copying features..." ), tr( "Abort" ), 0, 0, 0 );
QProgressDialog *progress = new QProgressDialog( tr( "Copying features..." ), tr( "Abort" ), 0, 0, nullptr );
progress->setWindowTitle( tr( "Import layer" ) );
progress->setWindowModality( Qt::WindowModal );
progress->show();

QStringList importResults;
bool hasError = false;
bool cancelled = false;

QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( data );
Q_FOREACH ( const QgsMimeDataUtils::Uri& u, lst )
{
@@ -248,9 +250,11 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
QgsDebugMsgLevel( "URI " + uri.uri(), 3 );
QgsVectorLayerImport::ImportError err;
QString importError;
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri(), "oracle", &srcLayer->crs(), false, &importError, false, 0, progress );
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri(), "oracle", &srcLayer->crs(), false, &importError, false, nullptr, progress );
if ( err == QgsVectorLayerImport::NoError )
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
else if ( err == QgsVectorLayerImport::ErrUserCancelled )
cancelled = true;
else
{
importResults.append( QString( "%1: %2" ).arg( u.name ).arg( importError ) );
@@ -270,7 +274,12 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction

qApp->restoreOverrideCursor();

if ( hasError )
if ( cancelled )
{
QMessageBox::information( nullptr, tr( "Import to Oracle database" ), tr( "Import cancelled." ) );
refresh();
}
else if ( hasError )
{
QgsMessageOutput *output = QgsMessageOutput::createMessageOutput();
output->setTitle( tr( "Import to Oracle database" ) );
@@ -283,6 +292,11 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
refresh();
}

if ( state() == Populated )
refresh();
else
populate();

return true;
}

0 comments on commit a31a1d3

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