Skip to content
Permalink
Browse files

Partial fix for loading projects with missing layers from Sunilraj at…

… KCube. see #3468

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15332 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Mar 4, 2011
1 parent b7d97ad commit bb138abd904c3225427fa01f5ec4088cfe4e5bd3
Showing with 48 additions and 10 deletions.
  1. +13 −2 src/app/legend/qgslegend.cpp
  2. +32 −8 src/gui/qgsprojectbadlayerguihandler.cpp
  3. +3 −0 src/gui/qgsprojectbadlayerguihandler.h
@@ -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 QgsLegend::readXML( QgsLegendGroup *parent, const QDomNode &node )
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 )
{
@@ -4,6 +4,7 @@
#include <QDomDocument>
#include <QFileInfo>
#include <QMessageBox>
#include <QtGui/QPushButton>

#include "qgslogger.h"
#include "qgisgui.h"
@@ -13,27 +14,50 @@ QgsProjectBadLayerGuiHandler::QgsProjectBadLayerGuiHandler()
{
}

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();
}

@@ -19,6 +19,9 @@ class GUI_EXPORT QgsProjectBadLayerGuiHandler : public QObject, public QgsProjec

/** 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:

0 comments on commit bb138ab

Please sign in to comment.
You can’t perform that action at this time.