17#include "moc_qgsmaplayerserverpropertieswidget.cpp"
22#include <QRegularExpressionValidator>
23#include <QStandardItemModel>
29 connect( buttonRemoveMetadataUrl, &QPushButton::clicked,
this, &QgsMapLayerServerPropertiesWidget::removeSelectedMetadataUrl );
30 connect( buttonAddMetadataUrl, &QPushButton::clicked,
this, &QgsMapLayerServerPropertiesWidget::addMetadataUrl );
35 mServerProperties = serverProperties;
42 mLayerOptWfsTitleLineEdit->setVisible( mHasWfsTitle );
43 mLayerOptWfsTitleLabel->setVisible( mHasWfsTitle );
53 if ( !mServerProperties )
56 bool hasChanged = mServerProperties->
shortName() != mLayerShortNameLineEdit->text()
57 || mServerProperties->
title() != mLayerTitleLineEdit->text()
58 || mServerProperties->
abstract() != mLayerAbstractTextEdit->toPlainText()
59 || mServerProperties->
keywordList() != mLayerKeywordListLineEdit->text()
60 || mServerProperties->
dataUrl() != mLayerDataUrlLineEdit->text()
61 || mServerProperties->
dataUrlFormat() != mLayerDataUrlFormatComboBox->currentText()
62 || mServerProperties->
attribution() != mLayerAttributionLineEdit->text()
63 || mServerProperties->
attributionUrl() != mLayerAttributionUrlLineEdit->text()
64 || mServerProperties->
legendUrl() != mLayerLegendUrlLineEdit->text()
65 || mServerProperties->
legendUrlFormat() != mLayerLegendUrlFormatComboBox->currentText();
67 mServerProperties->
setShortName( mLayerShortNameLineEdit->text() );
68 mServerProperties->
setTitle( mLayerTitleLineEdit->text() );
69 mServerProperties->
setAbstract( mLayerAbstractTextEdit->toPlainText() );
70 mServerProperties->
setKeywordList( mLayerKeywordListLineEdit->text() );
71 mServerProperties->
setDataUrl( mLayerDataUrlLineEdit->text() );
72 mServerProperties->
setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );
73 mServerProperties->
setAttribution( mLayerAttributionLineEdit->text() );
75 mServerProperties->
setLegendUrl( mLayerLegendUrlLineEdit->text() );
78 if ( !mLayerOptWfsTitleLineEdit->text().isEmpty() && mLayerOptWfsTitleLineEdit->text() != mLayerTitleLineEdit->text() )
80 mServerProperties->
setWfsTitle( mLayerOptWfsTitleLineEdit->text() );
89 QList<QgsMapLayerServerProperties::MetadataUrl> metaUrls;
90 for (
int row = 0; row < mMetadataUrlModel->rowCount(); row++ )
93 metaUrl.
url = mMetadataUrlModel->item( row, 0 )->text();
94 metaUrl.
type = mMetadataUrlModel->item( row, 1 )->text();
95 metaUrl.
format = mMetadataUrlModel->item( row, 2 )->text();
96 metaUrls.append( metaUrl );
108 if ( !mServerProperties )
112 mLayerShortNameLineEdit->setText( mServerProperties->
shortName() );
115 mLayerShortNameLineEdit->setValidator( shortNameValidator );
118 mLayerTitleLineEdit->setText( mServerProperties->
title() );
120 if ( mServerProperties->
wfsTitle() != mServerProperties->
title() )
121 mLayerOptWfsTitleLineEdit->setText( mServerProperties->
wfsTitle() );
123 mLayerAbstractTextEdit->setPlainText( mServerProperties->
abstract() );
124 mLayerKeywordListLineEdit->setText( mServerProperties->
keywordList() );
125 mLayerDataUrlLineEdit->setText( mServerProperties->
dataUrl() );
126 mLayerDataUrlFormatComboBox->setCurrentIndex(
127 mLayerDataUrlFormatComboBox->findText(
132 mLayerAttributionLineEdit->setText( mServerProperties->
attribution() );
133 mLayerAttributionUrlLineEdit->setText( mServerProperties->
attributionUrl() );
136 tableViewMetadataUrl->setSelectionMode( QAbstractItemView::SingleSelection );
137 tableViewMetadataUrl->setSelectionBehavior( QAbstractItemView::SelectRows );
138 tableViewMetadataUrl->horizontalHeader()->setStretchLastSection(
true );
139 tableViewMetadataUrl->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch );
141 mMetadataUrlModel =
new QStandardItemModel( tableViewMetadataUrl );
142 mMetadataUrlModel->clear();
143 mMetadataUrlModel->setColumnCount( 3 );
144 QStringList metadataUrlHeaders;
145 metadataUrlHeaders << tr(
"URL" ) << tr(
"Type" ) << tr(
"Format" );
146 mMetadataUrlModel->setHorizontalHeaderLabels( metadataUrlHeaders );
147 tableViewMetadataUrl->setModel( mMetadataUrlModel );
148 tableViewMetadataUrl->setItemDelegate(
new MetadataUrlItemDelegate(
this ) );
150 const QList<QgsMapLayerServerProperties::MetadataUrl> &metaUrls = mServerProperties->
metadataUrls();
153 const int row = mMetadataUrlModel->rowCount();
154 mMetadataUrlModel->setItem( row, 0,
new QStandardItem( metaUrl.url ) );
155 mMetadataUrlModel->setItem( row, 1,
new QStandardItem( metaUrl.type ) );
156 mMetadataUrlModel->setItem( row, 2,
new QStandardItem( metaUrl.format ) );
160 mLayerLegendUrlLineEdit->setText( mServerProperties->
legendUrl() );
161 mLayerLegendUrlFormatComboBox->setCurrentIndex(
162 mLayerLegendUrlFormatComboBox->findText(
168void QgsMapLayerServerPropertiesWidget::addMetadataUrl()
170 const int row = mMetadataUrlModel->rowCount();
171 mMetadataUrlModel->setItem( row, 0,
new QStandardItem( QLatin1String() ) );
172 mMetadataUrlModel->setItem( row, 1,
new QStandardItem( QLatin1String() ) );
173 mMetadataUrlModel->setItem( row, 2,
new QStandardItem( QLatin1String() ) );
176void QgsMapLayerServerPropertiesWidget::removeSelectedMetadataUrl()
178 const QModelIndexList selectedRows = tableViewMetadataUrl->selectionModel()->selectedRows();
179 if ( selectedRows.empty() )
181 mMetadataUrlModel->removeRow( selectedRows[0].row() );
static QRegularExpression shortNameRegularExpression()
Returns the short name regular expression for line edit validator.
Manages QGIS Server properties for a map layer.
void setLegendUrl(const QString &legendUrl)
Sets the URL for the layer's legend.
void setDataUrl(const QString &dataUrl)
Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request.
void setAbstract(const QString &abstract)
Sets the abstract of the layer used by QGIS Server in GetCapabilities request.
void setDataUrlFormat(const QString &dataUrlFormat)
Sets the DataUrl format of the layerused by QGIS Server in GetCapabilities request.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
void setAttributionUrl(const QString &url)
Sets the attribution url of the layer used by QGIS Server in GetCapabilities request.
QString dataUrlFormat() const
Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request.
void setAttribution(const QString &attrib)
Sets the attribution of the layer used by QGIS Server in GetCapabilities request.
void setShortName(const QString &name)
Sets the short name of the layer used by QGIS Server to identify the layer.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
void setLegendUrlFormat(const QString &legendUrlFormat)
Sets the format for a URL based layer legend.
QString legendUrlFormat() const
Returns the format for a URL based layer legend.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QString keywordList() const
Returns the keyword list of the layerused by QGIS Server in GetCapabilities request.
QString wfsTitle() const
Returns the optional WFS title if set or the title of the layer used by QGIS WFS in GetCapabilities r...
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
void setTitle(const QString &title)
Sets the title of the layer used by QGIS Server in GetCapabilities request.
void setKeywordList(const QString &keywords)
Sets the keywords list of the layerused by QGIS Server in GetCapabilities request.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
void setWfsTitle(const QString &title)
Sets the title of the layer used by QGIS Server in WFS GetCapabilities request.
QString legendUrl() const
Returns the URL for the layer's legend.
QString abstract() const
Returns the abstract of the layerused by QGIS Server in GetCapabilities request.