4
4
#include < QDomDocument>
5
5
#include < QFileInfo>
6
6
#include < QMessageBox>
7
+ #include < QtGui/QPushButton>
7
8
8
9
#include " qgslogger.h"
9
10
#include " qgisgui.h"
@@ -13,27 +14,50 @@ QgsProjectBadLayerGuiHandler::QgsProjectBadLayerGuiHandler()
13
14
{
14
15
}
15
16
17
+ bool QgsProjectBadLayerGuiHandler::mIgnore = false ;
18
+
16
19
void QgsProjectBadLayerGuiHandler::handleBadLayers ( QList<QDomNode> layers, QDomDocument projectDom )
17
20
{
18
21
QgsDebugMsg ( QString ( " %1 bad layers found" ).arg ( layers.size () ) );
19
22
20
23
// make sure we have arrow cursor (and not a wait cursor)
21
24
QApplication::setOverrideCursor ( Qt::ArrowCursor );
22
-
23
- if ( QMessageBox::Ok == QMessageBox::critical ( NULL ,
24
- tr ( " QGIS Project Read Error" ),
25
- tr ( " Unable to open one or more project layers\n Try to find missing layers?" ),
26
- QMessageBox::Ok | QMessageBox::Cancel ) )
25
+
26
+ QMessageBox messageBox;
27
+
28
+ QAbstractButton *ignoreButton =
29
+ messageBox.addButton (tr (" Ignore" ),QMessageBox::ActionRole);
30
+
31
+ QAbstractButton *okButton = messageBox.addButton ( QMessageBox :: Ok );
32
+
33
+ messageBox.addButton ( QMessageBox :: Cancel );
34
+
35
+ messageBox.setWindowTitle (tr (" QGIS Project Read Error" ));
36
+ messageBox.setText (tr (" Unable to open one or more project layers\n Try to find missing layers?" ));
37
+ messageBox.setIcon (QMessageBox::Critical);
38
+ messageBox.exec ();
39
+
40
+ QgsProjectBadLayerGuiHandler::mIgnore = false ;
41
+
42
+ if (messageBox.clickedButton () == okButton)
27
43
{
28
44
QgsDebugMsg ( " want to find missing layers is true" );
29
-
45
+
30
46
// attempt to find the new locations for missing layers
31
47
// XXX vector file hard-coded -- but what if it's raster?
32
48
33
49
QString filter = QgsProviderRegistry::instance ()->fileVectorFilters ();
34
50
findLayers ( filter, layers );
35
- }
36
-
51
+ }
52
+ else if (messageBox.clickedButton () == ignoreButton)
53
+ {
54
+ QgsProjectBadLayerGuiHandler::mIgnore = true ;
55
+ }
56
+ else
57
+ {
58
+ // Do nothing
59
+ }
60
+
37
61
QApplication::restoreOverrideCursor ();
38
62
}
39
63
0 commit comments