Skip to content
Permalink
Browse files

[gui] do not automatically format name of added layers (fixes #17741)

(users wanting to re-enable that behavior can do so by switching
qgis/formatLayerName to true)
  • Loading branch information
nirvn committed Jan 15, 2018
1 parent b9aa768 commit e3cfbb0805ad5b6c7fec0e38505ac71c7412b894
Showing with 23 additions and 7 deletions.
  1. +3 −1 resources/qgis_global_settings.ini
  2. +20 −5 src/app/qgisapp.cpp
  3. +0 −1 src/core/qgsmaplayer.cpp
@@ -1,8 +1,10 @@
[qgis]
# if formatLayerName is set to true, added layer names will be automatically capitalized and underscores replaced with spaces
formatLayerName=false
connections-xyz\OpenStreetMap\authcfg=
connections-xyz\OpenStreetMap\password=
connections-xyz\OpenStreetMap\referer=
connections-xyz\OpenStreetMap\url=http://a.tile.openstreetmap.org/{z}/{x}/{y}.png
connections-xyz\OpenStreetMap\username=
connections-xyz\OpenStreetMap\zmax=19
connections-xyz\OpenStreetMap\zmin=0
connections-xyz\OpenStreetMap\zmin=0
@@ -4182,6 +4182,8 @@ bool QgisApp::addVectorLayers( const QStringList &layerQStringList, const QStrin
{
bool wasfrozen = mMapCanvas->isFrozen();
QList<QgsMapLayer *> myList;
QgsSettings settings;

Q_FOREACH ( QString src, layerQStringList )
{
src = src.trimmed();
@@ -4213,7 +4215,10 @@ bool QgisApp::addVectorLayers( const QStringList &layerQStringList, const QStrin
QFileInfo fi( src );
base = fi.completeBaseName();
}
base = QgsMapLayer::formatLayerName( base );
if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() )
{
base = QgsMapLayer::formatLayerName( base );
}

QgsDebugMsg( "completeBaseName: " + base );

@@ -4257,7 +4262,11 @@ bool QgisApp::addVectorLayers( const QStringList &layerQStringList, const QStrin
{
//set friendly name for datasources with only one layer
QStringList elements = sublayers.at( 0 ).split( QgsDataProvider::SUBLAYER_SEPARATOR );
QString subLayerNameFormatted = elements.size() >= 2 ? QgsMapLayer::formatLayerName( elements.at( 1 ) ) : QString();
QString subLayerNameFormatted = elements.size() >= 2 ? elements.at( 1 ) : QString();
if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() )
{
subLayerNameFormatted = QgsMapLayer::formatLayerName( subLayerNameFormatted );
}

if ( elements.size() >= 4 && layer->name().compare( elements.at( 1 ), Qt::CaseInsensitive ) != 0
&& layer->name().compare( subLayerNameFormatted, Qt::CaseInsensitive ) != 0 )
@@ -9998,10 +10007,11 @@ void QgisApp::showLayoutManager()
QgsVectorLayer *QgisApp::addVectorLayer( const QString &vectorLayerPath, const QString &name, const QString &providerKey )
{
bool wasfrozen = mMapCanvas->isFrozen();
QgsSettings settings;

freezeCanvases();

QString baseName = QgsMapLayer::formatLayerName( name );
QString baseName = settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() ? QgsMapLayer::formatLayerName( name ) : name;

/* Eliminate the need to instantiate the layer based on provider type.
The caller is responsible for cobbling together the needed information to
@@ -10056,7 +10066,11 @@ QgsVectorLayer *QgisApp::addVectorLayer( const QString &vectorLayerPath, const Q
if ( !sublayers.isEmpty() )
{
QStringList elements = sublayers.at( 0 ).split( QgsDataProvider::SUBLAYER_SEPARATOR );
QString subLayerNameFormatted = elements.size() >= 2 ? QgsMapLayer::formatLayerName( elements.at( 1 ) ) : QString();
QString subLayerNameFormatted = elements.size() >= 2 ? elements.at( 1 ) : QString();
if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() )
{
subLayerNameFormatted = QgsMapLayer::formatLayerName( subLayerNameFormatted );
}

if ( elements.size() >= 4 && layer->name().compare( elements.at( 1 ), Qt::CaseInsensitive ) != 0
&& layer->name().compare( subLayerNameFormatted, Qt::CaseInsensitive ) != 0 )
@@ -11935,7 +11949,8 @@ QgsRasterLayer *QgisApp::addRasterLayerPrivate(
freezeCanvases();
}

QString baseName = QgsMapLayer::formatLayerName( name );
QgsSettings settings;
QString baseName = settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() ? QgsMapLayer::formatLayerName( name ) : name;

QgsDebugMsg( "Creating new raster layer using " + uri
+ " with baseName of " + baseName );
@@ -51,7 +51,6 @@
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgsxmlutils.h"
#include "qgssettings.h" // TODO: get rid of it [MD]
#include "qgsstringutils.h"

QString QgsMapLayer::extensionPropertyType( QgsMapLayer::PropertyType type )

0 comments on commit e3cfbb0

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