[QGIS Commit] r15332 - in trunk/qgis/src: app/legend gui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Mar 4 15:46:59 EST 2011
Author: timlinux
Date: 2011-03-04 12:46:59 -0800 (Fri, 04 Mar 2011)
New Revision: 15332
Modified:
trunk/qgis/src/app/legend/qgslegend.cpp
trunk/qgis/src/gui/qgsprojectbadlayerguihandler.cpp
trunk/qgis/src/gui/qgsprojectbadlayerguihandler.h
Log:
Partial fix for loading projects with missing layers from Sunilraj at KCube. see #3468
Modified: trunk/qgis/src/app/legend/qgslegend.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegend.cpp 2011-03-04 17:13:55 UTC (rev 15331)
+++ trunk/qgis/src/app/legend/qgslegend.cpp 2011-03-04 20:46:59 UTC (rev 15332)
@@ -33,6 +33,7 @@
#include "qgsproject.h"
#include "qgsrasterlayer.h"
#include "qgsvectorlayer.h"
+#include "qgsprojectbadlayerguihandler.h"
#include <QFont>
#include <QDomDocument>
@@ -999,9 +1000,19 @@
bool isOpen;
QgsLegendLayer* currentLayer = readLayerFromXML( childelem, isOpen );
+ bool ignorePressed = QgsProjectBadLayerGuiHandler::mIgnore;
+
if ( !currentLayer )
- return false;
-
+ {
+ if( ignorePressed == true )
+ {
+ continue;
+ }
+ else
+ {
+ return false;
+ }
+ }
// add to tree - either as a top-level node or a child of a group
if ( parent )
{
Modified: trunk/qgis/src/gui/qgsprojectbadlayerguihandler.cpp
===================================================================
--- trunk/qgis/src/gui/qgsprojectbadlayerguihandler.cpp 2011-03-04 17:13:55 UTC (rev 15331)
+++ trunk/qgis/src/gui/qgsprojectbadlayerguihandler.cpp 2011-03-04 20:46:59 UTC (rev 15332)
@@ -4,6 +4,7 @@
#include <QDomDocument>
#include <QFileInfo>
#include <QMessageBox>
+#include <QtGui/QPushButton>
#include "qgslogger.h"
#include "qgisgui.h"
@@ -13,27 +14,50 @@
{
}
+bool QgsProjectBadLayerGuiHandler::mIgnore = false;
+
void QgsProjectBadLayerGuiHandler::handleBadLayers( QList<QDomNode> layers, QDomDocument projectDom )
{
QgsDebugMsg( QString( "%1 bad layers found" ).arg( layers.size() ) );
// make sure we have arrow cursor (and not a wait cursor)
QApplication::setOverrideCursor( Qt::ArrowCursor );
-
- if ( QMessageBox::Ok == QMessageBox::critical( NULL,
- tr( "QGIS Project Read Error" ),
- tr( "Unable to open one or more project layers\nTry to find missing layers?" ),
- QMessageBox::Ok | QMessageBox::Cancel ) )
+
+ QMessageBox messageBox;
+
+ QAbstractButton *ignoreButton =
+ messageBox.addButton(tr("Ignore"),QMessageBox::ActionRole);
+
+ QAbstractButton *okButton = messageBox.addButton( QMessageBox :: Ok );
+
+ messageBox.addButton( QMessageBox :: Cancel );
+
+ messageBox.setWindowTitle(tr("QGIS Project Read Error"));
+ messageBox.setText(tr("Unable to open one or more project layers\nTry to find missing layers?"));
+ messageBox.setIcon(QMessageBox::Critical);
+ messageBox.exec();
+
+ QgsProjectBadLayerGuiHandler::mIgnore = false;
+
+ if(messageBox.clickedButton() == okButton)
{
QgsDebugMsg( "want to find missing layers is true" );
-
+
// attempt to find the new locations for missing layers
// XXX vector file hard-coded -- but what if it's raster?
QString filter = QgsProviderRegistry::instance()->fileVectorFilters();
findLayers( filter, layers );
- }
-
+ }
+ else if (messageBox.clickedButton() == ignoreButton)
+ {
+ QgsProjectBadLayerGuiHandler::mIgnore = true;
+ }
+ else
+ {
+ // Do nothing
+ }
+
QApplication::restoreOverrideCursor();
}
Modified: trunk/qgis/src/gui/qgsprojectbadlayerguihandler.h
===================================================================
--- trunk/qgis/src/gui/qgsprojectbadlayerguihandler.h 2011-03-04 17:13:55 UTC (rev 15331)
+++ trunk/qgis/src/gui/qgsprojectbadlayerguihandler.h 2011-03-04 20:46:59 UTC (rev 15332)
@@ -19,6 +19,9 @@
/** implementation of the handler */
virtual void handleBadLayers( QList<QDomNode> layers, QDomDocument projectDom );
+
+ /** Flag to store the Ignore button press of MessageBox used by QgsLegend */
+ static bool mIgnore;
protected:
More information about the QGIS-commit
mailing list