Skip to content
Permalink
Browse files

fit autofinder

didn't replace text used on apply and didn't find file properly
  • Loading branch information
roya0045 authored and nyalldawson committed Dec 21, 2020
1 parent c851c0f commit 67a8c306503aec87e5159efc5805b85b54830d29
Showing with 10 additions and 9 deletions.
  1. +10 −9 src/app/qgshandlebadlayers.cpp
@@ -129,7 +129,7 @@ QgsHandleBadLayers::QgsHandleBadLayers( const QList<QDomNode> &layers )
QString vectorProvider = type == QLatin1String( "vector" ) ? provider : tr( "none" );
bool providerFileBased = ( provider == QLatin1String( "gdal" ) || provider == QLatin1String( "ogr" ) || provider == QLatin1String( "mdal" ) );
const QString basepath = QFileInfo( datasource ).absolutePath();
mOriginalFileBase[name].append( basepath );
mOriginalFileBase[ node.namedItem( QStringLiteral( "id" ) ).toElement().text() ].append( basepath );

QgsDebugMsg( QStringLiteral( "name=%1 type=%2 provider=%3 datasource='%4'" )
.arg( name,
@@ -408,10 +408,9 @@ void QgsHandleBadLayers::apply()
{
fileName = longName;
}
if ( item->data( Qt::UserRole + 2 ).isValid() )
if ( !( item->data( Qt::UserRole + 2 ).isValid() && item->data( Qt::UserRole + 2 ).toBool() ) )
{
if ( item->data( Qt::UserRole + 2 ).toBool() )
datasource = QDir::toNativeSeparators( checkBasepath( layerId, datasource, fileName ).replace( fileName, longName ) );
datasource = QDir::toNativeSeparators( checkBasepath( layerId, datasource, fileName ).replace( fileName, longName ) );
}

bool dataSourceChanged { false };
@@ -518,10 +517,11 @@ int QgsHandleBadLayers::layerCount()
QString QgsHandleBadLayers::checkBasepath( const QString &layerId, const QString &newPath, const QString &fileName )
{
const QString originalBase = mOriginalFileBase.value( layerId );
const QFileInfo newpathInfo = QFileInfo( newPath );
if ( newpathInfo.exists() && newpathInfo.isFile() )
const QDir newpathDir = QDir( newPath );
bool exists = newpathDir.exists( fileName );
if ( exists )
{
const QString newBasepath = newpathInfo.absoluteDir().path();
const QString newBasepath = newpathDir.absolutePath();
if ( !mAlternativeBasepaths.value( originalBase ).contains( newBasepath ) )
mAlternativeBasepaths[ originalBase ].append( newBasepath );
return ( newPath );
@@ -643,8 +643,8 @@ void QgsHandleBadLayers::autoFind()
}
if ( dataSourceChanged )
{
const QString altBasepath = QFileInfo( datasource ).absoluteDir().path();
checkBasepath( layerId, altBasepath, fileName );
QString cleanSrc = QFileInfo( datasource ).absoluteDir().absolutePath();
checkBasepath( layerId, cleanSrc, fileName );
}
}

@@ -654,6 +654,7 @@ void QgsHandleBadLayers::autoFind()
if ( dataSourceChanged )
{
setFilename( i, datasource );
item->setText( datasource );
item->setForeground( QBrush( Qt::green ) );
item->setData( Qt::UserRole + 2, QVariant( true ) );
}

0 comments on commit 67a8c30

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