mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Add project metadata mode to QgsMetadataWidget
This commit is contained in:
parent
b10be8a8a3
commit
f4ed93e1ca
@ -39,6 +39,14 @@ using QgsNativeMetadataValidator.
|
|||||||
|
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include "qgsabstractmetadatabase.h"
|
#include "qgsabstractmetadatabase.h"
|
||||||
|
%End
|
||||||
|
%ConvertToSubClassCode
|
||||||
|
if ( dynamic_cast< QgsLayerMetadata * >( sipCpp ) != NULL )
|
||||||
|
sipType = sipType_QgsLayerMetadata;
|
||||||
|
else if ( dynamic_cast< QgsLayerMetadata * >( sipCpp ) != NULL )
|
||||||
|
sipType = sipType_QgsProjectMetadata;
|
||||||
|
else
|
||||||
|
sipType = NULL;
|
||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -127,6 +135,13 @@ Constructor for Link.
|
|||||||
|
|
||||||
virtual ~QgsAbstractMetadataBase();
|
virtual ~QgsAbstractMetadataBase();
|
||||||
|
|
||||||
|
virtual QgsAbstractMetadataBase *clone() const = 0 /Factory/;
|
||||||
|
%Docstring
|
||||||
|
Clones the metadata object.
|
||||||
|
|
||||||
|
.. versionadded:: 3.2
|
||||||
|
%End
|
||||||
|
|
||||||
QString identifier() const;
|
QString identifier() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
A reference, URI, URL or some other mechanism to identify the resource.
|
A reference, URI, URL or some other mechanism to identify the resource.
|
||||||
|
@ -115,6 +115,9 @@ Constructor for Constraint.
|
|||||||
Constructor for QgsLayerMetadata.
|
Constructor for QgsLayerMetadata.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
virtual QgsLayerMetadata *clone() const /Factory/;
|
||||||
|
|
||||||
|
|
||||||
QString fees() const;
|
QString fees() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns any fees associated with using the resource.
|
Returns any fees associated with using the resource.
|
||||||
|
@ -46,6 +46,9 @@ using QgsNativeProjectMetadataValidator.
|
|||||||
Constructor for QgsProjectMetadata.
|
Constructor for QgsProjectMetadata.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
virtual QgsProjectMetadata *clone() const /Factory/;
|
||||||
|
|
||||||
|
|
||||||
QString author() const;
|
QString author() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns the project author string.
|
Returns the project author string.
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QgsAbstractMetadataBaseWidget : QWidget
|
class QgsMetadataWidget : QWidget
|
||||||
{
|
{
|
||||||
%Docstring
|
%Docstring
|
||||||
A wizard to edit metadata on a map layer.
|
A wizard to edit metadata on a map layer.
|
||||||
@ -23,7 +23,13 @@ class QgsAbstractMetadataBaseWidget : QWidget
|
|||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QgsAbstractMetadataBaseWidget( QWidget *parent, QgsMapLayer *layer = 0 );
|
enum Mode
|
||||||
|
{
|
||||||
|
LayerMetadata,
|
||||||
|
ProjectMetadata,
|
||||||
|
};
|
||||||
|
|
||||||
|
QgsMetadataWidget( QWidget *parent /TransferThis/ = 0, QgsMapLayer *layer = 0 );
|
||||||
%Docstring
|
%Docstring
|
||||||
Constructor for the wizard.
|
Constructor for the wizard.
|
||||||
|
|
||||||
@ -33,26 +39,49 @@ the layer's metadata..
|
|||||||
.. seealso:: :py:func:`setMetadata`
|
.. seealso:: :py:func:`setMetadata`
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setMetadata( const QgsLayerMetadata &metadata );
|
void setMode( Mode mode );
|
||||||
|
%Docstring
|
||||||
|
Sets the widget's current ``mode``.
|
||||||
|
|
||||||
|
.. versionadded:: 3.2
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`mode`
|
||||||
|
%End
|
||||||
|
|
||||||
|
Mode mode() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the widget's current mode.
|
||||||
|
|
||||||
|
.. versionadded:: 3.2
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`setMode`
|
||||||
|
%End
|
||||||
|
|
||||||
|
void setMetadata( const QgsAbstractMetadataBase *metadata );
|
||||||
%Docstring
|
%Docstring
|
||||||
Sets the ``metadata`` to display in the widget.
|
Sets the ``metadata`` to display in the widget.
|
||||||
|
|
||||||
This method can be called after constructing a QgsAbstractMetadataBaseWidget in order
|
This method can be called after constructing a QgsAbstractMetadataBaseWidget in order
|
||||||
to set the displayed metadata to custom, non-layer based metadata.
|
to set the displayed metadata to custom, non-layer based metadata.
|
||||||
|
|
||||||
|
Calling this method will automatically setMode() to the correct mode corresponding
|
||||||
|
to the specified ``metadata`` object.
|
||||||
|
|
||||||
.. seealso:: :py:func:`metadata`
|
.. seealso:: :py:func:`metadata`
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QgsLayerMetadata metadata();
|
QgsAbstractMetadataBase *metadata() /Factory/;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns a QgsLayerMetadata object representing the current state of the widget.
|
Returns a QgsAbstractMetadataBase object representing the current state of the widget.
|
||||||
|
|
||||||
|
Caller takes ownership of the returned object.
|
||||||
|
|
||||||
.. seealso:: :py:func:`saveMetadata`
|
.. seealso:: :py:func:`saveMetadata`
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void saveMetadata( QgsLayerMetadata &layerMetadata );
|
void saveMetadata( QgsAbstractMetadataBase *metadata );
|
||||||
%Docstring
|
%Docstring
|
||||||
Save all fields in a QgsLayerMetadata object.
|
Save all fields in a metadata object.
|
||||||
|
|
||||||
.. seealso:: :py:func:`metadata`
|
.. seealso:: :py:func:`metadata`
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv
|
|||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout( metadataFrame );
|
QVBoxLayout *layout = new QVBoxLayout( metadataFrame );
|
||||||
layout->setMargin( 0 );
|
layout->setMargin( 0 );
|
||||||
mMetadataWidget = new QgsAbstractMetadataBaseWidget( this, mRasterLayer );
|
mMetadataWidget = new QgsMetadataWidget( this, mRasterLayer );
|
||||||
mMetadataWidget->layout()->setContentsMargins( -1, 0, -1, 0 );
|
mMetadataWidget->layout()->setContentsMargins( -1, 0, -1, 0 );
|
||||||
mMetadataWidget->setMapCanvas( mMapCanvas );
|
mMetadataWidget->setMapCanvas( mMapCanvas );
|
||||||
layout->addWidget( mMetadataWidget );
|
layout->addWidget( mMetadataWidget );
|
||||||
@ -1903,7 +1903,7 @@ void QgsRasterLayerProperties::loadMetadata()
|
|||||||
//reset if the default style was loaded OK only
|
//reset if the default style was loaded OK only
|
||||||
if ( defaultLoadedFlag )
|
if ( defaultLoadedFlag )
|
||||||
{
|
{
|
||||||
mMetadataWidget->setMetadata( mRasterLayer->metadata() );
|
mMetadataWidget->setMetadata( &mRasterLayer->metadata() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1965,7 +1965,7 @@ void QgsRasterLayerProperties::loadDefaultMetadata()
|
|||||||
//reset if the default metadata was loaded OK only
|
//reset if the default metadata was loaded OK only
|
||||||
if ( defaultLoadedFlag )
|
if ( defaultLoadedFlag )
|
||||||
{
|
{
|
||||||
mMetadataWidget->setMetadata( mRasterLayer->metadata() );
|
mMetadataWidget->setMetadata( &mRasterLayer->metadata() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ class QgsPointXY;
|
|||||||
class QgsMapLayer;
|
class QgsMapLayer;
|
||||||
class QgsMapCanvas;
|
class QgsMapCanvas;
|
||||||
class QgsRasterLayer;
|
class QgsRasterLayer;
|
||||||
class QgsAbstractMetadataBaseWidget;
|
class QgsMetadataWidget;
|
||||||
class QgsRasterRenderer;
|
class QgsRasterRenderer;
|
||||||
class QgsRasterRendererWidget;
|
class QgsRasterRendererWidget;
|
||||||
class QgsRasterHistogramWidget;
|
class QgsRasterHistogramWidget;
|
||||||
@ -181,7 +181,7 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
|
|||||||
//bool mRasterLayerIsInternal;
|
//bool mRasterLayerIsInternal;
|
||||||
|
|
||||||
QgsRasterRendererWidget *mRendererWidget = nullptr;
|
QgsRasterRendererWidget *mRendererWidget = nullptr;
|
||||||
QgsAbstractMetadataBaseWidget *mMetadataWidget = nullptr;
|
QgsMetadataWidget *mMetadataWidget = nullptr;
|
||||||
|
|
||||||
bool rasterIsMultiBandColor();
|
bool rasterIsMultiBandColor();
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
|
|||||||
// Metadata tab, before the syncToLayer
|
// Metadata tab, before the syncToLayer
|
||||||
QVBoxLayout *metadataLayout = new QVBoxLayout( metadataFrame );
|
QVBoxLayout *metadataLayout = new QVBoxLayout( metadataFrame );
|
||||||
metadataLayout->setMargin( 0 );
|
metadataLayout->setMargin( 0 );
|
||||||
mMetadataWidget = new QgsAbstractMetadataBaseWidget( this, mLayer );
|
mMetadataWidget = new QgsMetadataWidget( this, mLayer );
|
||||||
mMetadataWidget->layout()->setContentsMargins( -1, 0, -1, 0 );
|
mMetadataWidget->layout()->setContentsMargins( -1, 0, -1, 0 );
|
||||||
mMetadataWidget->setMapCanvas( QgisApp::instance()->mapCanvas() );
|
mMetadataWidget->setMapCanvas( QgisApp::instance()->mapCanvas() );
|
||||||
metadataLayout->addWidget( mMetadataWidget );
|
metadataLayout->addWidget( mMetadataWidget );
|
||||||
@ -560,7 +560,7 @@ void QgsVectorLayerProperties::syncToLayer()
|
|||||||
mVector3DWidget->setLayer( mLayer );
|
mVector3DWidget->setLayer( mLayer );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mMetadataWidget->setMetadata( mLayer->metadata() );
|
mMetadataWidget->setMetadata( &mLayer->metadata() );
|
||||||
|
|
||||||
} // syncToLayer()
|
} // syncToLayer()
|
||||||
|
|
||||||
@ -1017,7 +1017,7 @@ void QgsVectorLayerProperties::loadMetadata()
|
|||||||
//reset if the default style was loaded OK only
|
//reset if the default style was loaded OK only
|
||||||
if ( defaultLoadedFlag )
|
if ( defaultLoadedFlag )
|
||||||
{
|
{
|
||||||
mMetadataWidget->setMetadata( mLayer->metadata() );
|
mMetadataWidget->setMetadata( &mLayer->metadata() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1092,7 +1092,7 @@ void QgsVectorLayerProperties::loadDefaultMetadata()
|
|||||||
//reset if the default metadata was loaded OK only
|
//reset if the default metadata was loaded OK only
|
||||||
if ( defaultLoadedFlag )
|
if ( defaultLoadedFlag )
|
||||||
{
|
{
|
||||||
mMetadataWidget->setMetadata( mLayer->metadata() );
|
mMetadataWidget->setMetadata( &mLayer->metadata() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ class QgsAttributesFormProperties;
|
|||||||
class QgsRendererPropertiesDialog;
|
class QgsRendererPropertiesDialog;
|
||||||
class QgsMapLayerConfigWidgetFactory;
|
class QgsMapLayerConfigWidgetFactory;
|
||||||
class QgsMapLayerConfigWidget;
|
class QgsMapLayerConfigWidget;
|
||||||
class QgsAbstractMetadataBaseWidget;
|
class QgsMetadataWidget;
|
||||||
class QgsPanelWidget;
|
class QgsPanelWidget;
|
||||||
class QgsVectorLayer3DRendererWidget;
|
class QgsVectorLayer3DRendererWidget;
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
|
|||||||
|
|
||||||
void showHelp();
|
void showHelp();
|
||||||
|
|
||||||
QgsAbstractMetadataBaseWidget *mMetadataWidget = nullptr;
|
QgsMetadataWidget *mMetadataWidget = nullptr;
|
||||||
|
|
||||||
QAction *mAuxiliaryLayerActionNew = nullptr;
|
QAction *mAuxiliaryLayerActionNew = nullptr;
|
||||||
QAction *mAuxiliaryLayerActionClear = nullptr;
|
QAction *mAuxiliaryLayerActionClear = nullptr;
|
||||||
|
@ -52,6 +52,18 @@ class QDomDocument;
|
|||||||
*/
|
*/
|
||||||
class CORE_EXPORT QgsAbstractMetadataBase
|
class CORE_EXPORT QgsAbstractMetadataBase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef SIP_RUN
|
||||||
|
SIP_CONVERT_TO_SUBCLASS_CODE
|
||||||
|
if ( dynamic_cast< QgsLayerMetadata * >( sipCpp ) != NULL )
|
||||||
|
sipType = sipType_QgsLayerMetadata;
|
||||||
|
else if ( dynamic_cast< QgsLayerMetadata * >( sipCpp ) != NULL )
|
||||||
|
sipType = sipType_QgsProjectMetadata;
|
||||||
|
else
|
||||||
|
sipType = NULL;
|
||||||
|
SIP_END
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// NOTE - these really belong in a separate namespace, but SIP says no, I want to make you waste more time
|
// NOTE - these really belong in a separate namespace, but SIP says no, I want to make you waste more time
|
||||||
@ -249,6 +261,12 @@ class CORE_EXPORT QgsAbstractMetadataBase
|
|||||||
|
|
||||||
virtual ~QgsAbstractMetadataBase() = default;
|
virtual ~QgsAbstractMetadataBase() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones the metadata object.
|
||||||
|
* \since QGIS 3.2
|
||||||
|
*/
|
||||||
|
virtual QgsAbstractMetadataBase *clone() const = 0 SIP_FACTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reference, URI, URL or some other mechanism to identify the resource.
|
* A reference, URI, URL or some other mechanism to identify the resource.
|
||||||
* \see setIdentifier()
|
* \see setIdentifier()
|
||||||
|
@ -18,6 +18,11 @@
|
|||||||
#include "qgslayermetadata.h"
|
#include "qgslayermetadata.h"
|
||||||
#include "qgsmaplayer.h"
|
#include "qgsmaplayer.h"
|
||||||
|
|
||||||
|
QgsLayerMetadata *QgsLayerMetadata::clone() const
|
||||||
|
{
|
||||||
|
return new QgsLayerMetadata( *this );
|
||||||
|
}
|
||||||
|
|
||||||
QString QgsLayerMetadata::fees() const
|
QString QgsLayerMetadata::fees() const
|
||||||
{
|
{
|
||||||
return mFees;
|
return mFees;
|
||||||
|
@ -169,6 +169,8 @@ class CORE_EXPORT QgsLayerMetadata : public QgsAbstractMetadataBase
|
|||||||
*/
|
*/
|
||||||
QgsLayerMetadata() = default;
|
QgsLayerMetadata() = default;
|
||||||
|
|
||||||
|
QgsLayerMetadata *clone() const override SIP_FACTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns any fees associated with using the resource.
|
* Returns any fees associated with using the resource.
|
||||||
* An empty string will be returned if no fees are set.
|
* An empty string will be returned if no fees are set.
|
||||||
|
@ -62,6 +62,11 @@ bool QgsProjectMetadata::operator==( const QgsProjectMetadata &metadataOther )
|
|||||||
mCreationDateTime == metadataOther.mCreationDateTime ;
|
mCreationDateTime == metadataOther.mCreationDateTime ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QgsProjectMetadata *QgsProjectMetadata::clone() const
|
||||||
|
{
|
||||||
|
return new QgsProjectMetadata( *this );
|
||||||
|
}
|
||||||
|
|
||||||
QString QgsProjectMetadata::author() const
|
QString QgsProjectMetadata::author() const
|
||||||
{
|
{
|
||||||
return mAuthor;
|
return mAuthor;
|
||||||
|
@ -57,6 +57,8 @@ class CORE_EXPORT QgsProjectMetadata : public QgsAbstractMetadataBase
|
|||||||
*/
|
*/
|
||||||
QgsProjectMetadata() = default;
|
QgsProjectMetadata() = default;
|
||||||
|
|
||||||
|
QgsProjectMetadata *clone() const override SIP_FACTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the project author string.
|
* Returns the project author string.
|
||||||
* \see setAuthor()
|
* \see setAuthor()
|
||||||
|
@ -510,6 +510,7 @@ void QgsProject::clear()
|
|||||||
mTrustLayerMetadata = false;
|
mTrustLayerMetadata = false;
|
||||||
mCustomVariables.clear();
|
mCustomVariables.clear();
|
||||||
mMetadata = QgsProjectMetadata();
|
mMetadata = QgsProjectMetadata();
|
||||||
|
mMetadata.setCreationDateTime( QDateTime::currentDateTime() );
|
||||||
emit metadataChanged();
|
emit metadataChanged();
|
||||||
|
|
||||||
QgsCoordinateTransformContext context;
|
QgsCoordinateTransformContext context;
|
||||||
|
@ -29,16 +29,14 @@
|
|||||||
#include "qgslayermetadatavalidator.h"
|
#include "qgslayermetadatavalidator.h"
|
||||||
#include "qgsapplication.h"
|
#include "qgsapplication.h"
|
||||||
#include "qgsmapcanvas.h"
|
#include "qgsmapcanvas.h"
|
||||||
|
#include "qgsprojectmetadata.h"
|
||||||
|
#include "qgsproject.h"
|
||||||
|
|
||||||
QgsAbstractMetadataBaseWidget::QgsAbstractMetadataBaseWidget( QWidget *parent, QgsMapLayer *layer )
|
QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer )
|
||||||
: QWidget( parent ),
|
: QWidget( parent ),
|
||||||
mLayer( layer )
|
mLayer( layer )
|
||||||
{
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
if ( mLayer )
|
|
||||||
{
|
|
||||||
mMetadata = mLayer->metadata();
|
|
||||||
}
|
|
||||||
tabWidget->setCurrentIndex( 0 );
|
tabWidget->setCurrentIndex( 0 );
|
||||||
|
|
||||||
// Disable the encoding
|
// Disable the encoding
|
||||||
@ -87,27 +85,27 @@ QgsAbstractMetadataBaseWidget::QgsAbstractMetadataBaseWidget( QWidget *parent, Q
|
|||||||
listHistory->setModel( mHistoryModel );
|
listHistory->setModel( mHistoryModel );
|
||||||
|
|
||||||
// Connect signals and slots
|
// Connect signals and slots
|
||||||
connect( tabWidget, &QTabWidget::currentChanged, this, &QgsAbstractMetadataBaseWidget::updatePanel );
|
connect( tabWidget, &QTabWidget::currentChanged, this, &QgsMetadataWidget::updatePanel );
|
||||||
connect( btnAutoSource, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::fillSourceFromLayer );
|
connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWidget::fillSourceFromLayer );
|
||||||
connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::addVocabulary );
|
connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::addVocabulary );
|
||||||
connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::removeSelectedVocabulary );
|
connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedVocabulary );
|
||||||
connect( btnAddRight, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::addRight );
|
connect( btnAddRight, &QPushButton::clicked, this, &QgsMetadataWidget::addRight );
|
||||||
connect( btnRemoveRight, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::removeSelectedRight );
|
connect( btnRemoveRight, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedRight );
|
||||||
connect( btnAddLicence, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::addLicence );
|
connect( btnAddLicence, &QPushButton::clicked, this, &QgsMetadataWidget::addLicence );
|
||||||
connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::removeSelectedLicence );
|
connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedLicence );
|
||||||
connect( btnAddConstraint, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::addConstraint );
|
connect( btnAddConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::addConstraint );
|
||||||
connect( btnRemoveConstraint, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::removeSelectedConstraint );
|
connect( btnRemoveConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedConstraint );
|
||||||
connect( btnSetCrsFromLayer, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::fillCrsFromLayer );
|
connect( btnSetCrsFromLayer, &QPushButton::clicked, this, &QgsMetadataWidget::fillCrsFromLayer );
|
||||||
connect( btnSetCrsFromProvider, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::fillCrsFromProvider );
|
connect( btnSetCrsFromProvider, &QPushButton::clicked, this, &QgsMetadataWidget::fillCrsFromProvider );
|
||||||
connect( btnAddAddress, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::addAddress );
|
connect( btnAddAddress, &QPushButton::clicked, this, &QgsMetadataWidget::addAddress );
|
||||||
connect( btnRemoveAddress, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::removeSelectedAddress );
|
connect( btnRemoveAddress, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedAddress );
|
||||||
connect( btnAddLink, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::addLink );
|
connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWidget::addLink );
|
||||||
connect( btnRemoveLink, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::removeSelectedLink );
|
connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedLink );
|
||||||
connect( btnAddHistory, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::addHistory );
|
connect( btnAddHistory, &QPushButton::clicked, this, &QgsMetadataWidget::addHistory );
|
||||||
connect( btnRemoveHistory, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::removeSelectedHistory );
|
connect( btnRemoveHistory, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedHistory );
|
||||||
connect( btnNewCategory, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::addNewCategory );
|
connect( btnNewCategory, &QPushButton::clicked, this, &QgsMetadataWidget::addNewCategory );
|
||||||
connect( btnAddDefaultCategory, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::addDefaultCategories );
|
connect( btnAddDefaultCategory, &QPushButton::clicked, this, &QgsMetadataWidget::addDefaultCategories );
|
||||||
connect( btnRemoveCategory, &QPushButton::clicked, this, &QgsAbstractMetadataBaseWidget::removeSelectedCategories );
|
connect( btnRemoveCategory, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedCategories );
|
||||||
|
|
||||||
fillComboBox();
|
fillComboBox();
|
||||||
if ( !mLayer )
|
if ( !mLayer )
|
||||||
@ -116,31 +114,99 @@ QgsAbstractMetadataBaseWidget::QgsAbstractMetadataBaseWidget( QWidget *parent, Q
|
|||||||
btnAutoEncoding->setEnabled( false );
|
btnAutoEncoding->setEnabled( false );
|
||||||
btnSetCrsFromLayer->setEnabled( false );
|
btnSetCrsFromLayer->setEnabled( false );
|
||||||
}
|
}
|
||||||
setMetadata( mMetadata );
|
|
||||||
}
|
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::setMetadata( const QgsLayerMetadata &layerMetadata )
|
|
||||||
{
|
|
||||||
mMetadata = layerMetadata;
|
|
||||||
setPropertiesFromLayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
QgsLayerMetadata QgsAbstractMetadataBaseWidget::metadata()
|
|
||||||
{
|
|
||||||
QgsLayerMetadata md;
|
|
||||||
saveMetadata( md );
|
|
||||||
return md;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::fillSourceFromLayer()
|
|
||||||
{
|
|
||||||
if ( mLayer )
|
if ( mLayer )
|
||||||
{
|
{
|
||||||
lineEditIdentifier->setText( mLayer->publicSource() );
|
mMetadata.reset( mLayer->metadata().clone() );
|
||||||
|
setUiFromMetadata();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::addVocabulary()
|
void QgsMetadataWidget::setMode( QgsMetadataWidget::Mode mode )
|
||||||
|
{
|
||||||
|
QString type;
|
||||||
|
QString typeUpper;
|
||||||
|
mMode = mode;
|
||||||
|
switch ( mMode )
|
||||||
|
{
|
||||||
|
case LayerMetadata:
|
||||||
|
type = tr( "dataset" );
|
||||||
|
typeUpper = tr( "Dataset" );
|
||||||
|
mEncodingFrame->show();
|
||||||
|
mAuthorFrame->hide();
|
||||||
|
btnAutoSource->setEnabled( mLayer );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ProjectMetadata:
|
||||||
|
type = tr( "project" );
|
||||||
|
typeUpper = tr( "Project" );
|
||||||
|
mEncodingFrame->hide();
|
||||||
|
mAuthorFrame->show();
|
||||||
|
tabWidget->removeTab( 4 );
|
||||||
|
tabWidget->removeTab( 3 );
|
||||||
|
btnAutoSource->setEnabled( true );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mIdLabel->setText( tr( "This page describes the basic attribution of the %1. Please use the tooltips for more information." ).arg( type ) );
|
||||||
|
mLabelCategories->setText( tr( "%1 categories." ).arg( typeUpper ) );
|
||||||
|
mLabelContact->setText( tr( "Contact describe the owner of the %1." ).arg( type ) );
|
||||||
|
mLabelLinks->setText( tr( "Links describe ancillary resources and information related to this %1." ).arg( type ) );
|
||||||
|
mLabelHistory->setText( tr( "History about the %1." ).arg( type ) );
|
||||||
|
btnAutoSource->setText( tr( "Set from %1" ).arg( mMode == LayerMetadata ? tr( "layer" ) : tr( "project" ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsMetadataWidget::setMetadata( const QgsAbstractMetadataBase *metadata )
|
||||||
|
{
|
||||||
|
if ( !metadata )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( dynamic_cast< const QgsLayerMetadata * >( metadata ) )
|
||||||
|
setMode( LayerMetadata );
|
||||||
|
else if ( dynamic_cast< const QgsProjectMetadata * >( metadata ) )
|
||||||
|
setMode( ProjectMetadata );
|
||||||
|
|
||||||
|
mMetadata.reset( metadata->clone() );
|
||||||
|
setUiFromMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
QgsAbstractMetadataBase *QgsMetadataWidget::metadata()
|
||||||
|
{
|
||||||
|
std::unique_ptr< QgsAbstractMetadataBase > md;
|
||||||
|
switch ( mMode )
|
||||||
|
{
|
||||||
|
case LayerMetadata:
|
||||||
|
md = qgis::make_unique< QgsLayerMetadata >();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ProjectMetadata:
|
||||||
|
md = qgis::make_unique< QgsProjectMetadata >();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
saveMetadata( md.get() );
|
||||||
|
return md.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsMetadataWidget::fillSourceFromLayer()
|
||||||
|
{
|
||||||
|
switch ( mMode )
|
||||||
|
{
|
||||||
|
case LayerMetadata:
|
||||||
|
if ( mLayer )
|
||||||
|
{
|
||||||
|
lineEditIdentifier->setText( mLayer->publicSource() );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ProjectMetadata:
|
||||||
|
lineEditIdentifier->setText( QgsProject::instance()->fileName() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsMetadataWidget::addVocabulary()
|
||||||
{
|
{
|
||||||
int row = tabKeywords->rowCount();
|
int row = tabKeywords->rowCount();
|
||||||
tabKeywords->setRowCount( row + 1 );
|
tabKeywords->setRowCount( row + 1 );
|
||||||
@ -155,7 +221,7 @@ void QgsAbstractMetadataBaseWidget::addVocabulary()
|
|||||||
tabKeywords->setItem( row, 1, pCell );
|
tabKeywords->setItem( row, 1, pCell );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::removeSelectedVocabulary()
|
void QgsMetadataWidget::removeSelectedVocabulary()
|
||||||
{
|
{
|
||||||
QItemSelectionModel *selectionModel = tabKeywords->selectionModel();
|
QItemSelectionModel *selectionModel = tabKeywords->selectionModel();
|
||||||
const QModelIndexList selectedRows = selectionModel->selectedRows();
|
const QModelIndexList selectedRows = selectionModel->selectedRows();
|
||||||
@ -165,7 +231,7 @@ void QgsAbstractMetadataBaseWidget::removeSelectedVocabulary()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::addLicence()
|
void QgsMetadataWidget::addLicence()
|
||||||
{
|
{
|
||||||
QString newLicence = QInputDialog::getItem( this, tr( "New Licence" ), tr( "New Licence" ), parseLicenses(), 0, true );
|
QString newLicence = QInputDialog::getItem( this, tr( "New Licence" ), tr( "New Licence" ), parseLicenses(), 0, true );
|
||||||
if ( tabLicenses->findItems( newLicence, Qt::MatchExactly ).isEmpty() )
|
if ( tabLicenses->findItems( newLicence, Qt::MatchExactly ).isEmpty() )
|
||||||
@ -177,7 +243,7 @@ void QgsAbstractMetadataBaseWidget::addLicence()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::removeSelectedLicence()
|
void QgsMetadataWidget::removeSelectedLicence()
|
||||||
{
|
{
|
||||||
QItemSelectionModel *selectionModel = tabLicenses->selectionModel();
|
QItemSelectionModel *selectionModel = tabLicenses->selectionModel();
|
||||||
const QModelIndexList selectedRows = selectionModel->selectedRows();
|
const QModelIndexList selectedRows = selectionModel->selectedRows();
|
||||||
@ -187,7 +253,7 @@ void QgsAbstractMetadataBaseWidget::removeSelectedLicence()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::addRight()
|
void QgsMetadataWidget::addRight()
|
||||||
{
|
{
|
||||||
QString newRight = QInputDialog::getText( this, tr( "New Right" ), tr( "New Right" ) );
|
QString newRight = QInputDialog::getText( this, tr( "New Right" ), tr( "New Right" ) );
|
||||||
QStringList existingRights = mRightsModel->stringList();
|
QStringList existingRights = mRightsModel->stringList();
|
||||||
@ -198,7 +264,7 @@ void QgsAbstractMetadataBaseWidget::addRight()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::removeSelectedRight()
|
void QgsMetadataWidget::removeSelectedRight()
|
||||||
{
|
{
|
||||||
QItemSelectionModel *selection = listRights->selectionModel();
|
QItemSelectionModel *selection = listRights->selectionModel();
|
||||||
if ( selection->hasSelection() )
|
if ( selection->hasSelection() )
|
||||||
@ -212,20 +278,20 @@ void QgsAbstractMetadataBaseWidget::removeSelectedRight()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::addConstraint()
|
void QgsMetadataWidget::addConstraint()
|
||||||
{
|
{
|
||||||
int row = mConstraintsModel->rowCount();
|
int row = mConstraintsModel->rowCount();
|
||||||
mConstraintsModel->setItem( row, 0, new QStandardItem( QString( tr( "undefined %1" ) ).arg( row + 1 ) ) );
|
mConstraintsModel->setItem( row, 0, new QStandardItem( QString( tr( "undefined %1" ) ).arg( row + 1 ) ) );
|
||||||
mConstraintsModel->setItem( row, 1, new QStandardItem( QString( tr( "undefined %1" ) ).arg( row + 1 ) ) );
|
mConstraintsModel->setItem( row, 1, new QStandardItem( QString( tr( "undefined %1" ) ).arg( row + 1 ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::removeSelectedConstraint()
|
void QgsMetadataWidget::removeSelectedConstraint()
|
||||||
{
|
{
|
||||||
const QModelIndexList selectedRows = tabConstraints->selectionModel()->selectedRows();
|
const QModelIndexList selectedRows = tabConstraints->selectionModel()->selectedRows();
|
||||||
mConstraintsModel->removeRow( selectedRows[0].row() );
|
mConstraintsModel->removeRow( selectedRows[0].row() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::crsChanged()
|
void QgsMetadataWidget::crsChanged()
|
||||||
{
|
{
|
||||||
if ( ( mCrs.isValid() ) && ( mLayer ) )
|
if ( ( mCrs.isValid() ) && ( mLayer ) )
|
||||||
{
|
{
|
||||||
@ -258,7 +324,7 @@ void QgsAbstractMetadataBaseWidget::crsChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::addAddress()
|
void QgsMetadataWidget::addAddress()
|
||||||
{
|
{
|
||||||
int row = tabAddresses->rowCount();
|
int row = tabAddresses->rowCount();
|
||||||
tabAddresses->setRowCount( row + 1 );
|
tabAddresses->setRowCount( row + 1 );
|
||||||
@ -284,7 +350,7 @@ void QgsAbstractMetadataBaseWidget::addAddress()
|
|||||||
tabAddresses->setItem( row, 5, new QTableWidgetItem() );
|
tabAddresses->setItem( row, 5, new QTableWidgetItem() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::removeSelectedAddress()
|
void QgsMetadataWidget::removeSelectedAddress()
|
||||||
{
|
{
|
||||||
QItemSelectionModel *selectionModel = tabAddresses->selectionModel();
|
QItemSelectionModel *selectionModel = tabAddresses->selectionModel();
|
||||||
const QModelIndexList selectedRows = selectionModel->selectedRows();
|
const QModelIndexList selectedRows = selectionModel->selectedRows();
|
||||||
@ -294,19 +360,19 @@ void QgsAbstractMetadataBaseWidget::removeSelectedAddress()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::fillCrsFromLayer()
|
void QgsMetadataWidget::fillCrsFromLayer()
|
||||||
{
|
{
|
||||||
mCrs = mLayer->crs();
|
mCrs = mLayer->crs();
|
||||||
crsChanged();
|
crsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::fillCrsFromProvider()
|
void QgsMetadataWidget::fillCrsFromProvider()
|
||||||
{
|
{
|
||||||
mCrs = mLayer->dataProvider()->crs();
|
mCrs = mLayer->dataProvider()->crs();
|
||||||
crsChanged();
|
crsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::addLink()
|
void QgsMetadataWidget::addLink()
|
||||||
{
|
{
|
||||||
int row = mLinksModel->rowCount();
|
int row = mLinksModel->rowCount();
|
||||||
mLinksModel->setItem( row, 0, new QStandardItem( QString( tr( "undefined %1" ) ).arg( row + 1 ) ) );
|
mLinksModel->setItem( row, 0, new QStandardItem( QString( tr( "undefined %1" ) ).arg( row + 1 ) ) );
|
||||||
@ -318,13 +384,13 @@ void QgsAbstractMetadataBaseWidget::addLink()
|
|||||||
mLinksModel->setItem( row, 6, new QStandardItem() );
|
mLinksModel->setItem( row, 6, new QStandardItem() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::removeSelectedLink()
|
void QgsMetadataWidget::removeSelectedLink()
|
||||||
{
|
{
|
||||||
const QModelIndexList selectedRows = tabLinks->selectionModel()->selectedRows();
|
const QModelIndexList selectedRows = tabLinks->selectionModel()->selectedRows();
|
||||||
mLinksModel->removeRow( selectedRows[0].row() );
|
mLinksModel->removeRow( selectedRows[0].row() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::addHistory()
|
void QgsMetadataWidget::addHistory()
|
||||||
{
|
{
|
||||||
QString newHistory = QInputDialog::getText( this, tr( "New History" ), tr( "New History" ) );
|
QString newHistory = QInputDialog::getText( this, tr( "New History" ), tr( "New History" ) );
|
||||||
QStringList existingHistory = mHistoryModel->stringList();
|
QStringList existingHistory = mHistoryModel->stringList();
|
||||||
@ -335,7 +401,7 @@ void QgsAbstractMetadataBaseWidget::addHistory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::removeSelectedHistory()
|
void QgsMetadataWidget::removeSelectedHistory()
|
||||||
{
|
{
|
||||||
QItemSelectionModel *selection = listHistory->selectionModel();
|
QItemSelectionModel *selection = listHistory->selectionModel();
|
||||||
if ( selection->hasSelection() )
|
if ( selection->hasSelection() )
|
||||||
@ -349,7 +415,7 @@ void QgsAbstractMetadataBaseWidget::removeSelectedHistory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::fillComboBox()
|
void QgsMetadataWidget::fillComboBox()
|
||||||
{
|
{
|
||||||
// Set default values in type combobox
|
// Set default values in type combobox
|
||||||
// It is advised to use the ISO 19115 MD_ScopeCode values. E.g. 'dataset' or 'series'.
|
// It is advised to use the ISO 19115 MD_ScopeCode values. E.g. 'dataset' or 'series'.
|
||||||
@ -381,52 +447,52 @@ void QgsAbstractMetadataBaseWidget::fillComboBox()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::setPropertiesFromLayer()
|
void QgsMetadataWidget::setUiFromMetadata()
|
||||||
{
|
{
|
||||||
// Parent ID
|
// Parent ID
|
||||||
lineEditParentId->setText( mMetadata.parentIdentifier() );
|
lineEditParentId->setText( mMetadata->parentIdentifier() );
|
||||||
|
|
||||||
// Identifier
|
// Identifier
|
||||||
if ( ! mMetadata.identifier().isEmpty() )
|
if ( ! mMetadata->identifier().isEmpty() )
|
||||||
{
|
{
|
||||||
lineEditIdentifier->setText( mMetadata.identifier() );
|
lineEditIdentifier->setText( mMetadata->identifier() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
if ( ! mMetadata.title().isEmpty() )
|
if ( ! mMetadata->title().isEmpty() )
|
||||||
{
|
{
|
||||||
lineEditTitle->setText( mMetadata.title() );
|
lineEditTitle->setText( mMetadata->title() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
if ( ! mMetadata.type().isEmpty() )
|
if ( ! mMetadata->type().isEmpty() )
|
||||||
{
|
{
|
||||||
if ( comboType->findText( mMetadata.type() ) == -1 )
|
if ( comboType->findText( mMetadata->type() ) == -1 )
|
||||||
{
|
{
|
||||||
comboType->addItem( mMetadata.type() );
|
comboType->addItem( mMetadata->type() );
|
||||||
}
|
}
|
||||||
comboType->setCurrentIndex( comboType->findText( mMetadata.type() ) );
|
comboType->setCurrentIndex( comboType->findText( mMetadata->type() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
if ( ! mMetadata.language().isEmpty() )
|
if ( ! mMetadata->language().isEmpty() )
|
||||||
{
|
{
|
||||||
if ( comboLanguage->findText( mMetadata.language() ) == -1 )
|
if ( comboLanguage->findText( mMetadata->language() ) == -1 )
|
||||||
{
|
{
|
||||||
comboLanguage->addItem( mMetadata.language() );
|
comboLanguage->addItem( mMetadata->language() );
|
||||||
}
|
}
|
||||||
comboLanguage->setCurrentIndex( comboLanguage->findText( mMetadata.language() ) );
|
comboLanguage->setCurrentIndex( comboLanguage->findText( mMetadata->language() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abstract
|
// Abstract
|
||||||
textEditAbstract->setPlainText( mMetadata.abstract() );
|
textEditAbstract->setPlainText( mMetadata->abstract() );
|
||||||
|
|
||||||
// Categories
|
// Categories
|
||||||
mCategoriesModel->setStringList( mMetadata.categories() );
|
mCategoriesModel->setStringList( mMetadata->categories() );
|
||||||
|
|
||||||
// Keywords
|
// Keywords
|
||||||
tabKeywords->setRowCount( 0 );
|
tabKeywords->setRowCount( 0 );
|
||||||
QMapIterator<QString, QStringList> i( mMetadata.keywords() );
|
QMapIterator<QString, QStringList> i( mMetadata->keywords() );
|
||||||
while ( i.hasNext() )
|
while ( i.hasNext() )
|
||||||
{
|
{
|
||||||
i.next();
|
i.next();
|
||||||
@ -436,69 +502,78 @@ void QgsAbstractMetadataBaseWidget::setPropertiesFromLayer()
|
|||||||
tabKeywords->item( currentRow, 1 )->setText( i.value().join( QStringLiteral( "," ) ) );
|
tabKeywords->item( currentRow, 1 )->setText( i.value().join( QStringLiteral( "," ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fees
|
if ( QgsLayerMetadata *layerMetadata = dynamic_cast< QgsLayerMetadata * >( mMetadata.get() ) )
|
||||||
lineEditFees->setText( mMetadata.fees() );
|
|
||||||
|
|
||||||
// Licenses
|
|
||||||
tabLicenses->setRowCount( 0 );
|
|
||||||
const QStringList &licenses = mMetadata.licenses();
|
|
||||||
for ( const QString &licence : licenses )
|
|
||||||
{
|
{
|
||||||
int currentRow = tabLicenses->rowCount();
|
|
||||||
tabLicenses->setRowCount( currentRow + 1 );
|
// Fees
|
||||||
QTableWidgetItem *pCell = tabLicenses->item( currentRow, 0 );
|
lineEditFees->setText( layerMetadata->fees() );
|
||||||
if ( !pCell )
|
|
||||||
|
// Licenses
|
||||||
|
tabLicenses->setRowCount( 0 );
|
||||||
|
const QStringList &licenses = layerMetadata->licenses();
|
||||||
|
for ( const QString &licence : licenses )
|
||||||
{
|
{
|
||||||
pCell = new QTableWidgetItem;
|
int currentRow = tabLicenses->rowCount();
|
||||||
tabLicenses->setItem( currentRow, 0, pCell );
|
tabLicenses->setRowCount( currentRow + 1 );
|
||||||
|
QTableWidgetItem *pCell = tabLicenses->item( currentRow, 0 );
|
||||||
|
if ( !pCell )
|
||||||
|
{
|
||||||
|
pCell = new QTableWidgetItem;
|
||||||
|
tabLicenses->setItem( currentRow, 0, pCell );
|
||||||
|
}
|
||||||
|
pCell->setText( licence );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rights
|
||||||
|
mRightsModel->setStringList( layerMetadata->rights() );
|
||||||
|
|
||||||
|
// Constraints
|
||||||
|
const QList<QgsLayerMetadata::Constraint> &constraints = layerMetadata->constraints();
|
||||||
|
for ( const QgsLayerMetadata::Constraint &constraint : constraints )
|
||||||
|
{
|
||||||
|
int row = mConstraintsModel->rowCount();
|
||||||
|
mConstraintsModel->setItem( row, 0, new QStandardItem( constraint.type ) );
|
||||||
|
mConstraintsModel->setItem( row, 1, new QStandardItem( constraint.constraint ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// CRS
|
||||||
|
mCrs = layerMetadata->crs();
|
||||||
|
crsChanged();
|
||||||
|
|
||||||
|
// Spatial extent
|
||||||
|
const QList<QgsLayerMetadata::SpatialExtent> &spatialExtents = layerMetadata->extent().spatialExtents();
|
||||||
|
if ( ! spatialExtents.isEmpty() )
|
||||||
|
{
|
||||||
|
// Even if it's a list, it's supposed to store the same extent in different CRS.
|
||||||
|
spatialExtentSelector->setOutputCrs( spatialExtents.at( 0 ).extentCrs );
|
||||||
|
spatialExtentSelector->setOriginalExtent( spatialExtents.at( 0 ).bounds.toRectangle(), spatialExtents.at( 0 ).extentCrs );
|
||||||
|
spatialExtentSelector->setOutputExtentFromOriginal();
|
||||||
|
spinBoxZMaximum->setValue( spatialExtents.at( 0 ).bounds.zMaximum() );
|
||||||
|
spinBoxZMinimum->setValue( spatialExtents.at( 0 ).bounds.zMinimum() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temporal extent
|
||||||
|
const QList<QgsDateTimeRange> &temporalExtents = layerMetadata->extent().temporalExtents();
|
||||||
|
if ( ! temporalExtents.isEmpty() )
|
||||||
|
{
|
||||||
|
// Even if it's a list, it seems we use only one for now (cf discussion with Tom)
|
||||||
|
dateTimeFrom->setDateTime( temporalExtents.at( 0 ).begin() );
|
||||||
|
dateTimeTo->setDateTime( temporalExtents.at( 0 ).end() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dateTimeFrom->clear();
|
||||||
|
dateTimeTo->clear();
|
||||||
}
|
}
|
||||||
pCell->setText( licence );
|
|
||||||
}
|
}
|
||||||
|
else if ( QgsProjectMetadata *projectMetadata = dynamic_cast< QgsProjectMetadata * >( mMetadata.get() ) )
|
||||||
// Rights
|
|
||||||
mRightsModel->setStringList( mMetadata.rights() );
|
|
||||||
|
|
||||||
// Constraints
|
|
||||||
const QList<QgsLayerMetadata::Constraint> &constraints = mMetadata.constraints();
|
|
||||||
for ( const QgsLayerMetadata::Constraint &constraint : constraints )
|
|
||||||
{
|
{
|
||||||
int row = mConstraintsModel->rowCount();
|
mLineEditAuthor->setText( projectMetadata->author() );
|
||||||
mConstraintsModel->setItem( row, 0, new QStandardItem( constraint.type ) );
|
mCreationDateTimeEdit->setDateTime( projectMetadata->creationDateTime() );
|
||||||
mConstraintsModel->setItem( row, 1, new QStandardItem( constraint.constraint ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// CRS
|
|
||||||
mCrs = mMetadata.crs();
|
|
||||||
crsChanged();
|
|
||||||
|
|
||||||
// Spatial extent
|
|
||||||
const QList<QgsLayerMetadata::SpatialExtent> &spatialExtents = mMetadata.extent().spatialExtents();
|
|
||||||
if ( ! spatialExtents.isEmpty() )
|
|
||||||
{
|
|
||||||
// Even if it's a list, it's supposed to store the same extent in different CRS.
|
|
||||||
spatialExtentSelector->setOutputCrs( spatialExtents.at( 0 ).extentCrs );
|
|
||||||
spatialExtentSelector->setOriginalExtent( spatialExtents.at( 0 ).bounds.toRectangle(), spatialExtents.at( 0 ).extentCrs );
|
|
||||||
spatialExtentSelector->setOutputExtentFromOriginal();
|
|
||||||
spinBoxZMaximum->setValue( spatialExtents.at( 0 ).bounds.zMaximum() );
|
|
||||||
spinBoxZMinimum->setValue( spatialExtents.at( 0 ).bounds.zMinimum() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Temporal extent
|
|
||||||
const QList<QgsDateTimeRange> &temporalExtents = mMetadata.extent().temporalExtents();
|
|
||||||
if ( ! temporalExtents.isEmpty() )
|
|
||||||
{
|
|
||||||
// Even if it's a list, it seems we use only one for now (cf discussion with Tom)
|
|
||||||
dateTimeFrom->setDateTime( temporalExtents.at( 0 ).begin() );
|
|
||||||
dateTimeTo->setDateTime( temporalExtents.at( 0 ).end() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dateTimeFrom->clear();
|
|
||||||
dateTimeTo->clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contacts
|
// Contacts
|
||||||
const QList<QgsAbstractMetadataBase::Contact> &contacts = mMetadata.contacts();
|
const QList<QgsAbstractMetadataBase::Contact> &contacts = mMetadata->contacts();
|
||||||
if ( ! contacts.isEmpty() )
|
if ( ! contacts.isEmpty() )
|
||||||
{
|
{
|
||||||
// Only one contact supported in the UI for now
|
// Only one contact supported in the UI for now
|
||||||
@ -530,7 +605,7 @@ void QgsAbstractMetadataBaseWidget::setPropertiesFromLayer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Links
|
// Links
|
||||||
const QList<QgsAbstractMetadataBase::Link> &links = mMetadata.links();
|
const QList<QgsAbstractMetadataBase::Link> &links = mMetadata->links();
|
||||||
mLinksModel->setRowCount( 0 );
|
mLinksModel->setRowCount( 0 );
|
||||||
for ( const QgsAbstractMetadataBase::Link &link : links )
|
for ( const QgsAbstractMetadataBase::Link &link : links )
|
||||||
{
|
{
|
||||||
@ -545,17 +620,20 @@ void QgsAbstractMetadataBaseWidget::setPropertiesFromLayer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// History
|
// History
|
||||||
mHistoryModel->setStringList( mMetadata.history() );
|
mHistoryModel->setStringList( mMetadata->history() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::saveMetadata( QgsLayerMetadata &layerMetadata )
|
void QgsMetadataWidget::saveMetadata( QgsAbstractMetadataBase *metadata )
|
||||||
{
|
{
|
||||||
layerMetadata.setParentIdentifier( lineEditParentId->text() );
|
if ( !metadata )
|
||||||
layerMetadata.setIdentifier( lineEditIdentifier->text() );
|
return;
|
||||||
layerMetadata.setTitle( lineEditTitle->text() );
|
|
||||||
layerMetadata.setType( comboType->currentText() );
|
metadata->setParentIdentifier( lineEditParentId->text() );
|
||||||
layerMetadata.setLanguage( comboLanguage->currentText() );
|
metadata->setIdentifier( lineEditIdentifier->text() );
|
||||||
layerMetadata.setAbstract( textEditAbstract->toPlainText() );
|
metadata->setTitle( lineEditTitle->text() );
|
||||||
|
metadata->setType( comboType->currentText() );
|
||||||
|
metadata->setLanguage( comboLanguage->currentText() );
|
||||||
|
metadata->setAbstract( textEditAbstract->toPlainText() );
|
||||||
|
|
||||||
// Keywords, it will save categories too.
|
// Keywords, it will save categories too.
|
||||||
syncFromCategoriesTabToKeywordsTab();
|
syncFromCategoriesTabToKeywordsTab();
|
||||||
@ -564,57 +642,73 @@ void QgsAbstractMetadataBaseWidget::saveMetadata( QgsLayerMetadata &layerMetadat
|
|||||||
{
|
{
|
||||||
keywords.insert( tabKeywords->item( i, 0 )->text(), tabKeywords->item( i, 1 )->text().split( ',' ) );
|
keywords.insert( tabKeywords->item( i, 0 )->text(), tabKeywords->item( i, 1 )->text().split( ',' ) );
|
||||||
}
|
}
|
||||||
layerMetadata.setKeywords( keywords );
|
metadata->setKeywords( keywords );
|
||||||
|
|
||||||
// Fees
|
switch ( mMode )
|
||||||
layerMetadata.setFees( lineEditFees->text() );
|
|
||||||
|
|
||||||
// Licenses
|
|
||||||
QStringList licenses;
|
|
||||||
for ( int i = 0; i < tabLicenses->rowCount() ; i++ )
|
|
||||||
{
|
{
|
||||||
licenses.append( tabLicenses->item( i, 0 )->text() );
|
case LayerMetadata:
|
||||||
|
{
|
||||||
|
QgsLayerMetadata *layerMetadata = static_cast< QgsLayerMetadata * >( metadata );
|
||||||
|
// Fees
|
||||||
|
layerMetadata->setFees( lineEditFees->text() );
|
||||||
|
|
||||||
|
// Licenses
|
||||||
|
QStringList licenses;
|
||||||
|
for ( int i = 0; i < tabLicenses->rowCount() ; i++ )
|
||||||
|
{
|
||||||
|
licenses.append( tabLicenses->item( i, 0 )->text() );
|
||||||
|
}
|
||||||
|
layerMetadata->setLicenses( licenses );
|
||||||
|
|
||||||
|
// Rights
|
||||||
|
layerMetadata->setRights( mRightsModel->stringList() );
|
||||||
|
|
||||||
|
// Constraints
|
||||||
|
QList<QgsLayerMetadata::Constraint> constraints;
|
||||||
|
for ( int row = 0; row < mConstraintsModel->rowCount() ; row++ )
|
||||||
|
{
|
||||||
|
QgsLayerMetadata::Constraint constraint;
|
||||||
|
constraint.type = mConstraintsModel->item( row, 0 )->text();
|
||||||
|
constraint.constraint = mConstraintsModel->item( row, 1 )->text();
|
||||||
|
constraints.append( constraint );
|
||||||
|
}
|
||||||
|
layerMetadata->setConstraints( constraints );
|
||||||
|
|
||||||
|
// CRS
|
||||||
|
if ( mCrs.isValid() )
|
||||||
|
{
|
||||||
|
layerMetadata->setCrs( mCrs );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extent
|
||||||
|
QgsLayerMetadata::SpatialExtent spatialExtent;
|
||||||
|
spatialExtent.bounds = QgsBox3d( spatialExtentSelector->outputExtent() );
|
||||||
|
spatialExtent.bounds.setZMinimum( spinBoxZMinimum->value() );
|
||||||
|
spatialExtent.bounds.setZMaximum( spinBoxZMaximum->value() );
|
||||||
|
spatialExtent.extentCrs = spatialExtentSelector->outputCrs();
|
||||||
|
QList<QgsLayerMetadata::SpatialExtent> spatialExtents;
|
||||||
|
spatialExtents.append( spatialExtent );
|
||||||
|
QList<QgsDateTimeRange> temporalExtents;
|
||||||
|
temporalExtents.append( QgsDateTimeRange( dateTimeFrom->dateTime(), dateTimeTo->dateTime() ) );
|
||||||
|
QgsLayerMetadata::Extent extent;
|
||||||
|
extent.setSpatialExtents( spatialExtents );
|
||||||
|
extent.setTemporalExtents( temporalExtents );
|
||||||
|
layerMetadata->setExtent( extent );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ProjectMetadata:
|
||||||
|
{
|
||||||
|
QgsProjectMetadata *projectMetadata = static_cast< QgsProjectMetadata * >( metadata );
|
||||||
|
projectMetadata->setAuthor( mLineEditAuthor->text() );
|
||||||
|
projectMetadata->setCreationDateTime( mCreationDateTimeEdit->dateTime() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
layerMetadata.setLicenses( licenses );
|
|
||||||
|
|
||||||
// Rights
|
|
||||||
layerMetadata.setRights( mRightsModel->stringList() );
|
|
||||||
|
|
||||||
// Constraints
|
|
||||||
QList<QgsLayerMetadata::Constraint> constraints;
|
|
||||||
for ( int row = 0; row < mConstraintsModel->rowCount() ; row++ )
|
|
||||||
{
|
|
||||||
QgsLayerMetadata::Constraint constraint;
|
|
||||||
constraint.type = mConstraintsModel->item( row, 0 )->text();
|
|
||||||
constraint.constraint = mConstraintsModel->item( row, 1 )->text();
|
|
||||||
constraints.append( constraint );
|
|
||||||
}
|
|
||||||
layerMetadata.setConstraints( constraints );
|
|
||||||
|
|
||||||
// CRS
|
|
||||||
if ( mCrs.isValid() )
|
|
||||||
{
|
|
||||||
layerMetadata.setCrs( mCrs );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extent
|
|
||||||
QgsLayerMetadata::SpatialExtent spatialExtent;
|
|
||||||
spatialExtent.bounds = QgsBox3d( spatialExtentSelector->outputExtent() );
|
|
||||||
spatialExtent.bounds.setZMinimum( spinBoxZMinimum->value() );
|
|
||||||
spatialExtent.bounds.setZMaximum( spinBoxZMaximum->value() );
|
|
||||||
spatialExtent.extentCrs = spatialExtentSelector->outputCrs();
|
|
||||||
QList<QgsLayerMetadata::SpatialExtent> spatialExtents;
|
|
||||||
spatialExtents.append( spatialExtent );
|
|
||||||
QList<QgsDateTimeRange> temporalExtents;
|
|
||||||
temporalExtents.append( QgsDateTimeRange( dateTimeFrom->dateTime(), dateTimeTo->dateTime() ) );
|
|
||||||
QgsLayerMetadata::Extent extent;
|
|
||||||
extent.setSpatialExtents( spatialExtents );
|
|
||||||
extent.setTemporalExtents( temporalExtents );
|
|
||||||
layerMetadata.setExtent( extent );
|
|
||||||
|
|
||||||
// Contacts, only one contact supported in the UI for now.
|
// Contacts, only one contact supported in the UI for now.
|
||||||
// We don't want to lost data if more than one contact, so we update only the first one.
|
// We don't want to lost data if more than one contact, so we update only the first one.
|
||||||
QList<QgsAbstractMetadataBase::Contact> contacts = mMetadata.contacts();
|
QList<QgsAbstractMetadataBase::Contact> contacts = mMetadata->contacts();
|
||||||
if ( contacts.size() > 0 )
|
if ( contacts.size() > 0 )
|
||||||
contacts.removeFirst();
|
contacts.removeFirst();
|
||||||
QgsAbstractMetadataBase::Contact contact;
|
QgsAbstractMetadataBase::Contact contact;
|
||||||
@ -639,7 +733,7 @@ void QgsAbstractMetadataBaseWidget::saveMetadata( QgsLayerMetadata &layerMetadat
|
|||||||
}
|
}
|
||||||
contact.addresses = addresses;
|
contact.addresses = addresses;
|
||||||
contacts.insert( 0, contact );
|
contacts.insert( 0, contact );
|
||||||
layerMetadata.setContacts( contacts );
|
metadata->setContacts( contacts );
|
||||||
|
|
||||||
// Links
|
// Links
|
||||||
QList<QgsAbstractMetadataBase::Link> links;
|
QList<QgsAbstractMetadataBase::Link> links;
|
||||||
@ -655,19 +749,30 @@ void QgsAbstractMetadataBaseWidget::saveMetadata( QgsLayerMetadata &layerMetadat
|
|||||||
link.size = mLinksModel->item( row, 6 )->text();
|
link.size = mLinksModel->item( row, 6 )->text();
|
||||||
links.append( link );
|
links.append( link );
|
||||||
}
|
}
|
||||||
layerMetadata.setLinks( links );
|
metadata->setLinks( links );
|
||||||
|
|
||||||
// History
|
// History
|
||||||
layerMetadata.setHistory( mHistoryModel->stringList() );
|
metadata->setHistory( mHistoryModel->stringList() );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsAbstractMetadataBaseWidget::checkMetadata()
|
bool QgsMetadataWidget::checkMetadata()
|
||||||
{
|
{
|
||||||
QgsLayerMetadata metadata = QgsLayerMetadata();
|
std::unique_ptr< QgsAbstractMetadataBase > md( metadata() );
|
||||||
saveMetadata( metadata );
|
|
||||||
QgsNativeMetadataValidator validator;
|
std::unique_ptr< QgsNativeMetadataBaseValidator > validator;
|
||||||
|
switch ( mMode )
|
||||||
|
{
|
||||||
|
case LayerMetadata:
|
||||||
|
validator = qgis::make_unique< QgsNativeMetadataValidator>();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ProjectMetadata:
|
||||||
|
validator = qgis::make_unique< QgsNativeProjectMetadataValidator>();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
QList<QgsAbstractMetadataBaseValidator::ValidationResult> validationResults;
|
QList<QgsAbstractMetadataBaseValidator::ValidationResult> validationResults;
|
||||||
bool results = validator.validate( &metadata, validationResults );
|
bool results = validator->validate( md.get(), validationResults );
|
||||||
|
|
||||||
QString errors;
|
QString errors;
|
||||||
if ( !results )
|
if ( !results )
|
||||||
@ -696,7 +801,7 @@ bool QgsAbstractMetadataBaseWidget::checkMetadata()
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QString> QgsAbstractMetadataBaseWidget::parseLanguages()
|
QMap<QString, QString> QgsMetadataWidget::parseLanguages()
|
||||||
{
|
{
|
||||||
QMap<QString, QString> countries;
|
QMap<QString, QString> countries;
|
||||||
countries.insert( QString(), QString() ); // We add an empty line, because it's not compulsory.
|
countries.insert( QString(), QString() ); // We add an empty line, because it's not compulsory.
|
||||||
@ -739,7 +844,7 @@ QMap<QString, QString> QgsAbstractMetadataBaseWidget::parseLanguages()
|
|||||||
return countries;
|
return countries;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QgsAbstractMetadataBaseWidget::parseLicenses()
|
QStringList QgsMetadataWidget::parseLicenses()
|
||||||
{
|
{
|
||||||
QStringList wordList;
|
QStringList wordList;
|
||||||
wordList.append( QString() ); // We add an empty line, because it's not compulsory.
|
wordList.append( QString() ); // We add an empty line, because it's not compulsory.
|
||||||
@ -763,7 +868,7 @@ QStringList QgsAbstractMetadataBaseWidget::parseLicenses()
|
|||||||
return wordList;
|
return wordList;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QgsAbstractMetadataBaseWidget::parseLinkTypes()
|
QStringList QgsMetadataWidget::parseLinkTypes()
|
||||||
{
|
{
|
||||||
QStringList wordList;
|
QStringList wordList;
|
||||||
wordList.append( QString() ); // We add an empty line, because it's not compulsory.
|
wordList.append( QString() ); // We add an empty line, because it's not compulsory.
|
||||||
@ -787,7 +892,7 @@ QStringList QgsAbstractMetadataBaseWidget::parseLinkTypes()
|
|||||||
return wordList;
|
return wordList;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QgsAbstractMetadataBaseWidget::parseMimeTypes()
|
QStringList QgsMetadataWidget::parseMimeTypes()
|
||||||
{
|
{
|
||||||
QStringList wordList;
|
QStringList wordList;
|
||||||
wordList.append( QString() ); // We add an empty line, because it's not compulsory.
|
wordList.append( QString() ); // We add an empty line, because it's not compulsory.
|
||||||
@ -809,7 +914,7 @@ QStringList QgsAbstractMetadataBaseWidget::parseMimeTypes()
|
|||||||
return wordList;
|
return wordList;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QString> QgsAbstractMetadataBaseWidget::parseTypes()
|
QMap<QString, QString> QgsMetadataWidget::parseTypes()
|
||||||
{
|
{
|
||||||
QMap<QString, QString> types;
|
QMap<QString, QString> types;
|
||||||
types.insert( QString(), QString() ); // We add an empty line, because it's not compulsory.
|
types.insert( QString(), QString() ); // We add an empty line, because it's not compulsory.
|
||||||
@ -832,23 +937,32 @@ QMap<QString, QString> QgsAbstractMetadataBaseWidget::parseTypes()
|
|||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::setMapCanvas( QgsMapCanvas *canvas )
|
void QgsMetadataWidget::setMapCanvas( QgsMapCanvas *canvas )
|
||||||
{
|
{
|
||||||
if ( canvas )
|
if ( canvas )
|
||||||
spatialExtentSelector->setCurrentExtent( canvas->extent(), canvas->mapSettings().destinationCrs() );
|
spatialExtentSelector->setCurrentExtent( canvas->extent(), canvas->mapSettings().destinationCrs() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::acceptMetadata()
|
void QgsMetadataWidget::acceptMetadata()
|
||||||
{
|
{
|
||||||
saveMetadata( mMetadata );
|
saveMetadata( mMetadata.get() );
|
||||||
if ( mLayer )
|
switch ( mMode )
|
||||||
{
|
{
|
||||||
// Save layer metadata properties
|
case LayerMetadata:
|
||||||
mLayer->setMetadata( mMetadata );
|
if ( mLayer )
|
||||||
|
{
|
||||||
|
// Save layer metadata properties
|
||||||
|
mLayer->setMetadata( *static_cast< QgsLayerMetadata * >( mMetadata.get() ) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ProjectMetadata:
|
||||||
|
QgsProject::instance()->setMetadata( *static_cast< QgsProjectMetadata * >( mMetadata.get() ) );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::syncFromCategoriesTabToKeywordsTab()
|
void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab()
|
||||||
{
|
{
|
||||||
if ( mCategoriesModel->rowCount() > 0 )
|
if ( mCategoriesModel->rowCount() > 0 )
|
||||||
{
|
{
|
||||||
@ -869,7 +983,7 @@ void QgsAbstractMetadataBaseWidget::syncFromCategoriesTabToKeywordsTab()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::updatePanel()
|
void QgsMetadataWidget::updatePanel()
|
||||||
{
|
{
|
||||||
int index = tabWidget->currentIndex();
|
int index = tabWidget->currentIndex();
|
||||||
QString currentTabText = tabWidget->widget( index )->objectName();
|
QString currentTabText = tabWidget->widget( index )->objectName();
|
||||||
@ -900,7 +1014,7 @@ void QgsAbstractMetadataBaseWidget::updatePanel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::addNewCategory()
|
void QgsMetadataWidget::addNewCategory()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
QString text = QInputDialog::getText( this, tr( "New Category" ),
|
QString text = QInputDialog::getText( this, tr( "New Category" ),
|
||||||
@ -918,7 +1032,7 @@ void QgsAbstractMetadataBaseWidget::addNewCategory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::addDefaultCategories()
|
void QgsMetadataWidget::addDefaultCategories()
|
||||||
{
|
{
|
||||||
const QModelIndexList selectedIndexes = listDefaultCategories->selectionModel()->selectedIndexes();
|
const QModelIndexList selectedIndexes = listDefaultCategories->selectionModel()->selectedIndexes();
|
||||||
QStringList defaultCategoriesList = mDefaultCategoriesModel->stringList();
|
QStringList defaultCategoriesList = mDefaultCategoriesModel->stringList();
|
||||||
@ -937,7 +1051,7 @@ void QgsAbstractMetadataBaseWidget::addDefaultCategories()
|
|||||||
mCategoriesModel->sort( 0 );
|
mCategoriesModel->sort( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAbstractMetadataBaseWidget::removeSelectedCategories()
|
void QgsMetadataWidget::removeSelectedCategories()
|
||||||
{
|
{
|
||||||
const QModelIndexList selectedIndexes = listCategories->selectionModel()->selectedIndexes();
|
const QModelIndexList selectedIndexes = listCategories->selectionModel()->selectedIndexes();
|
||||||
QStringList categories = mCategoriesModel->stringList();
|
QStringList categories = mCategoriesModel->stringList();
|
||||||
@ -973,7 +1087,7 @@ QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionView
|
|||||||
QComboBox *typeEditor = new QComboBox( parent );
|
QComboBox *typeEditor = new QComboBox( parent );
|
||||||
typeEditor->setEditable( true );
|
typeEditor->setEditable( true );
|
||||||
QStringListModel *model = new QStringListModel( parent );
|
QStringListModel *model = new QStringListModel( parent );
|
||||||
model->setStringList( QgsAbstractMetadataBaseWidget::parseLinkTypes() );
|
model->setStringList( QgsMetadataWidget::parseLinkTypes() );
|
||||||
typeEditor->setModel( model );
|
typeEditor->setModel( model );
|
||||||
return typeEditor;
|
return typeEditor;
|
||||||
}
|
}
|
||||||
@ -983,7 +1097,7 @@ QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionView
|
|||||||
QComboBox *mimeEditor = new QComboBox( parent );
|
QComboBox *mimeEditor = new QComboBox( parent );
|
||||||
mimeEditor->setEditable( true );
|
mimeEditor->setEditable( true );
|
||||||
QStringListModel *model = new QStringListModel( parent );
|
QStringListModel *model = new QStringListModel( parent );
|
||||||
model->setStringList( QgsAbstractMetadataBaseWidget::parseMimeTypes() );
|
model->setStringList( QgsMetadataWidget::parseMimeTypes() );
|
||||||
mimeEditor->setModel( model );
|
mimeEditor->setModel( model );
|
||||||
return mimeEditor;
|
return mimeEditor;
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,22 @@
|
|||||||
* \since QGIS 3.0
|
* \since QGIS 3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class GUI_EXPORT QgsAbstractMetadataBaseWidget : public QWidget, private Ui::QgsAbstractMetadataBaseWidget
|
class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsAbstractMetadataBaseWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Widget modes.
|
||||||
|
* \since QGIS 3.2
|
||||||
|
*/
|
||||||
|
enum Mode
|
||||||
|
{
|
||||||
|
LayerMetadata = 0, //!< Show layer metadata
|
||||||
|
ProjectMetadata, //!< Show project metadata
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the wizard.
|
* Constructor for the wizard.
|
||||||
*
|
*
|
||||||
@ -49,7 +59,21 @@ class GUI_EXPORT QgsAbstractMetadataBaseWidget : public QWidget, private Ui::Qgs
|
|||||||
|
|
||||||
* \see setMetadata()
|
* \see setMetadata()
|
||||||
*/
|
*/
|
||||||
QgsAbstractMetadataBaseWidget( QWidget *parent, QgsMapLayer *layer = nullptr );
|
QgsMetadataWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsMapLayer *layer = nullptr );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the widget's current \a mode.
|
||||||
|
* \since QGIS 3.2
|
||||||
|
* \see mode()
|
||||||
|
*/
|
||||||
|
void setMode( Mode mode );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the widget's current mode.
|
||||||
|
* \since QGIS 3.2
|
||||||
|
* \see setMode()
|
||||||
|
*/
|
||||||
|
Mode mode() const { return mMode; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the \a metadata to display in the widget.
|
* Sets the \a metadata to display in the widget.
|
||||||
@ -57,23 +81,29 @@ class GUI_EXPORT QgsAbstractMetadataBaseWidget : public QWidget, private Ui::Qgs
|
|||||||
* This method can be called after constructing a QgsAbstractMetadataBaseWidget in order
|
* This method can be called after constructing a QgsAbstractMetadataBaseWidget in order
|
||||||
* to set the displayed metadata to custom, non-layer based metadata.
|
* to set the displayed metadata to custom, non-layer based metadata.
|
||||||
*
|
*
|
||||||
|
* Calling this method will automatically setMode() to the correct mode corresponding
|
||||||
|
* to the specified \a metadata object.
|
||||||
|
*
|
||||||
* \see metadata()
|
* \see metadata()
|
||||||
*/
|
*/
|
||||||
void setMetadata( const QgsLayerMetadata &metadata );
|
void setMetadata( const QgsAbstractMetadataBase *metadata );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a QgsLayerMetadata object representing the current state of the widget.
|
* Returns a QgsAbstractMetadataBase object representing the current state of the widget.
|
||||||
|
*
|
||||||
|
* Caller takes ownership of the returned object.
|
||||||
|
*
|
||||||
* \see saveMetadata()
|
* \see saveMetadata()
|
||||||
*/
|
*/
|
||||||
QgsLayerMetadata metadata();
|
QgsAbstractMetadataBase *metadata() SIP_FACTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save all fields in a QgsLayerMetadata object.
|
* Save all fields in a metadata object.
|
||||||
* \see metadata()
|
* \see metadata()
|
||||||
* \see acceptMetadata()
|
* \see acceptMetadata()
|
||||||
* \see checkMetadata()
|
* \see checkMetadata()
|
||||||
*/
|
*/
|
||||||
void saveMetadata( QgsLayerMetadata &layerMetadata );
|
void saveMetadata( QgsAbstractMetadataBase *metadata );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if values in the wizard are correct.
|
* Check if values in the wizard are correct.
|
||||||
@ -149,12 +179,15 @@ class GUI_EXPORT QgsAbstractMetadataBaseWidget : public QWidget, private Ui::Qgs
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
void fillComboBox();
|
void fillComboBox();
|
||||||
void setPropertiesFromLayer();
|
void setUiFromMetadata();
|
||||||
void syncFromCategoriesTabToKeywordsTab();
|
void syncFromCategoriesTabToKeywordsTab();
|
||||||
|
|
||||||
|
Mode mMode = LayerMetadata;
|
||||||
|
|
||||||
QStringList mDefaultCategories;
|
QStringList mDefaultCategories;
|
||||||
QgsMapLayer *mLayer = nullptr;
|
QgsMapLayer *mLayer = nullptr;
|
||||||
QgsCoordinateReferenceSystem mCrs;
|
QgsCoordinateReferenceSystem mCrs;
|
||||||
QgsLayerMetadata mMetadata;
|
std::unique_ptr< QgsAbstractMetadataBase > mMetadata;
|
||||||
QStandardItemModel *mConstraintsModel = nullptr;
|
QStandardItemModel *mConstraintsModel = nullptr;
|
||||||
QStandardItemModel *mLinksModel = nullptr;
|
QStandardItemModel *mLinksModel = nullptr;
|
||||||
QStringListModel *mCategoriesModel = nullptr;
|
QStringListModel *mCategoriesModel = nullptr;
|
||||||
|
@ -66,14 +66,14 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>-52</y>
|
||||||
<width>800</width>
|
<width>786</width>
|
||||||
<height>670</height>
|
<height>721</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_15">
|
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_11">
|
<widget class="QLabel" name="mIdLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>This page describes the basic attribution of the dataset. Please use the tooltips for more information.</string>
|
<string>This page describes the basic attribution of the dataset. Please use the tooltips for more information.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -173,6 +173,73 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="mAuthorFrame">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_13">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Returns the human readable name of the resource, typically displayed in search results.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Creation date</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QDateTimeEdit" name="mCreationDateTimeEdit">
|
||||||
|
<property name="displayFormat">
|
||||||
|
<string>yyyy-mm-dd HH:mm</string>
|
||||||
|
</property>
|
||||||
|
<property name="calendarPopup">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="mLineEditAuthor">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Returns the human readable name of the resource, typically displayed in search results.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Returns the human readable name of the resource, typically displayed in search results.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Author</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -244,33 +311,60 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_24">
|
<widget class="QFrame" name="mEncodingFrame">
|
||||||
<property name="text">
|
<property name="frameShape">
|
||||||
<string>Encoding</string>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_18">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_24">
|
||||||
|
<property name="text">
|
||||||
|
<string>Encoding</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboEncoding">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnAutoEncoding">
|
||||||
|
<property name="text">
|
||||||
|
<string>Set from layer</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="comboEncoding">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btnAutoEncoding">
|
|
||||||
<property name="text">
|
|
||||||
<string>Set from layer</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -286,7 +380,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_14">
|
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_25">
|
<widget class="QLabel" name="mLabelCategories">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Dataset categories.</string>
|
<string>Dataset categories.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -575,7 +669,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>800</width>
|
||||||
<height>670</height>
|
<height>634</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||||
@ -956,7 +1050,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_16">
|
<widget class="QLabel" name="mLabelContact">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Contact describe the owner of the dataset.</string>
|
<string>Contact describe the owner of the dataset.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -981,7 +1075,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>778</width>
|
<width>778</width>
|
||||||
<height>628</height>
|
<height>586</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
@ -1235,7 +1329,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_13">
|
<widget class="QLabel" name="mLabelLinks">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>a list of online resources associated with the resource.</string>
|
<string>a list of online resources associated with the resource.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1310,7 +1404,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_30">
|
<widget class="QLabel" name="mLabelHistory">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>History about the dataset.</string>
|
<string>History about the dataset.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1422,6 +1516,8 @@
|
|||||||
<tabstop>btnAutoSource</tabstop>
|
<tabstop>btnAutoSource</tabstop>
|
||||||
<tabstop>lineEditTitle</tabstop>
|
<tabstop>lineEditTitle</tabstop>
|
||||||
<tabstop>comboType</tabstop>
|
<tabstop>comboType</tabstop>
|
||||||
|
<tabstop>mLineEditAuthor</tabstop>
|
||||||
|
<tabstop>mCreationDateTimeEdit</tabstop>
|
||||||
<tabstop>comboLanguage</tabstop>
|
<tabstop>comboLanguage</tabstop>
|
||||||
<tabstop>textEditAbstract</tabstop>
|
<tabstop>textEditAbstract</tabstop>
|
||||||
<tabstop>comboEncoding</tabstop>
|
<tabstop>comboEncoding</tabstop>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user