mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
remove CRS picker and allow only layer CRS or provider CRS in metadata editor (#5915)
This commit is contained in:
parent
3c7f745424
commit
9a5435ff1e
@ -50,6 +50,9 @@ using QgsNativeMetadataValidator.
|
||||
QgsCoordinateReferenceSystem extentCrs;
|
||||
%Docstring
|
||||
Coordinate reference system for spatial extent.
|
||||
The CRS should match the CRS defined in the QgsLayerMetadata CRS property.
|
||||
|
||||
.. seealso:: :py:func:`QgsLayerMetadata.crs()`
|
||||
|
||||
.. seealso:: :py:func:`spatial`
|
||||
%End
|
||||
@ -505,6 +508,11 @@ CRS which is actually used to display and manipulate the layer within QGIS.
|
||||
This may be the case when a layer has an incorrect CRS within its metadata
|
||||
and a user has manually overridden the layer's CRS within QGIS.
|
||||
|
||||
The CRS described here should either match the CRS from the layer QgsMapLayer.crs()
|
||||
or the CRS from the data provider.
|
||||
|
||||
This property should also match the CRS property used in the spatial extent.
|
||||
|
||||
.. seealso:: :py:func:`setCrs()`
|
||||
%End
|
||||
|
||||
@ -523,6 +531,11 @@ CRS which is actually used to display and manipulate the layer within QGIS.
|
||||
This may be the case when a layer has an incorrect CRS within its metadata
|
||||
and a user has manually overridden the layer's CRS within QGIS.
|
||||
|
||||
The CRS described here should either match the CRS from the layer QgsMapLayer.crs()
|
||||
or the CRS from the data provider.
|
||||
|
||||
This property should also match the CRS property used in the spatial extent.
|
||||
|
||||
.. seealso:: :py:func:`crs()`
|
||||
%End
|
||||
|
||||
|
@ -36,6 +36,11 @@ Save all fields in a QgsLayerMetadata object.
|
||||
bool checkMetadata() const;
|
||||
%Docstring
|
||||
Check if values in the wizard are correct.
|
||||
%End
|
||||
|
||||
void crsChanged() const;
|
||||
%Docstring
|
||||
If the CRS is updated.
|
||||
%End
|
||||
|
||||
void acceptMetadata();
|
||||
|
@ -1223,6 +1223,7 @@ void QgsRasterLayerProperties::mCrsSelector_crsChanged( const QgsCoordinateRefer
|
||||
{
|
||||
QgisApp::instance()->askUserForDatumTransform( crs, QgsProject::instance()->crs() );
|
||||
mRasterLayer->setCrs( crs );
|
||||
mMetadataWidget->crsChanged();
|
||||
}
|
||||
|
||||
void QgsRasterLayerProperties::pbnDefaultValues_clicked()
|
||||
|
@ -834,6 +834,7 @@ void QgsVectorLayerProperties::mCrsSelector_crsChanged( const QgsCoordinateRefer
|
||||
QgisApp::instance()->askUserForDatumTransform( crs, QgsProject::instance()->crs() );
|
||||
mLayer->setCrs( crs );
|
||||
mMetadataFilled = false;
|
||||
mMetadataWidget->crsChanged();
|
||||
}
|
||||
|
||||
void QgsVectorLayerProperties::loadDefaultStyle_clicked()
|
||||
|
@ -69,6 +69,8 @@ class CORE_EXPORT QgsLayerMetadata
|
||||
|
||||
/**
|
||||
* Coordinate reference system for spatial extent.
|
||||
* The CRS should match the CRS defined in the QgsLayerMetadata CRS property.
|
||||
* \see QgsLayerMetadata::crs()
|
||||
* \see spatial
|
||||
*/
|
||||
QgsCoordinateReferenceSystem extentCrs;
|
||||
@ -535,6 +537,12 @@ class CORE_EXPORT QgsLayerMetadata
|
||||
* CRS which is actually used to display and manipulate the layer within QGIS.
|
||||
* This may be the case when a layer has an incorrect CRS within its metadata
|
||||
* and a user has manually overridden the layer's CRS within QGIS.
|
||||
*
|
||||
* The CRS described here should either match the CRS from the layer QgsMapLayer::crs()
|
||||
* or the CRS from the data provider.
|
||||
*
|
||||
* This property should also match the CRS property used in the spatial extent.
|
||||
*
|
||||
* \see setCrs()
|
||||
*/
|
||||
QgsCoordinateReferenceSystem crs() const;
|
||||
@ -552,6 +560,12 @@ class CORE_EXPORT QgsLayerMetadata
|
||||
* CRS which is actually used to display and manipulate the layer within QGIS.
|
||||
* This may be the case when a layer has an incorrect CRS within its metadata
|
||||
* and a user has manually overridden the layer's CRS within QGIS.
|
||||
*
|
||||
* The CRS described here should either match the CRS from the layer QgsMapLayer::crs()
|
||||
* or the CRS from the data provider.
|
||||
*
|
||||
* This property should also match the CRS property used in the spatial extent.
|
||||
*
|
||||
* \see crs()
|
||||
*/
|
||||
void setCrs( const QgsCoordinateReferenceSystem &crs );
|
||||
|
@ -66,7 +66,6 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer )
|
||||
tabConstraints->setItemDelegate( new ConstraintItemDelegate( this ) );
|
||||
|
||||
// Extent
|
||||
selectionCrs->setOptionVisible( QgsProjectionSelectionWidget::CrsNotSet, true );
|
||||
dateTimeFrom->setAllowNull( true );
|
||||
dateTimeTo->setAllowNull( true );
|
||||
|
||||
@ -94,8 +93,8 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer )
|
||||
connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedLicence );
|
||||
connect( btnAddConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::addConstraint );
|
||||
connect( btnRemoveConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedConstraint );
|
||||
connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWidget::fillCrsFromLayer );
|
||||
connect( selectionCrs, &QgsProjectionSelectionWidget::crsChanged, this, &QgsMetadataWidget::toggleExtentSelector );
|
||||
connect( btnSetCrsFromLayer, &QPushButton::clicked, this, &QgsMetadataWidget::fillCrsFromLayer );
|
||||
connect( btnSetCrsFromProvider, &QPushButton::clicked, this, &QgsMetadataWidget::fillCrsFromProvider );
|
||||
connect( btnAddAddress, &QPushButton::clicked, this, &QgsMetadataWidget::addAddress );
|
||||
connect( btnRemoveAddress, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedAddress );
|
||||
connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWidget::addLink );
|
||||
@ -200,10 +199,37 @@ void QgsMetadataWidget::removeSelectedConstraint() const
|
||||
mConstraintsModel->removeRow( selectedRows[0].row() );
|
||||
}
|
||||
|
||||
void QgsMetadataWidget::toggleExtentSelector() const
|
||||
void QgsMetadataWidget::crsChanged() const
|
||||
{
|
||||
spatialExtentSelector->setEnabled( selectionCrs->crs().isValid() );
|
||||
spatialExtentSelector->setOutputCrs( selectionCrs->crs() );
|
||||
if ( mCrs.isValid() )
|
||||
{
|
||||
lblCurrentCrs->setText( tr( "CRS: %1 - %2" ).arg( mCrs.authid(), mCrs.description() ) );
|
||||
spatialExtentSelector->setEnabled( true );
|
||||
spatialExtentSelector->setOutputCrs( mCrs );
|
||||
|
||||
if ( mCrs == mLayer->crs() && mCrs == mLayer->dataProvider()->crs() )
|
||||
{
|
||||
lblCurrentCrsStatus->setText( tr( "Same as layer properties and provider." ) );
|
||||
}
|
||||
else if ( mCrs == mLayer->crs() && mCrs != mLayer->dataProvider()->crs() )
|
||||
{
|
||||
lblCurrentCrsStatus->setText( tr( "Same as layer properties but different than the provider." ) );
|
||||
}
|
||||
else if ( mCrs != mLayer->crs() && mCrs == mLayer->dataProvider()->crs() )
|
||||
{
|
||||
lblCurrentCrsStatus->setText( tr( "Same as the provider but different than the layer properties." ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
lblCurrentCrsStatus->setText( tr( "Does not match either layer properties or the provider." ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lblCurrentCrs->setText( tr( "CRS: Not set." ) );
|
||||
lblCurrentCrsStatus->setText( QString() );
|
||||
spatialExtentSelector->setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMetadataWidget::addAddress() const
|
||||
@ -242,9 +268,16 @@ void QgsMetadataWidget::removeSelectedAddress() const
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMetadataWidget::fillCrsFromLayer() const
|
||||
void QgsMetadataWidget::fillCrsFromLayer()
|
||||
{
|
||||
selectionCrs->setCrs( mLayer->crs() );
|
||||
mCrs = mLayer->crs();
|
||||
crsChanged();
|
||||
}
|
||||
|
||||
void QgsMetadataWidget::fillCrsFromProvider()
|
||||
{
|
||||
mCrs = mLayer->dataProvider()->crs();
|
||||
crsChanged();
|
||||
}
|
||||
|
||||
void QgsMetadataWidget::addLink() const
|
||||
@ -322,7 +355,7 @@ void QgsMetadataWidget::fillComboBox() const
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMetadataWidget::setPropertiesFromLayer() const
|
||||
void QgsMetadataWidget::setPropertiesFromLayer()
|
||||
{
|
||||
// Parent ID
|
||||
lineEditParentId->setText( mMetadata.parentIdentifier() );
|
||||
@ -409,11 +442,8 @@ void QgsMetadataWidget::setPropertiesFromLayer() const
|
||||
}
|
||||
|
||||
// CRS
|
||||
if ( mMetadata.crs().isValid() )
|
||||
{
|
||||
selectionCrs->setCrs( mMetadata.crs() );
|
||||
}
|
||||
toggleExtentSelector();
|
||||
mCrs = mMetadata.crs();
|
||||
crsChanged();
|
||||
|
||||
// Spatial extent
|
||||
const QList<QgsLayerMetadata::SpatialExtent> &spatialExtents = mMetadata.extent().spatialExtents();
|
||||
@ -534,7 +564,10 @@ void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) const
|
||||
layerMetadata.setConstraints( constraints );
|
||||
|
||||
// CRS
|
||||
layerMetadata.setCrs( selectionCrs->crs() );
|
||||
if ( mCrs.isValid() )
|
||||
{
|
||||
layerMetadata.setCrs( mCrs );
|
||||
}
|
||||
|
||||
// Extent
|
||||
struct QgsLayerMetadata::SpatialExtent spatialExtent = QgsLayerMetadata::SpatialExtent();
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "QStyledItemDelegate"
|
||||
|
||||
#include "qgis_gui.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgsdataprovider.h"
|
||||
#include "qgsmaplayer.h"
|
||||
#include "qgslayermetadata.h"
|
||||
#include "ui_qgsmetadatawidget.h"
|
||||
@ -54,6 +56,11 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg
|
||||
*/
|
||||
bool checkMetadata() const;
|
||||
|
||||
/**
|
||||
* If the CRS is updated.
|
||||
*/
|
||||
void crsChanged() const;
|
||||
|
||||
/**
|
||||
* Saves the metadata to the layer.
|
||||
*/
|
||||
@ -89,7 +96,8 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg
|
||||
private:
|
||||
void updatePanel() const;
|
||||
void fillSourceFromLayer() const;
|
||||
void fillCrsFromLayer() const;
|
||||
void fillCrsFromLayer();
|
||||
void fillCrsFromProvider();
|
||||
void addDefaultCategory() const;
|
||||
void addNewCategory();
|
||||
void removeSelectedCategory() const;
|
||||
@ -101,7 +109,6 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg
|
||||
void removeSelectedRight() const;
|
||||
void addConstraint() const;
|
||||
void removeSelectedConstraint() const;
|
||||
void toggleExtentSelector() const;
|
||||
void addAddress() const;
|
||||
void removeSelectedAddress() const;
|
||||
void addLink() const;
|
||||
@ -109,10 +116,11 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg
|
||||
void addHistory();
|
||||
void removeSelectedHistory() const;
|
||||
void fillComboBox() const;
|
||||
void setPropertiesFromLayer() const;
|
||||
void setPropertiesFromLayer();
|
||||
void syncFromCategoriesTabToKeywordsTab() const;
|
||||
QStringList mDefaultCategories;
|
||||
QgsMapLayer *mLayer = nullptr;
|
||||
QgsCoordinateReferenceSystem mCrs;
|
||||
QgsLayerMetadata mMetadata;
|
||||
QStandardItemModel *mConstraintsModel = nullptr;
|
||||
QStandardItemModel *mLinksModel = nullptr;
|
||||
|
@ -818,10 +818,14 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QgsProjectionSelectionWidget" name="selectionCrs" native="true"/>
|
||||
<widget class="QLabel" name="lblCurrentCrs">
|
||||
<property name="text">
|
||||
<string notr="true">CRS label set in cpp code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnAutoCrs">
|
||||
<widget class="QPushButton" name="btnSetCrsFromLayer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -833,8 +837,28 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSetCrsFromProvider">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set CRS from provider</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblCurrentCrsStatus">
|
||||
<property name="text">
|
||||
<string notr="true">CRS status set in cpp code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1370,12 +1394,6 @@
|
||||
<header>qgscollapsiblegroupbox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsProjectionSelectionWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qgsprojectionselectionwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsExtentGroupBox</class>
|
||||
<extends>QGroupBox</extends>
|
||||
|
Loading…
x
Reference in New Issue
Block a user