Skip to content

Commit

Permalink
Remove duplicate code - now handled by QgsPathResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed May 13, 2017
1 parent bbe5996 commit 15fc16d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 70 deletions.
1 change: 0 additions & 1 deletion src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
69 changes: 0 additions & 69 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 15fc16d

Please sign in to comment.