Skip to content

Commit

Permalink
[oracle] Don't report import failures when user has cancelled import
Browse files Browse the repository at this point in the history
On behalf of Faunalia, sponsored by ENEL

(cherry-picked from a31a1d3)
  • Loading branch information
nyalldawson committed Jul 6, 2016
1 parent 432934c commit 04dc5cc
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/providers/oracle/qgsoracledataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,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 )
{
Expand All @@ -249,9 +251,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 ) );
Expand All @@ -271,7 +275,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" ) );
Expand All @@ -284,6 +293,11 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
refresh();
}

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

return true;
}

Expand Down

0 comments on commit 04dc5cc

Please sign in to comment.