Skip to content
Permalink
Browse files

Link metadata widget to canvas

So that child widgets which can take properties from canvas
can have full functionality
  • Loading branch information
nyalldawson committed Jan 2, 2018
1 parent 433d659 commit 21296982e19f5f2b136d4ba600ae8ea9ade685ce
@@ -75,6 +75,11 @@ Returns a list of MIME types available by default in the wizard.
static QMap<QString, QString> parseTypes();
%Docstring
Returns a list of types available by default in the wizard.
%End

void setMapCanvas( QgsMapCanvas *canvas );
%Docstring
Sets a map ``canvas`` associated with the widget.
%End

};
@@ -245,6 +245,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
layout->setMargin( 0 );
mMetadataWidget = new QgsMetadataWidget( this, mRasterLayer );
mMetadataWidget->layout()->setContentsMargins( -1, 0, -1, 0 );
mMetadataWidget->setMapCanvas( mMapCanvas );
layout->addWidget( mMetadataWidget );
metadataFrame->setLayout( layout );

@@ -287,6 +287,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
metadataLayout->setMargin( 0 );
mMetadataWidget = new QgsMetadataWidget( this, mLayer );
mMetadataWidget->layout()->setContentsMargins( -1, 0, -1, 0 );
mMetadataWidget->setMapCanvas( QgisApp::instance()->mapCanvas() );
metadataLayout->addWidget( mMetadataWidget );
metadataFrame->setLayout( metadataLayout );

@@ -28,6 +28,7 @@
#include "qgslogger.h"
#include "qgslayermetadatavalidator.h"
#include "qgsapplication.h"
#include "qgsmapcanvas.h"

QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer )
: QWidget( parent ),
@@ -805,6 +806,12 @@ QMap<QString, QString> QgsMetadataWidget::parseTypes()
return types;
}

void QgsMetadataWidget::setMapCanvas( QgsMapCanvas *canvas )
{
if ( canvas )
spatialExtentSelector->setCurrentExtent( canvas->extent(), canvas->mapSettings().destinationCrs() );
}

void QgsMetadataWidget::acceptMetadata()
{
saveMetadata( mMetadata );
@@ -93,6 +93,11 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg
*/
static QMap<QString, QString> parseTypes();

/**
* Sets a map \a canvas associated with the widget.
*/
void setMapCanvas( QgsMapCanvas *canvas );

private:
void updatePanel() const;
void fillSourceFromLayer() const;

0 comments on commit 2129698

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