Skip to content

Commit 04dc5cc

Browse files
committedJul 6, 2016
[oracle] Don't report import failures when user has cancelled import
On behalf of Faunalia, sponsored by ENEL (cherry-picked from a31a1d3)
1 parent 432934c commit 04dc5cc

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
@@ -217,13 +217,15 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
217217

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

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

225225
QStringList importResults;
226226
bool hasError = false;
227+
bool cancelled = false;
228+
227229
QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( data );
228230
Q_FOREACH ( const QgsMimeDataUtils::Uri& u, lst )
229231
{
@@ -249,9 +251,11 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
249251
QgsDebugMsgLevel( "URI " + uri.uri(), 3 );
250252
QgsVectorLayerImport::ImportError err;
251253
QString importError;
252-
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri(), "oracle", &srcLayer->crs(), false, &importError, false, 0, progress );
254+
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri(), "oracle", &srcLayer->crs(), false, &importError, false, nullptr, progress );
253255
if ( err == QgsVectorLayerImport::NoError )
254256
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
257+
else if ( err == QgsVectorLayerImport::ErrUserCancelled )
258+
cancelled = true;
255259
else
256260
{
257261
importResults.append( QString( "%1: %2" ).arg( u.name ).arg( importError ) );
@@ -271,7 +275,12 @@ bool QgsOracleConnectionItem::handleDrop( const QMimeData * data, Qt::DropAction
271275

272276
qApp->restoreOverrideCursor();
273277

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.