Skip to content

Commit a31a1d3

Browse files
committed
[oracle] Don't report import failures when user has cancelled import
On behalf of Faunalia, sponsored by ENEL
1 parent 82be399 commit a31a1d3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/providers/oracle/qgsoracledataitems.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,15 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
216216

217217
qApp->setOverrideCursor( Qt::WaitCursor );
218218

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

224224
QStringList importResults;
225225
bool hasError = false;
226+
bool cancelled = false;
227+
226228
QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( data );
227229
Q_FOREACH ( const QgsMimeDataUtils::Uri& u, lst )
228230
{
@@ -248,9 +250,11 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
248250
QgsDebugMsgLevel( "URI " + uri.uri(), 3 );
249251
QgsVectorLayerImport::ImportError err;
250252
QString importError;
251-
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri(), "oracle", &srcLayer->crs(), false, &importError, false, 0, progress );
253+
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri(), "oracle", &srcLayer->crs(), false, &importError, false, nullptr, progress );
252254
if ( err == QgsVectorLayerImport::NoError )
253255
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
256+
else if ( err == QgsVectorLayerImport::ErrUserCancelled )
257+
cancelled = true;
254258
else
255259
{
256260
importResults.append( QString( "%1: %2" ).arg( u.name ).arg( importError ) );
@@ -270,7 +274,12 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
270274

271275
qApp->restoreOverrideCursor();
272276

273-
if ( hasError )
277+
if ( cancelled )
278+
{
279+
QMessageBox::information( nullptr, tr( "Import to Oracle database" ), tr( "Import cancelled." ) );
280+
refresh();
281+
}
282+
else if ( hasError )
274283
{
275284
QgsMessageOutput *output = QgsMessageOutput::createMessageOutput();
276285
output->setTitle( tr( "Import to Oracle database" ) );
@@ -283,6 +292,11 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
283292
refresh();
284293
}
285294

295+
if ( state() == Populated )
296+
refresh();
297+
else
298+
populate();
299+
286300
return true;
287301
}
288302

0 commit comments

Comments
 (0)