Bug report #17741
Layer name renamed when loaded
Status: | Closed | ||
---|---|---|---|
Priority: | High | ||
Assignee: | - | ||
Category: | GUI | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | fixed/implemented |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 25637 |
Description
Hello everybody,
if I load any layer that contains underscore _ in the file name, the loaded layer has a different name (underscore replaced by space) and first letters capitalized.
For instance a file named
a_raster_b1
is loaded as
A Raster B1
I think it is related to #17713
If this is a feature please consider removing this because it could create confusion to the user.
Thank you,
Luca
Related issues
Associated revisions
[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)
History
#1 Updated by Ismail Sunni almost 7 years ago
I think it's a feature. I check the code, the is this function to remove the underscore and to capitalize the first letter.
QString QgsMapLayer::formatLayerName( const QString &name ) { QString layerName( name ); layerName.replace( '_', ' ' ); layerName = QgsStringUtils::capitalize( layerName, QgsStringUtils::ForceFirstLetterToCapital ); return layerName; }
I think it should be straight forward to remove the function (or just simply return the same layer name). But I am not sure if it's better to remove the feature or not (perhaps there is pro-reason for this feature)
#2 Updated by Harrissou Santanna almost 7 years ago
To be complete, here's the pull request https://github.com/qgis/QGIS/pull/5608 that made the change and the rationale.
I didn't notice the changes until your message (new loaded layers are indeed renamed). I'd personally love to keep the layers the way I named them in the datasource; actually I've never used the capitalized naming option and prefer to rename layer (if needed) in a (grammatically) comprehensible "title" rather than simply remove underscore (eg for legend).
More information why i'd like to keep the case: I use to retrieve data from partners that have a way to name their data (using capitalized letters - not strict btw) and have to find changes on some area and paste those data in my layers with the same name but always in lower case (with underscore when needed). When all files are in the same project, I can easily identify what is my layer and what is theirs. With the automatic renaming, this would become less obvious imho.
#3 Updated by Luca Congedo almost 7 years ago
I think it should be straight forward to remove the function (or just simply return the same layer name). But I am not sure if it's better to remove the feature or not (perhaps there is pro-reason for this feature)
Thank you Ismail, I think it should be better to remove this function (or at least set this as optional), because it could create confusion.
It also overrides the name when loading a layer through Python APIs.
actually I've never used the capitalized naming option and prefer to rename layer (if needed) in a (grammatically) comprehensible "title" rather than simply remove underscore (eg for legend).
Thank you Harrissou, I agree.
I work with satellite images that have names including underscores. I think that it is always better to leave the original file name.
#4 Updated by Jürgen Fischer almost 7 years ago
- Description updated (diff)
#5 Updated by Jürgen Fischer almost 7 years ago
- Related to Bug report #17713: Layer name case doesn't match entered name or filename when creating new or saving new version of layer added
#6 Updated by Mathieu Pellerin - nIRV almost 7 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset qgis|e3cfbb0805ad5b6c7fec0e38505ac71c7412b894.
#7 Updated by Giovanni Manghi over 6 years ago
- Resolution set to fixed/implemented