Skip to content

Commit

Permalink
Use ProviderMetaData to decode string
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 24, 2020
1 parent 632ab0e commit ad9f968
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -38,6 +38,8 @@
#include "qgsogrutils.h"
#include "qgsvectorfilewriter.h"
#include "qgsvectorlayer.h"
#include "qgsproviderregistry.h"
#include "qgsprovidermetadata.h"

#include <QDir>
#include <QDomDocument>
Expand Down Expand Up @@ -1492,12 +1494,10 @@ void QgsOfflineEditing::committedFeaturesAdded( const QString &qgisLayerId, cons
}
else
{
if ( dataSourceString.indexOf( QLatin1String( "|layername=" ) ) != -1 )
{
QRegularExpression regex( QStringLiteral( "\\|layername=([^|]*)" ) );
tableName = regex.match( dataSourceString ).captured( 1 );
}
else
QgsProviderMetadata *ogrProviderMetaData = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "ogr" ) );
QVariantMap decodedUri = ogrProviderMetaData->decodeUri( dataSourceString );
tableName = decodedUri.value( QStringLiteral( "layerName" ) ).toString();
if ( tableName.isEmpty() )
{
showWarning( tr( "Could not deduce table name from data source %1." ).arg( dataSourceString ) );
}
Expand Down

0 comments on commit ad9f968

Please sign in to comment.