Skip to content

Commit 0088f28

Browse files
committedMay 10, 2013
handle bad layer: show unfixable layer count as message bar and skip dialog when list is empty.
1 parent 5346c80 commit 0088f28

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
 

‎src/app/qgshandlebadlayers.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "qgslogger.h"
2323
#include "qgsrasterlayer.h"
2424
#include "qgsproviderregistry.h"
25+
#include "qgsmessagebar.h"
2526

2627
#include <QDomDocument>
2728
#include <QDomElement>
@@ -37,7 +38,18 @@ void QgsHandleBadLayersHandler::handleBadLayers( QList<QDomNode> layers, QDomDoc
3738
{
3839
QApplication::setOverrideCursor( Qt::ArrowCursor );
3940
QgsHandleBadLayers *dialog = new QgsHandleBadLayers( layers, projectDom );
40-
dialog->exec();
41+
42+
if ( dialog->layerCount() < layers.size() )
43+
QgisApp::instance()->messageBar()->pushMessage(
44+
tr( "Handle Bad layers" ),
45+
tr( "%1 of %2 bad layers were not not fixable." )
46+
.arg( layers.size() - dialog->layerCount() )
47+
.arg( layers.size() ),
48+
QgsMessageBar::WARNING, QgisApp::instance()->messageTimeout() );
49+
50+
if ( dialog->layerCount() > 0 )
51+
dialog->exec();
52+
4153
delete dialog;
4254
QApplication::restoreOverrideCursor();
4355
}
@@ -357,3 +369,8 @@ void QgsHandleBadLayers::rejected()
357369

358370
QDialog::reject();
359371
}
372+
373+
int QgsHandleBadLayers::layerCount()
374+
{
375+
return mLayerList->rowCount();
376+
}

‎src/app/qgshandlebadlayers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class QgsHandleBadLayers
4646
QgsHandleBadLayers( const QList<QDomNode> &layers, const QDomDocument &dom );
4747
~QgsHandleBadLayers();
4848

49+
int layerCount();
50+
4951
private slots:
5052
void selectionChanged();
5153
void browseClicked();

0 commit comments

Comments
 (0)
Please sign in to comment.