Skip to content

Commit

Permalink
[FEATURE] Add metadata to QGIS projects
Browse files Browse the repository at this point in the history
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 8bc4576
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 33 deletions.
12 changes: 11 additions & 1 deletion src/app/qgsprojectproperties.cpp
Expand Up @@ -55,7 +55,7 @@
#include "qgstablewidgetitem.h"
#include "qgslayertree.h"
#include "qgsprintlayout.h"

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

//qt includes
Expand All @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() ) );
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsprojectproperties.h
Expand Up @@ -30,6 +30,7 @@ class QgsRelationManagerDialog;
class QgsStyle;
class QgsExpressionContext;
class QgsLayerTreeGroup;
class QgsMetadataWidget;

/**
* Dialog to set project level properties
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmetadatawidget.cpp
Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion src/ui/qgsmetadatawidget.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>804</width>
<height>697</height>
<height>668</height>
</rect>
</property>
<property name="windowTitle">
Expand Down
98 changes: 69 additions & 29 deletions src/ui/qgsprojectpropertiesbase.ui
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand All @@ -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">
Expand Down Expand Up @@ -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">
Expand All @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand All @@ -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">
Expand Down Expand Up @@ -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">
Expand All @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 8bc4576

Please sign in to comment.