Skip to content
Permalink
Browse files

Merge pull request #40100 from DelazJ/wmsDialog

Update the Add WM(T)S layers dialog
  • Loading branch information
elpaso committed Nov 20, 2020
2 parents 30e7913 + 3ca1faf commit 0f97ac7b597e3fec63aa45cd288bccada09f3f98
Showing with 70 additions and 60 deletions.
  1. +15 −29 src/providers/wms/qgswmssourceselect.cpp
  2. +1 −1 src/providers/wms/qgswmssourceselect.h
  3. +54 −30 src/ui/qgswmssourceselectbase.ui
@@ -67,7 +67,7 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
connect( btnSave, &QPushButton::clicked, this, &QgsWMSSourceSelect::btnSave_clicked );
connect( btnLoad, &QPushButton::clicked, this, &QgsWMSSourceSelect::btnLoad_clicked );
connect( btnConnect, &QPushButton::clicked, this, &QgsWMSSourceSelect::btnConnect_clicked );
connect( btnChangeSpatialRefSys, &QPushButton::clicked, this, &QgsWMSSourceSelect::btnChangeSpatialRefSys_clicked );
connect( mCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsWMSSourceSelect::crsSelectorChanged );
connect( lstLayers, &QTreeWidget::itemSelectionChanged, this, &QgsWMSSourceSelect::lstLayers_itemSelectionChanged );
connect( cmbConnections, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsWMSSourceSelect::cmbConnections_activated );
connect( lstTilesets, &QTableWidget::itemClicked, this, &QgsWMSSourceSelect::lstTilesets_itemClicked );
@@ -122,10 +122,12 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
if ( currentRefSys.isValid() )
{
mDefaultCRS = mCRS = currentRefSys.authid();
mCrsSelector->setCrs( currentRefSys );
}

// set up the default WMS Coordinate Reference System
labelCoordRefSys->setText( descriptionForAuthId( mCRS ) );
labelCoordRefSys->setDisabled( true );
mCrsSelector->setDisabled( true );

// disable layer order and tilesets until we have some
tabServers->setTabEnabled( tabServers->indexOf( tabLayerOrder ), false );
@@ -635,7 +637,7 @@ void QgsWMSSourceSelect::enableLayersForCrs( QTreeWidgetItem *item )
}
}

void QgsWMSSourceSelect::btnChangeSpatialRefSys_clicked()
void QgsWMSSourceSelect::crsSelectorChanged( const QgsCoordinateReferenceSystem &crs )
{
QStringList layers;
const auto constSelectedItems = lstLayers->selectedItems();
@@ -646,26 +648,7 @@ void QgsWMSSourceSelect::btnChangeSpatialRefSys_clicked()
layers << layer;
}

QgsProjectionSelectionDialog *mySelector = new QgsProjectionSelectionDialog( this );
mySelector->setOgcWmsCrsFilter( mCRSs );

QgsCoordinateReferenceSystem defaultCRS = QgsProject::instance()->crs();
if ( defaultCRS.isValid() )
{
mySelector->setCrs( defaultCRS );
}
else
{
mySelector->showNoCrsForLayerMessage();
}

if ( !mySelector->exec() )
return;

mCRS = mySelector->crs().authid();
delete mySelector;

labelCoordRefSys->setText( descriptionForAuthId( mCRS ) );
mCRS = crs.authid();

for ( int i = 0; i < lstLayers->topLevelItemCount(); i++ )
{
@@ -854,8 +837,9 @@ void QgsWMSSourceSelect::lstLayers_itemSelectionChanged()
}
}

gbCRS->setTitle( tr( "Options (%n coordinate reference systems available)", "crs count", mCRSs.count() ) );
btnChangeSpatialRefSys->setDisabled( mCRSs.isEmpty() );
labelCoordRefSys->setText( tr( "Coordinate Reference System (%n available)", "crs count", mCRSs.count() ) );
labelCoordRefSys->setDisabled( mCRSs.isEmpty() );
mCrsSelector->setDisabled( mCRSs.isEmpty() );

if ( !layers.isEmpty() && !mCRSs.isEmpty() )
{
@@ -882,14 +866,15 @@ void QgsWMSSourceSelect::lstLayers_itemSelectionChanged()
{
// not found
mCRS = defaultCRS;
labelCoordRefSys->setText( descriptionForAuthId( mCRS ) );
mCrsSelector->setCrs( QgsCoordinateReferenceSystem::fromOgcWmsCrs( mCRS ) );
}

}
else if ( layers.isEmpty() || mCRSs.isEmpty() )
{
mCRS.clear();
labelCoordRefSys->clear();
labelCoordRefSys->setText( tr( "Coordinate Reference System" ) );
labelCoordRefSys->setDisabled( true );
}

updateLayerOrderTab( layers, styles, titles );
@@ -956,8 +941,9 @@ void QgsWMSSourceSelect::updateButtons()
}
else
{
gbCRS->setTitle( tr( "Coordinate Reference System (%n available)", "crs count", mCRSs.count() ) );
btnChangeSpatialRefSys->setEnabled( !mCRSs.isEmpty() );
labelCoordRefSys->setText( tr( "Coordinate Reference System (%n available)", "crs count", mCRSs.count() ) );
labelCoordRefSys->setEnabled( !mCRSs.isEmpty() );
mCrsSelector->setEnabled( !mCRSs.isEmpty() );

if ( lstTilesets->selectedItems().isEmpty() )
{
@@ -79,7 +79,7 @@ class QgsWMSSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsWM
void btnConnect_clicked();

//! Opens the Spatial Reference System dialog.
void btnChangeSpatialRefSys_clicked();
void crsSelectorChanged( const QgsCoordinateReferenceSystem &crs );

//! Signaled when a layer selection is changed.
void lstLayers_itemSelectionChanged();
@@ -211,15 +211,19 @@
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Feature limit for GetFeatureInfo</string>
<string>Maximum number of GetFeatureInfo results</string>
</property>
<property name="buddy">
<cstring>mFeatureCount</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mTileWidth"/>
<widget class="QLineEdit" name="mTileWidth">
<property name="toolTip">
<string>Tile width</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="mFeatureCount">
@@ -228,29 +232,13 @@
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="btnChangeSpatialRefSys">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Change…</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="labelCoordRefSys">
<property name="text">
<string>Coordinate Reference System</string>
</property>
<property name="buddy">
<cstring>btnChangeSpatialRefSys</cstring>
<item row="1" column="2">
<widget class="QLineEdit" name="mTileHeight">
<property name="toolTip">
<string>Tile height</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="mTileHeight"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
@@ -262,10 +250,32 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="mStepWidth"/>
<widget class="QLineEdit" name="mStepWidth">
<property name="toolTip">
<string>Step width</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="mStepHeight"/>
<widget class="QLineEdit" name="mStepHeight">
<property name="toolTip">
<string>Step height</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="labelCoordRefSys">
<property name="text">
<string>Coordinate Reference System</string>
</property>
</widget>
</item>
</layout>
</widget>
@@ -329,7 +339,7 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="showSearchIcon">
<property name="showSearchIcon" stdset="0">
<bool>true</bool>
</property>
<property name="qgisRelation" stdset="0">
@@ -480,7 +490,7 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="showSearchIcon">
<property name="showSearchIcon" stdset="0">
<bool>true</bool>
</property>
<property name="qgisRelation" stdset="0">
@@ -503,23 +513,37 @@
<extends>QLineEdit</extends>
<header>qgsfilterlineedit.h</header>
</customwidget>
<customwidget>
<class>QgsProjectionSelectionWidget</class>
<extends>QWidget</extends>
<header>qgsprojectionselectionwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabServers</tabstop>
<tabstop>cmbConnections</tabstop>
<tabstop>btnConnect</tabstop>
<tabstop>btnNew</tabstop>
<tabstop>btnEdit</tabstop>
<tabstop>btnDelete</tabstop>
<tabstop>btnLoad</tabstop>
<tabstop>btnSave</tabstop>
<tabstop>mLayersFilterLineEdit</tabstop>
<tabstop>lstLayers</tabstop>
<tabstop>mTileWidth</tabstop>
<tabstop>mTileHeight</tabstop>
<tabstop>mStepWidth</tabstop>
<tabstop>mStepHeight</tabstop>
<tabstop>mFeatureCount</tabstop>
<tabstop>btnChangeSpatialRefSys</tabstop>
<tabstop>mCrsSelector</tabstop>
<tabstop>mContextualLegendCheckbox</tabstop>
<tabstop>leLayerName</tabstop>
<tabstop>lstTilesets</tabstop>
<tabstop>mLayerOrderTreeWidget</tabstop>
<tabstop>mLayerDownButton</tabstop>
<tabstop>mLayerUpButton</tabstop>
<tabstop>mLayerDownButton</tabstop>
<tabstop>mLayerOrderTreeWidget</tabstop>
<tabstop>mTilesetsFilterLineEdit</tabstop>
<tabstop>lstTilesets</tabstop>
</tabstops>
<resources/>
<connections>

0 comments on commit 0f97ac7

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