Skip to content
Permalink
Browse files

[FEATURE] Add metadata to QGIS projects

Allows for detailed metadata to be set in project properties,
including abstracts, keywords, contact details, links, etc.

Developed for Arpa Piemonte (Dipartimento Tematico Geologia e Dissesto)
within ERIKUS project
  • Loading branch information
nyalldawson committed Mar 22, 2018
1 parent f4ed93e commit 8bc45769df41dfae2fb4221bf443e6c7988e105b
@@ -55,7 +55,7 @@
#include "qgstablewidgetitem.h"
#include "qgslayertree.h"
#include "qgsprintlayout.h"

#include "qgsmetadatawidget.h"
#include "qgsmessagelog.h"

//qt includes
@@ -75,6 +75,10 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
, mEllipsoidIndex( 0 )
{
setupUi( this );

mMetadataWidget = new QgsMetadataWidget();
mMetadataPage->layout()->addWidget( mMetadataWidget );

connect( pbnAddScale, &QToolButton::clicked, this, &QgsProjectProperties::pbnAddScale_clicked );
connect( pbnRemoveScale, &QToolButton::clicked, this, &QgsProjectProperties::pbnRemoveScale_clicked );
connect( pbnImportScales, &QToolButton::clicked, this, &QgsProjectProperties::pbnImportScales_clicked );
@@ -818,6 +822,10 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mVariableEditor->reloadContext();
mVariableEditor->setEditableScopeIndex( 1 );

// metadata
mMetadataWidget->setMode( QgsMetadataWidget::ProjectMetadata );
mMetadataWidget->setMetadata( &QgsProject::instance()->metadata() );

projectionSelectorInitialized();
restoreOptionsBaseUi();
restoreState();
@@ -866,6 +874,8 @@ void QgsProjectProperties::apply()
QgsCoordinateTransformContext transformContext = mDatumTransformTableWidget->transformContext();
QgsProject::instance()->setTransformContext( transformContext );

mMetadataWidget->acceptMetadata();

// Set the project title
QgsProject::instance()->setTitle( title() );
QgsProject::instance()->setPresetHomePath( QDir::fromNativeSeparators( mProjectHomeLineEdit->text() ) );
@@ -30,6 +30,7 @@ class QgsRelationManagerDialog;
class QgsStyle;
class QgsExpressionContext;
class QgsLayerTreeGroup;
class QgsMetadataWidget;

/**
* Dialog to set project level properties
@@ -173,6 +174,7 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
QgsRelationManagerDialog *mRelationManagerDlg = nullptr;
QgsMapCanvas *mMapCanvas = nullptr;
QgsStyle *mStyle = nullptr;
QgsMetadataWidget *mMetadataWidget = nullptr;

QgsCoordinateReferenceSystem mCrs;

@@ -161,9 +161,9 @@ void QgsMetadataWidget::setMetadata( const QgsAbstractMetadataBase *metadata )
if ( !metadata )
return;

if ( dynamic_cast< const QgsLayerMetadata * >( metadata ) )
if ( dynamic_cast< const QgsLayerMetadata * >( metadata ) && mMode != LayerMetadata )
setMode( LayerMetadata );
else if ( dynamic_cast< const QgsProjectMetadata * >( metadata ) )
else if ( dynamic_cast< const QgsProjectMetadata * >( metadata ) && mMode != ProjectMetadata )
setMode( ProjectMetadata );

mMetadata.reset( metadata->clone() );
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>804</width>
<height>697</height>
<height>668</height>
</rect>
</property>
<property name="windowTitle">
@@ -104,6 +104,15 @@
<normaloff>:/images/themes/default/propertyicons/general.svg</normaloff>:/images/themes/default/propertyicons/general.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Metadata</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/propertyicons/editmetadata.svg</normaloff>:/images/themes/default/propertyicons/editmetadata.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>CRS</string>
@@ -268,8 +277,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>565</width>
<height>699</height>
<width>685</width>
<height>778</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
@@ -810,6 +819,9 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mMetadataPage">
<layout class="QVBoxLayout" name="verticalLayout_19"/>
</widget>
<widget class="QWidget" name="mProjOptsCRS">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="leftMargin">
@@ -837,8 +849,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>676</width>
<height>764</height>
<width>579</width>
<height>170</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@@ -912,8 +924,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>269</width>
<height>605</height>
<width>284</width>
<height>573</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
@@ -922,7 +934,7 @@
<property name="title">
<string>Default symbols</string>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">projstyles</string>
</property>
<layout class="QGridLayout" name="gridLayout_11">
@@ -1149,7 +1161,7 @@
<property name="title">
<string>Options</string>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">projstyles</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
@@ -1163,7 +1175,7 @@
</widget>
</item>
<item>
<widget class="QgsOpacityWidget" name="mDefaultOpacityWidget">
<widget class="QgsOpacityWidget" name="mDefaultOpacityWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
@@ -1350,8 +1362,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>676</width>
<height>764</height>
<width>136</width>
<height>100</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
@@ -1506,8 +1518,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>156</width>
<height>59</height>
<width>165</width>
<height>57</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
@@ -1568,8 +1580,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>598</width>
<height>2363</height>
<width>624</width>
<height>2451</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@@ -1590,13 +1602,13 @@
<property name="checked">
<bool>false</bool>
</property>
<property name="collapsed">
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">projowsserver</string>
</property>
<property name="saveCollapsedState">
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_6">
@@ -1833,7 +1845,7 @@
<property name="title">
<string>WMS capabilities</string>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">projowsserver</string>
</property>
<layout class="QGridLayout" name="gridLayout_13">
@@ -1848,10 +1860,10 @@
<property name="checked">
<bool>false</bool>
</property>
<property name="collapsed">
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState">
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
@@ -1957,10 +1969,10 @@
<property name="checked">
<bool>false</bool>
</property>
<property name="collapsed">
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState">
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_10">
@@ -2022,10 +2034,10 @@
<property name="checked">
<bool>false</bool>
</property>
<property name="collapsed">
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState">
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
@@ -2087,10 +2099,10 @@
<property name="checked">
<bool>false</bool>
</property>
<property name="collapsed">
<property name="collapsed" stdset="0">
<bool>false</bool>
</property>
<property name="saveCollapsedState">
<property name="saveCollapsedState" stdset="0">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
@@ -2418,7 +2430,7 @@
<property name="title">
<string>WFS capabilities (also influences DXF export)</string>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">projowsserver</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
@@ -2504,7 +2516,7 @@
<property name="title">
<string>WCS capabilities</string>
</property>
<property name="syncGroup">
<property name="syncGroup" stdset="0">
<string notr="true">projowsserver</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
@@ -2869,6 +2881,34 @@
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>

0 comments on commit 8bc4576

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