Skip to content
Permalink
Browse files

Remove duplicate code - now handled by QgsPathResolver

  • Loading branch information
wonder-sk committed May 13, 2017
1 parent bbe5996 commit 15fc16df6a5fa39283e05c921c323fcad0ca13d4
Showing with 0 additions and 70 deletions.
  1. +0 −1 src/core/qgsmaplayer.cpp
  2. +0 −69 src/core/qgsproject.cpp
@@ -179,7 +179,6 @@ bool QgsMapLayer::readLayerXml( const QDomElement &layerElement, const QgsPathRe
}

// TODO: this should go to providers
// see also QgsProject::createEmbeddedLayer
if ( provider == QLatin1String( "spatialite" ) )
{
QgsDataSourceUri uri( mDataSource );
@@ -1746,75 +1746,6 @@ bool QgsProject::createEmbeddedLayer( const QString &layerId, const QString &pro

mEmbeddedLayers.insert( layerId, qMakePair( projectFilePath, saveFlag ) );

// change datasource path from relative to absolute if necessary
// see also QgsMapLayer::readLayerXML
if ( !useAbsolutePaths )
{
QString provider( mapLayerElem.firstChildElement( QStringLiteral( "provider" ) ).text() );
QDomElement dsElem( mapLayerElem.firstChildElement( QStringLiteral( "datasource" ) ) );
QString datasource( dsElem.text() );
if ( provider == QLatin1String( "spatialite" ) )
{
QgsDataSourceUri uri( datasource );
QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + '/' + uri.database() );
if ( absoluteDs.exists() )
{
uri.setDatabase( absoluteDs.absoluteFilePath() );
datasource = uri.uri();
}
}
else if ( provider == QLatin1String( "ogr" ) )
{
QStringList theURIParts( datasource.split( '|' ) );
QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + '/' + theURIParts[0] );
if ( absoluteDs.exists() )
{
theURIParts[0] = absoluteDs.absoluteFilePath();
datasource = theURIParts.join( QStringLiteral( "|" ) );
}
}
else if ( provider == QLatin1String( "gpx" ) )
{
QStringList theURIParts( datasource.split( '?' ) );
QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + '/' + theURIParts[0] );
if ( absoluteDs.exists() )
{
theURIParts[0] = absoluteDs.absoluteFilePath();
datasource = theURIParts.join( QStringLiteral( "?" ) );
}
}
else if ( provider == QLatin1String( "delimitedtext" ) )
{
QUrl urlSource( QUrl::fromEncoded( datasource.toLatin1() ) );

if ( !datasource.startsWith( QLatin1String( "file:" ) ) )
{
QUrl file( QUrl::fromLocalFile( datasource.left( datasource.indexOf( '?' ) ) ) );
urlSource.setScheme( QStringLiteral( "file" ) );
urlSource.setPath( file.path() );
}

QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + '/' + urlSource.toLocalFile() );
if ( absoluteDs.exists() )
{
QUrl urlDest = QUrl::fromLocalFile( absoluteDs.absoluteFilePath() );
urlDest.setQueryItems( urlSource.queryItems() );
datasource = QString::fromAscii( urlDest.toEncoded() );
}
}
else
{
QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + '/' + datasource );
if ( absoluteDs.exists() )
{
datasource = absoluteDs.absoluteFilePath();
}
}

dsElem.removeChild( dsElem.childNodes().at( 0 ) );
dsElem.appendChild( sProjectDocument.createTextNode( datasource ) );
}

if ( addLayer( mapLayerElem, brokenNodes, embeddedPathResolver ) )
{
return true;

0 comments on commit 15fc16d

Please sign in to comment.