18 #include <QApplication>
19 #include <QDomDocument>
21 #include <QMessageBox>
22 #include <QPushButton>
36 Q_UNUSED( projectDom );
38 QgsDebugMsg( QString(
"%1 bad layers found" ).arg( layers.size() ) );
41 QApplication::setOverrideCursor( Qt::ArrowCursor );
43 QMessageBox messageBox;
45 QAbstractButton *ignoreButton =
46 messageBox.addButton(
tr(
"Ignore" ), QMessageBox::ActionRole );
48 QAbstractButton *okButton = messageBox.addButton( QMessageBox :: Ok );
50 messageBox.addButton( QMessageBox :: Cancel );
52 messageBox.setWindowTitle(
tr(
"QGIS Project Read Error" ) );
53 messageBox.setText(
tr(
"Unable to open one or more project layers.\nChoose "
54 "ignore to continue loading without the missing layers. Choose cancel to "
55 "return to your pre-project load state. Choose OK to try to find the "
56 "missing layers." ) );
57 messageBox.setIcon( QMessageBox::Critical );
62 if ( messageBox.clickedButton() == okButton )
64 QgsDebugMsg(
"want to find missing layers is true" );
72 else if ( messageBox.clickedButton() == ignoreButton )
81 QApplication::restoreOverrideCursor();
86 QString type = layerNode.toElement().attribute(
"type" );
88 if ( QString::null == type )
95 if (
"raster" == type )
101 else if (
"vector" == type )
116 QDomNode dataSourceNode = layerNode.namedItem(
"datasource" );
118 if ( dataSourceNode.isNull() )
122 return QString::null;
125 return dataSourceNode.toElement().text();
144 if ( ds.contains(
"host=" ) )
148 #ifdef HAVE_POSTGRESQL
149 else if ( ds.contains(
"dbname=" ) )
176 QDomNode dataSourceNode = layerNode.namedItem(
"datasource" );
177 QDomElement dataSourceElement = dataSourceNode.toElement();
178 QDomText dataSourceText = dataSourceElement.firstChild().toText();
180 QgsDebugMsg(
"datasource changed from " + dataSourceText.data() );
182 dataSourceText.setData( dataSource );
196 QFileInfo originalDataSource(
dataSource( layerNode ) );
198 QString memoryQualifier;
205 memoryQualifier =
"lastVectorFileFilter";
211 memoryQualifier =
"lastRasterFileFilter";
225 QString myFileFilters = originalDataSource.fileName() +
";;" + fileFilters;
227 QStringList selectedFiles;
229 QString title =
QObject::tr(
"Where is '%1' (original location: %2)?" )
230 .arg( originalDataSource.fileName() )
231 .arg( originalDataSource.absoluteFilePath() );
240 if ( selectedFiles.isEmpty() )
261 QDomNode & layerNode =
const_cast<QDomNode&
>( constLayerNode );
293 for ( QList<QDomNode>::const_iterator i = layerNodes.begin();
294 i != layerNodes.end();