Skip to content
Permalink
Browse files

[BUGFIX] The way layer's shortname is write in QGIS project and used …

…in QGIS Server
  • Loading branch information
rldhont committed Apr 21, 2016
1 parent e6bb623 commit 32000628a066123f5d6b967ae423d66127f3c52f
Showing with 26 additions and 15 deletions.
  1. +25 −14 src/core/qgsmaplayer.cpp
  2. +1 −1 src/server/qgsserverprojectparser.cpp
@@ -69,6 +69,9 @@ QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
mLayerName = capitaliseLayerName( mLayerOrigName );
QgsDebugMsg( "display name: '" + mLayerName + '\'' );

mShortName = "";
//mShortName.replace( QRegExp( "[\\W]" ), "_" );

// Generate the unique ID of this layer
QDateTime dt = QDateTime::currentDateTime();
mID = lyrname + dt.toString( "yyyyMMddhhmmsszzz" );
@@ -653,26 +656,34 @@ bool QgsMapLayer::writeLayerXML( QDomElement& layerElement, QDomDocument& docume
QDomElement layerName = document.createElement( "layername" );
QDomText layerNameText = document.createTextNode( originalName() );
layerName.appendChild( layerNameText );
layerElement.appendChild( layerName );

// layer short name
QDomElement layerShortName = document.createElement( "shortname" );
QDomText layerShortNameText = document.createTextNode( shortName() );
layerShortName.appendChild( layerShortNameText );
if ( !mShortName.isEmpty() )
{
QDomElement layerShortName = document.createElement( "shortname" );
QDomText layerShortNameText = document.createTextNode( mShortName );
layerShortName.appendChild( layerShortNameText );
layerElement.appendChild( layerShortName );
}

// layer title
QDomElement layerTitle = document.createElement( "title" );
QDomText layerTitleText = document.createTextNode( title() );
layerTitle.appendChild( layerTitleText );
if ( !mTitle.isEmpty() )
{
QDomElement layerTitle = document.createElement( "title" );
QDomText layerTitleText = document.createTextNode( mTitle );
layerTitle.appendChild( layerTitleText );
layerElement.appendChild( layerTitle );
}

// layer abstract
QDomElement layerAbstract = document.createElement( "abstract" );
QDomText layerAbstractText = document.createTextNode( abstract() );
layerAbstract.appendChild( layerAbstractText );

layerElement.appendChild( layerName );
layerElement.appendChild( layerShortName );
layerElement.appendChild( layerTitle );
layerElement.appendChild( layerAbstract );
if ( !mAbstract.isEmpty() )
{
QDomElement layerAbstract = document.createElement( "abstract" );
QDomText layerAbstractText = document.createTextNode( mAbstract );
layerAbstract.appendChild( layerAbstractText );
layerElement.appendChild( layerAbstract );
}

// layer keyword list
QStringList keywordStringList = keywordList().split( ',' );
@@ -50,7 +50,7 @@ QgsServerProjectParser::QgsServerProjectParser( QDomDocument* xmlDoc, const QStr
currentElement = layerNodeList.at( i ).toElement();
mProjectLayerElements.push_back( currentElement );
QString lName = layerShortName( currentElement );
if ( lName.isNull() )
if ( lName.isEmpty() )
lName = layerName( currentElement );
mProjectLayerElementsByName.insert( lName, currentElement );
mProjectLayerElementsById.insert( layerId( currentElement ), currentElement );

0 comments on commit 3200062

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