Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove QgsMapLayer::originalName()
Now QgsMapLayer::name() is guaranteed to return the same string
  • Loading branch information
nyalldawson committed Nov 14, 2017
1 parent 1e4f691 commit 6f55e50
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 34 deletions.
1 change: 1 addition & 0 deletions doc/api_break.dox
Expand Up @@ -1667,6 +1667,7 @@ screenUpdateRequested() were removed. These members have had no effect for a num
now sets the maximum (i.e. largest scale, or most zoomed in) at which the layer will appear, and setMinimumScale now sets the minimum (i.e. smallest scale,
or most zoomed out) at which the layer will appear. The same is true for the maximumScale and minimumScale getters.
- capitalizeLayerName() was removed. Use formatLayerName() instead.
- originalName() was removed. Use name() instead.


QgsMapLayerActionRegistry {#qgis_api_break_3_0_QgsMapLayerActionRegistry}
Expand Down
8 changes: 0 additions & 8 deletions python/core/qgsmaplayer.sip
Expand Up @@ -97,7 +97,6 @@ Returns the layer's unique ID, which is used to access this layer from QgsProjec
QString name() const;
%Docstring
Returns the display name of the layer.
:return: the layer name
.. seealso:: setName()
:rtype: str
%End
Expand All @@ -109,12 +108,6 @@ Returns the layer's unique ID, which is used to access this layer from QgsProjec
%End


QString originalName() const;
%Docstring
Returns the original name of the layer.
:rtype: str
%End

void setShortName( const QString &shortName );
%Docstring
Sets the short name of the layer
Expand Down Expand Up @@ -1184,7 +1177,6 @@ Set error message




bool hasDependencyCycle( const QSet<QgsMapLayerDependency> &layers ) const;
%Docstring
Checks whether a new set of dependencies will introduce a cycle
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -724,7 +724,7 @@ void QgsRasterLayerProperties::sync()
*/

//these properties (layer name and label) are provided by the qgsmaplayer superclass
mLayerOrigNameLineEd->setText( mRasterLayer->originalName() );
mLayerOrigNameLineEd->setText( mRasterLayer->name() );
leDisplayName->setText( mRasterLayer->name() );

//get the thumbnail for the layer
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -432,7 +432,7 @@ void QgsVectorLayerProperties::insertFieldOrExpression()
void QgsVectorLayerProperties::syncToLayer()
{
// populate the general information
mLayerOrigNameLineEdit->setText( mLayer->originalName() );
mLayerOrigNameLineEdit->setText( mLayer->name() );
txtDisplayName->setText( mLayer->name() );
pbnQueryBuilder->setWhatsThis( tr( "This button opens the query "
"builder and allows you to create a subset of features to display on "
Expand Down
11 changes: 2 additions & 9 deletions src/core/qgsmaplayer.cpp
Expand Up @@ -55,7 +55,6 @@ QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
const QString &lyrname,
const QString &source )
: mDataSource( source )
, mLayerOrigName( lyrname ) // store the original name
, mLayerType( type )
, mStyleManager( new QgsMapLayerStyleManager( this ) )
{
Expand Down Expand Up @@ -137,10 +136,9 @@ QString QgsMapLayer::id() const

void QgsMapLayer::setName( const QString &name )
{
if ( name == mLayerOrigName && name == mLayerName )
if ( name == mLayerName )
return;

mLayerOrigName = name;
mLayerName = name;

emit nameChanged();
Expand All @@ -162,11 +160,6 @@ const QgsDataProvider *QgsMapLayer::dataProvider() const
return nullptr;
}

QString QgsMapLayer::originalName() const
{
return mLayerOrigName;
}

QString QgsMapLayer::publicSource() const
{
// Redo this every time we're asked for it, as we don't know if
Expand Down Expand Up @@ -720,7 +713,7 @@ bool QgsMapLayer::writeLayerXml( QDomElement &layerElement, QDomDocument &docume

// layer name
QDomElement layerName = document.createElement( QStringLiteral( "layername" ) );
QDomText layerNameText = document.createTextNode( originalName() );
QDomText layerNameText = document.createTextNode( name() );
layerName.appendChild( layerNameText );
layerElement.appendChild( layerName );

Expand Down
11 changes: 0 additions & 11 deletions src/core/qgsmaplayer.h
Expand Up @@ -138,7 +138,6 @@ class CORE_EXPORT QgsMapLayer : public QObject

/**
* Returns the display name of the layer.
* \returns the layer name
* \see setName()
*/
QString name() const;
Expand All @@ -154,11 +153,6 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
virtual const QgsDataProvider *dataProvider() const SIP_SKIP;

/**
* Returns the original name of the layer.
*/
QString originalName() const;

/**
* Sets the short name of the layer
* used by QGIS Server to identify the layer.
Expand Down Expand Up @@ -1125,11 +1119,6 @@ class CORE_EXPORT QgsMapLayer : public QObject
//! Name of the layer - used for display
QString mLayerName;

/**
* Original name of the layer
*/
QString mLayerOrigName;

QString mShortName;
QString mTitle;

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -194,7 +194,7 @@ QgsVectorLayer::~QgsVectorLayer()

QgsVectorLayer *QgsVectorLayer::clone() const
{
QgsVectorLayer *layer = new QgsVectorLayer( source(), originalName(), mProviderKey );
QgsVectorLayer *layer = new QgsVectorLayer( source(), name(), mProviderKey );
QgsMapLayer::clone( layer );

QList<QgsVectorLayerJoinInfo> joins = vectorJoins();
Expand Down Expand Up @@ -3997,7 +3997,7 @@ QString QgsVectorLayer::htmlMetadata() const
myMetadata += QLatin1String( "<table class=\"list-view\">\n" );

// original name
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Original" ) + QStringLiteral( "</td><td>" ) + originalName() + QStringLiteral( "</td></tr>\n" );
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Original" ) + QStringLiteral( "</td><td>" ) + name() + QStringLiteral( "</td></tr>\n" );

// name
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Name" ) + QStringLiteral( "</td><td>" ) + name() + QStringLiteral( "</td></tr>\n" );
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -146,7 +146,7 @@ QgsRasterLayer::~QgsRasterLayer()

QgsRasterLayer *QgsRasterLayer::clone() const
{
QgsRasterLayer *layer = new QgsRasterLayer( source(), originalName(), mProviderKey );
QgsRasterLayer *layer = new QgsRasterLayer( source(), name(), mProviderKey );
QgsMapLayer::clone( layer );

// do not clone data provider which is the first element in pipe
Expand Down Expand Up @@ -317,7 +317,7 @@ QString QgsRasterLayer::htmlMetadata() const
myMetadata += QLatin1String( "<table class=\"list-view\">\n" );

// original name
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Original" ) + QStringLiteral( "</td><td>" ) + originalName() + QStringLiteral( "</td></tr>\n" );
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Original" ) + QStringLiteral( "</td><td>" ) + name() + QStringLiteral( "</td></tr>\n" );

// name
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Name" ) + QStringLiteral( "</td><td>" ) + name() + QStringLiteral( "</td></tr>\n" );
Expand Down

0 comments on commit 6f55e50

Please sign in to comment.