Skip to content

Commit

Permalink
Possibility to set a WMS print layer for WMS/WMTS layers in qgis serv…
Browse files Browse the repository at this point in the history
…er. This print layer is then advertized in the GetProjectSettings output
  • Loading branch information
mhugent committed Oct 19, 2017
1 parent ac7e041 commit 9ce7361
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 16 deletions.
13 changes: 13 additions & 0 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -786,6 +786,13 @@ void QgsRasterLayerProperties::sync()
mLayerLegendUrlLineEdit->setText( mRasterLayer->legendUrl() );
mLayerLegendUrlFormatComboBox->setCurrentIndex( mLayerLegendUrlFormatComboBox->findText( mRasterLayer->legendUrlFormat() ) );

//WMS print layer
QVariant wmsPrintLayer = mRasterLayer->customProperty( QStringLiteral( "WMSPrintLayer" ) );
if ( wmsPrintLayer.isValid() )
{
mWMSPrintLayerLineEdit->setText( wmsPrintLayer.toString() );
}

/*
* Legend Tab
*/
Expand Down Expand Up @@ -1013,6 +1020,12 @@ void QgsRasterLayerProperties::apply()
mMetadataFilled = false;
mRasterLayer->setLegendUrlFormat( mLayerLegendUrlFormatComboBox->currentText() );

QString wmsPrintLayer = mWMSPrintLayerLineEdit->text();
if ( !wmsPrintLayer.isEmpty() )
{
mRasterLayer->setCustomProperty( QStringLiteral( "WMSPrintLayer" ), mWMSPrintLayerLineEdit->text() );
}

// update symbology
emit refreshLegend( mRasterLayer->id(), false );

Expand Down
11 changes: 11 additions & 0 deletions src/server/services/wms/qgswmsgetcapabilities.cpp
Expand Up @@ -1692,6 +1692,17 @@ namespace QgsWms

layerElem.appendChild( attributesElem );
}
else if ( currentLayer->type() == QgsMapLayer::RasterLayer )
{
QVariant wmsPrintLayer = currentLayer->customProperty( QStringLiteral( "WMSPrintLayer" ) );
if ( wmsPrintLayer.isValid() )
{
QDomElement wmsPrintLayerElem = doc.createElement( "WMSPrintLayer" );
QDomText wmsPrintLayerText = doc.createTextNode( wmsPrintLayer.toString() );
wmsPrintLayerElem.appendChild( wmsPrintLayerText );
layerElem.appendChild( wmsPrintLayerElem );
}
}
}

}
Expand Down
44 changes: 28 additions & 16 deletions src/ui/qgsrasterlayerpropertiesbase.ui
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>789</width>
<height>593</height>
<width>815</width>
<height>777</height>
</rect>
</property>
<property name="minimumSize">
Expand Down Expand Up @@ -236,7 +236,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>2</number>
<number>9</number>
</property>
<widget class="QWidget" name="mOptsPage_Information">
<layout class="QVBoxLayout" name="verticalLayout_20">
Expand Down Expand Up @@ -272,8 +272,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>608</width>
<height>527</height>
<width>311</width>
<height>106</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
Expand Down Expand Up @@ -392,8 +392,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>545</width>
<height>544</height>
<width>562</width>
<height>578</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
Expand Down Expand Up @@ -1023,8 +1023,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<height>502</height>
<width>371</width>
<height>550</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
Expand Down Expand Up @@ -1476,8 +1476,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>617</width>
<height>199</height>
<width>642</width>
<height>206</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
Expand Down Expand Up @@ -1540,7 +1540,7 @@ border-radius: 2px;</string>
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:12pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Cantarell'; font-size:11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
Expand Down Expand Up @@ -1646,8 +1646,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>85</width>
<height>31</height>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
Expand Down Expand Up @@ -1721,8 +1721,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>383</width>
<height>539</height>
<width>630</width>
<height>724</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_12">
Expand Down Expand Up @@ -2072,6 +2072,18 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="4" column="0">
<widget class="QgsCollapsibleGroupBox" name="mWMSPrintGroupBox">
<property name="title">
<string>WMS Print layer</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLineEdit" name="mWMSPrintLayerLineEdit"/>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down

0 comments on commit 9ce7361

Please sign in to comment.