From ef008164f0b58d69c6335064340830c1f4c968a7 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 15 Jun 2017 07:44:34 +0200 Subject: [PATCH 01/39] first version of metadata wizard --- src/app/CMakeLists.txt | 3 + src/app/qgisapp.cpp | 15 +++ src/app/qgisapp.h | 4 + src/app/qgsapplayertreeviewmenuprovider.cpp | 2 + src/app/qgsmetadatawizard.cpp | 113 ++++++++++++++++++++ src/app/qgsmetadatawizard.h | 41 +++++++ src/ui/qgisapp.ui | 14 +++ 7 files changed, 192 insertions(+) create mode 100644 src/app/qgsmetadatawizard.cpp create mode 100644 src/app/qgsmetadatawizard.h diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index e2595ea34af1..dc709756df6e 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -131,6 +131,7 @@ SET(QGIS_APP_SRCS qgsmaptooladdcircularstring.cpp qgsmaptoolcircularstringcurvepoint.cpp qgsmaptoolcircularstringradius.cpp + qgsmetadatawizard.cpp composer/qgsattributeselectiondialog.cpp composer/qgscomposer.cpp @@ -289,6 +290,8 @@ SET (QGIS_APP_MOC_HDRS qgsmaptooladdcircularstring.h qgsmaptoolcircularstringcurvepoint.h + qgsmetadatawizard.h + nodetool/qgsselectedfeature.h nodetool/qgsnodeeditor.h nodetool/qgsnodetool.h diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index d0a6dd4143d4..30ceed6ebf48 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1842,6 +1842,7 @@ void QgisApp::createActions() connect( mActionAddAmsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "arcgismapserver" ) ); } ); connect( mActionAddDelimitedText, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "delimitedtext" ) ); } ); connect( mActionAddVirtualLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "virtual" ) ); } ); + connect( mActionOpenMetadataWizardEditor, &QAction::triggered, this, &QgisApp::metadataWizard ); connect( mActionOpenTable, &QAction::triggered, this, &QgisApp::attributeTable ); connect( mActionOpenFieldCalc, &QAction::triggered, this, &QgisApp::fieldCalculator ); connect( mActionToggleEditing, &QAction::triggered, this, [ = ] { toggleEditing(); } ); @@ -4595,6 +4596,17 @@ void QgisApp::addVirtualLayer() delete dts; } // QgisApp::addVirtualLayer() +void QgisApp::metadataWizard() +{ + QgsMapLayer *myLayer = activeLayer(); + if ( !myLayer ) + { + return; + } + QgsMetadataWizard wizard( this, myLayer ); + wizard.exec(); +} // QgisApp::metadataWizard() + void QgisApp::addSelectedVectorLayer( const QString &uri, const QString &layerName, const QString &provider ) { addVectorLayer( uri, layerName, provider ); @@ -10998,6 +11010,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) mActionSelectByForm->setEnabled( false ); mActionLabeling->setEnabled( false ); mActionOpenTable->setEnabled( false ); + mActionOpenMetadataWizardEditor->setEnabled( false ); mActionSelectAll->setEnabled( false ); mActionInvertSelection->setEnabled( false ); mActionOpenFieldCalc->setEnabled( false ); @@ -11106,6 +11119,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) mActionSelectByExpression->setEnabled( true ); mActionSelectByForm->setEnabled( true ); mActionOpenTable->setEnabled( true ); + mActionOpenMetadataWizardEditor->setEnabled( true ); mActionSelectAll->setEnabled( true ); mActionInvertSelection->setEnabled( true ); mActionSaveLayerDefinition->setEnabled( true ); @@ -11310,6 +11324,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) mActionZoomToLayer->setEnabled( true ); mActionZoomToSelected->setEnabled( false ); mActionOpenTable->setEnabled( false ); + mActionOpenMetadataWizardEditor->setEnabled( true ); mActionSelectAll->setEnabled( false ); mActionInvertSelection->setEnabled( false ); mActionSelectByExpression->setEnabled( false ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 3ea173cdb56e..61e5c776c377 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -73,6 +73,7 @@ class QgsMapTip; class QgsMapTool; class QgsMapToolAdvancedDigitizing; class QgsMapToolIdentifyAction; +class QgsMetadataWizard; class QgsPluginLayer; class QgsPluginLayer; class QgsPluginManager; @@ -146,6 +147,7 @@ class QgsGeoCmsProviderRegistry; #include "qgsrasterminmaxorigin.h" #include "qgsmaplayeractionregistry.h" #include "qgsoptionswidgetfactory.h" +#include "qgsmetadatawizard.h" #include "ui_qgisapp.h" #include "qgis_app.h" @@ -929,6 +931,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow //#endif //! Add a virtual layer void addVirtualLayer(); + //! Open the metadata wizard + void metadataWizard(); //! toggles whether the current selected layer is in overview or not void isInOverview(); //! Store the position for map tool tip diff --git a/src/app/qgsapplayertreeviewmenuprovider.cpp b/src/app/qgsapplayertreeviewmenuprovider.cpp index 475e97e61805..6d50e081b807 100644 --- a/src/app/qgsapplayertreeviewmenuprovider.cpp +++ b/src/app/qgsapplayertreeviewmenuprovider.cpp @@ -267,6 +267,8 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() addCustomLayerActions( menu, layer ); + menu->addAction( tr( "Metadata Wizard" ), QgisApp::instance(), SLOT( metadataWizard() ) ); + if ( layer && QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() ) menu->addAction( tr( "&Properties" ), QgisApp::instance(), SLOT( layerProperties() ) ); diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp new file mode 100644 index 000000000000..0f460c08db76 --- /dev/null +++ b/src/app/qgsmetadatawizard.cpp @@ -0,0 +1,113 @@ +/*************************************************************************** + qgsmetadatawizard.h - description + ------------------- + begin : 17/05/2017 + copyright : (C) 2017 by Etienne Trimaille + email : etienne at kartoza.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include + +#include "qgsmetadatawizard.h" + +QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) + : QDialog( parent ), mLayer( layer ) +{ + setupUi( this ); + + basicMetadataButton->setChecked( true ); + backButton->setVisible( false ); + nextButton->setVisible( true ); + + connect( basicMetadataButton, &QPushButton::clicked, this, &QgsMetadataWizard::updatePanel ); + connect( locationButton, &QPushButton::clicked, this, &QgsMetadataWizard::updatePanel ); + connect( optionalButton, &QPushButton::clicked, this, &QgsMetadataWizard::updatePanel ); + + connect( cancelButton, &QPushButton::clicked, this, &QgsMetadataWizard::cancelClicked ); + connect( backButton, &QPushButton::clicked, this, &QgsMetadataWizard::backClicked ); + connect( nextButton, &QPushButton::clicked, this, &QgsMetadataWizard::nextClicked ); + connect( finishButton, &QPushButton::clicked, this, &QgsMetadataWizard::finishedClicked ); + + layerLabel->setText( mLayer->name() ); + lineEditTitle->setText( mLayer->name() ); + textEditAbstract->setText( mLayer->abstract() ); + textEditKeywords->setText( mLayer->keywordList() ); +} + +QgsMetadataWizard::~QgsMetadataWizard() +{ +} + +void QgsMetadataWizard::cancelClicked() +{ + hide(); +} + +void QgsMetadataWizard::backClicked() +{ + int index = stackedWidget->currentIndex(); + if ( index == 1 ) + { + basicMetadataButton->setChecked( true ); + } + else if ( index == 2 ) + { + locationButton->setChecked( true ); + } + updatePanel(); +} + +void QgsMetadataWizard::nextClicked() +{ + int index = stackedWidget->currentIndex(); + if ( index == 0 ) + { + locationButton->setChecked( true ); + } + else if ( index == 1 ) + { + optionalButton->setChecked( true ); + } + updatePanel(); +} + +void QgsMetadataWizard::finishedClicked() +{ + mLayer->setName( lineEditTitle->text() ); + mLayer->setAbstract( textEditAbstract->toPlainText() ); + mLayer->setKeywordList( textEditKeywords->toPlainText() ); + hide(); +} + +void QgsMetadataWizard::updatePanel() +{ + if ( basicMetadataButton->isChecked() ) + { + backButton->setVisible( false ); + nextButton->setVisible( true ); + stackedWidget->setCurrentIndex( 0 ); + } + else if ( locationButton->isChecked() ) + { + backButton->setVisible( true ); + backButton->setVisible( true ); + stackedWidget->setCurrentIndex( 1 ); + } + else + { + backButton->setVisible( true ); + nextButton->setVisible( false ); + stackedWidget->setCurrentIndex( 2 ); + } +} diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h new file mode 100644 index 000000000000..d9ac80c48ae4 --- /dev/null +++ b/src/app/qgsmetadatawizard.h @@ -0,0 +1,41 @@ +/*************************************************************************** + qgsmetadatawizard.h - description + ------------------- + begin : 17/05/2017 + copyright : (C) 2017 by Etienne Trimaille + email : etienne at kartoza.com + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef QGSMETADATAWIZARD_H +#define QGSMETADATAWIZARD_H + +#include "qgis_app.h" +#include "qgsmaplayer.h" +#include "ui_qgsmetadatawizard.h" + +class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWizard +{ + Q_OBJECT + + public: + QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer = nullptr ); + ~QgsMetadataWizard(); + + private: + void cancelClicked(); + void backClicked(); + void nextClicked(); + void finishedClicked(); + void updatePanel(); + QgsMapLayer *mLayer = nullptr; +}; + +#endif diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index bf469bfa0e22..d5242aa779b7 100755 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -157,6 +157,8 @@ + + @@ -361,6 +363,9 @@ + + + @@ -2670,6 +2675,15 @@ Acts on currently active editable layer Ctrl+L + + + + :/images/themes/default/propertyicons/metadata.svg:/images/themes/default/propertyicons/metadata.svg + + + Open Metadata Wizard Editor + + From 9b13d466efa8966657cff589ef1a1ee5ab25d0d6 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Tue, 20 Jun 2017 08:45:47 +0200 Subject: [PATCH 02/39] use tabwidget --- src/app/qgsmetadatawizard.cpp | 74 ++++++++++++++++++----------------- src/app/qgsmetadatawizard.h | 3 ++ 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index 0f460c08db76..ab4a076bf9d4 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "qgsmetadatawizard.h" @@ -26,19 +27,20 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) { setupUi( this ); - basicMetadataButton->setChecked( true ); - backButton->setVisible( false ); - nextButton->setVisible( true ); - - connect( basicMetadataButton, &QPushButton::clicked, this, &QgsMetadataWizard::updatePanel ); - connect( locationButton, &QPushButton::clicked, this, &QgsMetadataWizard::updatePanel ); - connect( optionalButton, &QPushButton::clicked, this, &QgsMetadataWizard::updatePanel ); + tabWidget->setCurrentIndex( 0 ); + backButton->setEnabled( false ); + nextButton->setEnabled( true ); + connect( tabWidget, &QTabWidget::currentChanged, this, &QgsMetadataWizard::updatePanel ); connect( cancelButton, &QPushButton::clicked, this, &QgsMetadataWizard::cancelClicked ); connect( backButton, &QPushButton::clicked, this, &QgsMetadataWizard::backClicked ); connect( nextButton, &QPushButton::clicked, this, &QgsMetadataWizard::nextClicked ); connect( finishButton, &QPushButton::clicked, this, &QgsMetadataWizard::finishedClicked ); + connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWizard::addLink ); + connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWizard::removeLink ); + + // Set all properties layerLabel->setText( mLayer->name() ); lineEditTitle->setText( mLayer->name() ); textEditAbstract->setText( mLayer->abstract() ); @@ -56,29 +58,17 @@ void QgsMetadataWizard::cancelClicked() void QgsMetadataWizard::backClicked() { - int index = stackedWidget->currentIndex(); - if ( index == 1 ) - { - basicMetadataButton->setChecked( true ); - } - else if ( index == 2 ) - { - locationButton->setChecked( true ); - } + int index = tabWidget->currentIndex(); + if ( index > 0 ) + tabWidget->setCurrentIndex( index - 1 ); updatePanel(); } void QgsMetadataWizard::nextClicked() { - int index = stackedWidget->currentIndex(); - if ( index == 0 ) - { - locationButton->setChecked( true ); - } - else if ( index == 1 ) - { - optionalButton->setChecked( true ); - } + int index = tabWidget->currentIndex(); + if ( index < tabWidget->count() ) + tabWidget->setCurrentIndex( index + 1 ); updatePanel(); } @@ -92,22 +82,34 @@ void QgsMetadataWizard::finishedClicked() void QgsMetadataWizard::updatePanel() { - if ( basicMetadataButton->isChecked() ) + int index = tabWidget->currentIndex(); + if ( index == 0 ) { - backButton->setVisible( false ); - nextButton->setVisible( true ); - stackedWidget->setCurrentIndex( 0 ); + backButton->setEnabled( false ); + nextButton->setEnabled( true ); } - else if ( locationButton->isChecked() ) + else if ( index == tabWidget->count() - 1 ) { - backButton->setVisible( true ); - backButton->setVisible( true ); - stackedWidget->setCurrentIndex( 1 ); + backButton->setEnabled( true ); + nextButton->setEnabled( false ); } else { - backButton->setVisible( true ); - nextButton->setVisible( false ); - stackedWidget->setCurrentIndex( 2 ); + backButton->setEnabled( true ); + nextButton->setEnabled( true ); } } + +void QgsMetadataWizard::addLink() +{ +// int index = tabLinks->topLevelItemCount(); +// QTreeWidgetItem *link = new QTreeWidgetItem( tabLinks ); +// link->setText( 0, tr( "Link" ) + QString::number( index ) ); +// tabLinks->addTopLevelItem( link ); +} + +void QgsMetadataWizard::removeLink() +{ +// if ( tabLinks->currentItem() ) +// tabLinks->takeTopLevelItem( tabLinks->currentIndex() ); +} diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index d9ac80c48ae4..c5fd9c100b7a 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -29,6 +29,9 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer = nullptr ); ~QgsMetadataWizard(); + void addLink(); + void removeLink(); + private: void cancelClicked(); void backClicked(); From ec2442547a7adbf709fdae2a95eca189925bb077 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 21 Jun 2017 17:00:27 +0200 Subject: [PATCH 03/39] links --- src/app/qgsmetadatawizard.cpp | 57 +++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index ab4a076bf9d4..44c2aba5b6a6 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -18,9 +18,11 @@ #include #include #include +#include #include #include "qgsmetadatawizard.h" +#include "qgslogger.h" QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) : QDialog( parent ), mLayer( layer ) @@ -102,14 +104,57 @@ void QgsMetadataWizard::updatePanel() void QgsMetadataWizard::addLink() { -// int index = tabLinks->topLevelItemCount(); -// QTreeWidgetItem *link = new QTreeWidgetItem( tabLinks ); -// link->setText( 0, tr( "Link" ) + QString::number( index ) ); -// tabLinks->addTopLevelItem( link ); + int row = tabLinks->rowCount(); + tabLinks->setRowCount( row + 1 ); + QTableWidgetItem *pCell; + + // Name + pCell = new QTableWidgetItem( QString( "undefined" ) ); + tabLinks->setItem( row, 0, pCell ); + + // Type + // See https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv + QComboBox *typeCombo = new QComboBox(); + typeCombo->setEditable( true ); + QStringList types; + types << "" << "OGC:CSW" << "OGC:SOS" << "OGC:WFS"; + typeCombo->addItems( types ); + tabLinks->setCellWidget( row, 1, typeCombo ); + + // Description + pCell = new QTableWidgetItem(); + tabLinks->setItem( row, 2, pCell ); + + // URL + pCell = new QTableWidgetItem(); + tabLinks->setItem( row, 3, pCell ); + + // Format + pCell = new QTableWidgetItem(); + tabLinks->setItem( row, 4, pCell ); + + // MIME + // See https://fr.wikipedia.org/wiki/Type_MIME + QComboBox *mimeCombo = new QComboBox(); + mimeCombo->setEditable( true ); + QStringList mime; + mime << "" << "image/png" << "image/tiff" << "application/pdf"; + mimeCombo->addItems( mime ); + tabLinks->setCellWidget( row, 5, mimeCombo ); + + // Size + pCell = new QTableWidgetItem(); + tabLinks->setItem( row, 6, pCell ); } void QgsMetadataWizard::removeLink() { -// if ( tabLinks->currentItem() ) -// tabLinks->takeTopLevelItem( tabLinks->currentIndex() ); + QItemSelectionModel *selectionModel = tabLinks->selectionModel(); + QModelIndexList selectedRows = selectionModel->selectedIndexes(); + QgsDebugMsg( QString( "Remove: %1 " ).arg( QString::number( selectedRows.count() ) ) ); + + for ( int i = 0 ; i < selectedRows.size() ; i++ ) + { + tabLinks->model()->removeRow( selectedRows[i].row() ); + } } From 1f57cadd99e419f968dfe648dc7db44d7e79abaa Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 22 Jun 2017 08:16:17 +0200 Subject: [PATCH 04/39] add qgslayermetadata to the wizard --- src/app/qgsmetadatawizard.cpp | 8 ++++++++ src/app/qgsmetadatawizard.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index 44c2aba5b6a6..174399e8e94b 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -28,6 +28,7 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) : QDialog( parent ), mLayer( layer ) { setupUi( this ); + mMetadata = layer->metadata(); tabWidget->setCurrentIndex( 0 ); backButton->setEnabled( false ); @@ -77,8 +78,15 @@ void QgsMetadataWizard::nextClicked() void QgsMetadataWizard::finishedClicked() { mLayer->setName( lineEditTitle->text() ); + mMetadata.setTitle( lineEditTitle->text() ); + mLayer->setAbstract( textEditAbstract->toPlainText() ); + mMetadata.setAbstract( lineEditTitle->text() ); + mLayer->setKeywordList( textEditKeywords->toPlainText() ); + + // Layer metadata properties + mLayer->setMetadata( mMetadata ); hide(); } diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index c5fd9c100b7a..0dcef3a5fcff 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -19,6 +19,7 @@ #include "qgis_app.h" #include "qgsmaplayer.h" +#include "qgslayermetadata.h" #include "ui_qgsmetadatawizard.h" class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWizard @@ -39,6 +40,7 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza void finishedClicked(); void updatePanel(); QgsMapLayer *mLayer = nullptr; + QgsLayerMetadata mMetadata; }; #endif From 960b1f8d2f989647e6025d1553bc1c713cccc62b Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Mon, 17 Jul 2017 16:48:38 +0300 Subject: [PATCH 05/39] add metadata validator --- src/app/qgsmetadatawizard.cpp | 191 ++++++++- src/app/qgsmetadatawizard.h | 4 + src/ui/qgsmetadatawizard.ui | 768 ++++++++++++++++++++++++++++++++++ 3 files changed, 949 insertions(+), 14 deletions(-) create mode 100644 src/ui/qgsmetadatawizard.ui diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index 174399e8e94b..f6b3c0068f4d 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -21,8 +21,11 @@ #include #include +//#include "qgsmetadatalinkdelegate.h" #include "qgsmetadatawizard.h" #include "qgslogger.h" +#include "qgslayermetadatavalidator.h" +#include "qgisapp.h" QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) : QDialog( parent ), mLayer( layer ) @@ -31,6 +34,7 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) mMetadata = layer->metadata(); tabWidget->setCurrentIndex( 0 ); +// tabWidget->setItemDelegate(new TableDelegate()); backButton->setEnabled( false ); nextButton->setEnabled( true ); @@ -41,13 +45,10 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) connect( finishButton, &QPushButton::clicked, this, &QgsMetadataWizard::finishedClicked ); connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWizard::addLink ); connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWizard::removeLink ); + connect( btnCheckMetadata, &QPushButton::clicked, this, &QgsMetadataWizard::checkMetadata ); - - // Set all properties - layerLabel->setText( mLayer->name() ); - lineEditTitle->setText( mLayer->name() ); - textEditAbstract->setText( mLayer->abstract() ); - textEditKeywords->setText( mLayer->keywordList() ); + fillComboBox(); + setPropertiesFromLayer(); } QgsMetadataWizard::~QgsMetadataWizard() @@ -77,17 +78,31 @@ void QgsMetadataWizard::nextClicked() void QgsMetadataWizard::finishedClicked() { + // OLD API (to remove later) mLayer->setName( lineEditTitle->text() ); - mMetadata.setTitle( lineEditTitle->text() ); - mLayer->setAbstract( textEditAbstract->toPlainText() ); - mMetadata.setAbstract( lineEditTitle->text() ); - mLayer->setKeywordList( textEditKeywords->toPlainText() ); - // Layer metadata properties + // New Metadata API + saveMetadata( mMetadata ); + + // Save layer metadata properties mLayer->setMetadata( mMetadata ); + + QgsNativeMetadataValidator validator; + QList validationResults; + bool results = validator.validate( mMetadata, validationResults ); + hide(); + + if ( results ) + { + QgisApp::instance()->messageBar()->pushInfo( tr( "Save metadata" ), tr( "Saving metadata successfull into the project" ) ); + } + else + { + QgisApp::instance()->messageBar()->pushWarning( tr( "Save metadata" ), tr( "Saving metadata successfull but some fields were missing" ) ); + } } void QgsMetadataWizard::updatePanel() @@ -117,7 +132,7 @@ void QgsMetadataWizard::addLink() QTableWidgetItem *pCell; // Name - pCell = new QTableWidgetItem( QString( "undefined" ) ); + pCell = new QTableWidgetItem( QString( "undefined %1" ).arg( row ) ); tabLinks->setItem( row, 0, pCell ); // Type @@ -138,6 +153,7 @@ void QgsMetadataWizard::addLink() tabLinks->setItem( row, 3, pCell ); // Format + // It is strongly suggested to use GDAL/OGR format values. QgsLayerMetadata documentation pCell = new QTableWidgetItem(); tabLinks->setItem( row, 4, pCell ); @@ -158,11 +174,158 @@ void QgsMetadataWizard::addLink() void QgsMetadataWizard::removeLink() { QItemSelectionModel *selectionModel = tabLinks->selectionModel(); - QModelIndexList selectedRows = selectionModel->selectedIndexes(); - QgsDebugMsg( QString( "Remove: %1 " ).arg( QString::number( selectedRows.count() ) ) ); + QModelIndexList selectedRows = selectionModel->selectedRows(); + QgsDebugMsg( QString( "Remove: %1 " ).arg( selectedRows.count() ) ); for ( int i = 0 ; i < selectedRows.size() ; i++ ) { tabLinks->model()->removeRow( selectedRows[i].row() ); } } + +void QgsMetadataWizard::fillComboBox() +{ + // Set default values in type combobox + // It is advised to use the ISO 19115 MD_ScopeCode values. E.g. 'dataset' or 'series'. + // http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml + comboType->setEditable( true ); + QStringList types; + types << "" << "attribute" << "attributeType" << "dataset" << "nonGeographicDataset" << "series" << "document"; + comboType->addItems( types ); + + // Set default values in language combobox + // It is advised to use the ISO 639.2 or ISO 3166 specifications, e.g. 'ENG' or 'SPA', + comboLanguage->setEditable( true ); + types.clear(); + types << "" << "ENG" << "SPA" << "IND" << "FRE"; + comboLanguage->addItems( types ); +} + +void QgsMetadataWizard::setPropertiesFromLayer() +{ + // Set all properties USING THE OLD API + layerLabel->setText( mLayer->name() ); + lineEditTitle->setText( mLayer->name() ); + textEditAbstract->setText( mLayer->abstract() ); + textEditKeywords->setText( mLayer->keywordList() ); + + // Set all properties USING THE NEW API + // It will overwrite existing settings + + // Title + if ( ! mMetadata.title().isEmpty() ) + { + lineEditTitle->setText( mMetadata.title() ); + } + + // Type + if ( ! mMetadata.type().isEmpty() ) + { + if ( comboType->findText( mMetadata.type() ) == -1 ) + { + comboType->addItem( mMetadata.type() ); + } + comboType->setCurrentIndex( comboType->findText( mMetadata.type() ) ); + } + + // Language + if ( ! mMetadata.language().isEmpty() ) + { + if ( comboLanguage->findText( mMetadata.language() ) == -1 ) + { + comboLanguage->addItem( mMetadata.language() ); + } + comboLanguage->setCurrentIndex( comboLanguage->findText( mMetadata.language() ) ); + } + + // Links + tabLinks->setRowCount( 0 ); + for ( QgsLayerMetadata::Link link : mMetadata.links() ) + { + addLink(); + int currentRow = tabLinks->rowCount() - 1; + tabLinks->item( currentRow, 0 )->setText( link.name ); + if ( ! link.type.isEmpty() ) + { + QComboBox *combo = dynamic_cast( tabLinks->cellWidget( currentRow, 1 ) ); + if ( combo->findText( link.type ) == -1 ) + { + combo->addItem( link.type ); + } + combo->setCurrentIndex( combo->findText( link.type ) ); + } + tabLinks->item( currentRow, 2 )->setText( link.description ); + tabLinks->item( currentRow, 3 )->setText( link.url ); + tabLinks->item( currentRow, 4 )->setText( link.format ); + if ( ! link.mimeType.isEmpty() ) + { + QComboBox *combo = dynamic_cast( tabLinks->cellWidget( currentRow, 5 ) ); + if ( combo->findText( link.mimeType ) == -1 ) + { + combo->addItem( link.mimeType ); + } + combo->setCurrentIndex( combo->findText( link.mimeType ) ); + } + tabLinks->item( currentRow, 6 )->setText( link.size ); + } +} + +void QgsMetadataWizard::saveMetadata( QgsLayerMetadata &layerMetadata ) +{ + layerMetadata.setTitle( lineEditTitle->text() ); + layerMetadata.setType( comboType->currentText() ); + layerMetadata.setLanguage( comboLanguage->currentText() ); + layerMetadata.setAbstract( textEditAbstract->toPlainText() ); + + // Links + QList links; + for ( int i = 0 ; i < tabLinks->rowCount() ; i++ ) + { + struct QgsLayerMetadata::Link link = QgsLayerMetadata::Link(); + link.name = tabLinks->item( i, 0 )->text(); + link.type = dynamic_cast( tabLinks->cellWidget( i, 1 ) )->currentText(); + link.description = tabLinks->item( i, 2 )->text(); + link.url = tabLinks->item( i, 3 )->text(); + link.format = tabLinks->item( i, 4 )->text(); + link.mimeType = dynamic_cast( tabLinks->cellWidget( i, 5 ) )->currentText(); + link.size = tabLinks->item( i, 6 )->text(); + links.append( link ); + } + layerMetadata.setLinks( links ); +} + +bool QgsMetadataWizard::checkMetadata() +{ + QgsLayerMetadata metadata = QgsLayerMetadata(); + saveMetadata( metadata ); + QgsNativeMetadataValidator validator; + QList validationResults; + bool results = validator.validate( metadata, validationResults ); + + QString errors; + if ( results == false ) + { + errors = QStringLiteral(); + for ( QgsMetadataValidator::ValidationResult result : validationResults ) + { + errors += QLatin1String( "" ) % result.section; + if ( ! result.identifier.isNull() ) + { + errors += QLatin1String( " " ) % QVariant( result.identifier.toInt() + 1 ).toString(); + } + errors += QLatin1String( ": " ) % result.note % QLatin1String( "
" ); + } + } + else + { + errors = QStringLiteral( "Ok, it seems valid." ); + } + + QString myStyle = QgsApplication::reportStyleSheet(); + myStyle.append( QStringLiteral( "body { margin: 10px; }\n " ) ); + resultsCheckMetadata->clear(); + resultsCheckMetadata->document()->setDefaultStyleSheet( myStyle ); + resultsCheckMetadata->setHtml( errors ); + + return results; +} diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index 0dcef3a5fcff..1218f8f5d872 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -32,6 +32,10 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza void addLink(); void removeLink(); + void fillComboBox(); + void setPropertiesFromLayer(); + void saveMetadata( QgsLayerMetadata &layerMetadata ); + bool checkMetadata(); private: void cancelClicked(); diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui new file mode 100644 index 000000000000..fb659080098a --- /dev/null +++ b/src/ui/qgsmetadatawizard.ui @@ -0,0 +1,768 @@ + + + QgsMetadataWizard + + + + 0 + 0 + 721 + 546 + + + + Metadata Editor + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + background: #93b023; border: none; + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + font: 16pt; color: #fff; + + + Placeholder set in C++ code for the layer title being edited + + + + + + + font: 22pt; color: #fff; + + + Metadata Editor + + + + + + + + + + + 0 + 20 + + + + background: #589632; border: none; + + + QFrame::NoFrame + + + + + + + true + + + QTabWidget::Rounded + + + 0 + + + + Identification + + + + + + Identification, HELP TEXT + + + + + + + + + 0 + + + + + Title + + + + + + + + 0 + 0 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Type + + + + + + + true + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Language + + + + + + + true + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Encoding + + + + + + + false + + + + Society + + + + + Economy + + + + + Utilities Communication + + + + + Environment + + + + + Oceans + + + + + + + + + + + + Free-text Keywords + + + + + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Abstract + + + + + + + + 0 + 0 + + + + + + + + + + + + + false + + + Access + + + + + 10 + 10 + 60 + 16 + + + + Fees + + + + + false + + + + 10 + 30 + 113 + 21 + + + + + + + 10 + 80 + 101 + 16 + + + + Constraints + + + + + false + + + + 10 + 110 + 221 + 151 + + + + 2 + + + + Type + + + + + Label + + + + + + + 240 + 230 + 62 + 32 + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + false + + + + 400 + 70 + 256 + 192 + + + + + + + 240 + 200 + 62 + 32 + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + 400 + 40 + 60 + 16 + + + + Rights + + + + + + false + + + Extent + + + + + 30 + 50 + 541 + 61 + + + + Temporal, it's a list of QgsDateTimeRange, need to check how to present this + + + + + + 30 + 220 + 411 + 16 + + + + Spatial, need to check how to present this + + + + + + false + + + Contacts + + + + + + Contacts, HELP TEXT + + + + + + + QAbstractItemView::SelectRows + + + + Name + + + + + Role + + + + + Organization + + + + + Position + + + + + Email + + + + + Voice + + + + + Fax + + + + + Address + + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Links + + + + + + Links, HELP TEXT + + + + + + + QAbstractItemView::SelectRows + + + + Name + + + + + Type + + + + + Description + + + + + URL + + + + + Format + + + + + MIME + + + + + Size + + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Validation + + + + + + + + Check metadata + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + Next + + + + + + + Cancel + + + + + + + Save + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Back + + + + + + + + + + + + From 48125357925d8b9c84aa290042d7cc1c3ebe2a5d Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Mon, 17 Jul 2017 22:49:18 +0300 Subject: [PATCH 06/39] add country list ISO --- python/core/qgsapplication.sip | 6 + .../metadata-ISO/country_code_ISO_3166.csv | 250 ++++++++++++++++++ src/app/qgsmetadatawizard.cpp | 23 +- src/app/qgsmetadatawizard.h | 1 + src/core/qgsapplication.cpp | 5 + src/core/qgsapplication.h | 3 + 6 files changed, 287 insertions(+), 1 deletion(-) create mode 100644 resources/metadata-ISO/country_code_ISO_3166.csv diff --git a/python/core/qgsapplication.sip b/python/core/qgsapplication.sip index 8f051af9cebe..25dc3bc4255a 100644 --- a/python/core/qgsapplication.sip +++ b/python/core/qgsapplication.sip @@ -229,6 +229,12 @@ Returns the path to the translation directory. :rtype: str %End + static QString metadataPath(); +%Docstring +Returns the path to the metadata directory. + :rtype: str +%End + static QString qgisMasterDatabaseFilePath(); %Docstring Returns the path to the master qgis.db file. diff --git a/resources/metadata-ISO/country_code_ISO_3166.csv b/resources/metadata-ISO/country_code_ISO_3166.csv new file mode 100644 index 000000000000..2708d592ae4f --- /dev/null +++ b/resources/metadata-ISO/country_code_ISO_3166.csv @@ -0,0 +1,250 @@ +name,alpha-2,alpha-3,country-code,iso_3166-2,region,sub-region,region-code,sub-region-code +Afghanistan,AF,AFG,004,ISO 3166-2:AF,Asia,Southern Asia,142,034 +Åland Islands,AX,ALA,248,ISO 3166-2:AX,Europe,Northern Europe,150,154 +Albania,AL,ALB,008,ISO 3166-2:AL,Europe,Southern Europe,150,039 +Algeria,DZ,DZA,012,ISO 3166-2:DZ,Africa,Northern Africa,002,015 +American Samoa,AS,ASM,016,ISO 3166-2:AS,Oceania,Polynesia,009,061 +Andorra,AD,AND,020,ISO 3166-2:AD,Europe,Southern Europe,150,039 +Angola,AO,AGO,024,ISO 3166-2:AO,Africa,Middle Africa,002,017 +Anguilla,AI,AIA,660,ISO 3166-2:AI,Americas,Caribbean,019,029 +Antarctica,AQ,ATA,010,ISO 3166-2:AQ,,,, +Antigua and Barbuda,AG,ATG,028,ISO 3166-2:AG,Americas,Caribbean,019,029 +Argentina,AR,ARG,032,ISO 3166-2:AR,Americas,South America,019,005 +Armenia,AM,ARM,051,ISO 3166-2:AM,Asia,Western Asia,142,145 +Aruba,AW,ABW,533,ISO 3166-2:AW,Americas,Caribbean,019,029 +Australia,AU,AUS,036,ISO 3166-2:AU,Oceania,Australia and New Zealand,009,053 +Austria,AT,AUT,040,ISO 3166-2:AT,Europe,Western Europe,150,155 +Azerbaijan,AZ,AZE,031,ISO 3166-2:AZ,Asia,Western Asia,142,145 +Bahamas,BS,BHS,044,ISO 3166-2:BS,Americas,Caribbean,019,029 +Bahrain,BH,BHR,048,ISO 3166-2:BH,Asia,Western Asia,142,145 +Bangladesh,BD,BGD,050,ISO 3166-2:BD,Asia,Southern Asia,142,034 +Barbados,BB,BRB,052,ISO 3166-2:BB,Americas,Caribbean,019,029 +Belarus,BY,BLR,112,ISO 3166-2:BY,Europe,Eastern Europe,150,151 +Belgium,BE,BEL,056,ISO 3166-2:BE,Europe,Western Europe,150,155 +Belize,BZ,BLZ,084,ISO 3166-2:BZ,Americas,Central America,019,013 +Benin,BJ,BEN,204,ISO 3166-2:BJ,Africa,Western Africa,002,011 +Bermuda,BM,BMU,060,ISO 3166-2:BM,Americas,Northern America,019,021 +Bhutan,BT,BTN,064,ISO 3166-2:BT,Asia,Southern Asia,142,034 +Bolivia (Plurinational State of),BO,BOL,068,ISO 3166-2:BO,Americas,South America,019,005 +"Bonaire, Sint Eustatius and Saba",BQ,BES,535,ISO 3166-2:BQ,Americas,Caribbean,019,029 +Bosnia and Herzegovina,BA,BIH,070,ISO 3166-2:BA,Europe,Southern Europe,150,039 +Botswana,BW,BWA,072,ISO 3166-2:BW,Africa,Southern Africa,002,018 +Bouvet Island,BV,BVT,074,ISO 3166-2:BV,,,, +Brazil,BR,BRA,076,ISO 3166-2:BR,Americas,South America,019,005 +British Indian Ocean Territory,IO,IOT,086,ISO 3166-2:IO,,,, +Brunei Darussalam,BN,BRN,096,ISO 3166-2:BN,Asia,South-Eastern Asia,142,035 +Bulgaria,BG,BGR,100,ISO 3166-2:BG,Europe,Eastern Europe,150,151 +Burkina Faso,BF,BFA,854,ISO 3166-2:BF,Africa,Western Africa,002,011 +Burundi,BI,BDI,108,ISO 3166-2:BI,Africa,Eastern Africa,002,014 +Cambodia,KH,KHM,116,ISO 3166-2:KH,Asia,South-Eastern Asia,142,035 +Cameroon,CM,CMR,120,ISO 3166-2:CM,Africa,Middle Africa,002,017 +Canada,CA,CAN,124,ISO 3166-2:CA,Americas,Northern America,019,021 +Cabo Verde,CV,CPV,132,ISO 3166-2:CV,Africa,Western Africa,002,011 +Cayman Islands,KY,CYM,136,ISO 3166-2:KY,Americas,Caribbean,019,029 +Central African Republic,CF,CAF,140,ISO 3166-2:CF,Africa,Middle Africa,002,017 +Chad,TD,TCD,148,ISO 3166-2:TD,Africa,Middle Africa,002,017 +Chile,CL,CHL,152,ISO 3166-2:CL,Americas,South America,019,005 +China,CN,CHN,156,ISO 3166-2:CN,Asia,Eastern Asia,142,030 +Christmas Island,CX,CXR,162,ISO 3166-2:CX,,,, +Cocos (Keeling) Islands,CC,CCK,166,ISO 3166-2:CC,,,, +Colombia,CO,COL,170,ISO 3166-2:CO,Americas,South America,019,005 +Comoros,KM,COM,174,ISO 3166-2:KM,Africa,Eastern Africa,002,014 +Congo,CG,COG,178,ISO 3166-2:CG,Africa,Middle Africa,002,017 +Congo (Democratic Republic of the),CD,COD,180,ISO 3166-2:CD,Africa,Middle Africa,002,017 +Cook Islands,CK,COK,184,ISO 3166-2:CK,Oceania,Polynesia,009,061 +Costa Rica,CR,CRI,188,ISO 3166-2:CR,Americas,Central America,019,013 +Côte d'Ivoire,CI,CIV,384,ISO 3166-2:CI,Africa,Western Africa,002,011 +Croatia,HR,HRV,191,ISO 3166-2:HR,Europe,Southern Europe,150,039 +Cuba,CU,CUB,192,ISO 3166-2:CU,Americas,Caribbean,019,029 +Curaçao,CW,CUW,531,ISO 3166-2:CW,Americas,Caribbean,019,029 +Cyprus,CY,CYP,196,ISO 3166-2:CY,Asia,Western Asia,142,145 +Czech Republic,CZ,CZE,203,ISO 3166-2:CZ,Europe,Eastern Europe,150,151 +Denmark,DK,DNK,208,ISO 3166-2:DK,Europe,Northern Europe,150,154 +Djibouti,DJ,DJI,262,ISO 3166-2:DJ,Africa,Eastern Africa,002,014 +Dominica,DM,DMA,212,ISO 3166-2:DM,Americas,Caribbean,019,029 +Dominican Republic,DO,DOM,214,ISO 3166-2:DO,Americas,Caribbean,019,029 +Ecuador,EC,ECU,218,ISO 3166-2:EC,Americas,South America,019,005 +Egypt,EG,EGY,818,ISO 3166-2:EG,Africa,Northern Africa,002,015 +El Salvador,SV,SLV,222,ISO 3166-2:SV,Americas,Central America,019,013 +Equatorial Guinea,GQ,GNQ,226,ISO 3166-2:GQ,Africa,Middle Africa,002,017 +Eritrea,ER,ERI,232,ISO 3166-2:ER,Africa,Eastern Africa,002,014 +Estonia,EE,EST,233,ISO 3166-2:EE,Europe,Northern Europe,150,154 +Ethiopia,ET,ETH,231,ISO 3166-2:ET,Africa,Eastern Africa,002,014 +Falkland Islands (Malvinas),FK,FLK,238,ISO 3166-2:FK,Americas,South America,019,005 +Faroe Islands,FO,FRO,234,ISO 3166-2:FO,Europe,Northern Europe,150,154 +Fiji,FJ,FJI,242,ISO 3166-2:FJ,Oceania,Melanesia,009,054 +Finland,FI,FIN,246,ISO 3166-2:FI,Europe,Northern Europe,150,154 +France,FR,FRA,250,ISO 3166-2:FR,Europe,Western Europe,150,155 +French Guiana,GF,GUF,254,ISO 3166-2:GF,Americas,South America,019,005 +French Polynesia,PF,PYF,258,ISO 3166-2:PF,Oceania,Polynesia,009,061 +French Southern Territories,TF,ATF,260,ISO 3166-2:TF,,,, +Gabon,GA,GAB,266,ISO 3166-2:GA,Africa,Middle Africa,002,017 +Gambia,GM,GMB,270,ISO 3166-2:GM,Africa,Western Africa,002,011 +Georgia,GE,GEO,268,ISO 3166-2:GE,Asia,Western Asia,142,145 +Germany,DE,DEU,276,ISO 3166-2:DE,Europe,Western Europe,150,155 +Ghana,GH,GHA,288,ISO 3166-2:GH,Africa,Western Africa,002,011 +Gibraltar,GI,GIB,292,ISO 3166-2:GI,Europe,Southern Europe,150,039 +Greece,GR,GRC,300,ISO 3166-2:GR,Europe,Southern Europe,150,039 +Greenland,GL,GRL,304,ISO 3166-2:GL,Americas,Northern America,019,021 +Grenada,GD,GRD,308,ISO 3166-2:GD,Americas,Caribbean,019,029 +Guadeloupe,GP,GLP,312,ISO 3166-2:GP,Americas,Caribbean,019,029 +Guam,GU,GUM,316,ISO 3166-2:GU,Oceania,Micronesia,009,057 +Guatemala,GT,GTM,320,ISO 3166-2:GT,Americas,Central America,019,013 +Guernsey,GG,GGY,831,ISO 3166-2:GG,Europe,Northern Europe,150,154 +Guinea,GN,GIN,324,ISO 3166-2:GN,Africa,Western Africa,002,011 +Guinea-Bissau,GW,GNB,624,ISO 3166-2:GW,Africa,Western Africa,002,011 +Guyana,GY,GUY,328,ISO 3166-2:GY,Americas,South America,019,005 +Haiti,HT,HTI,332,ISO 3166-2:HT,Americas,Caribbean,019,029 +Heard Island and McDonald Islands,HM,HMD,334,ISO 3166-2:HM,,,, +Holy See,VA,VAT,336,ISO 3166-2:VA,Europe,Southern Europe,150,039 +Honduras,HN,HND,340,ISO 3166-2:HN,Americas,Central America,019,013 +Hong Kong,HK,HKG,344,ISO 3166-2:HK,Asia,Eastern Asia,142,030 +Hungary,HU,HUN,348,ISO 3166-2:HU,Europe,Eastern Europe,150,151 +Iceland,IS,ISL,352,ISO 3166-2:IS,Europe,Northern Europe,150,154 +India,IN,IND,356,ISO 3166-2:IN,Asia,Southern Asia,142,034 +Indonesia,ID,IDN,360,ISO 3166-2:ID,Asia,South-Eastern Asia,142,035 +Iran (Islamic Republic of),IR,IRN,364,ISO 3166-2:IR,Asia,Southern Asia,142,034 +Iraq,IQ,IRQ,368,ISO 3166-2:IQ,Asia,Western Asia,142,145 +Ireland,IE,IRL,372,ISO 3166-2:IE,Europe,Northern Europe,150,154 +Isle of Man,IM,IMN,833,ISO 3166-2:IM,Europe,Northern Europe,150,154 +Israel,IL,ISR,376,ISO 3166-2:IL,Asia,Western Asia,142,145 +Italy,IT,ITA,380,ISO 3166-2:IT,Europe,Southern Europe,150,039 +Jamaica,JM,JAM,388,ISO 3166-2:JM,Americas,Caribbean,019,029 +Japan,JP,JPN,392,ISO 3166-2:JP,Asia,Eastern Asia,142,030 +Jersey,JE,JEY,832,ISO 3166-2:JE,Europe,Northern Europe,150,154 +Jordan,JO,JOR,400,ISO 3166-2:JO,Asia,Western Asia,142,145 +Kazakhstan,KZ,KAZ,398,ISO 3166-2:KZ,Asia,Central Asia,142,143 +Kenya,KE,KEN,404,ISO 3166-2:KE,Africa,Eastern Africa,002,014 +Kiribati,KI,KIR,296,ISO 3166-2:KI,Oceania,Micronesia,009,057 +Korea (Democratic People's Republic of),KP,PRK,408,ISO 3166-2:KP,Asia,Eastern Asia,142,030 +Korea (Republic of),KR,KOR,410,ISO 3166-2:KR,Asia,Eastern Asia,142,030 +Kuwait,KW,KWT,414,ISO 3166-2:KW,Asia,Western Asia,142,145 +Kyrgyzstan,KG,KGZ,417,ISO 3166-2:KG,Asia,Central Asia,142,143 +Lao People's Democratic Republic,LA,LAO,418,ISO 3166-2:LA,Asia,South-Eastern Asia,142,035 +Latvia,LV,LVA,428,ISO 3166-2:LV,Europe,Northern Europe,150,154 +Lebanon,LB,LBN,422,ISO 3166-2:LB,Asia,Western Asia,142,145 +Lesotho,LS,LSO,426,ISO 3166-2:LS,Africa,Southern Africa,002,018 +Liberia,LR,LBR,430,ISO 3166-2:LR,Africa,Western Africa,002,011 +Libya,LY,LBY,434,ISO 3166-2:LY,Africa,Northern Africa,002,015 +Liechtenstein,LI,LIE,438,ISO 3166-2:LI,Europe,Western Europe,150,155 +Lithuania,LT,LTU,440,ISO 3166-2:LT,Europe,Northern Europe,150,154 +Luxembourg,LU,LUX,442,ISO 3166-2:LU,Europe,Western Europe,150,155 +Macao,MO,MAC,446,ISO 3166-2:MO,Asia,Eastern Asia,142,030 +Macedonia (the former Yugoslav Republic of),MK,MKD,807,ISO 3166-2:MK,Europe,Southern Europe,150,039 +Madagascar,MG,MDG,450,ISO 3166-2:MG,Africa,Eastern Africa,002,014 +Malawi,MW,MWI,454,ISO 3166-2:MW,Africa,Eastern Africa,002,014 +Malaysia,MY,MYS,458,ISO 3166-2:MY,Asia,South-Eastern Asia,142,035 +Maldives,MV,MDV,462,ISO 3166-2:MV,Asia,Southern Asia,142,034 +Mali,ML,MLI,466,ISO 3166-2:ML,Africa,Western Africa,002,011 +Malta,MT,MLT,470,ISO 3166-2:MT,Europe,Southern Europe,150,039 +Marshall Islands,MH,MHL,584,ISO 3166-2:MH,Oceania,Micronesia,009,057 +Martinique,MQ,MTQ,474,ISO 3166-2:MQ,Americas,Caribbean,019,029 +Mauritania,MR,MRT,478,ISO 3166-2:MR,Africa,Western Africa,002,011 +Mauritius,MU,MUS,480,ISO 3166-2:MU,Africa,Eastern Africa,002,014 +Mayotte,YT,MYT,175,ISO 3166-2:YT,Africa,Eastern Africa,002,014 +Mexico,MX,MEX,484,ISO 3166-2:MX,Americas,Central America,019,013 +Micronesia (Federated States of),FM,FSM,583,ISO 3166-2:FM,Oceania,Micronesia,009,057 +Moldova (Republic of),MD,MDA,498,ISO 3166-2:MD,Europe,Eastern Europe,150,151 +Monaco,MC,MCO,492,ISO 3166-2:MC,Europe,Western Europe,150,155 +Mongolia,MN,MNG,496,ISO 3166-2:MN,Asia,Eastern Asia,142,030 +Montenegro,ME,MNE,499,ISO 3166-2:ME,Europe,Southern Europe,150,039 +Montserrat,MS,MSR,500,ISO 3166-2:MS,Americas,Caribbean,019,029 +Morocco,MA,MAR,504,ISO 3166-2:MA,Africa,Northern Africa,002,015 +Mozambique,MZ,MOZ,508,ISO 3166-2:MZ,Africa,Eastern Africa,002,014 +Myanmar,MM,MMR,104,ISO 3166-2:MM,Asia,South-Eastern Asia,142,035 +Namibia,NA,NAM,516,ISO 3166-2:NA,Africa,Southern Africa,002,018 +Nauru,NR,NRU,520,ISO 3166-2:NR,Oceania,Micronesia,009,057 +Nepal,NP,NPL,524,ISO 3166-2:NP,Asia,Southern Asia,142,034 +Netherlands,NL,NLD,528,ISO 3166-2:NL,Europe,Western Europe,150,155 +New Caledonia,NC,NCL,540,ISO 3166-2:NC,Oceania,Melanesia,009,054 +New Zealand,NZ,NZL,554,ISO 3166-2:NZ,Oceania,Australia and New Zealand,009,053 +Nicaragua,NI,NIC,558,ISO 3166-2:NI,Americas,Central America,019,013 +Niger,NE,NER,562,ISO 3166-2:NE,Africa,Western Africa,002,011 +Nigeria,NG,NGA,566,ISO 3166-2:NG,Africa,Western Africa,002,011 +Niue,NU,NIU,570,ISO 3166-2:NU,Oceania,Polynesia,009,061 +Norfolk Island,NF,NFK,574,ISO 3166-2:NF,Oceania,Australia and New Zealand,009,053 +Northern Mariana Islands,MP,MNP,580,ISO 3166-2:MP,Oceania,Micronesia,009,057 +Norway,NO,NOR,578,ISO 3166-2:NO,Europe,Northern Europe,150,154 +Oman,OM,OMN,512,ISO 3166-2:OM,Asia,Western Asia,142,145 +Pakistan,PK,PAK,586,ISO 3166-2:PK,Asia,Southern Asia,142,034 +Palau,PW,PLW,585,ISO 3166-2:PW,Oceania,Micronesia,009,057 +"Palestine, State of",PS,PSE,275,ISO 3166-2:PS,Asia,Western Asia,142,145 +Panama,PA,PAN,591,ISO 3166-2:PA,Americas,Central America,019,013 +Papua New Guinea,PG,PNG,598,ISO 3166-2:PG,Oceania,Melanesia,009,054 +Paraguay,PY,PRY,600,ISO 3166-2:PY,Americas,South America,019,005 +Peru,PE,PER,604,ISO 3166-2:PE,Americas,South America,019,005 +Philippines,PH,PHL,608,ISO 3166-2:PH,Asia,South-Eastern Asia,142,035 +Pitcairn,PN,PCN,612,ISO 3166-2:PN,Oceania,Polynesia,009,061 +Poland,PL,POL,616,ISO 3166-2:PL,Europe,Eastern Europe,150,151 +Portugal,PT,PRT,620,ISO 3166-2:PT,Europe,Southern Europe,150,039 +Puerto Rico,PR,PRI,630,ISO 3166-2:PR,Americas,Caribbean,019,029 +Qatar,QA,QAT,634,ISO 3166-2:QA,Asia,Western Asia,142,145 +Réunion,RE,REU,638,ISO 3166-2:RE,Africa,Eastern Africa,002,014 +Romania,RO,ROU,642,ISO 3166-2:RO,Europe,Eastern Europe,150,151 +Russian Federation,RU,RUS,643,ISO 3166-2:RU,Europe,Eastern Europe,150,151 +Rwanda,RW,RWA,646,ISO 3166-2:RW,Africa,Eastern Africa,002,014 +Saint Barthélemy,BL,BLM,652,ISO 3166-2:BL,Americas,Caribbean,019,029 +"Saint Helena, Ascension and Tristan da Cunha",SH,SHN,654,ISO 3166-2:SH,Africa,Western Africa,002,011 +Saint Kitts and Nevis,KN,KNA,659,ISO 3166-2:KN,Americas,Caribbean,019,029 +Saint Lucia,LC,LCA,662,ISO 3166-2:LC,Americas,Caribbean,019,029 +Saint Martin (French part),MF,MAF,663,ISO 3166-2:MF,Americas,Caribbean,019,029 +Saint Pierre and Miquelon,PM,SPM,666,ISO 3166-2:PM,Americas,Northern America,019,021 +Saint Vincent and the Grenadines,VC,VCT,670,ISO 3166-2:VC,Americas,Caribbean,019,029 +Samoa,WS,WSM,882,ISO 3166-2:WS,Oceania,Polynesia,009,061 +San Marino,SM,SMR,674,ISO 3166-2:SM,Europe,Southern Europe,150,039 +Sao Tome and Principe,ST,STP,678,ISO 3166-2:ST,Africa,Middle Africa,002,017 +Saudi Arabia,SA,SAU,682,ISO 3166-2:SA,Asia,Western Asia,142,145 +Senegal,SN,SEN,686,ISO 3166-2:SN,Africa,Western Africa,002,011 +Serbia,RS,SRB,688,ISO 3166-2:RS,Europe,Southern Europe,150,039 +Seychelles,SC,SYC,690,ISO 3166-2:SC,Africa,Eastern Africa,002,014 +Sierra Leone,SL,SLE,694,ISO 3166-2:SL,Africa,Western Africa,002,011 +Singapore,SG,SGP,702,ISO 3166-2:SG,Asia,South-Eastern Asia,142,035 +Sint Maarten (Dutch part),SX,SXM,534,ISO 3166-2:SX,Americas,Caribbean,019,029 +Slovakia,SK,SVK,703,ISO 3166-2:SK,Europe,Eastern Europe,150,151 +Slovenia,SI,SVN,705,ISO 3166-2:SI,Europe,Southern Europe,150,039 +Solomon Islands,SB,SLB,090,ISO 3166-2:SB,Oceania,Melanesia,009,054 +Somalia,SO,SOM,706,ISO 3166-2:SO,Africa,Eastern Africa,002,014 +South Africa,ZA,ZAF,710,ISO 3166-2:ZA,Africa,Southern Africa,002,018 +South Georgia and the South Sandwich Islands,GS,SGS,239,ISO 3166-2:GS,,,, +South Sudan,SS,SSD,728,ISO 3166-2:SS,Africa,Eastern Africa,002,014 +Spain,ES,ESP,724,ISO 3166-2:ES,Europe,Southern Europe,150,039 +Sri Lanka,LK,LKA,144,ISO 3166-2:LK,Asia,Southern Asia,142,034 +Sudan,SD,SDN,729,ISO 3166-2:SD,Africa,Northern Africa,002,015 +Suriname,SR,SUR,740,ISO 3166-2:SR,Americas,South America,019,005 +Svalbard and Jan Mayen,SJ,SJM,744,ISO 3166-2:SJ,Europe,Northern Europe,150,154 +Swaziland,SZ,SWZ,748,ISO 3166-2:SZ,Africa,Southern Africa,002,018 +Sweden,SE,SWE,752,ISO 3166-2:SE,Europe,Northern Europe,150,154 +Switzerland,CH,CHE,756,ISO 3166-2:CH,Europe,Western Europe,150,155 +Syrian Arab Republic,SY,SYR,760,ISO 3166-2:SY,Asia,Western Asia,142,145 +"Taiwan, Province of China",TW,TWN,158,ISO 3166-2:TW,Asia,Eastern Asia,142,030 +Tajikistan,TJ,TJK,762,ISO 3166-2:TJ,Asia,Central Asia,142,143 +"Tanzania, United Republic of",TZ,TZA,834,ISO 3166-2:TZ,Africa,Eastern Africa,002,014 +Thailand,TH,THA,764,ISO 3166-2:TH,Asia,South-Eastern Asia,142,035 +Timor-Leste,TL,TLS,626,ISO 3166-2:TL,Asia,South-Eastern Asia,142,035 +Togo,TG,TGO,768,ISO 3166-2:TG,Africa,Western Africa,002,011 +Tokelau,TK,TKL,772,ISO 3166-2:TK,Oceania,Polynesia,009,061 +Tonga,TO,TON,776,ISO 3166-2:TO,Oceania,Polynesia,009,061 +Trinidad and Tobago,TT,TTO,780,ISO 3166-2:TT,Americas,Caribbean,019,029 +Tunisia,TN,TUN,788,ISO 3166-2:TN,Africa,Northern Africa,002,015 +Turkey,TR,TUR,792,ISO 3166-2:TR,Asia,Western Asia,142,145 +Turkmenistan,TM,TKM,795,ISO 3166-2:TM,Asia,Central Asia,142,143 +Turks and Caicos Islands,TC,TCA,796,ISO 3166-2:TC,Americas,Caribbean,019,029 +Tuvalu,TV,TUV,798,ISO 3166-2:TV,Oceania,Polynesia,009,061 +Uganda,UG,UGA,800,ISO 3166-2:UG,Africa,Eastern Africa,002,014 +Ukraine,UA,UKR,804,ISO 3166-2:UA,Europe,Eastern Europe,150,151 +United Arab Emirates,AE,ARE,784,ISO 3166-2:AE,Asia,Western Asia,142,145 +United Kingdom of Great Britain and Northern Ireland,GB,GBR,826,ISO 3166-2:GB,Europe,Northern Europe,150,154 +United States of America,US,USA,840,ISO 3166-2:US,Americas,Northern America,019,021 +United States Minor Outlying Islands,UM,UMI,581,ISO 3166-2:UM,,,, +Uruguay,UY,URY,858,ISO 3166-2:UY,Americas,South America,019,005 +Uzbekistan,UZ,UZB,860,ISO 3166-2:UZ,Asia,Central Asia,142,143 +Vanuatu,VU,VUT,548,ISO 3166-2:VU,Oceania,Melanesia,009,054 +Venezuela (Bolivarian Republic of),VE,VEN,862,ISO 3166-2:VE,Americas,South America,019,005 +Viet Nam,VN,VNM,704,ISO 3166-2:VN,Asia,South-Eastern Asia,142,035 +Virgin Islands (British),VG,VGB,092,ISO 3166-2:VG,Americas,Caribbean,019,029 +Virgin Islands (U.S.),VI,VIR,850,ISO 3166-2:VI,Americas,Caribbean,019,029 +Wallis and Futuna,WF,WLF,876,ISO 3166-2:WF,Oceania,Polynesia,009,061 +Western Sahara,EH,ESH,732,ISO 3166-2:EH,Africa,Northern Africa,002,015 +Yemen,YE,YEM,887,ISO 3166-2:YE,Asia,Western Asia,142,145 +Zambia,ZM,ZMB,894,ISO 3166-2:ZM,Africa,Eastern Africa,002,014 +Zimbabwe,ZW,ZWE,716,ISO 3166-2:ZW,Africa,Eastern Africa,002,014 diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index f6b3c0068f4d..bd0db4045bbe 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -26,6 +26,7 @@ #include "qgslogger.h" #include "qgslayermetadatavalidator.h" #include "qgisapp.h" +#include "qgsapplication.h" QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) : QDialog( parent ), mLayer( layer ) @@ -198,7 +199,7 @@ void QgsMetadataWizard::fillComboBox() comboLanguage->setEditable( true ); types.clear(); types << "" << "ENG" << "SPA" << "IND" << "FRE"; - comboLanguage->addItems( types ); + comboLanguage->addItems( parseLanguages() ); } void QgsMetadataWizard::setPropertiesFromLayer() @@ -329,3 +330,23 @@ bool QgsMetadataWizard::checkMetadata() return results; } + +QStringList QgsMetadataWizard::parseLanguages() +{ + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "country_code_ISO_3166.csv" ) ); + QFile file( path ); + if ( !file.open( QIODevice::ReadOnly ) ) + { + QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + } + + QStringList wordList; + // Skip the first line of the CSV + file.readLine(); + while ( !file.atEnd() ) + { + QByteArray line = file.readLine(); + wordList.append( line.split( ',' ).at( 2 ) ); + } + return wordList; +} diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index 1218f8f5d872..0c942d596dfc 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -36,6 +36,7 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza void setPropertiesFromLayer(); void saveMetadata( QgsLayerMetadata &layerMetadata ); bool checkMetadata(); + QStringList parseLanguages(); private: void cancelClicked(); diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index 13d14d9d0b67..8720c61632d2 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -626,6 +626,11 @@ QString QgsApplication::i18nPath() return ABISYM( mPkgDataPath ) + QStringLiteral( "/i18n/" ); } +QString QgsApplication::metadataPath() +{ + return ABISYM( mPkgDataPath ) + QStringLiteral( "/resources/metadata-ISO/" ); +} + QString QgsApplication::qgisMasterDatabaseFilePath() { return ABISYM( mPkgDataPath ) + QStringLiteral( "/resources/qgis.db" ); diff --git a/src/core/qgsapplication.h b/src/core/qgsapplication.h index b51e0469e447..e5bca1cd2250 100644 --- a/src/core/qgsapplication.h +++ b/src/core/qgsapplication.h @@ -237,6 +237,9 @@ class CORE_EXPORT QgsApplication : public QApplication //! Returns the path to the translation directory. static QString i18nPath(); + //! Returns the path to the metadata directory. + static QString metadataPath(); + //! Returns the path to the master qgis.db file. static QString qgisMasterDatabaseFilePath(); From c58567b536a1754448b10c9c4ab9e869858fa264 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Tue, 18 Jul 2017 11:43:56 +0300 Subject: [PATCH 07/39] add link type CSV, add keywords --- .../metadata-ISO/LinkPropertyLookupTable.csv | 68 +++ src/app/qgsmetadatawizard.cpp | 101 ++++- src/app/qgsmetadatawizard.h | 4 + src/ui/qgsmetadatawizard.ui | 412 +++++++++--------- 4 files changed, 357 insertions(+), 228 deletions(-) create mode 100644 resources/metadata-ISO/LinkPropertyLookupTable.csv diff --git a/resources/metadata-ISO/LinkPropertyLookupTable.csv b/resources/metadata-ISO/LinkPropertyLookupTable.csv new file mode 100644 index 000000000000..32c6c8f695d5 --- /dev/null +++ b/resources/metadata-ISO/LinkPropertyLookupTable.csv @@ -0,0 +1,68 @@ +identifier,uri,label,url,target,owner,resource_type,registrant,comments,deprecated +OGC:CSW,http://www.opengis.net/def/serviceType/ogc/csw,OGC Catalogue Service for the Web,http://www.opengeospatial.org/standards/cat,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Catalog service for the web v2.0.2 endpoint (should use differnt protocol identifier if the endpoint is not v2.0.2; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. , +OGC:SOS,http://www.opengis.net/def/serviceType/ogc/sos,OGC Sensor Observation Service,http://www.opengeospatial.org/standards/sos,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Sensor Observation service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different offerings, the parameters necessary to access the correct offering should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.",urn:x-esri:specification:ServiceType:SOS; urn:x-esri:specification:ServiceType:sos:url +OGC:SPS,http://www.opengeospatial.org/standards/sps,OGC Sensor Planning Service,http://www.opengeospatial.org/standards/sps,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an Sensor Planning Service , +OGC:SAS,http://www.ogcnetwork.net/SAS,OGC Sensor Alert Service,http://www.ogcnetwork.net/SAS,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an Sensor Alert Service, +OGC:WNS,http://www.ogcnetwork.net/WNS,OGC Web Notification Service,http://portal.opengeospatial.org/files/?artifact_id=1367,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an Web Notification Service , +OGC:WCS,http://www.opengis.net/def/serviceType/ogc/wcs,OGC Web Coverage Service,http://www.opengeospatial.org/standards/wcs,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web coverage service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different coverages, the parameters necessary to access the correct coverage should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.",urn:x-esri:specification:ServiceType:WCS; urn:x-esri:specification:ServiceType:wcs:url +OGC:WFS,http://www.opengis.net/def/serviceType/ogc/wfs,OGC Web Feature Service,http://www.opengeospatial.org/standards/wfs,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Feature Service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different feature types the typeName parameter necessary to access the correct data should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.,urn:x-esri:specification:ServiceType:WFS; urn:x-esri:specification:ServiceType:wfs:url +OGC:WMS,http://www.opengis.net/def/serviceType/ogc/wms,OGC Web Map Service,http://www.opengeospatial.org/standards/wms,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Map Service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different map layers, the layers parameters necessary to access the correct data should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.",urn:x-esri:specification:ServiceType:WMS; urn:x-esri:specification:ServiceType:wms:url +OGC:WMS-C,http://www.opengis.net/def/serviceType/ogc/wms,OGC Web Map Service - Cached,https://wiki.osgeo.org/wiki/WMS_Tile_Caching,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pacioos,"This is an unofficial profile of WMS using OSGeo recommendations to pull cached map tiles from the server when available. Often this is specified with a 'tiled=true' URL parameter in the GetMap request.", "While WMS-C has been superceded by the OSGeo Tile Map Service specification (TMS) and the OGC Web Map Tile Service standard (WMTS), it is still widely supported." +OGC:WMTS,http://www.opengeospatial.org/standards/wmts,OGC Web Map Tile Service,http://www.opengeospatial.org/standards/wmts,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Map Tile Service, +OGC:WPS,http://www.opengis.net/def/serviceType/ogc/wps,OGC Web Processing Service,http://www.opengeospatial.org/standards/wps,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Processing Service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Other parameters necessary to access the correct processing service should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters., +OGC:ODS,http://www.opengeospatial.org/standards/ols#ods,OGC OpenLS Directory Service,http://www.opengeospatial.org/standards/ols,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC OpenLS Directory Service , +OGC:OGS,http://www.opengeospatial.org/standards/ols#ogs,OGC OpenLS Gateway Service,http://www.opengeospatial.org/standards/ols,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC OpenLS Gateway Service, +OGC:OUS,http://www.opengeospatial.org/standards/ols#ous,OGC OpenLS Utility Service,http://www.opengeospatial.org/standards/ols,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC OpenLS Utility Service, +OGC:OPS,http://www.opengeospatial.org/standards/ols#ops,OGC OpenLS Presentation Service,http://www.opengeospatial.org/standards/ols,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC OpenLS Presentation Service , +OGC:ORS,http://www.opengeospatial.org/standards/ols#ors,OGC OpenLS Route Service,http://www.opengeospatial.org/standards/ols,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC OpenLS Route Service, +OGC:CT,http://www.opengeospatial.org/standards/ct,OGC Coordinate Transformation Service,http://www.opengeospatial.org/standards/ct,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Coordinate Transformation Service, +OGC:WFS-G,http://www.opengeospatial.org/standards/wfs-g,Gazetteer Service Profile of the Web Feature Service Implementation Specification,http://portal.opengeospatial.org/files/?artifact_id=7175,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Gazetteer Service Profile of the Web Feature Service Implementation Specification, +OGC:OWC,http://www.opengeospatial.org/standards/owc,OGC OWS Context,http://www.opengeospatial.org/standards/owc,gmd:MD_Format/gmd:name;gmd:applicationProfile,,data,@pvgenuchten,Specifies a fully configured service set which can be exchanged, +OGC:GPKG,http://www.opengeospatial.org/standards/geopackage,OGC Geopackage,http://www.opengeospatial.org/standards/geopackage,gmd:MD_Format/gmd:name;gmd:applicationProfile,,data,@pvgenuchten,SQLite Extension for exchange or direct use of vector geospatial features and / or tile matrix sets of earth images and raster maps at various scales, +OGC:IoT,http://www.ogcnetwork.net/IoT,OGC SensorThings API,http://ogc-iot.github.io/ogc-iot-api,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for a SensorThings API, +ESRI:ArcIMS,urn:x-esri:serviceType:ArcIMS,ESRI ArcIMS Service,,srv:serviceType;gmd:protocol;usgin:overlayAPI,Esri Inc.,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an ArcIMS endpoint. ArcIMS requests are tunneled via HTTP Get URL's, +ESRI:ArcGIS,urn:x-esri:serviceType:ArcGIS,ESRI ArcGIS Service,,srv:serviceType;gmd:protocol;usgin:overlayAPI,Esri Inc.,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an ESRI Map service endpoint. ESRI REST requests are tunneled via HTTP Get URL's, +ESRI:MPK,http://esriurl.com/mpk.xml,ArcGIS Map Package, http://esriurl.com/mpk.xml,gmd:MD_Format/gmd:name;gmd:applicationProfile,Esri Inc.,data,@mhogeweg,"Example URI for ArcGIS Map Package. Mpk is a file format. A map package contains a map document (.mxd) and the data referenced by the layers it contains, packaged into one convenient, portable file.", +OPeNDAP:OPeNDAP,,OPeNDAP root URL,http://docs.opendap.org/index.php/UserGuideOPeNDAPMessages,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"Link is the root URL for an OpenDAP endpoint. An OPeNDAP server replies to queries for data and other services in the form of specially formed URLs that start with a root URL, and use a suffix on the root URL and a constraint expression to indicate which service is requested and what the parameters are. Example suffixes are dods, das, dds, nc. OpenDAP defines a syntax for constraint expressions as well.",urn:x-esri:specification:ServiceType:OPeNDAP; urn:x-esri:specification:ServiceType:odp:url +OPeNDAP:Hyrax,,OPeNDAP Hyrax server,http://docs.opendap.org/index.php/Hyrax,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@amilan17,"Link is the root URL for an This is the OPeNDAP 4 Data Server, also known as Hyrax. Hyrax is a data server that implements the DAP2 and DAP4 protocols, works with a number of different data formats and supports a wide variety of customization options from tailoring the look of the server's web pages to complex server-side processing operations.", +UNIDATA:NCSS,,NetCDF Subset Service,https://www.unidata.ucar.edu/software/thredds/current/tds/interfaceSpec/NetcdfSubsetService.html,gmd:protocol; usgin:overlayAPI,,service,@tomkralidis,"Link is the root URL for a THREDDS datasets. The NetCDF Subset Service enables subsetting CDM scientific datasets using earth coordinates, such as lat/lon bounding boxes and date ranges; requests are made via HTTP GET with key-value pairs (KVP) for parameters encoded in HTTP URIs. The resources identified are THREDDS datasets. The resource URIs have a root host name and path, typically something like http://servername:8080/thredds/ncss/, followed by a path that identifies a particular dataset {path/dataset}. A subset of the dataset is considered a view of a resource, specified by query parameters following the character '?' after the dataset path: http://servername:8080/thredds/ncss/{path/dataset}?{subset}. An 'accept' parameter may be used to specify the desired resource representation.", +UNIDATA:CDM,,Common Data Model Remote Web Service,https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/stream/CdmRemote.html,srv:serviceType;gmd:protocol;usgin:overlayAPI,Unidata,service,@tomkralidis,Example, +UNIDATA:CdmRemote,,Common Data Model index subsetting,https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/stream/CdmRemote.html,gmd:protocol; usgin:overlayAPI,Unidata,service,@smrazgs,"CDM Remote provides remote access to UNIDATA Common Data Model (CDM) datasets, using ncstream as the on-the-wire protocol. Client requests are of the form endpoint?query, and the specification defines a vocabulary of valid query parameters. There are two levels of service: 1) CdmRemote provides index subsetting on remote CDM datasets; 2) CdmrFeature provides coordinate subsetting on remote CDM Feature Datasets", +UNIDATA:CdmrFeature,,Common Data Model coordinate subsetting,https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/stream/CdmRemote.html,gmd:protocol; usgin:overlayAPI,Unidata,,@smrazgs,"Link is endpoint URL that provides coordinate subsetting on UNIDATA Common Data Model (CDM) datasets, using ncstream as the on-the-wire protocol. Client requests are of the form endpoint?query, and the specification defines a vocabulary of valid query parameters.", +UNIDATA:THREDDS,http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0,THREDDS Catalog,http://www.unidata.ucar.edu/software/thredds/current/tds/catalog/InvCatalogSpec.html,srv:serviceType;gmd:protocol;usgin:overlayAPI,Unidata,service,@kwilcox,"Link is a THREDDS Catalog URL that provides the XML for traversing programatically. Can be used for datasets and collections of datasets.", +OGC:GML,http://www.opengis.net/gml,OGC Geography Markup Language,,gmd:MD_Format/gmd:name;gmd:applicationProfile,,data,@tomkralidis,Example, +WWW:LINK,http://www.w3.org/TR/xlink/,Web Address (URL),,dct:references/@scheme,,information,@tomkralidis @smrazgs,Indicates that XLINK properties are encoded as key-value pairs in content of a dct:references element to provide a machine actionable link. , +WWW:WSDL,http://www.w3.org/TR/wsdl,Web Service Description Language XML document describing service operation,http://www.w3.org/TR/wsdl,gmd:applicationProfile,W3C,,@smrazgs,, +WWW:SPARQL:1.1,http://www.w3.org/TR/sparql11-protocol,SPARQL protocol for HTTP,http://www.w3.org/TR/rdf-sparql-query,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,SPARQL Protocol specifies a means for conveying SPARQL queries and updates to a SPARQL processing service and returning the results via HTTP to the entity that requested them, +OpenSearch1.1,http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_URL_template_syntax,OpenSearch template,http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_URL_template_syntax,usgin:template;gmd:applicationProfile,OpenSearch.org,,@smrazgs,use to indicate link is a template conforming to the OpenSearch specification, +OpenSearch1.1:Description,http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document,OpenSearch description document,http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document,gmd:applicationProfile,OpenSearch.org,,@smrazgs,indicates a link to get an openSearch description document, +information,,link provides information about resource,,gmd:function,ISO TC211,,@smrazgs,function of link it to http:GET information about resource, +template,http://tools.ietf.org/html/rfc6570,link provides template to access resource,http://tools.ietf.org/html/rfc6570,gmd:function,USGIN,,@smrazgs,Link text is a URI template; applicationProfile attribute value associated with the link should indicate the specification for the template scheme (e.g. OpenSearch1.1)., +download,,link will get resource,,gmd:function,ISO TC211,,@smrazgs,function of link it to http:GET a representation of the resource; the link type attribute value(s) should indicate the MIME types of available representations, +service,,link is service endpoint,,gmd:function,ISO TC211,,@smrazgs,"Link value is the URL of a service endpoint; the link protocol and applicationProfile (and possibly other link properties like overlayAPI, depending on the link attributes profile in use) attribute values should identify the service protocol specification", +order,,link provides form to obtain resource,,gmd:function,ISO TC211,,@smrazgs,link value is URL of web application requiring user interaction to order/request access to the resource, +search,,link provides form for searching resource,,gmd:function,ISO TC211,,@smrazgs,link value is URL of web application requiring user interaction to search/browse/subset the resource., +esip:CollectionCast,http://commons.esipfed.org/ns/discovery/1.2/collectionCast# ,ESIP collection cast,,gmd:applicationProfile,ESIP,,@smrazgs,, +tilejson:2.0.0,,tile mill map service description,https://github.com/mapbox/tilejson-spec,gmd:applicationProfile,MapBox,,@smrazgs,link is description of a TileMill map service endpoint. Link type would be application/json; function would be information., +iris:fdsnws-event,http://service.iris.edu/fdsnws/event/1/,IRIS Seismic event service,http://service.iris.edu/fdsnws/event/1,gmd:applicationProfile;usgin:overlayAPI,IRIS,,@smrazgs,Link returns event (earthquake) information from the catalogs submitted to the IRIS DMC, +QuakeML1.2,http://quakeml.org /xmlns /quakeml/1.2,Earthquake markup language,https://quake.ethz.ch/quakeml,gmd:MD_Format/gmd:name;gmd:applicationProfile,quakeml@sed.ethz.ch,,@smrazgs,XML markup language for earthquake hypocenter data, +file,,a file,http://docs.ckan.org/en/ckan-1.8/domain-model-resource.html,gmd:function,OKFN,,@smrazgs,CKAN metadata vocabulary for populating the type attribute on a CKAN resource; indicates that an http GET of this url should yield a bitstream, +ISO 19115:2003/19139,,ISO 19115 metadata in ISO19139 encoding,,gmd:metadataStandardName,GeoNetwork,,@smrazgs,This is the CharacterString value used by Geonetwork OpenSource to identify ISO metadata record instances; apparently have to assume that its using the 2006 corrigendum with no specific profile conventions., +ISO-USGIN,,USGIN-profile ISO 19115 metadata,http://repository.usgin.org/uri_gin/usgin/dlio/337,gmd:metadataStandardName,USGIN,,@smrazgs,This is the CharacterString Value mandated by the USGIN profile of ISO19115/19139 for instance documents to self-identify. , +http,https://www.ietf.org/rfc/rfc2616,"Hypertext transfer Protocol, v1.1",https://www.ietf.org/rfc/rfc2616.txt,gmd:protocol,IETF,,@smrazgs,Use to indicate gmd:CI_OnlineResource URLs that are simple http links to a target resource representation for download; redundant as the URL prefix 'http:' conveys the same information., +https,https://tools.ietf.org/html/rfc2818,HTTP over TLS,https://www.ietf.org/rfc/rfc2818.txt,gmd:protocol,IETF,,@amilan17,Use to indicate gmd:CI_OnlineResource URLs that are simple https links to a target resource representation for download; redundant as the URL prefix 'https:' conveys the same information., +ftp,https://tools.ietf.org/html/rfc959,FILE TRANSFER PROTOCOL (FTP),https://www.ietf.org/rfc/rfc959.txt,gmd:protocol,IETF,,@amilan17,Use to indicate gmd:CI_OnlineResource URLs that are simple ftp links to a target resource representation for download; redundant as the URL prefix 'ftp:' conveys the same information., +IETF:GeoJSON,http://geojson.org,GeoJSON,https://datatracker.ietf.org/doc/draft-butler-geojson,gmd:MD_Format/gmd:name;gmd:applicationProfile,,data,@pvgenuchten,GeoJSON is a geospatial data interchange format based on JavaScript Object Notation (JSON), +GIT,http://git-scm.com/,GIT,http://git-scm.com/book/commands,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for a GIT repository, +OKFN:datapackage,http://data.okfn.org/doc/data-package,OKFN Data Package,http://dataprotocols.org/data-packages,gmd:MD_Format/gmd:name;gmd:applicationProfile,,data,@pvgenuchten,A Data Package is a simple way of packaging up data, +boundless:geogig,http://geogig.org,Boundless GeoGig,http://geogig.org/docs/interaction/web-api.html,srv:serviceType;gmd:protocol;usgin:overlayAPI,Boundless,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for a GeoGig REST API, +OASIS:OData:4.0,http://docs.oasis-open.org/odata/odata/v4.0,OData v4.0,http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OData JSON endpoint, +maxogden:dat,http://dat-data.com,dat REST API,https://github.com/maxogden/dat/blob/master/docs/rest-api.md,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for a dat REST API, +geoserver:rest,http://docs.geoserver.org/latest/en/user/rest,GeoServer REST configuration API,http://docs.geoserver.org/latest/en/user/rest,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for a Geoserver rest API to configure featuretypes in Geoserver (and mapserver) remotely, +google:protocol-buffers,https://developers.google.com/protocol-buffers,Google Protocol Buffers,https://developers.google.com/protocol-buffers,gmd:MD_Format/gmd:name;gmd:applicationProfile,Google,data,@pvgenuchten,Googles mechanism for serializing structured data, +google:fusion-tables,http://google.com/fusiontables,Google Fusion Tables,https://developers.google.com/fusiontables,gmd:MD_Format/gmd:name;gmd:applicationProfile,Google,data,@pvgenuchten,Google mechanism for interating with online data tables, +NOAA:LAS,http://ferret.pmel.noaa.gov/LAS,Live Access Server,http://ferret.pmel.noaa.gov/LAS/documentation/developer-documentation/the-xml-messages-used-by-las,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is a LAS endpoint, +OSM,http://wiki.openstreetmap.org/wiki/API,Open Street Map API,http://wiki.openstreetmap.org/wiki/API,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for a OSM APIfor fetching and saving raw geodata from/to an OpenStreetMap database , +ERDDAP:griddap,http://coastwatch.pfeg.noaa.gov/erddap/griddap/documentation.html,ERDDAP Data Service for Gridded Datasets,http://coastwatch.pfeg.noaa.gov/erddap/griddap/documentation.html,srv:serviceType;gmd:protocol;usgin:overlayAPI,@BobSimons,service,@BobSimons,"griddap lets you request a data subset, graph, or map from a gridded dataset (for example, sea surface temperature data from a satellite), via a specially formed URL. griddap uses the OPeNDAP (external link) Data Access Protocol (DAP) (external link) and its projection constraints (external link). Link is the root URL for an ERDDAP griddap service endpoint. The service responds to OPeNDAP requests and related ERDDAP-specific requests to a gridded dataset. A request starts with this root URL, adds a file type extension, and sometimes a constraint expression to specify a subset of data. Example file type extensions which don't require a constraint are .das, .dds, .html, and .graph. Example file type extensions which do require a constraint are .dods, .nc, .mat, .json, and .htmlTable. Full documentation for ERDDAP API at http://coastwatch.pfeg.noaa.gov/erddap/rest.html", +ERDDAP:tabledap,http://coastwatch.pfeg.noaa.gov/erddap/tabledap/documentation.html,ERDDAP Data Service for Tabular Datasets,http://coastwatch.pfeg.noaa.gov/erddap/tabledap/documentation.html,srv:serviceType;gmd:protocol;usgin:overlayAPI,@BobSimons,service,@BobSimons,"Tabledap lets you request a data subset, a graph, or a map from a tabular dataset (for example, buoy data), via a specially formed URL. tabledap uses the OPeNDAP (external link) Data Access Protocol (DAP) (external link) and its selection constraints (external link). Link is the root URL for an ERDDAP tabledap service endpoint. The service responds to OPeNDAP requests and related ERDDAP-specific requests to a tabular (sequence) dataset. A request starts with this root URL, adds a file type extension, and sometimes a constraint expression to specify a subset of data. Example file type extensions which don't require a constraint are .das, .dds, .html, and .graph. Example file type extensions which do require a constraint are .dods, .nc, .mat, .json, and .htmlTable. Full documentation for ERDDAP API at http://coastwatch.pfeg.noaa.gov/erddap/rest.html", +OASIS:AMQP,https://amqp.org,Advanced Message Queuing Protocol,https://amqp.org,gmd:protocol,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an AMQP broker, diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index bd0db4045bbe..2ff4e8f2fef0 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -44,6 +44,9 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) connect( backButton, &QPushButton::clicked, this, &QgsMetadataWizard::backClicked ); connect( nextButton, &QPushButton::clicked, this, &QgsMetadataWizard::nextClicked ); connect( finishButton, &QPushButton::clicked, this, &QgsMetadataWizard::finishedClicked ); + connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWizard::setAutoSource ); + connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWizard::addVocabulary ); + connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWizard::removeVocabulary ); connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWizard::addLink ); connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWizard::removeLink ); connect( btnCheckMetadata, &QPushButton::clicked, this, &QgsMetadataWizard::checkMetadata ); @@ -56,6 +59,38 @@ QgsMetadataWizard::~QgsMetadataWizard() { } +void QgsMetadataWizard::setAutoSource() +{ + lineEditIdentifier->setText( mLayer->publicSource() ); +} + +void QgsMetadataWizard::addVocabulary() +{ + int row = tabKeywords->rowCount(); + tabKeywords->setRowCount( row + 1 ); + QTableWidgetItem *pCell; + + // Vocabulary + pCell = new QTableWidgetItem( QString( "undefined %1" ).arg( row ) ); + tabKeywords->setItem( row, 0, pCell ); + + // Keywords + pCell = new QTableWidgetItem(); + tabKeywords->setItem( row, 1, pCell ); +} + +void QgsMetadataWizard::removeVocabulary() +{ + QItemSelectionModel *selectionModel = tabKeywords->selectionModel(); + QModelIndexList selectedRows = selectionModel->selectedRows(); + QgsDebugMsg( QString( "Remove: %1 " ).arg( selectedRows.count() ) ); + + for ( int i = 0 ; i < selectedRows.size() ; i++ ) + { + tabKeywords->model()->removeRow( selectedRows[i].row() ); + } +} + void QgsMetadataWizard::cancelClicked() { hide(); @@ -82,7 +117,6 @@ void QgsMetadataWizard::finishedClicked() // OLD API (to remove later) mLayer->setName( lineEditTitle->text() ); mLayer->setAbstract( textEditAbstract->toPlainText() ); - mLayer->setKeywordList( textEditKeywords->toPlainText() ); // New Metadata API saveMetadata( mMetadata ); @@ -140,16 +174,14 @@ void QgsMetadataWizard::addLink() // See https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv QComboBox *typeCombo = new QComboBox(); typeCombo->setEditable( true ); - QStringList types; - types << "" << "OGC:CSW" << "OGC:SOS" << "OGC:WFS"; - typeCombo->addItems( types ); + typeCombo->addItems( parseLinkTypes() ); tabLinks->setCellWidget( row, 1, typeCombo ); - // Description + // URL pCell = new QTableWidgetItem(); tabLinks->setItem( row, 2, pCell ); - // URL + // Description pCell = new QTableWidgetItem(); tabLinks->setItem( row, 3, pCell ); @@ -198,7 +230,6 @@ void QgsMetadataWizard::fillComboBox() // It is advised to use the ISO 639.2 or ISO 3166 specifications, e.g. 'ENG' or 'SPA', comboLanguage->setEditable( true ); types.clear(); - types << "" << "ENG" << "SPA" << "IND" << "FRE"; comboLanguage->addItems( parseLanguages() ); } @@ -208,11 +239,16 @@ void QgsMetadataWizard::setPropertiesFromLayer() layerLabel->setText( mLayer->name() ); lineEditTitle->setText( mLayer->name() ); textEditAbstract->setText( mLayer->abstract() ); - textEditKeywords->setText( mLayer->keywordList() ); // Set all properties USING THE NEW API // It will overwrite existing settings + // Identifier + if ( ! mMetadata.identifier().isEmpty() ) + { + lineEditIdentifier->setText( mMetadata.identifier() ); + } + // Title if ( ! mMetadata.title().isEmpty() ) { @@ -239,6 +275,18 @@ void QgsMetadataWizard::setPropertiesFromLayer() comboLanguage->setCurrentIndex( comboLanguage->findText( mMetadata.language() ) ); } + // Keywords + tabKeywords->setRowCount( 0 ); + QMapIterator i( mMetadata.keywords() ); + while ( i.hasNext() ) + { + i.next(); + addVocabulary(); + int currentRow = tabKeywords->rowCount() - 1; + tabKeywords->item( currentRow, 0 )->setText( i.key() ); + tabKeywords->item( currentRow, 1 )->setText( i.value().join( "," ) ); + } + // Links tabLinks->setRowCount( 0 ); for ( QgsLayerMetadata::Link link : mMetadata.links() ) @@ -255,8 +303,8 @@ void QgsMetadataWizard::setPropertiesFromLayer() } combo->setCurrentIndex( combo->findText( link.type ) ); } - tabLinks->item( currentRow, 2 )->setText( link.description ); - tabLinks->item( currentRow, 3 )->setText( link.url ); + tabLinks->item( currentRow, 2 )->setText( link.url ); + tabLinks->item( currentRow, 3 )->setText( link.description ); tabLinks->item( currentRow, 4 )->setText( link.format ); if ( ! link.mimeType.isEmpty() ) { @@ -273,11 +321,20 @@ void QgsMetadataWizard::setPropertiesFromLayer() void QgsMetadataWizard::saveMetadata( QgsLayerMetadata &layerMetadata ) { + layerMetadata.setIdentifier( lineEditIdentifier->text() ); layerMetadata.setTitle( lineEditTitle->text() ); layerMetadata.setType( comboType->currentText() ); layerMetadata.setLanguage( comboLanguage->currentText() ); layerMetadata.setAbstract( textEditAbstract->toPlainText() ); + // Keywords + QMap keywords; + for ( int i = 0 ; i < tabKeywords->rowCount() ; i++ ) + { + keywords.insert( tabKeywords->item( i, 0 )->text(), tabKeywords->item( i, 1 )->text().split( "," ) ); + } + layerMetadata.setKeywords( keywords ); + // Links QList links; for ( int i = 0 ; i < tabLinks->rowCount() ; i++ ) @@ -285,8 +342,8 @@ void QgsMetadataWizard::saveMetadata( QgsLayerMetadata &layerMetadata ) struct QgsLayerMetadata::Link link = QgsLayerMetadata::Link(); link.name = tabLinks->item( i, 0 )->text(); link.type = dynamic_cast( tabLinks->cellWidget( i, 1 ) )->currentText(); - link.description = tabLinks->item( i, 2 )->text(); - link.url = tabLinks->item( i, 3 )->text(); + link.url = tabLinks->item( i, 2 )->text(); + link.description = tabLinks->item( i, 3 )->text(); link.format = tabLinks->item( i, 4 )->text(); link.mimeType = dynamic_cast( tabLinks->cellWidget( i, 5 ) )->currentText(); link.size = tabLinks->item( i, 6 )->text(); @@ -350,3 +407,23 @@ QStringList QgsMetadataWizard::parseLanguages() } return wordList; } + +QStringList QgsMetadataWizard::parseLinkTypes() +{ + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "LinkPropertyLookupTable.csv" ) ); + QFile file( path ); + if ( !file.open( QIODevice::ReadOnly ) ) + { + QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + } + + QStringList wordList; + // Skip the first line of the CSV + file.readLine(); + while ( !file.atEnd() ) + { + QByteArray line = file.readLine(); + wordList.append( line.split( ',' ).at( 0 ) ); + } + return wordList; +} diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index 0c942d596dfc..edd444abd678 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -30,6 +30,9 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer = nullptr ); ~QgsMetadataWizard(); + void setAutoSource(); + void addVocabulary(); + void removeVocabulary(); void addLink(); void removeLink(); void fillComboBox(); @@ -37,6 +40,7 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza void saveMetadata( QgsLayerMetadata &layerMetadata ); bool checkMetadata(); QStringList parseLanguages(); + QStringList parseLinkTypes(); private: void cancelClicked(); diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui index fb659080098a..f62bd1aa39cb 100644 --- a/src/ui/qgsmetadatawizard.ui +++ b/src/ui/qgsmetadatawizard.ui @@ -41,23 +41,23 @@ QFrame::Raised - - + + - font: 16pt; color: #fff; + font: 22pt; color: #fff; - Placeholder set in C++ code for the layer title being edited + Metadata Editor - - + + - font: 22pt; color: #fff; + font: 16pt; color: #fff; - Metadata Editor + Placeholder set in C++ code for the layer title being edited @@ -78,6 +78,7 @@ QFrame::NoFrame + tabWidget @@ -99,208 +100,181 @@ - Identification, HELP TEXT + Identification dialog, HELP TEXT TO ADD + + + + + + + Identifier - - - 0 + + + + + + Set from layer source - - - - Title - - - - - - - - 0 - 0 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Type - - - - - - - true - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Language - - - - - - - true - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Encoding - - - - - - - false - - - - Society - - - - - Economy - - - - - Utilities Communication - - - - - Environment - - - - - Oceans - - - - - + + + + + + + + Title + + + + + + + + 0 + 0 + + + + + + + + Type (it is advised to use the ISO 19115 MD_ScopeCode) + + + + + + + true + + + true + + + + + + + Language (it is advised to follow either the ISO 639.2 or ISO 3166) + + + + + + + true + + + true + + + + + + + Abstract + + + + + + + + 0 + 0 + + + + + + + + + Keywords + + + + + + Keywords dialog, the VOCABULARY must be unique. HELP TEXT TO ADD + + + + + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + Vocabulary + + + + + Keywords + + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + false + + - - - - - Free-text Keywords - - - - - - - false - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Abstract - - - - - - - - 0 - 0 - - - - - + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + @@ -584,12 +558,18 @@ - Links, HELP TEXT + Links dialog, HELP TEXT TO ADD + + true + + + QAbstractItemView::SingleSelection + QAbstractItemView::SelectRows @@ -605,12 +585,12 @@ - Description + URL - URL + Description @@ -716,24 +696,24 @@ - - + + - Next + Save - - + + - Cancel + Back - - + + - Save + Cancel @@ -750,10 +730,10 @@ - - + + - Back + Next From 28e21b7498d687eb7743d41d0946c08ea4f74bb5 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 19 Jul 2017 10:01:41 +0300 Subject: [PATCH 08/39] add licenses --- resources/metadata-ISO/licenses.csv | 7 + src/app/qgsmetadatawizard.cpp | 75 +++++++++++ src/app/qgsmetadatawizard.h | 3 + src/ui/qgsmetadatawizard.ui | 202 +++++++++------------------- 4 files changed, 151 insertions(+), 136 deletions(-) create mode 100644 resources/metadata-ISO/licenses.csv diff --git a/resources/metadata-ISO/licenses.csv b/resources/metadata-ISO/licenses.csv new file mode 100644 index 000000000000..c2a9a2ed4068 --- /dev/null +++ b/resources/metadata-ISO/licenses.csv @@ -0,0 +1,7 @@ +name,code +Creative Commons CC Zero,CC0 +Open Data Commons Public Domain Dedication and Licence,PDDL +Creative Commons Attribution 4.0,CC-BY-4.0 +Open Data Commons Attribution License,ODC-BY +Creative Commons Attribution Share-Alike 4.0,CC-BY-SA-4.0 +Open Data Commons Open Database License,ODBL diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index 2ff4e8f2fef0..69d67e4dc0d5 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -20,6 +20,7 @@ #include #include #include +#include //#include "qgsmetadatalinkdelegate.h" #include "qgsmetadatawizard.h" @@ -47,6 +48,8 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWizard::setAutoSource ); connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWizard::addVocabulary ); connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWizard::removeVocabulary ); + connect( btnAddLicence, &QPushButton::clicked, this, &QgsMetadataWizard::addLicence ); + connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWizard::removeLicence ); connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWizard::addLink ); connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWizard::removeLink ); connect( btnCheckMetadata, &QPushButton::clicked, this, &QgsMetadataWizard::checkMetadata ); @@ -91,6 +94,35 @@ void QgsMetadataWizard::removeVocabulary() } } +void QgsMetadataWizard::addLicence() +{ + QString newLicence = QInputDialog::getItem( this, tr( "New Licence" ), tr( "New Licence" ), parseLicenses(), 0, true ); + if ( tabLicenses->findItems( newLicence, Qt::MatchExactly ).isEmpty() ) + { + int row = tabLicenses->rowCount(); + tabLicenses->setRowCount( row + 1 ); + QTableWidgetItem *pCell = new QTableWidgetItem( newLicence ); + tabLicenses->setItem( row, 0, pCell ); + QgsDebugMsg( QString( "Adding" ) ); + } + else + { + QgsDebugMsg( QString( "Cant add" ) ); + } +} + +void QgsMetadataWizard::removeLicence() +{ + QItemSelectionModel *selectionModel = tabLicenses->selectionModel(); + QModelIndexList selectedRows = selectionModel->selectedRows(); + QgsDebugMsg( QString( "Remove: %1 " ).arg( selectedRows.count() ) ); + + for ( int i = 0 ; i < selectedRows.size() ; i++ ) + { + tabLicenses->model()->removeRow( selectedRows[i].row() ); + } +} + void QgsMetadataWizard::cancelClicked() { hide(); @@ -287,6 +319,21 @@ void QgsMetadataWizard::setPropertiesFromLayer() tabKeywords->item( currentRow, 1 )->setText( i.value().join( "," ) ); } + // Licenses + tabLicenses->setRowCount( 0 ); + for ( QString licence : mMetadata.licenses() ) + { + int currentRow = tabLicenses->rowCount(); + tabLicenses->setRowCount( currentRow + 1 ); + QTableWidgetItem *pCell = tabLicenses->item( currentRow, 0 ); + if ( !pCell ) + { + pCell = new QTableWidgetItem; + tabLicenses->setItem( currentRow, 0, pCell ); + } + pCell->setText( licence ); + } + // Links tabLinks->setRowCount( 0 ); for ( QgsLayerMetadata::Link link : mMetadata.links() ) @@ -335,6 +382,14 @@ void QgsMetadataWizard::saveMetadata( QgsLayerMetadata &layerMetadata ) } layerMetadata.setKeywords( keywords ); + // Licenses + QStringList licenses; + for ( int i = 0 ; i < tabLicenses->rowCount() ; i++ ) + { + licenses.append( tabLicenses->item( i, 0 )->text() ); + } + layerMetadata.setLicenses( licenses ); + // Links QList links; for ( int i = 0 ; i < tabLinks->rowCount() ; i++ ) @@ -408,6 +463,26 @@ QStringList QgsMetadataWizard::parseLanguages() return wordList; } +QStringList QgsMetadataWizard::parseLicenses() +{ + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "licenses.csv" ) ); + QFile file( path ); + if ( !file.open( QIODevice::ReadOnly ) ) + { + QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + } + + QStringList wordList; + // Skip the first line of the CSV + file.readLine(); + while ( !file.atEnd() ) + { + QByteArray line = file.readLine(); + wordList.append( line.split( ',' ).at( 0 ) ); + } + return wordList; +} + QStringList QgsMetadataWizard::parseLinkTypes() { QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "LinkPropertyLookupTable.csv" ) ); diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index edd444abd678..73254c9e90b7 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -33,6 +33,8 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza void setAutoSource(); void addVocabulary(); void removeVocabulary(); + void addLicence(); + void removeLicence(); void addLink(); void removeLink(); void fillComboBox(); @@ -40,6 +42,7 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza void saveMetadata( QgsLayerMetadata &layerMetadata ); bool checkMetadata(); QStringList parseLanguages(); + QStringList parseLicenses(); QStringList parseLinkTypes(); private: diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui index f62bd1aa39cb..be998bfa59df 100644 --- a/src/ui/qgsmetadatawizard.ui +++ b/src/ui/qgsmetadatawizard.ui @@ -7,7 +7,7 @@ 0 0 721 - 546 + 554 @@ -78,7 +78,6 @@ QFrame::NoFrame - tabWidget @@ -90,9 +89,9 @@ QTabWidget::Rounded - 0 + 2 - + Identification @@ -195,7 +194,7 @@ - + Keywords @@ -280,140 +279,71 @@ - + - false + true Access - - - - 10 - 10 - 60 - 16 - - - - Fees - - - - - false - - - - 10 - 30 - 113 - 21 - - - - - - - 10 - 80 - 101 - 16 - - - - Constraints - - - - - false - - - - 10 - 110 - 221 - 151 - - - - 2 - - - - Type - - - - - Label - - - - - - - 240 - 230 - 62 - 32 - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - false - - - - 400 - 70 - 256 - 192 - - - - - - - 240 - 200 - 62 - 32 - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - 400 - 40 - 60 - 16 - - - - Rights - - + + + + + Licenses + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + true + + + + Label + + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + - + false @@ -447,7 +377,7 @@ - + false @@ -550,7 +480,7 @@ - + Links @@ -651,7 +581,7 @@ - + Validation From 10ad5b53418d0b1e7722dd59a95580187bcb4ebb Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 19 Jul 2017 11:04:30 +0300 Subject: [PATCH 09/39] add CRS --- src/app/qgsmetadatawizard.cpp | 18 ++++++ src/app/qgsmetadatawizard.h | 1 + src/ui/qgsmetadatawizard.ui | 113 ++++++++++++++++++++++++---------- 3 files changed, 99 insertions(+), 33 deletions(-) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index 69d67e4dc0d5..c50971b278e0 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -50,6 +50,7 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWizard::removeVocabulary ); connect( btnAddLicence, &QPushButton::clicked, this, &QgsMetadataWizard::addLicence ); connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWizard::removeLicence ); + connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWizard::setAutoCrs ); connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWizard::addLink ); connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWizard::removeLink ); connect( btnCheckMetadata, &QPushButton::clicked, this, &QgsMetadataWizard::checkMetadata ); @@ -123,6 +124,11 @@ void QgsMetadataWizard::removeLicence() } } +void QgsMetadataWizard::setAutoCrs() +{ + selectionCrs->setCrs( mLayer->crs() ); +} + void QgsMetadataWizard::cancelClicked() { hide(); @@ -334,6 +340,12 @@ void QgsMetadataWizard::setPropertiesFromLayer() pCell->setText( licence ); } + // CRS + if ( mMetadata.crs().isValid() ) + { + selectionCrs->setCrs( mMetadata.crs() ); + } + // Links tabLinks->setRowCount( 0 ); for ( QgsLayerMetadata::Link link : mMetadata.links() ) @@ -390,6 +402,12 @@ void QgsMetadataWizard::saveMetadata( QgsLayerMetadata &layerMetadata ) } layerMetadata.setLicenses( licenses ); + // CRS + if ( selectionCrs->crs().isValid() ) + { + layerMetadata.setCrs( selectionCrs->crs() ); + } + // Links QList links; for ( int i = 0 ; i < tabLinks->rowCount() ; i++ ) diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index 73254c9e90b7..baa843efd745 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -35,6 +35,7 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza void removeVocabulary(); void addLicence(); void removeLicence(); + void setAutoCrs(); void addLink(); void removeLink(); void fillComboBox(); diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui index be998bfa59df..32b412a60641 100644 --- a/src/ui/qgsmetadatawizard.ui +++ b/src/ui/qgsmetadatawizard.ui @@ -89,7 +89,7 @@ QTabWidget::Rounded - 2 + 3 @@ -280,13 +280,17 @@ - - true - Access + + + + Access dialog. HELP TEXT TO ADD + + + @@ -344,38 +348,67 @@ - - false - Extent - - - - 30 - 50 - 541 - 61 - - - - Temporal, it's a list of QgsDateTimeRange, need to check how to present this - - - - - - 30 - 220 - 411 - 16 - - - - Spatial, need to check how to present this - - + + + + + Extent dialog. HELP TEXT TO ADD + + + + + + + Spatial Extent + + + + + + + + + + + + 0 + 0 + + + + Set CRS from layer + + + + + + + + + + + + Temporal Extent + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -671,6 +704,20 @@ + + + QgsCollapsibleGroupBox + QGroupBox +
qgscollapsiblegroupbox.h
+ 1 +
+ + QgsProjectionSelectionWidget + QWidget +
qgsprojectionselectionwidget.h
+ 1 +
+
From 9428d9ba67d19c61bf1a6c79f779ed7330a53fa2 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 19 Jul 2017 14:19:37 +0300 Subject: [PATCH 10/39] docstring --- src/app/qgsmetadatawizard.cpp | 1 + src/app/qgsmetadatawizard.h | 71 +++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index c50971b278e0..72d9732ce5e0 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -471,6 +471,7 @@ QStringList QgsMetadataWizard::parseLanguages() } QStringList wordList; + wordList.append( "" ); // Skip the first line of the CSV file.readLine(); while ( !file.atEnd() ) diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index baa843efd745..9da324f00788 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -22,28 +22,99 @@ #include "qgslayermetadata.h" #include "ui_qgsmetadatawizard.h" +/** + * \ingroup app + * \class QgsMetadataWizard + * \brief A wizard to edit metadata on a map layer. + * + * \since QGIS 3.0 + */ + class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWizard { Q_OBJECT public: + + /** + * Constructor for the wizard. + */ QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer = nullptr ); ~QgsMetadataWizard(); + /** + * Set the source field from the layer. + */ void setAutoSource(); + + /** + * Add a new vocabulary. + */ void addVocabulary(); + + /** + * Remove a selected vocabulary. + */ void removeVocabulary(); + + /** + * Add a new licence. + */ void addLicence(); + + /** + * Remove a selected licence. + */ void removeLicence(); + + /** + * Set the CRS field from the layer. + */ void setAutoCrs(); + + /** + * Add a new link. + */ void addLink(); + + /** + * Remove a selected link. + */ void removeLink(); + + /** + * Function to fill combobox like language, type. + */ void fillComboBox(); + + /** + * Fill the wizard from values in the layer metadata object. + */ void setPropertiesFromLayer(); + + /** + * Save all fields in a QgsLayerMetadata object. + */ void saveMetadata( QgsLayerMetadata &layerMetadata ); + + /** + * Check if values in the wizard are correct. + */ bool checkMetadata(); + + /** + * Returns a list of languages by default available in the wizard. + */ QStringList parseLanguages(); + + /** + * Returns a list of licences by default available in the wizard. + */ QStringList parseLicenses(); + + /** + * Returns a list of link types by default available in the wizard. + */ QStringList parseLinkTypes(); private: From 09e5314941b5a5a70fbed76f50cfe12218d1fa84 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 19 Jul 2017 21:51:59 +0300 Subject: [PATCH 11/39] reorder in cpp file, add contact UI --- src/app/qgsmetadatawizard.cpp | 134 +++++++++-------- src/app/qgsmetadatawizard.h | 10 ++ src/ui/qgsmetadatawizard.ui | 261 ++++++++++++++++++++++++++-------- 3 files changed, 286 insertions(+), 119 deletions(-) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index 72d9732ce5e0..55bcf53a74e1 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -51,6 +51,8 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) connect( btnAddLicence, &QPushButton::clicked, this, &QgsMetadataWizard::addLicence ); connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWizard::removeLicence ); connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWizard::setAutoCrs ); + connect( btnAddContact, &QPushButton::clicked, this, &QgsMetadataWizard::addContact ); + connect( btnRemoveContact, &QPushButton::clicked, this, &QgsMetadataWizard::removeContact ); connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWizard::addLink ); connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWizard::removeLink ); connect( btnCheckMetadata, &QPushButton::clicked, this, &QgsMetadataWizard::checkMetadata ); @@ -129,73 +131,14 @@ void QgsMetadataWizard::setAutoCrs() selectionCrs->setCrs( mLayer->crs() ); } -void QgsMetadataWizard::cancelClicked() +void QgsMetadataWizard::addContact() { - hide(); -} -void QgsMetadataWizard::backClicked() -{ - int index = tabWidget->currentIndex(); - if ( index > 0 ) - tabWidget->setCurrentIndex( index - 1 ); - updatePanel(); } -void QgsMetadataWizard::nextClicked() +void QgsMetadataWizard::removeContact() { - int index = tabWidget->currentIndex(); - if ( index < tabWidget->count() ) - tabWidget->setCurrentIndex( index + 1 ); - updatePanel(); -} - -void QgsMetadataWizard::finishedClicked() -{ - // OLD API (to remove later) - mLayer->setName( lineEditTitle->text() ); - mLayer->setAbstract( textEditAbstract->toPlainText() ); - - // New Metadata API - saveMetadata( mMetadata ); - - // Save layer metadata properties - mLayer->setMetadata( mMetadata ); - - QgsNativeMetadataValidator validator; - QList validationResults; - bool results = validator.validate( mMetadata, validationResults ); - - hide(); - if ( results ) - { - QgisApp::instance()->messageBar()->pushInfo( tr( "Save metadata" ), tr( "Saving metadata successfull into the project" ) ); - } - else - { - QgisApp::instance()->messageBar()->pushWarning( tr( "Save metadata" ), tr( "Saving metadata successfull but some fields were missing" ) ); - } -} - -void QgsMetadataWizard::updatePanel() -{ - int index = tabWidget->currentIndex(); - if ( index == 0 ) - { - backButton->setEnabled( false ); - nextButton->setEnabled( true ); - } - else if ( index == tabWidget->count() - 1 ) - { - backButton->setEnabled( true ); - nextButton->setEnabled( false ); - } - else - { - backButton->setEnabled( true ); - nextButton->setEnabled( true ); - } } void QgsMetadataWizard::addLink() @@ -521,3 +464,72 @@ QStringList QgsMetadataWizard::parseLinkTypes() } return wordList; } + +void QgsMetadataWizard::cancelClicked() +{ + hide(); +} + +void QgsMetadataWizard::backClicked() +{ + int index = tabWidget->currentIndex(); + if ( index > 0 ) + tabWidget->setCurrentIndex( index - 1 ); + updatePanel(); +} + +void QgsMetadataWizard::nextClicked() +{ + int index = tabWidget->currentIndex(); + if ( index < tabWidget->count() ) + tabWidget->setCurrentIndex( index + 1 ); + updatePanel(); +} + +void QgsMetadataWizard::finishedClicked() +{ + // OLD API (to remove later) + mLayer->setName( lineEditTitle->text() ); + mLayer->setAbstract( textEditAbstract->toPlainText() ); + + // New Metadata API + saveMetadata( mMetadata ); + + // Save layer metadata properties + mLayer->setMetadata( mMetadata ); + + QgsNativeMetadataValidator validator; + QList validationResults; + bool results = validator.validate( mMetadata, validationResults ); + + hide(); + + if ( results ) + { + QgisApp::instance()->messageBar()->pushInfo( tr( "Save metadata" ), tr( "Saving metadata successfull into the project" ) ); + } + else + { + QgisApp::instance()->messageBar()->pushWarning( tr( "Save metadata" ), tr( "Saving metadata successfull but some fields were missing" ) ); + } +} + +void QgsMetadataWizard::updatePanel() +{ + int index = tabWidget->currentIndex(); + if ( index == 0 ) + { + backButton->setEnabled( false ); + nextButton->setEnabled( true ); + } + else if ( index == tabWidget->count() - 1 ) + { + backButton->setEnabled( true ); + nextButton->setEnabled( false ); + } + else + { + backButton->setEnabled( true ); + nextButton->setEnabled( true ); + } +} diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index 9da324f00788..4b8103b4e02d 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -72,6 +72,16 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza */ void setAutoCrs(); + /** + * Add a new contact. + */ + void addContact(); + + /** + * Remove a selected contact. + */ + void removeContact(); + /** * Add a new link. */ diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui index 32b412a60641..be73dd589940 100644 --- a/src/ui/qgsmetadatawizard.ui +++ b/src/ui/qgsmetadatawizard.ui @@ -6,8 +6,8 @@ 0 0 - 721 - 554 + 781 + 712 @@ -30,7 +30,7 @@ 0 - + background: #93b023; border: none; @@ -65,7 +65,7 @@ - + 0 @@ -78,6 +78,7 @@ QFrame::NoFrame + tabWidget @@ -89,7 +90,7 @@ QTabWidget::Rounded - 3 + 4 @@ -411,13 +412,10 @@ - - false - Contacts - + @@ -426,54 +424,7 @@ - - - QAbstractItemView::SelectRows - - - - Name - - - - - Role - - - - - Organization - - - - - Position - - - - - Email - - - - - Voice - - - - - Fax - - - - - Address - - - - - - + @@ -497,7 +448,7 @@ - + Qt::Horizontal @@ -511,7 +462,201 @@ + + + + + + + 200 + 16777215 + + + + + + + + true + + + + + 0 + 0 + 521 + 450 + + + + + + + + + Name + + + + + + + + + + Role + + + + + + + + + + Organization + + + + + + + + + + Position + + + + + + + + + + Email + + + + + + + + + + Voice + + + + + + + + + + Fax + + + + + + + + + + Address + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + true + + + + Type + + + + + Address + + + + + Postal Code + + + + + City + + + + + Administrative Area + + + + + Country + + + + + + + + + + + label_16 + horizontalLayoutWidget_3 + btnRemoveContact_2 + horizontalLayoutWidget From 2bbcba0f98b7f8f437a5939985646588d13416d4 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 20 Jul 2017 13:17:15 +0300 Subject: [PATCH 12/39] disable UI for contacts --- src/app/qgsmetadatawizard.cpp | 45 +++++++++++++++++++++++++++++++++-- src/app/qgsmetadatawizard.h | 5 ++++ src/ui/qgsmetadatawizard.ui | 43 +++++++++++++++++++++++++++------ 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index 55bcf53a74e1..f464044a24b9 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -53,12 +53,14 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWizard::setAutoCrs ); connect( btnAddContact, &QPushButton::clicked, this, &QgsMetadataWizard::addContact ); connect( btnRemoveContact, &QPushButton::clicked, this, &QgsMetadataWizard::removeContact ); + connect( tabContacts, &QTableWidget::itemSelectionChanged, this, &QgsMetadataWizard::updateContactDetails ); connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWizard::addLink ); connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWizard::removeLink ); connect( btnCheckMetadata, &QPushButton::clicked, this, &QgsMetadataWizard::checkMetadata ); fillComboBox(); setPropertiesFromLayer(); + updateContactDetails(); } QgsMetadataWizard::~QgsMetadataWizard() @@ -77,7 +79,7 @@ void QgsMetadataWizard::addVocabulary() QTableWidgetItem *pCell; // Vocabulary - pCell = new QTableWidgetItem( QString( "undefined %1" ).arg( row ) ); + pCell = new QTableWidgetItem( QString( "undefined %1" ).arg( row + 1 ) ); tabKeywords->setItem( row, 0, pCell ); // Keywords @@ -133,12 +135,51 @@ void QgsMetadataWizard::setAutoCrs() void QgsMetadataWizard::addContact() { + int row = tabContacts->rowCount(); + tabContacts->setRowCount( row + 1 ); + QTableWidgetItem *pCell; + + // Name + pCell = new QTableWidgetItem( QString( "unnamed %1" ).arg( row + 1 ) ); + tabContacts->setItem( row, 0, pCell ); + + // Organization + pCell = new QTableWidgetItem(); + tabContacts->setItem( row, 1, pCell ); + // Set last item selected + tabContacts->selectRow( row ); } void QgsMetadataWizard::removeContact() { + QItemSelectionModel *selectionModel = tabContacts->selectionModel(); + QModelIndexList selectedRows = selectionModel->selectedRows(); + QgsDebugMsg( QString( "Remove: %1 " ).arg( selectedRows.count() ) ); + + for ( int i = 0 ; i < selectedRows.size() ; i++ ) + { + tabContacts->model()->removeRow( selectedRows[i].row() ); + } +} + +void QgsMetadataWizard::updateContactDetails() +{ + QItemSelectionModel *selectionModel = tabContacts->selectionModel(); + QModelIndexList selectedRows = selectionModel->selectedRows(); + if ( selectedRows.size() > 0 ) + { + panelDetails->setDisabled( false ); + lineEditContactName->setText( tabContacts->item( selectedRows[0].row(), 0 )->text() ); + lineEditContactOrganization->setText( tabContacts->item( selectedRows[0].row(), 1 )->text() ); + } + else + { + panelDetails->setDisabled( true ); + lineEditContactName->clear(); + lineEditContactOrganization->clear(); + } } void QgsMetadataWizard::addLink() @@ -148,7 +189,7 @@ void QgsMetadataWizard::addLink() QTableWidgetItem *pCell; // Name - pCell = new QTableWidgetItem( QString( "undefined %1" ).arg( row ) ); + pCell = new QTableWidgetItem( QString( "undefined %1" ).arg( row + 1 ) ); tabLinks->setItem( row, 0, pCell ); // Type diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index 4b8103b4e02d..a92115d4df39 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -82,6 +82,11 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza */ void removeContact(); + /** + * Update the contact details according to the selection in the contact list. + */ + void updateContactDetails(); + /** * Add a new link. */ diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui index be73dd589940..00372b6450dd 100644 --- a/src/ui/qgsmetadatawizard.ui +++ b/src/ui/qgsmetadatawizard.ui @@ -78,7 +78,6 @@ QFrame::NoFrame - tabWidget @@ -412,6 +411,9 @@
+ + false + Contacts @@ -465,17 +467,45 @@ - + 200 16777215 + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + Name + + + + + Organization + + - + + + + 0 + 0 + + true @@ -491,6 +521,9 @@ + + QLayout::SetNoConstraint + @@ -653,10 +686,6 @@ - label_16 - horizontalLayoutWidget_3 - btnRemoveContact_2 - horizontalLayoutWidget From 982f04385fce51d9ffd84e7052a5794665166490 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 20 Jul 2017 17:17:37 +0300 Subject: [PATCH 13/39] switch from QTableWidget to QTableView for links --- src/app/qgsmetadatawizard.cpp | 144 +++++++++++++++------------------- src/app/qgsmetadatawizard.h | 20 ++++- src/ui/qgsmetadatawizard.ui | 42 ++-------- 3 files changed, 84 insertions(+), 122 deletions(-) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index f464044a24b9..683058dae413 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -40,6 +40,15 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) backButton->setEnabled( false ); nextButton->setEnabled( true ); + // Setup the link view + mLinksModel = new QStandardItemModel(); + mLinksModel->setColumnCount( 7 ); + QStringList headers = QStringList(); + headers << tr( "Name" ) << tr( "Type" ) << tr( "URL" ) << tr( "Description" ) << tr( "Format" ) << tr( "MIME" ) << tr( "Size" ); + mLinksModel->setHorizontalHeaderLabels( headers ); + tabLinks->setModel( mLinksModel ); + tabLinks->setItemDelegate( new LinkItemDelegate() ); + connect( tabWidget, &QTabWidget::currentChanged, this, &QgsMetadataWizard::updatePanel ); connect( cancelButton, &QPushButton::clicked, this, &QgsMetadataWizard::cancelClicked ); connect( backButton, &QPushButton::clicked, this, &QgsMetadataWizard::backClicked ); @@ -184,58 +193,20 @@ void QgsMetadataWizard::updateContactDetails() void QgsMetadataWizard::addLink() { - int row = tabLinks->rowCount(); - tabLinks->setRowCount( row + 1 ); - QTableWidgetItem *pCell; - - // Name - pCell = new QTableWidgetItem( QString( "undefined %1" ).arg( row + 1 ) ); - tabLinks->setItem( row, 0, pCell ); - - // Type - // See https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv - QComboBox *typeCombo = new QComboBox(); - typeCombo->setEditable( true ); - typeCombo->addItems( parseLinkTypes() ); - tabLinks->setCellWidget( row, 1, typeCombo ); - - // URL - pCell = new QTableWidgetItem(); - tabLinks->setItem( row, 2, pCell ); - - // Description - pCell = new QTableWidgetItem(); - tabLinks->setItem( row, 3, pCell ); - - // Format - // It is strongly suggested to use GDAL/OGR format values. QgsLayerMetadata documentation - pCell = new QTableWidgetItem(); - tabLinks->setItem( row, 4, pCell ); - - // MIME - // See https://fr.wikipedia.org/wiki/Type_MIME - QComboBox *mimeCombo = new QComboBox(); - mimeCombo->setEditable( true ); - QStringList mime; - mime << "" << "image/png" << "image/tiff" << "application/pdf"; - mimeCombo->addItems( mime ); - tabLinks->setCellWidget( row, 5, mimeCombo ); - - // Size - pCell = new QTableWidgetItem(); - tabLinks->setItem( row, 6, pCell ); + int row = mLinksModel->rowCount(); + mLinksModel->setItem( row, 0, new QStandardItem( QString( "undefined %1" ).arg( row + 1 ) ) ); + mLinksModel->setItem( row, 1, new QStandardItem() ); + mLinksModel->setItem( row, 2, new QStandardItem() ); + mLinksModel->setItem( row, 3, new QStandardItem() ); + mLinksModel->setItem( row, 4, new QStandardItem() ); + mLinksModel->setItem( row, 5, new QStandardItem() ); + mLinksModel->setItem( row, 6, new QStandardItem() ); } void QgsMetadataWizard::removeLink() { - QItemSelectionModel *selectionModel = tabLinks->selectionModel(); - QModelIndexList selectedRows = selectionModel->selectedRows(); - QgsDebugMsg( QString( "Remove: %1 " ).arg( selectedRows.count() ) ); - - for ( int i = 0 ; i < selectedRows.size() ; i++ ) - { - tabLinks->model()->removeRow( selectedRows[i].row() ); - } + QModelIndexList selectedRows = tabLinks->selectionModel()->selectedRows(); + mLinksModel->removeRow( selectedRows[0].row() ); } void QgsMetadataWizard::fillComboBox() @@ -331,34 +302,16 @@ void QgsMetadataWizard::setPropertiesFromLayer() } // Links - tabLinks->setRowCount( 0 ); for ( QgsLayerMetadata::Link link : mMetadata.links() ) { - addLink(); - int currentRow = tabLinks->rowCount() - 1; - tabLinks->item( currentRow, 0 )->setText( link.name ); - if ( ! link.type.isEmpty() ) - { - QComboBox *combo = dynamic_cast( tabLinks->cellWidget( currentRow, 1 ) ); - if ( combo->findText( link.type ) == -1 ) - { - combo->addItem( link.type ); - } - combo->setCurrentIndex( combo->findText( link.type ) ); - } - tabLinks->item( currentRow, 2 )->setText( link.url ); - tabLinks->item( currentRow, 3 )->setText( link.description ); - tabLinks->item( currentRow, 4 )->setText( link.format ); - if ( ! link.mimeType.isEmpty() ) - { - QComboBox *combo = dynamic_cast( tabLinks->cellWidget( currentRow, 5 ) ); - if ( combo->findText( link.mimeType ) == -1 ) - { - combo->addItem( link.mimeType ); - } - combo->setCurrentIndex( combo->findText( link.mimeType ) ); - } - tabLinks->item( currentRow, 6 )->setText( link.size ); + int row = mLinksModel->rowCount(); + mLinksModel->setItem( row, 0, new QStandardItem( link.name ) ); + mLinksModel->setItem( row, 1, new QStandardItem( link.type ) ); + mLinksModel->setItem( row, 2, new QStandardItem( link.url ) ); + mLinksModel->setItem( row, 3, new QStandardItem( link.description ) ); + mLinksModel->setItem( row, 4, new QStandardItem( link.format ) ); + mLinksModel->setItem( row, 5, new QStandardItem( link.mimeType ) ); + mLinksModel->setItem( row, 6, new QStandardItem( link.size ) ); } } @@ -394,16 +347,16 @@ void QgsMetadataWizard::saveMetadata( QgsLayerMetadata &layerMetadata ) // Links QList links; - for ( int i = 0 ; i < tabLinks->rowCount() ; i++ ) + for ( int row = 0 ; row < mLinksModel->rowCount() ; row++ ) { struct QgsLayerMetadata::Link link = QgsLayerMetadata::Link(); - link.name = tabLinks->item( i, 0 )->text(); - link.type = dynamic_cast( tabLinks->cellWidget( i, 1 ) )->currentText(); - link.url = tabLinks->item( i, 2 )->text(); - link.description = tabLinks->item( i, 3 )->text(); - link.format = tabLinks->item( i, 4 )->text(); - link.mimeType = dynamic_cast( tabLinks->cellWidget( i, 5 ) )->currentText(); - link.size = tabLinks->item( i, 6 )->text(); + link.name = mLinksModel->item( row, 0 )->text(); + link.type = mLinksModel->item( row, 1 )->text(); + link.url = mLinksModel->item( row, 2 )->text(); + link.description = mLinksModel->item( row, 3 )->text(); + link.format = mLinksModel->item( row, 4 )->text(); + link.mimeType = mLinksModel->item( row, 5 )->text(); + link.size = mLinksModel->item( row, 6 )->text(); links.append( link ); } layerMetadata.setLinks( links ); @@ -574,3 +527,30 @@ void QgsMetadataWizard::updatePanel() nextButton->setEnabled( true ); } } + +QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const +{ + if ( index.column() == 1 ) + { + QComboBox *typeEditor = new QComboBox( parent ); + typeEditor->setEditable( true ); + QStringListModel *model = new QStringListModel( parent ); + model->setStringList( QgsMetadataWizard::parseLinkTypes() ); + typeEditor->setModel( model ); + return typeEditor; + } + else if ( index.column() == 5 ) + { + // See https://fr.wikipedia.org/wiki/Type_MIME + QComboBox *mimeEditor = new QComboBox( parent ); + mimeEditor->setEditable( true ); + QStringListModel *model = new QStringListModel( parent ); + QStringList mime; + mime << "" << "image/png" << "image/tiff" << "application/pdf"; + model->setStringList( mime ); + mimeEditor->setModel( model ); + return mimeEditor; + } + + return QStyledItemDelegate::createEditor( parent, option, index ); +} diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index a92115d4df39..253ed45571fb 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -17,6 +17,9 @@ #ifndef QGSMETADATAWIZARD_H #define QGSMETADATAWIZARD_H +#include "QStandardItemModel" +#include "QStyledItemDelegate" + #include "qgis_app.h" #include "qgsmaplayer.h" #include "qgslayermetadata.h" @@ -120,17 +123,18 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza /** * Returns a list of languages by default available in the wizard. */ - QStringList parseLanguages(); + static QStringList parseLanguages(); /** * Returns a list of licences by default available in the wizard. */ - QStringList parseLicenses(); + static QStringList parseLicenses(); /** * Returns a list of link types by default available in the wizard. + * \see https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv */ - QStringList parseLinkTypes(); + static QStringList parseLinkTypes(); private: void cancelClicked(); @@ -140,6 +144,16 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza void updatePanel(); QgsMapLayer *mLayer = nullptr; QgsLayerMetadata mMetadata; + QStandardItemModel *mLinksModel = nullptr; +}; + +class LinkItemDelegate : public QStyledItemDelegate +{ + + Q_OBJECT + + public: + QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const; }; #endif diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui index 00372b6450dd..cd5006355b2e 100644 --- a/src/ui/qgsmetadatawizard.ui +++ b/src/ui/qgsmetadatawizard.ui @@ -89,7 +89,7 @@ QTabWidget::Rounded - 4 + 5 @@ -700,7 +700,7 @@ - + true @@ -710,41 +710,9 @@ QAbstractItemView::SelectRows - - - Name - - - - - Type - - - - - URL - - - - - Description - - - - - Format - - - - - MIME - - - - - Size - - + + true + From 954e4d73a7bbff37751fadf6b75355f79ebf297e Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 3 Aug 2017 08:57:28 +0200 Subject: [PATCH 14/39] review strings --- src/ui/qgsmetadatawizard.ui | 234 +++++++++++++++++------------------- 1 file changed, 108 insertions(+), 126 deletions(-) diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui index cd5006355b2e..f8649cf09949 100644 --- a/src/ui/qgsmetadatawizard.ui +++ b/src/ui/qgsmetadatawizard.ui @@ -89,7 +89,7 @@ QTabWidget::Rounded - 5 + 4 @@ -99,7 +99,10 @@ - Identification dialog, HELP TEXT TO ADD + This page describes the basic attribution of the dataset. If unsure about which type to select, use 'dataset'. Use the abstract field to provide a verbose description of this dataset. + + + true @@ -202,7 +205,10 @@ - Keywords dialog, the VOCABULARY must be unique. HELP TEXT TO ADD + Keywords are optional, and provide a way to provide additional descriptive information about the dataset. For example you can specify the category for this dataset by adding a vocabulary items 'category' with a comma separated list of category keywords. + + + true @@ -518,131 +524,107 @@ 450 - - - - - QLayout::SetNoConstraint + + + + + Name - - - - Name - - - - - - - - - - Role - - - - - - - - - - Organization - - - - - - - - - - Position - - - - - - - - - - Email - - - - - - - - - - Voice - - - - - - - - - - Fax - - - - - - - - - - Address - - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - + + + + + + + + + Role + + + + + + + + + + Organization + + + + + + + + + + Position + + + + + + + + + + Email + + + + + + + + + + Voice + + + + + + + + + + Fax + + + + + + + + + + Address + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + - + true From b548fd51c083d1090bd5d1f05f7cd1a557c56d7d Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 9 Aug 2017 10:58:19 +0200 Subject: [PATCH 15/39] add proper categories managment --- src/app/qgsmetadatawizard.cpp | 128 +++++++++++++++++++++++++++++++++- src/app/qgsmetadatawizard.h | 7 ++ src/ui/qgsmetadatawizard.ui | 112 ++++++++++++++++++++++------- 3 files changed, 219 insertions(+), 28 deletions(-) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index 683058dae413..08c71a20cb65 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -21,6 +21,7 @@ #include #include #include +#include //#include "qgsmetadatalinkdelegate.h" #include "qgsmetadatawizard.h" @@ -35,8 +36,19 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) setupUi( this ); mMetadata = layer->metadata(); + // Default categories + mDefaultCategories << tr( "Farming" ) << tr( "Climatology Meteorology Atmosphere" ) << tr( "Location" ) << tr( "Intelligence Military" ) << tr( "Transportation" ) << tr( "Structure" ) << tr( "Boundaries" ); + mDefaultCategories << tr( "Inland Waters" ) << tr( "Planning Cadastre" ) << tr( "Geoscientific Information" ) << tr( "Elevation" ) << tr( "Health" ) << tr( "Biota" ) << tr( "Oceans" ) << tr( "Environment" ); + mDefaultCategories << tr( "Utilities Communication" ) << tr( "Economy" ) << tr( "Society" ) << tr( "Imagery Base Maps Earth Cover" ); + mDefaultCategoriesModel = new QStringListModel( mDefaultCategories ); + mDefaultCategoriesModel->sort( 0 ); // Sorting using translations + listDefaultCategories->setModel( mDefaultCategoriesModel ); + + // Categories + mCategoriesModel = new QStringListModel(); + listCategories->setModel( mCategoriesModel ); + tabWidget->setCurrentIndex( 0 ); -// tabWidget->setItemDelegate(new TableDelegate()); backButton->setEnabled( false ); nextButton->setEnabled( true ); @@ -65,7 +77,9 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) connect( tabContacts, &QTableWidget::itemSelectionChanged, this, &QgsMetadataWizard::updateContactDetails ); connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWizard::addLink ); connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWizard::removeLink ); - connect( btnCheckMetadata, &QPushButton::clicked, this, &QgsMetadataWizard::checkMetadata ); + connect( btnNewCategory, &QPushButton::clicked, this, &QgsMetadataWizard::addNewCategory ); + connect( btnAddDefaultCategory, &QPushButton::clicked, this, &QgsMetadataWizard::addDefaultCategory ); + connect( btnRemoveCategory, &QPushButton::clicked, this, &QgsMetadataWizard::removeCategory ); fillComboBox(); setPropertiesFromLayer(); @@ -268,6 +282,9 @@ void QgsMetadataWizard::setPropertiesFromLayer() comboLanguage->setCurrentIndex( comboLanguage->findText( mMetadata.language() ) ); } + // Categories + mCategoriesModel->setStringList( mMetadata.categories() ); + // Keywords tabKeywords->setRowCount( 0 ); QMapIterator i( mMetadata.keywords() ); @@ -323,7 +340,8 @@ void QgsMetadataWizard::saveMetadata( QgsLayerMetadata &layerMetadata ) layerMetadata.setLanguage( comboLanguage->currentText() ); layerMetadata.setAbstract( textEditAbstract->toPlainText() ); - // Keywords + // Keywords, it will save categories too. + syncFromCategoriesTabToKeywordsTab(); QMap keywords; for ( int i = 0 ; i < tabKeywords->rowCount() ; i++ ) { @@ -508,6 +526,27 @@ void QgsMetadataWizard::finishedClicked() } } +void QgsMetadataWizard::syncFromCategoriesTabToKeywordsTab() +{ + if ( mCategoriesModel->rowCount() > 0 ) + { + QList categories = tabKeywords->findItems( "gmd:topicCategory", Qt::MatchExactly ); + int row; + if ( !categories.isEmpty() ) + { + row = categories.at( 0 )->row(); + } + else + { + // Create a new line with 'gmd:topicCategory' + addVocabulary(); + row = tabKeywords->rowCount() - 1; + tabKeywords->item( row, 0 )->setText( "gmd:topicCategory" ); + } + tabKeywords->item( row, 1 )->setText( mCategoriesModel->stringList().join( "," ) ); + } +} + void QgsMetadataWizard::updatePanel() { int index = tabWidget->currentIndex(); @@ -516,10 +555,33 @@ void QgsMetadataWizard::updatePanel() backButton->setEnabled( false ); nextButton->setEnabled( true ); } + else if ( index == 1 ) + { + // Categories tab + // We need to take keywords and insert them into the list + QList categories = tabKeywords->findItems( "gmd:topicCategory", Qt::MatchExactly ); + if ( !categories.isEmpty() ) + { + int row = categories.at( 0 )->row(); + mCategoriesModel->setStringList( tabKeywords->item( row, 1 )->text().split( "," ) ); + } + else + { + mCategoriesModel->setStringList( QStringList() ); + } + } + else if ( index == 2 ) + { + // Keywords tab + // We need to take categories and insert them into the table + syncFromCategoriesTabToKeywordsTab(); + } else if ( index == tabWidget->count() - 1 ) { + // Validation tab backButton->setEnabled( true ); nextButton->setEnabled( false ); + checkMetadata(); } else { @@ -528,6 +590,66 @@ void QgsMetadataWizard::updatePanel() } } +void QgsMetadataWizard::addNewCategory() +{ + bool ok; + QString text = QInputDialog::getText( this, tr( "New Category" ), + tr( "New Category:" ), QLineEdit::Normal, + QString( "" ), &ok ); + if ( ok && !text.isEmpty() ) + { + QStringList list = mCategoriesModel->stringList(); + if ( ! list.contains( text ) ) + { + list.append( text ); + mCategoriesModel->setStringList( list ); + mCategoriesModel->sort( 0 ); + } + } +} + +void QgsMetadataWizard::addDefaultCategory() +{ + QItemSelectionModel *selection = listDefaultCategories->selectionModel(); + if ( selection->hasSelection() ) + { + QModelIndex indexElementSelectionne = selection->currentIndex(); + + QVariant item = mDefaultCategoriesModel->data( indexElementSelectionne, Qt::DisplayRole ); + QStringList list = mDefaultCategoriesModel->stringList(); + list.removeOne( item.toString() ); + mDefaultCategoriesModel->setStringList( list ); + + list = mCategoriesModel->stringList(); + list.append( item.toString() ); + mCategoriesModel->setStringList( list ); + mCategoriesModel->sort( 0 ); + } +} + + +void QgsMetadataWizard::removeCategory() +{ + QItemSelectionModel *selection = listCategories->selectionModel(); + if ( selection->hasSelection() ) + { + QModelIndex indexElementSelectionne = listCategories->selectionModel()->currentIndex(); + + QVariant item = mCategoriesModel->data( indexElementSelectionne, Qt::DisplayRole ); + QStringList list = mCategoriesModel->stringList(); + list.removeOne( item.toString() ); + mCategoriesModel->setStringList( list ); + + if ( mDefaultCategories.contains( item.toString() ) ) + { + list = mDefaultCategoriesModel->stringList(); + list.append( item.toString() ); + mDefaultCategoriesModel->setStringList( list ); + mDefaultCategoriesModel->sort( 0 ); + } + } +} + QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const { if ( index.column() == 1 ) diff --git a/src/app/qgsmetadatawizard.h b/src/app/qgsmetadatawizard.h index 253ed45571fb..91fbe451e4a9 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/app/qgsmetadatawizard.h @@ -142,9 +142,16 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza void nextClicked(); void finishedClicked(); void updatePanel(); + void addDefaultCategory(); + void addNewCategory(); + void removeCategory(); + QStringList mDefaultCategories; QgsMapLayer *mLayer = nullptr; QgsLayerMetadata mMetadata; QStandardItemModel *mLinksModel = nullptr; + QStringListModel *mCategoriesModel = nullptr; + QStringListModel *mDefaultCategoriesModel = nullptr; + void syncFromCategoriesTabToKeywordsTab(); }; class LinkItemDelegate : public QStyledItemDelegate diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui index f8649cf09949..1786f6f618ea 100644 --- a/src/ui/qgsmetadatawizard.ui +++ b/src/ui/qgsmetadatawizard.ui @@ -89,7 +89,7 @@ QTabWidget::Rounded - 4 + 1 @@ -197,6 +197,92 @@ + + + Categories + + + + + + + + Available categories + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + New + + + + + + + > + + + + + + + Delete + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Categories + + + + + + + + + + Keywords @@ -743,30 +829,6 @@ Validation - - - - - - Check metadata - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - From 6a4931178b9cb980d3957c05f03266555ab6859b Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 9 Aug 2017 12:32:29 +0200 Subject: [PATCH 16/39] encoding and help text --- src/app/qgsmetadatawizard.cpp | 5 + src/ui/qgsmetadatawizard.ui | 280 ++++++++++++++++++++++++---------- 2 files changed, 207 insertions(+), 78 deletions(-) diff --git a/src/app/qgsmetadatawizard.cpp b/src/app/qgsmetadatawizard.cpp index 08c71a20cb65..7f2bb2f00c18 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/app/qgsmetadatawizard.cpp @@ -36,6 +36,9 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) setupUi( this ); mMetadata = layer->metadata(); + // Disable the encoding + encodingFrame->setHidden( true ); + // Default categories mDefaultCategories << tr( "Farming" ) << tr( "Climatology Meteorology Atmosphere" ) << tr( "Location" ) << tr( "Intelligence Military" ) << tr( "Transportation" ) << tr( "Structure" ) << tr( "Boundaries" ); mDefaultCategories << tr( "Inland Waters" ) << tr( "Planning Cadastre" ) << tr( "Geoscientific Information" ) << tr( "Elevation" ) << tr( "Health" ) << tr( "Biota" ) << tr( "Oceans" ) << tr( "Environment" ); @@ -43,6 +46,8 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) mDefaultCategoriesModel = new QStringListModel( mDefaultCategories ); mDefaultCategoriesModel->sort( 0 ); // Sorting using translations listDefaultCategories->setModel( mDefaultCategoriesModel ); +// listDefaultCategories->setEditTriggers(QAbstractItemView.NoEditTriggers); +// listCategories->setEditTriggers(QAbstractItemView.NoEditTriggers); // Categories mCategoriesModel = new QStringListModel(); diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui index 1786f6f618ea..17edec0baa5b 100644 --- a/src/ui/qgsmetadatawizard.ui +++ b/src/ui/qgsmetadatawizard.ui @@ -121,7 +121,7 @@ - Set from layer source + Set from layer @@ -195,91 +195,215 @@ + + + + false + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Encoding + + + + + + + + + + 0 + 0 + + + + + + + + Set from layer + + + + + + + +
Categories - - - - - - - Available categories - - - - - - - - + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - New - - - - - - - > - - - - - - - Delete - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + Categories dialog. It a shortcuts for 'gmd:topicCategory' in the keywords tab. + + - - - - - Categories - - - - - - - + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + Categories + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + :/images/themes/default/mActionNewBookmark.svg:/images/themes/default/mActionNewBookmark.svg + + + + + + + + 0 + 0 + + + + + + + + :/images/themes/default/mActionArrowRight.svg:/images/themes/default/mActionArrowRight.svg + + + + 16 + 18 + + + + + + + + + 0 + 0 + + + + + + + + :/images/themes/default/mActionArrowLeft.svg:/images/themes/default/mActionArrowLeft.svg + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Available categories + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + @@ -291,7 +415,7 @@ - Keywords are optional, and provide a way to provide additional descriptive information about the dataset. For example you can specify the category for this dataset by adding a vocabulary items 'category' with a comma separated list of category keywords. + Keywords are optional, and provide a way to provide additional descriptive information about the dataset. For example you can specify the category for this dataset by adding a vocabulary items 'gmd:topicCategory' with a comma separated list of category keywords. true From 76f559b6f4ea3492be5467088324475e1234232c Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 9 Aug 2017 16:11:37 +0200 Subject: [PATCH 17/39] move metadata wizard to a widget in gui --- src/app/CMakeLists.txt | 3 - src/app/qgisapp.cpp | 15 - src/app/qgisapp.h | 4 - src/app/qgsapplayertreeviewmenuprovider.cpp | 2 - src/gui/CMakeLists.txt | 2 + .../qgsmetadatawidget.cpp} | 142 ++- .../qgsmetadatawidget.h} | 20 +- src/ui/qgisapp.ui | 16 +- src/ui/qgsmetadatawidget.ui | 917 +++++++++++++++ src/ui/qgsmetadatawizard.ui | 1035 ----------------- 10 files changed, 1000 insertions(+), 1156 deletions(-) rename src/{app/qgsmetadatawizard.cpp => gui/qgsmetadatawidget.cpp} (86%) rename src/{app/qgsmetadatawizard.h => gui/qgsmetadatawidget.h} (90%) create mode 100644 src/ui/qgsmetadatawidget.ui delete mode 100644 src/ui/qgsmetadatawizard.ui diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index dc709756df6e..e2595ea34af1 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -131,7 +131,6 @@ SET(QGIS_APP_SRCS qgsmaptooladdcircularstring.cpp qgsmaptoolcircularstringcurvepoint.cpp qgsmaptoolcircularstringradius.cpp - qgsmetadatawizard.cpp composer/qgsattributeselectiondialog.cpp composer/qgscomposer.cpp @@ -290,8 +289,6 @@ SET (QGIS_APP_MOC_HDRS qgsmaptooladdcircularstring.h qgsmaptoolcircularstringcurvepoint.h - qgsmetadatawizard.h - nodetool/qgsselectedfeature.h nodetool/qgsnodeeditor.h nodetool/qgsnodetool.h diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 30ceed6ebf48..d0a6dd4143d4 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -1842,7 +1842,6 @@ void QgisApp::createActions() connect( mActionAddAmsLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "arcgismapserver" ) ); } ); connect( mActionAddDelimitedText, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "delimitedtext" ) ); } ); connect( mActionAddVirtualLayer, &QAction::triggered, this, [ = ] { dataSourceManager( QStringLiteral( "virtual" ) ); } ); - connect( mActionOpenMetadataWizardEditor, &QAction::triggered, this, &QgisApp::metadataWizard ); connect( mActionOpenTable, &QAction::triggered, this, &QgisApp::attributeTable ); connect( mActionOpenFieldCalc, &QAction::triggered, this, &QgisApp::fieldCalculator ); connect( mActionToggleEditing, &QAction::triggered, this, [ = ] { toggleEditing(); } ); @@ -4596,17 +4595,6 @@ void QgisApp::addVirtualLayer() delete dts; } // QgisApp::addVirtualLayer() -void QgisApp::metadataWizard() -{ - QgsMapLayer *myLayer = activeLayer(); - if ( !myLayer ) - { - return; - } - QgsMetadataWizard wizard( this, myLayer ); - wizard.exec(); -} // QgisApp::metadataWizard() - void QgisApp::addSelectedVectorLayer( const QString &uri, const QString &layerName, const QString &provider ) { addVectorLayer( uri, layerName, provider ); @@ -11010,7 +10998,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) mActionSelectByForm->setEnabled( false ); mActionLabeling->setEnabled( false ); mActionOpenTable->setEnabled( false ); - mActionOpenMetadataWizardEditor->setEnabled( false ); mActionSelectAll->setEnabled( false ); mActionInvertSelection->setEnabled( false ); mActionOpenFieldCalc->setEnabled( false ); @@ -11119,7 +11106,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) mActionSelectByExpression->setEnabled( true ); mActionSelectByForm->setEnabled( true ); mActionOpenTable->setEnabled( true ); - mActionOpenMetadataWizardEditor->setEnabled( true ); mActionSelectAll->setEnabled( true ); mActionInvertSelection->setEnabled( true ); mActionSaveLayerDefinition->setEnabled( true ); @@ -11324,7 +11310,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) mActionZoomToLayer->setEnabled( true ); mActionZoomToSelected->setEnabled( false ); mActionOpenTable->setEnabled( false ); - mActionOpenMetadataWizardEditor->setEnabled( true ); mActionSelectAll->setEnabled( false ); mActionInvertSelection->setEnabled( false ); mActionSelectByExpression->setEnabled( false ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 61e5c776c377..3ea173cdb56e 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -73,7 +73,6 @@ class QgsMapTip; class QgsMapTool; class QgsMapToolAdvancedDigitizing; class QgsMapToolIdentifyAction; -class QgsMetadataWizard; class QgsPluginLayer; class QgsPluginLayer; class QgsPluginManager; @@ -147,7 +146,6 @@ class QgsGeoCmsProviderRegistry; #include "qgsrasterminmaxorigin.h" #include "qgsmaplayeractionregistry.h" #include "qgsoptionswidgetfactory.h" -#include "qgsmetadatawizard.h" #include "ui_qgisapp.h" #include "qgis_app.h" @@ -931,8 +929,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow //#endif //! Add a virtual layer void addVirtualLayer(); - //! Open the metadata wizard - void metadataWizard(); //! toggles whether the current selected layer is in overview or not void isInOverview(); //! Store the position for map tool tip diff --git a/src/app/qgsapplayertreeviewmenuprovider.cpp b/src/app/qgsapplayertreeviewmenuprovider.cpp index 6d50e081b807..475e97e61805 100644 --- a/src/app/qgsapplayertreeviewmenuprovider.cpp +++ b/src/app/qgsapplayertreeviewmenuprovider.cpp @@ -267,8 +267,6 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu() addCustomLayerActions( menu, layer ); - menu->addAction( tr( "Metadata Wizard" ), QgisApp::instance(), SLOT( metadataWizard() ) ); - if ( layer && QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() ) menu->addAction( tr( "&Properties" ), QgisApp::instance(), SLOT( layerProperties() ) ); diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 6abdf37f634d..660bc35876cc 100755 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -293,6 +293,7 @@ SET(QGIS_GUI_SRCS qgsmessagebaritem.cpp qgsmessagelogviewer.cpp qgsmessageviewer.cpp + qgsmetadatawidget.cpp qgsnewhttpconnection.cpp qgsnewmemorylayerdialog.cpp qgsnewnamedialog.cpp @@ -452,6 +453,7 @@ SET(QGIS_GUI_MOC_HDRS qgsmessagebaritem.h qgsmessagelogviewer.h qgsmessageviewer.h + qgsmetadatawidget.h qgsnewhttpconnection.h qgsnewmemorylayerdialog.h qgsnewnamedialog.h diff --git a/src/app/qgsmetadatawizard.cpp b/src/gui/qgsmetadatawidget.cpp similarity index 86% rename from src/app/qgsmetadatawizard.cpp rename to src/gui/qgsmetadatawidget.cpp index 7f2bb2f00c18..c628ee1ff976 100644 --- a/src/app/qgsmetadatawizard.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - qgsmetadatawizard.h - description + qgsmetadatawidget.h - description ------------------- begin : 17/05/2017 copyright : (C) 2017 by Etienne Trimaille @@ -23,15 +23,13 @@ #include #include -//#include "qgsmetadatalinkdelegate.h" -#include "qgsmetadatawizard.h" +#include "qgsmetadatawidget.h" #include "qgslogger.h" #include "qgslayermetadatavalidator.h" -#include "qgisapp.h" #include "qgsapplication.h" -QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) - : QDialog( parent ), mLayer( layer ) +QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) + : QWidget( parent ), mLayer( layer ) { setupUi( this ); mMetadata = layer->metadata(); @@ -54,8 +52,8 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) listCategories->setModel( mCategoriesModel ); tabWidget->setCurrentIndex( 0 ); - backButton->setEnabled( false ); - nextButton->setEnabled( true ); +// backButton->setEnabled( false ); +// nextButton->setEnabled( true ); // Setup the link view mLinksModel = new QStandardItemModel(); @@ -66,41 +64,41 @@ QgsMetadataWizard::QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer ) tabLinks->setModel( mLinksModel ); tabLinks->setItemDelegate( new LinkItemDelegate() ); - connect( tabWidget, &QTabWidget::currentChanged, this, &QgsMetadataWizard::updatePanel ); - connect( cancelButton, &QPushButton::clicked, this, &QgsMetadataWizard::cancelClicked ); - connect( backButton, &QPushButton::clicked, this, &QgsMetadataWizard::backClicked ); - connect( nextButton, &QPushButton::clicked, this, &QgsMetadataWizard::nextClicked ); - connect( finishButton, &QPushButton::clicked, this, &QgsMetadataWizard::finishedClicked ); - connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWizard::setAutoSource ); - connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWizard::addVocabulary ); - connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWizard::removeVocabulary ); - connect( btnAddLicence, &QPushButton::clicked, this, &QgsMetadataWizard::addLicence ); - connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWizard::removeLicence ); - connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWizard::setAutoCrs ); - connect( btnAddContact, &QPushButton::clicked, this, &QgsMetadataWizard::addContact ); - connect( btnRemoveContact, &QPushButton::clicked, this, &QgsMetadataWizard::removeContact ); - connect( tabContacts, &QTableWidget::itemSelectionChanged, this, &QgsMetadataWizard::updateContactDetails ); - connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWizard::addLink ); - connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWizard::removeLink ); - connect( btnNewCategory, &QPushButton::clicked, this, &QgsMetadataWizard::addNewCategory ); - connect( btnAddDefaultCategory, &QPushButton::clicked, this, &QgsMetadataWizard::addDefaultCategory ); - connect( btnRemoveCategory, &QPushButton::clicked, this, &QgsMetadataWizard::removeCategory ); + connect( tabWidget, &QTabWidget::currentChanged, this, &QgsMetadataWidget::updatePanel ); +// connect( cancelButton, &QPushButton::clicked, this, &QgsMetadataWidget::cancelClicked ); +// connect( backButton, &QPushButton::clicked, this, &QgsMetadataWidget::backClicked ); +// connect( nextButton, &QPushButton::clicked, this, &QgsMetadataWidget::nextClicked ); +// connect( finishButton, &QPushButton::clicked, this, &QgsMetadataWidget::finishedClicked ); + connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWidget::setAutoSource ); + connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::addVocabulary ); + connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::removeVocabulary ); + connect( btnAddLicence, &QPushButton::clicked, this, &QgsMetadataWidget::addLicence ); + connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWidget::removeLicence ); + connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWidget::setAutoCrs ); + connect( btnAddContact, &QPushButton::clicked, this, &QgsMetadataWidget::addContact ); + connect( btnRemoveContact, &QPushButton::clicked, this, &QgsMetadataWidget::removeContact ); + connect( tabContacts, &QTableWidget::itemSelectionChanged, this, &QgsMetadataWidget::updateContactDetails ); + connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWidget::addLink ); + connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWidget::removeLink ); + connect( btnNewCategory, &QPushButton::clicked, this, &QgsMetadataWidget::addNewCategory ); + connect( btnAddDefaultCategory, &QPushButton::clicked, this, &QgsMetadataWidget::addDefaultCategory ); + connect( btnRemoveCategory, &QPushButton::clicked, this, &QgsMetadataWidget::removeCategory ); fillComboBox(); setPropertiesFromLayer(); updateContactDetails(); } -QgsMetadataWizard::~QgsMetadataWizard() +QgsMetadataWidget::~QgsMetadataWidget() { } -void QgsMetadataWizard::setAutoSource() +void QgsMetadataWidget::setAutoSource() { lineEditIdentifier->setText( mLayer->publicSource() ); } -void QgsMetadataWizard::addVocabulary() +void QgsMetadataWidget::addVocabulary() { int row = tabKeywords->rowCount(); tabKeywords->setRowCount( row + 1 ); @@ -115,7 +113,7 @@ void QgsMetadataWizard::addVocabulary() tabKeywords->setItem( row, 1, pCell ); } -void QgsMetadataWizard::removeVocabulary() +void QgsMetadataWidget::removeVocabulary() { QItemSelectionModel *selectionModel = tabKeywords->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); @@ -127,7 +125,7 @@ void QgsMetadataWizard::removeVocabulary() } } -void QgsMetadataWizard::addLicence() +void QgsMetadataWidget::addLicence() { QString newLicence = QInputDialog::getItem( this, tr( "New Licence" ), tr( "New Licence" ), parseLicenses(), 0, true ); if ( tabLicenses->findItems( newLicence, Qt::MatchExactly ).isEmpty() ) @@ -144,7 +142,7 @@ void QgsMetadataWizard::addLicence() } } -void QgsMetadataWizard::removeLicence() +void QgsMetadataWidget::removeLicence() { QItemSelectionModel *selectionModel = tabLicenses->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); @@ -156,12 +154,12 @@ void QgsMetadataWizard::removeLicence() } } -void QgsMetadataWizard::setAutoCrs() +void QgsMetadataWidget::setAutoCrs() { selectionCrs->setCrs( mLayer->crs() ); } -void QgsMetadataWizard::addContact() +void QgsMetadataWidget::addContact() { int row = tabContacts->rowCount(); tabContacts->setRowCount( row + 1 ); @@ -179,7 +177,7 @@ void QgsMetadataWizard::addContact() tabContacts->selectRow( row ); } -void QgsMetadataWizard::removeContact() +void QgsMetadataWidget::removeContact() { QItemSelectionModel *selectionModel = tabContacts->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); @@ -191,7 +189,7 @@ void QgsMetadataWizard::removeContact() } } -void QgsMetadataWizard::updateContactDetails() +void QgsMetadataWidget::updateContactDetails() { QItemSelectionModel *selectionModel = tabContacts->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); @@ -210,7 +208,7 @@ void QgsMetadataWizard::updateContactDetails() } } -void QgsMetadataWizard::addLink() +void QgsMetadataWidget::addLink() { int row = mLinksModel->rowCount(); mLinksModel->setItem( row, 0, new QStandardItem( QString( "undefined %1" ).arg( row + 1 ) ) ); @@ -222,13 +220,13 @@ void QgsMetadataWizard::addLink() mLinksModel->setItem( row, 6, new QStandardItem() ); } -void QgsMetadataWizard::removeLink() +void QgsMetadataWidget::removeLink() { QModelIndexList selectedRows = tabLinks->selectionModel()->selectedRows(); mLinksModel->removeRow( selectedRows[0].row() ); } -void QgsMetadataWizard::fillComboBox() +void QgsMetadataWidget::fillComboBox() { // Set default values in type combobox // It is advised to use the ISO 19115 MD_ScopeCode values. E.g. 'dataset' or 'series'. @@ -245,10 +243,10 @@ void QgsMetadataWizard::fillComboBox() comboLanguage->addItems( parseLanguages() ); } -void QgsMetadataWizard::setPropertiesFromLayer() +void QgsMetadataWidget::setPropertiesFromLayer() { // Set all properties USING THE OLD API - layerLabel->setText( mLayer->name() ); +// layerLabel->setText( mLayer->name() ); lineEditTitle->setText( mLayer->name() ); textEditAbstract->setText( mLayer->abstract() ); @@ -337,7 +335,7 @@ void QgsMetadataWizard::setPropertiesFromLayer() } } -void QgsMetadataWizard::saveMetadata( QgsLayerMetadata &layerMetadata ) +void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) { layerMetadata.setIdentifier( lineEditIdentifier->text() ); layerMetadata.setTitle( lineEditTitle->text() ); @@ -385,7 +383,7 @@ void QgsMetadataWizard::saveMetadata( QgsLayerMetadata &layerMetadata ) layerMetadata.setLinks( links ); } -bool QgsMetadataWizard::checkMetadata() +bool QgsMetadataWidget::checkMetadata() { QgsLayerMetadata metadata = QgsLayerMetadata(); saveMetadata( metadata ); @@ -421,7 +419,7 @@ bool QgsMetadataWizard::checkMetadata() return results; } -QStringList QgsMetadataWizard::parseLanguages() +QStringList QgsMetadataWidget::parseLanguages() { QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "country_code_ISO_3166.csv" ) ); QFile file( path ); @@ -442,7 +440,7 @@ QStringList QgsMetadataWizard::parseLanguages() return wordList; } -QStringList QgsMetadataWizard::parseLicenses() +QStringList QgsMetadataWidget::parseLicenses() { QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "licenses.csv" ) ); QFile file( path ); @@ -462,7 +460,7 @@ QStringList QgsMetadataWizard::parseLicenses() return wordList; } -QStringList QgsMetadataWizard::parseLinkTypes() +QStringList QgsMetadataWidget::parseLinkTypes() { QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "LinkPropertyLookupTable.csv" ) ); QFile file( path ); @@ -482,12 +480,12 @@ QStringList QgsMetadataWizard::parseLinkTypes() return wordList; } -void QgsMetadataWizard::cancelClicked() +void QgsMetadataWidget::cancelClicked() { hide(); } -void QgsMetadataWizard::backClicked() +void QgsMetadataWidget::backClicked() { int index = tabWidget->currentIndex(); if ( index > 0 ) @@ -495,7 +493,7 @@ void QgsMetadataWizard::backClicked() updatePanel(); } -void QgsMetadataWizard::nextClicked() +void QgsMetadataWidget::nextClicked() { int index = tabWidget->currentIndex(); if ( index < tabWidget->count() ) @@ -503,7 +501,7 @@ void QgsMetadataWizard::nextClicked() updatePanel(); } -void QgsMetadataWizard::finishedClicked() +void QgsMetadataWidget::finishedClicked() { // OLD API (to remove later) mLayer->setName( lineEditTitle->text() ); @@ -517,21 +515,21 @@ void QgsMetadataWizard::finishedClicked() QgsNativeMetadataValidator validator; QList validationResults; - bool results = validator.validate( mMetadata, validationResults ); + validator.validate( mMetadata, validationResults ); hide(); - if ( results ) - { - QgisApp::instance()->messageBar()->pushInfo( tr( "Save metadata" ), tr( "Saving metadata successfull into the project" ) ); - } - else - { - QgisApp::instance()->messageBar()->pushWarning( tr( "Save metadata" ), tr( "Saving metadata successfull but some fields were missing" ) ); - } +// if ( results ) +// { +// QgisApp::instance()->messageBar()->pushInfo( tr( "Save metadata" ), tr( "Saving metadata successfull into the project" ) ); +// } +// else +// { +// QgisApp::instance()->messageBar()->pushWarning( tr( "Save metadata" ), tr( "Saving metadata successfull but some fields were missing" ) ); +// } } -void QgsMetadataWizard::syncFromCategoriesTabToKeywordsTab() +void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() { if ( mCategoriesModel->rowCount() > 0 ) { @@ -552,13 +550,13 @@ void QgsMetadataWizard::syncFromCategoriesTabToKeywordsTab() } } -void QgsMetadataWizard::updatePanel() +void QgsMetadataWidget::updatePanel() { int index = tabWidget->currentIndex(); if ( index == 0 ) { - backButton->setEnabled( false ); - nextButton->setEnabled( true ); +// backButton->setEnabled( false ); +// nextButton->setEnabled( true ); } else if ( index == 1 ) { @@ -584,18 +582,18 @@ void QgsMetadataWizard::updatePanel() else if ( index == tabWidget->count() - 1 ) { // Validation tab - backButton->setEnabled( true ); - nextButton->setEnabled( false ); +// backButton->setEnabled( true ); +// nextButton->setEnabled( false ); checkMetadata(); } else { - backButton->setEnabled( true ); - nextButton->setEnabled( true ); +// backButton->setEnabled( true ); +// nextButton->setEnabled( true ); } } -void QgsMetadataWizard::addNewCategory() +void QgsMetadataWidget::addNewCategory() { bool ok; QString text = QInputDialog::getText( this, tr( "New Category" ), @@ -613,7 +611,7 @@ void QgsMetadataWizard::addNewCategory() } } -void QgsMetadataWizard::addDefaultCategory() +void QgsMetadataWidget::addDefaultCategory() { QItemSelectionModel *selection = listDefaultCategories->selectionModel(); if ( selection->hasSelection() ) @@ -633,7 +631,7 @@ void QgsMetadataWizard::addDefaultCategory() } -void QgsMetadataWizard::removeCategory() +void QgsMetadataWidget::removeCategory() { QItemSelectionModel *selection = listCategories->selectionModel(); if ( selection->hasSelection() ) @@ -662,7 +660,7 @@ QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionView QComboBox *typeEditor = new QComboBox( parent ); typeEditor->setEditable( true ); QStringListModel *model = new QStringListModel( parent ); - model->setStringList( QgsMetadataWizard::parseLinkTypes() ); + model->setStringList( QgsMetadataWidget::parseLinkTypes() ); typeEditor->setModel( model ); return typeEditor; } diff --git a/src/app/qgsmetadatawizard.h b/src/gui/qgsmetadatawidget.h similarity index 90% rename from src/app/qgsmetadatawizard.h rename to src/gui/qgsmetadatawidget.h index 91fbe451e4a9..61d186577789 100644 --- a/src/app/qgsmetadatawizard.h +++ b/src/gui/qgsmetadatawidget.h @@ -1,5 +1,5 @@ /*************************************************************************** - qgsmetadatawizard.h - description + qgsmetadatawidget.h - description ------------------- begin : 17/05/2017 copyright : (C) 2017 by Etienne Trimaille @@ -14,26 +14,26 @@ * (at your option) any later version. * * * ***************************************************************************/ -#ifndef QGSMETADATAWIZARD_H -#define QGSMETADATAWIZARD_H +#ifndef QGSMETADATAWIDGET_H +#define QGSMETADATAWIDGET_H #include "QStandardItemModel" #include "QStyledItemDelegate" -#include "qgis_app.h" +#include "qgis_gui.h" #include "qgsmaplayer.h" #include "qgslayermetadata.h" -#include "ui_qgsmetadatawizard.h" +#include "ui_qgsmetadatawidget.h" /** - * \ingroup app - * \class QgsMetadataWizard + * \ingroup gui + * \class QgsMetadataWidget * \brief A wizard to edit metadata on a map layer. * * \since QGIS 3.0 */ -class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWizard +class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidget { Q_OBJECT @@ -42,8 +42,8 @@ class APP_EXPORT QgsMetadataWizard : public QDialog, private Ui::QgsMetadataWiza /** * Constructor for the wizard. */ - QgsMetadataWizard( QWidget *parent, QgsMapLayer *layer = nullptr ); - ~QgsMetadataWizard(); + QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer = nullptr ); + ~QgsMetadataWidget(); /** * Set the source field from the layer. diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index d5242aa779b7..0c5dc7760926 100755 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -17,7 +17,7 @@ 0 0 1018 - 21 + 22 @@ -157,8 +157,6 @@ - - @@ -363,9 +361,6 @@ - - -
@@ -2675,15 +2670,6 @@ Acts on currently active editable layer Ctrl+L - - - - :/images/themes/default/propertyicons/metadata.svg:/images/themes/default/propertyicons/metadata.svg - - - Open Metadata Wizard Editor - - diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui new file mode 100644 index 000000000000..3cc8a079aede --- /dev/null +++ b/src/ui/qgsmetadatawidget.ui @@ -0,0 +1,917 @@ + + + QgsMetadataWidget + + + + 0 + 0 + 797 + 528 + + + + Form + + + + + + true + + + QTabWidget::Rounded + + + 0 + + + + Identification + + + + + + This page describes the basic attribution of the dataset. If unsure about which type to select, use 'dataset'. Use the abstract field to provide a verbose description of this dataset. + + + true + + + + + + + Identifier + + + + + + + + + + + + Set from layer + + + + + + + + + Title + + + + + + + + 0 + 0 + + + + + + + + Type (it is advised to use the ISO 19115 MD_ScopeCode) + + + + + + + true + + + true + + + + + + + Language (it is advised to follow either the ISO 639.2 or ISO 3166) + + + + + + + true + + + true + + + + + + + Abstract + + + + + + + + 0 + 0 + + + + + + + + false + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Encoding + + + + + + + + + + 0 + 0 + + + + + + + + Set from layer + + + + + + + + + + + + + Categories + + + + + + Categories dialog. It a shortcuts for 'gmd:topicCategory' in the keywords tab. + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + Categories + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + :/images/themes/default/mActionNewBookmark.svg:/images/themes/default/mActionNewBookmark.svg + + + + + + + + 0 + 0 + + + + + + + + :/images/themes/default/mActionArrowRight.svg:/images/themes/default/mActionArrowRight.svg + + + + 16 + 18 + + + + + + + + + 0 + 0 + + + + + + + + :/images/themes/default/mActionArrowLeft.svg:/images/themes/default/mActionArrowLeft.svg + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Available categories + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + + + + + Keywords + + + + + + Keywords are optional, and provide a way to provide additional descriptive information about the dataset. For example you can specify the category for this dataset by adding a vocabulary items 'gmd:topicCategory' with a comma separated list of category keywords. + + + true + + + + + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + Vocabulary + + + + + Keywords + + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + false + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Access + + + + + + Access dialog. HELP TEXT TO ADD + + + + + + + Licenses + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + true + + + + Label + + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + + + + Extent + + + + + + Extent dialog. HELP TEXT TO ADD + + + + + + + Spatial Extent + + + + + + + + + + + + 0 + 0 + + + + Set CRS from layer + + + + + + + + + + + + Temporal Extent + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + false + + + Contacts + + + + + + Contacts, HELP TEXT + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 200 + 16777215 + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + Name + + + + + Organization + + + + + + + + + 0 + 0 + + + + true + + + + + 0 + 0 + 513 + 379 + + + + + + + Name + + + + + + + + + + Role + + + + + + + + + + Organization + + + + + + + + + + Position + + + + + + + + + + Email + + + + + + + + + + Voice + + + + + + + + + + Fax + + + + + + + + + + Address + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + true + + + + Type + + + + + Address + + + + + Postal Code + + + + + City + + + + + Administrative Area + + + + + Country + + + + + + + + + + + + + + + Links + + + + + + Links dialog, HELP TEXT TO ADD + + + + + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Validation + + + + + + + + + + + + + + QgsProjectionSelectionWidget + QWidget +
qgsprojectionselectionwidget.h
+ 1 +
+ + QgsCollapsibleGroupBox + QGroupBox +
qgscollapsiblegroupbox.h
+ 1 +
+
+ + + + +
diff --git a/src/ui/qgsmetadatawizard.ui b/src/ui/qgsmetadatawizard.ui deleted file mode 100644 index 17edec0baa5b..000000000000 --- a/src/ui/qgsmetadatawizard.ui +++ /dev/null @@ -1,1035 +0,0 @@ - - - QgsMetadataWizard - - - - 0 - 0 - 781 - 712 - - - - Metadata Editor - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - background: #93b023; border: none; - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - font: 22pt; color: #fff; - - - Metadata Editor - - - - - - - font: 16pt; color: #fff; - - - Placeholder set in C++ code for the layer title being edited - - - - - - - - - - - 0 - 20 - - - - background: #589632; border: none; - - - QFrame::NoFrame - - - - - - - true - - - QTabWidget::Rounded - - - 1 - - - - Identification - - - - - - This page describes the basic attribution of the dataset. If unsure about which type to select, use 'dataset'. Use the abstract field to provide a verbose description of this dataset. - - - true - - - - - - - Identifier - - - - - - - - - - - - Set from layer - - - - - - - - - Title - - - - - - - - 0 - 0 - - - - - - - - Type (it is advised to use the ISO 19115 MD_ScopeCode) - - - - - - - true - - - true - - - - - - - Language (it is advised to follow either the ISO 639.2 or ISO 3166) - - - - - - - true - - - true - - - - - - - Abstract - - - - - - - - 0 - 0 - - - - - - - - false - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Encoding - - - - - - - - - - 0 - 0 - - - - - - - - Set from layer - - - - - - - - - - - - - Categories - - - - - - Categories dialog. It a shortcuts for 'gmd:topicCategory' in the keywords tab. - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - Categories - - - - - - - QAbstractItemView::NoEditTriggers - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - :/images/themes/default/mActionNewBookmark.svg:/images/themes/default/mActionNewBookmark.svg - - - - - - - - 0 - 0 - - - - - - - - :/images/themes/default/mActionArrowRight.svg:/images/themes/default/mActionArrowRight.svg - - - - 16 - 18 - - - - - - - - - 0 - 0 - - - - - - - - :/images/themes/default/mActionArrowLeft.svg:/images/themes/default/mActionArrowLeft.svg - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Available categories - - - - - - - QAbstractItemView::NoEditTriggers - - - - - - - - - - - - - Keywords - - - - - - Keywords are optional, and provide a way to provide additional descriptive information about the dataset. For example you can specify the category for this dataset by adding a vocabulary items 'gmd:topicCategory' with a comma separated list of category keywords. - - - true - - - - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - - Vocabulary - - - - - Keywords - - - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - false - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Access - - - - - - Access dialog. HELP TEXT TO ADD - - - - - - - Licenses - - - - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - - - true - - - - Label - - - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - - - - Extent - - - - - - Extent dialog. HELP TEXT TO ADD - - - - - - - Spatial Extent - - - - - - - - - - - - 0 - 0 - - - - Set CRS from layer - - - - - - - - - - - - Temporal Extent - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - false - - - Contacts - - - - - - Contacts, HELP TEXT - - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 200 - 16777215 - - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - - Name - - - - - Organization - - - - - - - - - 0 - 0 - - - - true - - - - - 0 - 0 - 521 - 450 - - - - - - - Name - - - - - - - - - - Role - - - - - - - - - - Organization - - - - - - - - - - Position - - - - - - - - - - Email - - - - - - - - - - Voice - - - - - - - - - - Fax - - - - - - - - - - Address - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - true - - - - Type - - - - - Address - - - - - Postal Code - - - - - City - - - - - Administrative Area - - - - - Country - - - - - - - - - - - - - - - Links - - - - - - Links dialog, HELP TEXT TO ADD - - - - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Validation - - - - - - - - - - - - - Qt::Horizontal - - - - - - - - - Save - - - - - - - Back - - - - - - - Cancel - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Next - - - - - - - - - - QgsCollapsibleGroupBox - QGroupBox -
qgscollapsiblegroupbox.h
- 1 -
- - QgsProjectionSelectionWidget - QWidget -
qgsprojectionselectionwidget.h
- 1 -
-
- - - - -
From 7173214320c921d776e2d76f3eefaf97eadb2ade Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 9 Aug 2017 18:12:06 +0200 Subject: [PATCH 18/39] set the metadata dialog for raster layer --- src/app/qgsrasterlayerproperties.cpp | 10 + src/app/qgsrasterlayerproperties.h | 2 + src/gui/qgsmetadatawidget.cpp | 56 +- src/gui/qgsmetadatawidget.h | 6 +- src/ui/qgisapp.ui | 2 +- src/ui/qgsmetadatawidget.ui | 1816 +++++++++++++------------- 6 files changed, 929 insertions(+), 963 deletions(-) diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp index be099f941db2..3d55c783d330 100644 --- a/src/app/qgsrasterlayerproperties.cpp +++ b/src/app/qgsrasterlayerproperties.cpp @@ -31,6 +31,7 @@ #include "qgsmaplayerstyleguiutils.h" #include "qgsmaptoolemitpoint.h" #include "qgsmaptopixel.h" +#include "qgsmetadatawidget.h" #include "qgsmultibandcolorrenderer.h" #include "qgsmultibandcolorrendererwidget.h" #include "qgspalettedrendererwidget.h" @@ -231,6 +232,13 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv mOptsPage_Histogram->setEnabled( false ); } + QVBoxLayout *layout = new QVBoxLayout( metadataFrame ); + layout->setMargin( 0 ); + mMetadataWidget = new QgsMetadataWidget( this, mRasterLayer ); + mMetadataWidget->layout()->setContentsMargins( -1, 0, -1, 0 ); + layout->addWidget( mMetadataWidget ); + metadataFrame->setLayout( layout ); + QgsDebugMsg( "Setting crs to " + mRasterLayer->crs().toWkt() ); QgsDebugMsg( "Setting crs to " + mRasterLayer->crs().authid() + " - " + mRasterLayer->crs().description() ); mCrsSelector->setCrs( mRasterLayer->crs() ); @@ -829,6 +837,8 @@ void QgsRasterLayerProperties::apply() mRasterLayer->setRenderer( rendererWidget->renderer() ); } + mMetadataWidget->saveMetadata(); + //transparency settings QgsRasterRenderer *rasterRenderer = mRasterLayer->renderer(); if ( rasterRenderer ) diff --git a/src/app/qgsrasterlayerproperties.h b/src/app/qgsrasterlayerproperties.h index 5e0b63e5ff81..1e4238a4a5c2 100644 --- a/src/app/qgsrasterlayerproperties.h +++ b/src/app/qgsrasterlayerproperties.h @@ -22,6 +22,7 @@ #include "qgsoptionsdialogbase.h" #include "ui_qgsrasterlayerpropertiesbase.h" #include "qgsguiutils.h" +#include "qgsmetadatawidget.h" #include "qgshelp.h" #include "qgsmaplayerstylemanager.h" #include "qgis_app.h" @@ -154,6 +155,7 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private //bool mRasterLayerIsInternal; QgsRasterRendererWidget *mRendererWidget = nullptr; + QgsMetadataWidget *mMetadataWidget = nullptr; bool rasterIsMultiBandColor(); diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index c628ee1ff976..3153e7af74a1 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -44,16 +44,12 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) mDefaultCategoriesModel = new QStringListModel( mDefaultCategories ); mDefaultCategoriesModel->sort( 0 ); // Sorting using translations listDefaultCategories->setModel( mDefaultCategoriesModel ); -// listDefaultCategories->setEditTriggers(QAbstractItemView.NoEditTriggers); -// listCategories->setEditTriggers(QAbstractItemView.NoEditTriggers); // Categories mCategoriesModel = new QStringListModel(); listCategories->setModel( mCategoriesModel ); tabWidget->setCurrentIndex( 0 ); -// backButton->setEnabled( false ); -// nextButton->setEnabled( true ); // Setup the link view mLinksModel = new QStandardItemModel(); @@ -65,10 +61,6 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) tabLinks->setItemDelegate( new LinkItemDelegate() ); connect( tabWidget, &QTabWidget::currentChanged, this, &QgsMetadataWidget::updatePanel ); -// connect( cancelButton, &QPushButton::clicked, this, &QgsMetadataWidget::cancelClicked ); -// connect( backButton, &QPushButton::clicked, this, &QgsMetadataWidget::backClicked ); -// connect( nextButton, &QPushButton::clicked, this, &QgsMetadataWidget::nextClicked ); -// connect( finishButton, &QPushButton::clicked, this, &QgsMetadataWidget::finishedClicked ); connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWidget::setAutoSource ); connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::addVocabulary ); connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::removeVocabulary ); @@ -246,9 +238,8 @@ void QgsMetadataWidget::fillComboBox() void QgsMetadataWidget::setPropertiesFromLayer() { // Set all properties USING THE OLD API -// layerLabel->setText( mLayer->name() ); lineEditTitle->setText( mLayer->name() ); - textEditAbstract->setText( mLayer->abstract() ); + textEditAbstract->setPlainText( mLayer->abstract() ); // Set all properties USING THE NEW API // It will overwrite existing settings @@ -285,6 +276,8 @@ void QgsMetadataWidget::setPropertiesFromLayer() comboLanguage->setCurrentIndex( comboLanguage->findText( mMetadata.language() ) ); } + textEditAbstract->setPlainText( mMetadata.abstract() ); + // Categories mCategoriesModel->setStringList( mMetadata.categories() ); @@ -480,28 +473,7 @@ QStringList QgsMetadataWidget::parseLinkTypes() return wordList; } -void QgsMetadataWidget::cancelClicked() -{ - hide(); -} - -void QgsMetadataWidget::backClicked() -{ - int index = tabWidget->currentIndex(); - if ( index > 0 ) - tabWidget->setCurrentIndex( index - 1 ); - updatePanel(); -} - -void QgsMetadataWidget::nextClicked() -{ - int index = tabWidget->currentIndex(); - if ( index < tabWidget->count() ) - tabWidget->setCurrentIndex( index + 1 ); - updatePanel(); -} - -void QgsMetadataWidget::finishedClicked() +void QgsMetadataWidget::saveMetadata() { // OLD API (to remove later) mLayer->setName( lineEditTitle->text() ); @@ -553,12 +525,8 @@ void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() void QgsMetadataWidget::updatePanel() { int index = tabWidget->currentIndex(); - if ( index == 0 ) - { -// backButton->setEnabled( false ); -// nextButton->setEnabled( true ); - } - else if ( index == 1 ) + QString currentTabText = tabWidget->widget( index )->objectName(); + if ( currentTabText == "tabCategoriesDialog" ) { // Categories tab // We need to take keywords and insert them into the list @@ -573,24 +541,16 @@ void QgsMetadataWidget::updatePanel() mCategoriesModel->setStringList( QStringList() ); } } - else if ( index == 2 ) + else if ( currentTabText == "tabKeywordsDialog" ) { // Keywords tab // We need to take categories and insert them into the table syncFromCategoriesTabToKeywordsTab(); } - else if ( index == tabWidget->count() - 1 ) + else if ( currentTabText == "tabValidationDialog" ) { - // Validation tab -// backButton->setEnabled( true ); -// nextButton->setEnabled( false ); checkMetadata(); } - else - { -// backButton->setEnabled( true ); -// nextButton->setEnabled( true ); - } } void QgsMetadataWidget::addNewCategory() diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index 61d186577789..c50d75dad1f4 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -136,11 +136,9 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg */ static QStringList parseLinkTypes(); + void saveMetadata(); + private: - void cancelClicked(); - void backClicked(); - void nextClicked(); - void finishedClicked(); void updatePanel(); void addDefaultCategory(); void addNewCategory(); diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index 0c5dc7760926..bf469bfa0e22 100755 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -17,7 +17,7 @@ 0 0 1018 - 22 + 21 diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui index 3cc8a079aede..fa8b7fcc7030 100644 --- a/src/ui/qgsmetadatawidget.ui +++ b/src/ui/qgsmetadatawidget.ui @@ -1,917 +1,913 @@ - QgsMetadataWidget - - - - 0 - 0 - 797 - 528 - - - - Form - - + QgsMetadataWidget + + + + 0 + 0 + 797 + 528 + + + + Form + + + + + + true + + + QTabWidget::Rounded + + + 0 + + + + Identification + + + + + + This page describes the basic attribution of the dataset. If unsure about which type to select, use 'dataset'. Use the abstract field to provide a verbose description of this dataset. + + + true + + + + + + + Identifier + + + + + + + + + + + + Set from layer + + + + + + + + + Title + + + + + + + + 0 + 0 + + + + + + + + Type (it is advised to use the ISO 19115 MD_ScopeCode) + + + + + + + true + + + true + + + + + + + Language (it is advised to follow either the ISO 639.2 or ISO 3166) + + + + + + + true + + + true + + + + + + + Abstract + + + + + + + + 0 + 0 + + + + + + + + false + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Encoding + + + + + + + + + + 0 + 0 + + + + + + + + Set from layer + + + + + + + + + + + + + Categories + + + + + + Categories dialog. It a shortcuts for 'gmd:topicCategory' in the keywords tab. + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + Available categories + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + New + + + + + + + + 0 + 0 + + + + + + + + :/images/themes/default/mActionArrowRight.svg:/images/themes/default/mActionArrowRight.svg + + + + 16 + 18 + + + + - - - true - - - QTabWidget::Rounded - - - 0 - - - - Identification - - - - - - This page describes the basic attribution of the dataset. If unsure about which type to select, use 'dataset'. Use the abstract field to provide a verbose description of this dataset. - - - true - - - - - - - Identifier - - - - - - - - - - - - Set from layer - - - - - - - - - Title - - - - - - - - 0 - 0 - - - - - - - - Type (it is advised to use the ISO 19115 MD_ScopeCode) - - - - - - - true - - - true - - - - - - - Language (it is advised to follow either the ISO 639.2 or ISO 3166) - - - - - - - true - - - true - - - - - - - Abstract - - - - - - - - 0 - 0 - - - - - - - - false - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Encoding - - - - - - - - - - 0 - 0 - - - - - - - - Set from layer - - - - - - - - - - - - - Categories - - - - - - Categories dialog. It a shortcuts for 'gmd:topicCategory' in the keywords tab. - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - Categories - - - - - - - QAbstractItemView::NoEditTriggers - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - :/images/themes/default/mActionNewBookmark.svg:/images/themes/default/mActionNewBookmark.svg - - - - - - - - 0 - 0 - - - - - - - - :/images/themes/default/mActionArrowRight.svg:/images/themes/default/mActionArrowRight.svg - - - - 16 - 18 - - - - - - - - - 0 - 0 - - - - - - - - :/images/themes/default/mActionArrowLeft.svg:/images/themes/default/mActionArrowLeft.svg - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Available categories - - - - - - - QAbstractItemView::NoEditTriggers - - - - - - - - - - - - - Keywords - - - - - - Keywords are optional, and provide a way to provide additional descriptive information about the dataset. For example you can specify the category for this dataset by adding a vocabulary items 'gmd:topicCategory' with a comma separated list of category keywords. - - - true - - - - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - - Vocabulary - - - - - Keywords - - - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - false - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Access - - - - - - Access dialog. HELP TEXT TO ADD - - - - - - - Licenses - - - - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - - - true - - - - Label - - - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - - - - Extent - - - - - - Extent dialog. HELP TEXT TO ADD - - - - - - - Spatial Extent - - - - - - - - - - - - 0 - 0 - - - - Set CRS from layer - - - - - - - - - - - - Temporal Extent - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - false - - - Contacts - - - - - - Contacts, HELP TEXT - - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 200 - 16777215 - - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - - Name - - - - - Organization - - - - - - - - - 0 - 0 - - - - true - - - - - 0 - 0 - 513 - 379 - - - - - - - Name - - - - - - - - - - Role - - - - - - - - - - Organization - - - - - - - - - - Position - - - - - - - - - - Email - - - - - - - - - - Voice - - - - - - - - - - Fax - - - - - - - - - - Address - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - true - - - - Type - - - - - Address - - - - - Postal Code - - - - - City - - - - - Administrative Area - - - - - Country - - - - - - - - - - - - - - - Links - - - - - - Links dialog, HELP TEXT TO ADD - - - - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Validation - - - - - - - - + + + + 0 + 0 + + + + + + + + :/images/themes/default/mActionArrowLeft.svg:/images/themes/default/mActionArrowLeft.svg + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Categories + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + + + + + Keywords + + + + + + Keywords are optional, and provide a way to provide additional descriptive information about the dataset. For example you can specify the category for this dataset by adding a vocabulary items 'gmd:topicCategory' with a comma separated list of category keywords. + + + true + + + + + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + Vocabulary + + + + + Keywords + + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + false + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Access + + + + + + Access dialog. HELP TEXT TO ADD + + + + + + + Licenses + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + true + + + + Label + + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + + + + Extent + + + + + + Extent dialog. HELP TEXT TO ADD + + + + + + + Spatial Extent + + + + + + + + + + + + 0 + 0 + + + + Set CRS from layer + + + + + + + + + + + + Temporal Extent + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + false + + + Contacts + + + + + + Contacts, HELP TEXT + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 200 + 16777215 + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + Name + + + + + Organization + + + + + + + + + 0 + 0 + + + + true + + + + + 0 + 0 + 513 + 379 + + + + + + + Name + + + + + + + + + + Role + + + + + + + + + + Organization + + + + + + + + + + Position + + + + + + + + + + Email + + + + + + + + + + Voice + + + + + + + + + + Fax + + + + + + + + + + Address + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + true + + + + Type + + + + + Address + + + + + Postal Code + + + + + City + + + + + Administrative Area + + + + + Country + + + + + + + + + + + + + + + Links + + + + + + Links dialog, HELP TEXT TO ADD + + + + + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Validation + + + + + + + - - - QgsProjectionSelectionWidget - QWidget -
qgsprojectionselectionwidget.h
- 1 -
- - QgsCollapsibleGroupBox - QGroupBox -
qgscollapsiblegroupbox.h
- 1 -
-
- - - - +
+
+
+ + + QgsProjectionSelectionWidget + QWidget +
qgsprojectionselectionwidget.h
+ 1 +
+ + QgsCollapsibleGroupBox + QGroupBox +
qgscollapsiblegroupbox.h
+ 1 +
+
+ + + +
From 539055f4985a9744def463feae134d99b8eb15f0 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 10 Aug 2017 16:02:36 +0200 Subject: [PATCH 19/39] add metadata widget to the vector layer properties --- src/app/qgsrasterlayerproperties.cpp | 1 - src/app/qgsvectorlayerproperties.cpp | 11 +++++++++++ src/app/qgsvectorlayerproperties.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp index 3d55c783d330..1c10bebd06ce 100644 --- a/src/app/qgsrasterlayerproperties.cpp +++ b/src/app/qgsrasterlayerproperties.cpp @@ -31,7 +31,6 @@ #include "qgsmaplayerstyleguiutils.h" #include "qgsmaptoolemitpoint.h" #include "qgsmaptopixel.h" -#include "qgsmetadatawidget.h" #include "qgsmultibandcolorrenderer.h" #include "qgsmultibandcolorrendererwidget.h" #include "qgspalettedrendererwidget.h" diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index 15a3c056dd4c..d66fa5280a25 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -247,6 +247,14 @@ QgsVectorLayerProperties::QgsVectorLayerProperties( diagLayout->addWidget( diagramPropertiesDialog ); mDiagramFrame->setLayout( diagLayout ); + // Metadata tab + QVBoxLayout *metadataLayout = new QVBoxLayout( metadataFrame ); + metadataLayout->setMargin( 0 ); + mMetadataWidget = new QgsMetadataWidget( this, mLayer ); + mMetadataWidget->layout()->setContentsMargins( -1, 0, -1, 0 ); + metadataLayout->addWidget( mMetadataWidget ); + metadataFrame->setLayout( metadataLayout ); + // Legend tab mLegendConfigEmbeddedWidget->setLayer( mLayer ); @@ -489,6 +497,9 @@ void QgsVectorLayerProperties::apply() // apply legend settings mLegendConfigEmbeddedWidget->applyToLayer(); + // save metadata + mMetadataWidget->saveMetadata(); + // // Set up sql subset query if applicable // diff --git a/src/app/qgsvectorlayerproperties.h b/src/app/qgsvectorlayerproperties.h index 529a79b53af6..1c1315b70600 100644 --- a/src/app/qgsvectorlayerproperties.h +++ b/src/app/qgsvectorlayerproperties.h @@ -24,6 +24,7 @@ #include "qgsguiutils.h" #include "qgshelp.h" #include "qgsmaplayerstylemanager.h" +#include "qgsmetadatawidget.h" #include "qgsvectorlayer.h" #include "qgsvectorlayerjoininfo.h" #include "layertree/qgslayertree.h" @@ -212,6 +213,8 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private void showHelp(); + QgsMetadataWidget *mMetadataWidget = nullptr; + private slots: void openPanel( QgsPanelWidget *panel ); }; From 84deaee3d36176b452cd7452cb0aba18eb16f9b6 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Tue, 15 Aug 2017 18:28:01 +0200 Subject: [PATCH 20/39] add tooltip on languages --- src/gui/qgsmetadatawidget.cpp | 22 +++++++++++++++------- src/gui/qgsmetadatawidget.h | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 3153e7af74a1..538f393bd3e8 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -231,8 +231,15 @@ void QgsMetadataWidget::fillComboBox() // Set default values in language combobox // It is advised to use the ISO 639.2 or ISO 3166 specifications, e.g. 'ENG' or 'SPA', comboLanguage->setEditable( true ); - types.clear(); - comboLanguage->addItems( parseLanguages() ); + comboLanguage->clear(); + QMap countries = parseLanguages(); + int i = 0; + for ( QString countryCode : countries.keys() ) + { + comboLanguage->insertItem( i, countryCode ); + comboLanguage->setItemData( i, countries.value( countryCode ), Qt::ToolTipRole ); + i++; + } } void QgsMetadataWidget::setPropertiesFromLayer() @@ -412,7 +419,7 @@ bool QgsMetadataWidget::checkMetadata() return results; } -QStringList QgsMetadataWidget::parseLanguages() +QMap QgsMetadataWidget::parseLanguages() { QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "country_code_ISO_3166.csv" ) ); QFile file( path ); @@ -421,16 +428,17 @@ QStringList QgsMetadataWidget::parseLanguages() QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); } - QStringList wordList; - wordList.append( "" ); + QMap countries; + countries.insert( "", "" ); // We add an empty line, because it's not compulsory. // Skip the first line of the CSV file.readLine(); while ( !file.atEnd() ) { QByteArray line = file.readLine(); - wordList.append( line.split( ',' ).at( 2 ) ); + QList items = line.split( ',' ); + countries.insert( items.at( 2 ).constData(), items.at( 0 ).constData() ); } - return wordList; + return countries; } QStringList QgsMetadataWidget::parseLicenses() diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index c50d75dad1f4..3c419b3fe722 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -123,7 +123,7 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg /** * Returns a list of languages by default available in the wizard. */ - static QStringList parseLanguages(); + static QMap parseLanguages(); /** * Returns a list of licences by default available in the wizard. From efaefb0e46a88937abef6d63f8a5db6cf115ad92 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 16 Aug 2017 08:10:30 +0200 Subject: [PATCH 21/39] add tooltips on types --- src/gui/qgsmetadatawidget.cpp | 34 ++++++++++++++++++++++++++++++---- src/gui/qgsmetadatawidget.h | 5 +++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 538f393bd3e8..5b1795147d47 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -224,16 +224,22 @@ void QgsMetadataWidget::fillComboBox() // It is advised to use the ISO 19115 MD_ScopeCode values. E.g. 'dataset' or 'series'. // http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml comboType->setEditable( true ); - QStringList types; - types << "" << "attribute" << "attributeType" << "dataset" << "nonGeographicDataset" << "series" << "document"; - comboType->addItems( types ); + comboType->clear(); + QMap types = parseTypes(); + int i = 0; + for ( QString type : types.keys() ) + { + comboType->insertItem( i, type ); + comboType->setItemData( i, types.value( type ), Qt::ToolTipRole ); + i++; + } // Set default values in language combobox // It is advised to use the ISO 639.2 or ISO 3166 specifications, e.g. 'ENG' or 'SPA', comboLanguage->setEditable( true ); comboLanguage->clear(); QMap countries = parseLanguages(); - int i = 0; + i = 0; for ( QString countryCode : countries.keys() ) { comboLanguage->insertItem( i, countryCode ); @@ -481,6 +487,26 @@ QStringList QgsMetadataWidget::parseLinkTypes() return wordList; } +QMap QgsMetadataWidget::parseTypes() +{ + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "md_scope_codes.csv" ) ); + QFile file( path ); + if ( !file.open( QIODevice::ReadOnly ) ) + { + QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + } + + QMap types; + types.insert( "", "" ); // We add an empty line, because it's not compulsory. + while ( !file.atEnd() ) + { + QByteArray line = file.readLine(); + QList items = line.split( ';' ); + types.insert( items.at( 0 ).constData(), items.at( 1 ).constData() ); + } + return types; +} + void QgsMetadataWidget::saveMetadata() { // OLD API (to remove later) diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index 3c419b3fe722..da98f626887b 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -136,6 +136,11 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg */ static QStringList parseLinkTypes(); + /** + * Returns a list of types by default available in the wizard. + */ + static QMap parseTypes(); + void saveMetadata(); private: From a6dabf7972144bf902007cc6fa0898e895785940 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 16 Aug 2017 18:07:51 +0200 Subject: [PATCH 22/39] add MIME CSV in the links tab --- src/gui/qgsmetadatawidget.cpp | 25 +++++++++++++++++++++---- src/gui/qgsmetadatawidget.h | 14 ++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 5b1795147d47..c7be824723a1 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -487,6 +487,24 @@ QStringList QgsMetadataWidget::parseLinkTypes() return wordList; } +QStringList QgsMetadataWidget::parseMimeTypes() +{ + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "mime.csv" ) ); + QFile file( path ); + if ( !file.open( QIODevice::ReadOnly ) ) + { + QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + } + + QStringList wordList; + while ( !file.atEnd() ) + { + QByteArray line = file.readLine(); + wordList.append( line.split( ',' ).at( 0 ) ); + } + return wordList; +} + QMap QgsMetadataWidget::parseTypes() { QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "md_scope_codes.csv" ) ); @@ -651,6 +669,7 @@ QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionView { if ( index.column() == 1 ) { + // Link type QComboBox *typeEditor = new QComboBox( parent ); typeEditor->setEditable( true ); QStringListModel *model = new QStringListModel( parent ); @@ -660,13 +679,11 @@ QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionView } else if ( index.column() == 5 ) { - // See https://fr.wikipedia.org/wiki/Type_MIME + // MIME QComboBox *mimeEditor = new QComboBox( parent ); mimeEditor->setEditable( true ); QStringListModel *model = new QStringListModel( parent ); - QStringList mime; - mime << "" << "image/png" << "image/tiff" << "application/pdf"; - model->setStringList( mime ); + model->setStringList( QgsMetadataWidget::parseMimeTypes() ); mimeEditor->setModel( model ); return mimeEditor; } diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index da98f626887b..488aef556037 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -121,23 +121,29 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg bool checkMetadata(); /** - * Returns a list of languages by default available in the wizard. + * Returns a list of languages available by default in the wizard. */ static QMap parseLanguages(); /** - * Returns a list of licences by default available in the wizard. + * Returns a list of licences available by default in the wizard. */ static QStringList parseLicenses(); /** - * Returns a list of link types by default available in the wizard. + * Returns a list of link types available by default in the wizard. * \see https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv */ static QStringList parseLinkTypes(); /** - * Returns a list of types by default available in the wizard. + * Returns a list of MIME types available by default in the wizard. + * \see https://fr.wikipedia.org/wiki/Type_MIME + */ + static QStringList parseMimeTypes(); + + /** + * Returns a list of types available by default in the wizard. */ static QMap parseTypes(); From 2b24c47e80448e9b9fe8a1d79c1f5b2c38a8b05d Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 16 Aug 2017 22:47:45 +0200 Subject: [PATCH 23/39] add fees and fix save metadata --- src/app/qgsrasterlayerproperties.cpp | 2 +- src/app/qgsvectorlayerproperties.cpp | 2 +- src/gui/qgsmetadatawidget.cpp | 8 +++++++- src/gui/qgsmetadatawidget.h | 2 +- src/ui/qgsmetadatawidget.ui | 24 +++++++++++++++++------- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp index 1c10bebd06ce..563ccc14c542 100644 --- a/src/app/qgsrasterlayerproperties.cpp +++ b/src/app/qgsrasterlayerproperties.cpp @@ -836,7 +836,7 @@ void QgsRasterLayerProperties::apply() mRasterLayer->setRenderer( rendererWidget->renderer() ); } - mMetadataWidget->saveMetadata(); + mMetadataWidget->acceptMetadata(); //transparency settings QgsRasterRenderer *rasterRenderer = mRasterLayer->renderer(); diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index d66fa5280a25..cfd6588f59b1 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -498,7 +498,7 @@ void QgsVectorLayerProperties::apply() mLegendConfigEmbeddedWidget->applyToLayer(); // save metadata - mMetadataWidget->saveMetadata(); + mMetadataWidget->acceptMetadata(); // // Set up sql subset query if applicable diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index c7be824723a1..db00401f757f 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -306,6 +306,9 @@ void QgsMetadataWidget::setPropertiesFromLayer() tabKeywords->item( currentRow, 1 )->setText( i.value().join( "," ) ); } + // Fees + lineEditFees->setText( mMetadata.fees() ); + // Licenses tabLicenses->setRowCount( 0 ); for ( QString licence : mMetadata.licenses() ) @@ -358,6 +361,9 @@ void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) } layerMetadata.setKeywords( keywords ); + // Fees + layerMetadata.setFees( lineEditFees->text() ); + // Licenses QStringList licenses; for ( int i = 0 ; i < tabLicenses->rowCount() ; i++ ) @@ -525,7 +531,7 @@ QMap QgsMetadataWidget::parseTypes() return types; } -void QgsMetadataWidget::saveMetadata() +void QgsMetadataWidget::acceptMetadata() { // OLD API (to remove later) mLayer->setName( lineEditTitle->text() ); diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index 488aef556037..5cbcba1a079d 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -147,7 +147,7 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg */ static QMap parseTypes(); - void saveMetadata(); + void acceptMetadata(); private: void updatePanel(); diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui index fa8b7fcc7030..c59ea1079ccd 100644 --- a/src/ui/qgsmetadatawidget.ui +++ b/src/ui/qgsmetadatawidget.ui @@ -23,7 +23,7 @@ QTabWidget::Rounded
- 0 + 3 @@ -437,6 +437,16 @@ + + + + Fees + + + + + + @@ -893,18 +903,18 @@ - - QgsProjectionSelectionWidget - QWidget -
qgsprojectionselectionwidget.h
- 1 -
QgsCollapsibleGroupBox QGroupBox
qgscollapsiblegroupbox.h
1
+ + QgsProjectionSelectionWidget + QWidget +
qgsprojectionselectionwidget.h
+ 1 +
From f04e566ffc92333fa063a117f86deae880462785 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 16 Aug 2017 23:43:23 +0200 Subject: [PATCH 24/39] add rights --- src/gui/qgsmetadatawidget.cpp | 37 +++++++++++++++++ src/gui/qgsmetadatawidget.h | 11 +++++ src/ui/qgsmetadatawidget.ui | 78 +++++++++++++++++++++++++++++++---- 3 files changed, 118 insertions(+), 8 deletions(-) diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index db00401f757f..309e3ea11087 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -49,6 +49,10 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) mCategoriesModel = new QStringListModel(); listCategories->setModel( mCategoriesModel ); + // Rights + mRightsModel = new QStringListModel(); + listRights->setModel( mRightsModel ); + tabWidget->setCurrentIndex( 0 ); // Setup the link view @@ -64,6 +68,8 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWidget::setAutoSource ); connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::addVocabulary ); connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::removeVocabulary ); + connect( btnAddRight, &QPushButton::clicked, this, &QgsMetadataWidget::addRight ); + connect( btnRemoveRight, &QPushButton::clicked, this, &QgsMetadataWidget::removeRight ); connect( btnAddLicence, &QPushButton::clicked, this, &QgsMetadataWidget::addLicence ); connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWidget::removeLicence ); connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWidget::setAutoCrs ); @@ -146,6 +152,31 @@ void QgsMetadataWidget::removeLicence() } } +void QgsMetadataWidget::addRight() +{ + QString newRight = QInputDialog::getText( this, tr( "New Right" ), tr( "New Right" ) ); + QStringList existingRights = mRightsModel->stringList(); + if ( ! existingRights.contains( newRight ) ) + { + existingRights.append( newRight ); + mRightsModel->setStringList( existingRights ); + } +} + +void QgsMetadataWidget::removeRight() +{ + QItemSelectionModel *selection = listRights->selectionModel(); + if ( selection->hasSelection() ) + { + QModelIndex indexElementSelectionne = selection->currentIndex(); + + QVariant item = mRightsModel->data( indexElementSelectionne, Qt::DisplayRole ); + QStringList list = mRightsModel->stringList(); + list.removeOne( item.toString() ); + mRightsModel->setStringList( list ); + } +} + void QgsMetadataWidget::setAutoCrs() { selectionCrs->setCrs( mLayer->crs() ); @@ -324,6 +355,9 @@ void QgsMetadataWidget::setPropertiesFromLayer() pCell->setText( licence ); } + // Rights + mRightsModel->setStringList( mMetadata.rights() ); + // CRS if ( mMetadata.crs().isValid() ) { @@ -372,6 +406,9 @@ void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) } layerMetadata.setLicenses( licenses ); + // Rights + layerMetadata.setRights( mRightsModel->stringList() ); + // CRS if ( selectionCrs->crs().isValid() ) { diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index 5cbcba1a079d..6e1a7163bb6d 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -70,6 +70,16 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg */ void removeLicence(); + /** + * Add a new right. + */ + void addRight(); + + /** + * Remove a selected right. + */ + void removeRight(); + /** * Set the CRS field from the layer. */ @@ -160,6 +170,7 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg QStandardItemModel *mLinksModel = nullptr; QStringListModel *mCategoriesModel = nullptr; QStringListModel *mDefaultCategoriesModel = nullptr; + QStringListModel *mRightsModel = nullptr; void syncFromCategoriesTabToKeywordsTab(); }; diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui index c59ea1079ccd..bcb4c0c8f405 100644 --- a/src/ui/qgsmetadatawidget.ui +++ b/src/ui/qgsmetadatawidget.ui @@ -448,11 +448,50 @@
- - - Licenses - - + + + + + Licenses + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + @@ -476,9 +515,29 @@ - + - + + + Rights (attribution or copyright) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + Add class @@ -489,7 +548,7 @@ - + Delete @@ -501,6 +560,9 @@ + + +
From 168de3fabc621f5540207be82aae3620b0f3c508 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 17 Aug 2017 08:58:06 +0200 Subject: [PATCH 25/39] add parent ID --- src/gui/qgsmetadatawidget.cpp | 5 +++++ src/ui/qgsmetadatawidget.ui | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 309e3ea11087..a252e2dd6bff 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -36,6 +36,7 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) // Disable the encoding encodingFrame->setHidden( true ); + tabWidget->removeTab( 5 ); // Default categories mDefaultCategories << tr( "Farming" ) << tr( "Climatology Meteorology Atmosphere" ) << tr( "Location" ) << tr( "Intelligence Military" ) << tr( "Transportation" ) << tr( "Structure" ) << tr( "Boundaries" ); @@ -288,6 +289,9 @@ void QgsMetadataWidget::setPropertiesFromLayer() // Set all properties USING THE NEW API // It will overwrite existing settings + // Parent ID + lineEditParentId->setText( mMetadata.parentIdentifier() ); + // Identifier if ( ! mMetadata.identifier().isEmpty() ) { @@ -380,6 +384,7 @@ void QgsMetadataWidget::setPropertiesFromLayer() void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) { + layerMetadata.setParentIdentifier( lineEditParentId->text() ); layerMetadata.setIdentifier( lineEditIdentifier->text() ); layerMetadata.setTitle( lineEditTitle->text() ); layerMetadata.setType( comboType->currentText() ); diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui index bcb4c0c8f405..99cdcdf3a9cc 100644 --- a/src/ui/qgsmetadatawidget.ui +++ b/src/ui/qgsmetadatawidget.ui @@ -23,7 +23,7 @@ QTabWidget::Rounded - 3 + 0 @@ -40,6 +40,16 @@ + + + + Parent Identifier + + + + + + @@ -580,7 +590,7 @@ - Spatial Extent + Coordinate Reference System @@ -606,13 +616,6 @@ - - - - Temporal Extent - - - From 45bfac11bc6aa782d5ccfcd1c5e53b17caf7ec76 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 17 Aug 2017 10:40:24 +0200 Subject: [PATCH 26/39] add scrollbars for identification and access --- src/ui/qgsmetadatawidget.ui | 636 ++++++++++++++++++++---------------- 1 file changed, 352 insertions(+), 284 deletions(-) diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui index 99cdcdf3a9cc..38e3b515b4f3 100644 --- a/src/ui/qgsmetadatawidget.ui +++ b/src/ui/qgsmetadatawidget.ui @@ -7,7 +7,7 @@ 0 0 797 - 528 + 568 @@ -23,175 +23,209 @@ QTabWidget::Rounded - 0 + 3 Identification + + 0 + + + 0 + + + 0 + + + 0 + - - - This page describes the basic attribution of the dataset. If unsure about which type to select, use 'dataset'. Use the abstract field to provide a verbose description of this dataset. - - - true - - - - - - - Parent Identifier - - - - - - - - - - Identifier - - - - - - - - - - - - Set from layer - - - - - - - - - Title - - - - - - - - 0 - 0 - - - - - - - - Type (it is advised to use the ISO 19115 MD_ScopeCode) - - - - - - - true - - - true - - - - - - - Language (it is advised to follow either the ISO 639.2 or ISO 3166) - - - - - - - true - - - true - - - - - - - Abstract - - - - - - - - 0 - 0 - - - - - - - - false - + QFrame::NoFrame - - QFrame::Raised + + true - - - 0 - - - 0 - - - 0 + + + + 0 + 0 + 752 + 641 + - - 0 - - - - - Encoding - - - - - - - - - - 0 - 0 - + + + + + This page describes the basic attribution of the dataset. If unsure about which type to select, use 'dataset'. Use the abstract field to provide a verbose description of this dataset. + + + true + + + + + + + Parent Identifier + + + + + + + + + + Identifier + + + + + + + + + + + + Set from layer + + + + + + + + + Title + + + + + + + + 0 + 0 + + + + + + + + Type (it is advised to use the ISO 19115 MD_ScopeCode) + + + + + + + true + + + true + + + + + + + Language (it is advised to follow either the ISO 639.2 or ISO 3166) + + + + + + + true + + + true + + + + + + + Abstract + + + + + + + + 0 + 0 + + + + + + + + false + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 - - - - - - Set from layer + + 0 - - - - - + + 0 + + + 0 + + + + + Encoding + + + + + + + + + + 0 + 0 + + + + + + + + Set from layer + + + + + + + + + + @@ -440,139 +474,173 @@ Access + + 0 + + + 0 + + + 0 + + + 0 + - - - Access dialog. HELP TEXT TO ADD - - - - - - - Fees - - - - - - - - - - - - Licenses - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows + + + QFrame::NoFrame - - false - - + true - - - - Label + + + + + 0 + 0 + 767 + 521 + - + + + + + Access dialog. HELP TEXT TO ADD + + + + + + + Fees + + + + + + + + + + + + Licenses + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + true + + + + Label + + + + + + + + + + Rights (attribution or copyright) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Add class + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Delete + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + + + + - - - - - - Rights (attribution or copyright) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Add class - - - - :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg - - - - - - - Delete - - - - :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg - - - - - - - - @@ -736,7 +804,7 @@ 0 0 513 - 379 + 419 From b362e2eb4c32a57c09c20fc4fbc9f73aadfc63ca Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 17 Aug 2017 11:43:19 +0200 Subject: [PATCH 27/39] add tooltips and UI review --- src/gui/qgsmetadatawidget.cpp | 20 --- src/ui/qgsmetadatawidget.ui | 298 ++++++++++++++++++++++------------ 2 files changed, 195 insertions(+), 123 deletions(-) diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index a252e2dd6bff..405ebcbe8742 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -116,8 +116,6 @@ void QgsMetadataWidget::removeVocabulary() { QItemSelectionModel *selectionModel = tabKeywords->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); - QgsDebugMsg( QString( "Remove: %1 " ).arg( selectedRows.count() ) ); - for ( int i = 0 ; i < selectedRows.size() ; i++ ) { tabKeywords->model()->removeRow( selectedRows[i].row() ); @@ -133,11 +131,6 @@ void QgsMetadataWidget::addLicence() tabLicenses->setRowCount( row + 1 ); QTableWidgetItem *pCell = new QTableWidgetItem( newLicence ); tabLicenses->setItem( row, 0, pCell ); - QgsDebugMsg( QString( "Adding" ) ); - } - else - { - QgsDebugMsg( QString( "Cant add" ) ); } } @@ -145,8 +138,6 @@ void QgsMetadataWidget::removeLicence() { QItemSelectionModel *selectionModel = tabLicenses->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); - QgsDebugMsg( QString( "Remove: %1 " ).arg( selectedRows.count() ) ); - for ( int i = 0 ; i < selectedRows.size() ; i++ ) { tabLicenses->model()->removeRow( selectedRows[i].row() ); @@ -205,8 +196,6 @@ void QgsMetadataWidget::removeContact() { QItemSelectionModel *selectionModel = tabContacts->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); - QgsDebugMsg( QString( "Remove: %1 " ).arg( selectedRows.count() ) ); - for ( int i = 0 ; i < selectedRows.size() ; i++ ) { tabContacts->model()->removeRow( selectedRows[i].row() ); @@ -590,15 +579,6 @@ void QgsMetadataWidget::acceptMetadata() validator.validate( mMetadata, validationResults ); hide(); - -// if ( results ) -// { -// QgisApp::instance()->messageBar()->pushInfo( tr( "Save metadata" ), tr( "Saving metadata successfull into the project" ) ); -// } -// else -// { -// QgisApp::instance()->messageBar()->pushWarning( tr( "Save metadata" ), tr( "Saving metadata successfull but some fields were missing" ) ); -// } } void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui index 38e3b515b4f3..36dbb56e7c8b 100644 --- a/src/ui/qgsmetadatawidget.ui +++ b/src/ui/qgsmetadatawidget.ui @@ -23,7 +23,7 @@ QTabWidget::Rounded - 3 + 7 @@ -56,14 +56,14 @@ 0 0 752 - 641 + 625 - This page describes the basic attribution of the dataset. If unsure about which type to select, use 'dataset'. Use the abstract field to provide a verbose description of this dataset. + This page describes the basic attribution of the dataset. Please use the tooltips for more informations. true @@ -72,16 +72,26 @@ + + A reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of. + Parent Identifier - + + + A reference, URI, URL or some other mechanism to identify the parent resource that this resource is a part (child) of. + + + + A reference, URI, URL or some other mechanism to identify the resource. + Identifier @@ -90,7 +100,11 @@ - + + + A reference, URI, URL or some other mechanism to identify the resource. + + @@ -103,6 +117,9 @@ + + Returns the human readable name of the resource, typically displayed in search results. + Title @@ -116,12 +133,18 @@ 0 + + Returns the human readable name of the resource, typically displayed in search results. + + + While a formal vocabulary is not imposed, it is advised to use the ISO 19115 MD_ScopeCode values. E.g. 'dataset' or 'series'. If unsure about which type to select, use 'dataset'. + - Type (it is advised to use the ISO 19115 MD_ScopeCode) + Type @@ -130,6 +153,9 @@ true + + While a formal vocabulary is not imposed, it is advised to use the ISO 19115 MD_ScopeCode values. E.g. 'dataset' or 'series'. If unsure about which type to select, use 'dataset'. + true @@ -137,8 +163,11 @@ + + Usually the returned string will follow either the ISO 639.2 or ISO 3166 specifications, e.g. 'ENG' or 'SPA', however this is not a hard requirement and the caller must account for non compliant values. + - Language (it is advised to follow either the ISO 639.2 or ISO 3166) + Language @@ -147,6 +176,9 @@ true + + Usually the returned string will follow either the ISO 639.2 or ISO 3166 specifications, e.g. 'ENG' or 'SPA', however this is not a hard requirement and the caller must account for non compliant values. + true @@ -154,6 +186,9 @@ + + Free-form description of the resource + Abstract @@ -167,6 +202,9 @@ 0 + + Free-form description of the resource + @@ -238,7 +276,7 @@ - Categories dialog. It a shortcuts for 'gmd:topicCategory' in the keywords tab. + Dataset categories. @@ -274,6 +312,9 @@ + + Categories chosen will be added as a new entry in the keywords tab. + QAbstractItemView::NoEditTriggers @@ -298,6 +339,9 @@ + + Categories chosen will be added as a new entry in the keywords tab. + New @@ -311,6 +355,9 @@ 0 + + Categories chosen will be added as a new entry in the keywords tab. + @@ -334,6 +381,9 @@ 0 + + Categories chosen will be added as a new entry in the keywords tab. + @@ -369,6 +419,9 @@ + + Categories chosen will be added as a new entry in the keywords tab. + QAbstractItemView::NoEditTriggers @@ -389,45 +442,32 @@ - Keywords are optional, and provide a way to provide additional descriptive information about the dataset. For example you can specify the category for this dataset by adding a vocabulary items 'gmd:topicCategory' with a comma separated list of category keywords. + <html><head/><body><p>Keywords are optional, and provide a way to provide additional descriptive information about the dataset. Edits made in the categories tab will update the category entry below. For the concept, we suggest to use a standard based vocabulary such as <a href="https://www.eionet.europa.eu/gemet/en/inspire-themes/"><span style=" text-decoration: underline; color:#0000ff;">GEMET.</span></a></p></body></html> true - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - - Vocabulary - - - - - Keywords - - - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + - Add class + Adds a list of descriptive keywords for a specified vocabulary. @@ -441,7 +481,7 @@ - Delete + Removes a specified vocabulary. @@ -452,21 +492,37 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - + + + + A set of descriptive keywords associated with the resource for a specified concept. + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + + Concept + + + + + Keywords + + + + @@ -507,24 +563,34 @@ - Access dialog. HELP TEXT TO ADD + The fees, licences and rights for this dataset. + + Any fees associated with using the resource + Fees - + + + Any fees associated with using the resource + + + + A list of licenses associated with the resource + Licenses @@ -546,7 +612,7 @@ - Add class + Add license @@ -557,7 +623,7 @@ - Delete + Remove license @@ -569,6 +635,9 @@ + + A list of licenses associated with the resource + QAbstractItemView::SingleSelection @@ -592,6 +661,9 @@ + + List of attribution or copyright strings associated with the resource + Rights (attribution or copyright) @@ -613,7 +685,7 @@ - Add class + Add Right @@ -624,7 +696,7 @@ - Delete + Remove Right @@ -635,7 +707,11 @@ - + + + List of attribution or copyright strings associated with the resource + + @@ -651,12 +727,15 @@ - Extent dialog. HELP TEXT TO ADD + Coordinate Reference System, spatial and temporal extent(s) for this dataset. + + The coordinate reference system described by the layer's metadata + Coordinate Reference System @@ -716,6 +795,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -738,19 +830,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -959,33 +1038,33 @@ + + a list of online resources associated with the resource. + - Links dialog, HELP TEXT TO ADD + Links describe ancilliary resources and information related to this dataset. - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + - Add class + Add link @@ -996,7 +1075,7 @@ - Delete + Remove link @@ -1004,21 +1083,27 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - + + + + a list of online resources associated with the resource. + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + @@ -1026,6 +1111,13 @@ Validation + + + + Validation is not inforced, but it's recommended to resolve any validation issues listed here. + + + From 8b30d7f60a4b27efee26ba91d804cbb53751db4f Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 17 Aug 2017 13:42:37 +0200 Subject: [PATCH 28/39] fix documentation,CSV and SIP --- python/gui/gui_auto.sip | 1 + python/gui/qgsmetadatawidget.sip | 163 ++++++++++++++++++ .../metadata-ISO/LinkPropertyLookupTable.csv | 16 +- resources/metadata-ISO/md_scope_codes.csv | 16 ++ resources/metadata-ISO/mime.csv | 25 +++ src/gui/qgsmetadatawidget.h | 18 ++ src/ui/qgsmetadatawidget.ui | 4 +- 7 files changed, 233 insertions(+), 10 deletions(-) create mode 100644 python/gui/qgsmetadatawidget.sip create mode 100644 resources/metadata-ISO/md_scope_codes.csv create mode 100644 resources/metadata-ISO/mime.csv diff --git a/python/gui/gui_auto.sip b/python/gui/gui_auto.sip index a50c4c9df930..afda32cf5df4 100644 --- a/python/gui/gui_auto.sip +++ b/python/gui/gui_auto.sip @@ -150,6 +150,7 @@ %Include qgsmessagebaritem.sip %Include qgsmessagelogviewer.sip %Include qgsmessageviewer.sip +%Include qgsmetadatawidget.sip %Include qgsnewhttpconnection.sip %Include qgsnewmemorylayerdialog.sip %Include qgsnewnamedialog.sip diff --git a/python/gui/qgsmetadatawidget.sip b/python/gui/qgsmetadatawidget.sip new file mode 100644 index 000000000000..a7d605ec044a --- /dev/null +++ b/python/gui/qgsmetadatawidget.sip @@ -0,0 +1,163 @@ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/gui/qgsmetadatawidget.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + + + +class QgsMetadataWidget : QWidget +{ +%Docstring + A wizard to edit metadata on a map layer. + +.. versionadded:: 3.0 +%End + +%TypeHeaderCode +#include "qgsmetadatawidget.h" +%End + public: + + QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer = 0 ); +%Docstring + Constructor for the wizard. +%End + ~QgsMetadataWidget(); + + void setAutoSource(); +%Docstring + Set the source field from the layer. +%End + + void addVocabulary(); +%Docstring + Add a new vocabulary. +%End + + void removeVocabulary(); +%Docstring + Remove a selected vocabulary. +%End + + void addLicence(); +%Docstring + Add a new licence. +%End + + void removeLicence(); +%Docstring + Remove a selected licence. +%End + + void addRight(); +%Docstring + Add a new right. +%End + + void removeRight(); +%Docstring + Remove a selected right. +%End + + void setAutoCrs(); +%Docstring + Set the CRS field from the layer. +%End + + void addContact(); +%Docstring + Add a new contact. +%End + + void removeContact(); +%Docstring + Remove a selected contact. +%End + + void updateContactDetails(); +%Docstring + Update the contact details according to the selection in the contact list. +%End + + void addLink(); +%Docstring + Add a new link. +%End + + void removeLink(); +%Docstring + Remove a selected link. +%End + + void fillComboBox(); +%Docstring + Function to fill combobox like language, type. +%End + + void setPropertiesFromLayer(); +%Docstring + Fill the wizard from values in the layer metadata object. +%End + + void saveMetadata( QgsLayerMetadata &layerMetadata ); +%Docstring + Save all fields in a QgsLayerMetadata object. +%End + + bool checkMetadata(); +%Docstring + Check if values in the wizard are correct. + :rtype: bool +%End + + static QMap parseLanguages(); +%Docstring + Returns a list of languages available by default in the wizard. + :rtype: QMap +%End + + static QStringList parseLicenses(); +%Docstring + Returns a list of licences available by default in the wizard. + :rtype: list of str +%End + + static QStringList parseLinkTypes(); +%Docstring + Returns a list of link types available by default in the wizard. +.. seealso:: https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv + :rtype: list of str +%End + + static QStringList parseMimeTypes(); +%Docstring + Returns a list of MIME types available by default in the wizard. +.. seealso:: https://fr.wikipedia.org/wiki/Type_MIME + :rtype: list of str +%End + + static QMap parseTypes(); +%Docstring + Returns a list of types available by default in the wizard. + :rtype: QMap +%End + + void acceptMetadata(); +%Docstring + Saves the metadata to the layer. +%End + +}; + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/gui/qgsmetadatawidget.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/resources/metadata-ISO/LinkPropertyLookupTable.csv b/resources/metadata-ISO/LinkPropertyLookupTable.csv index 32c6c8f695d5..bf5aef86f628 100644 --- a/resources/metadata-ISO/LinkPropertyLookupTable.csv +++ b/resources/metadata-ISO/LinkPropertyLookupTable.csv @@ -1,15 +1,15 @@ identifier,uri,label,url,target,owner,resource_type,registrant,comments,deprecated -OGC:CSW,http://www.opengis.net/def/serviceType/ogc/csw,OGC Catalogue Service for the Web,http://www.opengeospatial.org/standards/cat,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Catalog service for the web v2.0.2 endpoint (should use differnt protocol identifier if the endpoint is not v2.0.2; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. , -OGC:SOS,http://www.opengis.net/def/serviceType/ogc/sos,OGC Sensor Observation Service,http://www.opengeospatial.org/standards/sos,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Sensor Observation service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different offerings, the parameters necessary to access the correct offering should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.",urn:x-esri:specification:ServiceType:SOS; urn:x-esri:specification:ServiceType:sos:url +OGC:CSW,http://www.opengis.net/def/serviceType/ogc/csw,OGC Catalog Service for the Web,http://www.opengeospatial.org/standards/cat,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Catalog service for the web v2.0.2 endpoint (should use different protocol identifier if the endpoint is not v2.0.2; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. , +OGC:SOS,http://www.opengis.net/def/serviceType/ogc/sos,OGC Sensor Observation Service,http://www.opengeospatial.org/standards/sos,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Sensor Observation service v?? endpoint (should use different protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different offerings, the parameters necessary to access the correct offering should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.",urn:x-esri:specification:ServiceType:SOS; urn:x-esri:specification:ServiceType:sos:url OGC:SPS,http://www.opengeospatial.org/standards/sps,OGC Sensor Planning Service,http://www.opengeospatial.org/standards/sps,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an Sensor Planning Service , OGC:SAS,http://www.ogcnetwork.net/SAS,OGC Sensor Alert Service,http://www.ogcnetwork.net/SAS,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an Sensor Alert Service, OGC:WNS,http://www.ogcnetwork.net/WNS,OGC Web Notification Service,http://portal.opengeospatial.org/files/?artifact_id=1367,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an Web Notification Service , -OGC:WCS,http://www.opengis.net/def/serviceType/ogc/wcs,OGC Web Coverage Service,http://www.opengeospatial.org/standards/wcs,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web coverage service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different coverages, the parameters necessary to access the correct coverage should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.",urn:x-esri:specification:ServiceType:WCS; urn:x-esri:specification:ServiceType:wcs:url -OGC:WFS,http://www.opengis.net/def/serviceType/ogc/wfs,OGC Web Feature Service,http://www.opengeospatial.org/standards/wfs,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Feature Service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different feature types the typeName parameter necessary to access the correct data should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.,urn:x-esri:specification:ServiceType:WFS; urn:x-esri:specification:ServiceType:wfs:url -OGC:WMS,http://www.opengis.net/def/serviceType/ogc/wms,OGC Web Map Service,http://www.opengeospatial.org/standards/wms,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Map Service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different map layers, the layers parameters necessary to access the correct data should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.",urn:x-esri:specification:ServiceType:WMS; urn:x-esri:specification:ServiceType:wms:url -OGC:WMS-C,http://www.opengis.net/def/serviceType/ogc/wms,OGC Web Map Service - Cached,https://wiki.osgeo.org/wiki/WMS_Tile_Caching,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pacioos,"This is an unofficial profile of WMS using OSGeo recommendations to pull cached map tiles from the server when available. Often this is specified with a 'tiled=true' URL parameter in the GetMap request.", "While WMS-C has been superceded by the OSGeo Tile Map Service specification (TMS) and the OGC Web Map Tile Service standard (WMTS), it is still widely supported." +OGC:WCS,http://www.opengis.net/def/serviceType/ogc/wcs,OGC Web Coverage Service,http://www.opengeospatial.org/standards/wcs,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web coverage service v?? endpoint (should use different protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different coverages, the parameters necessary to access the correct coverage should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.",urn:x-esri:specification:ServiceType:WCS; urn:x-esri:specification:ServiceType:wcs:url +OGC:WFS,http://www.opengis.net/def/serviceType/ogc/wfs,OGC Web Feature Service,http://www.opengeospatial.org/standards/wfs,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Feature Service v?? endpoint (should use different protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different feature types the typeName parameter necessary to access the correct data should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.,urn:x-esri:specification:ServiceType:WFS; urn:x-esri:specification:ServiceType:wfs:url +OGC:WMS,http://www.opengis.net/def/serviceType/ogc/wms,OGC Web Map Service,http://www.opengeospatial.org/standards/wms,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,"gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Map Service v?? endpoint (should use different protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Note that if the service offers multiple datasets in different map layers, the layers parameters necessary to access the correct data should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters.",urn:x-esri:specification:ServiceType:WMS; urn:x-esri:specification:ServiceType:wms:url +OGC:WMS-C,http://www.opengis.net/def/serviceType/ogc/wms,OGC Web Map Service - Cached,https://wiki.osgeo.org/wiki/WMS_Tile_Caching,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pacioos,"This is an unofficial profile of WMS using OSGeo recommendations to pull cached map tiles from the server when available. Often this is specified with a 'tiled=true' URL parameter in the GetMap request.", "While WMS-C has been superseded by the OSGeo Tile Map Service specification (TMS) and the OGC Web Map Tile Service standard (WMTS), it is still widely supported." OGC:WMTS,http://www.opengeospatial.org/standards/wmts,OGC Web Map Tile Service,http://www.opengeospatial.org/standards/wmts,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Map Tile Service, -OGC:WPS,http://www.opengis.net/def/serviceType/ogc/wps,OGC Web Processing Service,http://www.opengeospatial.org/standards/wps,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Processing Service v?? endpoint (should use differnt protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Other parameters necessary to access the correct processing service should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters., +OGC:WPS,http://www.opengis.net/def/serviceType/ogc/wps,OGC Web Processing Service,http://www.opengeospatial.org/standards/wps,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@tomkralidis,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC Web Processing Service v?? endpoint (should use different protocol identifier if the endpoint is not that version; these are not yet defined here). The gmd:function value in the CI_Online resource should be 'information' if the provided URL is a getCapabilities request. Other parameters necessary to access the correct processing service should be specified in the gmd:CI_OnlineResource/gmd:description element; recommended practice is to use a JSON object with keys that are parameter names and values that are the necessary parameters., OGC:ODS,http://www.opengeospatial.org/standards/ols#ods,OGC OpenLS Directory Service,http://www.opengeospatial.org/standards/ols,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC OpenLS Directory Service , OGC:OGS,http://www.opengeospatial.org/standards/ols#ogs,OGC OpenLS Gateway Service,http://www.opengeospatial.org/standards/ols,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC OpenLS Gateway Service, OGC:OUS,http://www.opengeospatial.org/standards/ols#ous,OGC OpenLS Utility Service,http://www.opengeospatial.org/standards/ols,srv:serviceType;gmd:protocol;usgin:overlayAPI,,service,@pvgenuchten,gmd:protocol value that indicates CI_OnlineResource URL is for an OGC OpenLS Utility Service, @@ -29,7 +29,7 @@ UNIDATA:NCSS,,NetCDF Subset Service,https://www.unidata.ucar.edu/software/thredd UNIDATA:CDM,,Common Data Model Remote Web Service,https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/stream/CdmRemote.html,srv:serviceType;gmd:protocol;usgin:overlayAPI,Unidata,service,@tomkralidis,Example, UNIDATA:CdmRemote,,Common Data Model index subsetting,https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/stream/CdmRemote.html,gmd:protocol; usgin:overlayAPI,Unidata,service,@smrazgs,"CDM Remote provides remote access to UNIDATA Common Data Model (CDM) datasets, using ncstream as the on-the-wire protocol. Client requests are of the form endpoint?query, and the specification defines a vocabulary of valid query parameters. There are two levels of service: 1) CdmRemote provides index subsetting on remote CDM datasets; 2) CdmrFeature provides coordinate subsetting on remote CDM Feature Datasets", UNIDATA:CdmrFeature,,Common Data Model coordinate subsetting,https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/stream/CdmRemote.html,gmd:protocol; usgin:overlayAPI,Unidata,,@smrazgs,"Link is endpoint URL that provides coordinate subsetting on UNIDATA Common Data Model (CDM) datasets, using ncstream as the on-the-wire protocol. Client requests are of the form endpoint?query, and the specification defines a vocabulary of valid query parameters.", -UNIDATA:THREDDS,http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0,THREDDS Catalog,http://www.unidata.ucar.edu/software/thredds/current/tds/catalog/InvCatalogSpec.html,srv:serviceType;gmd:protocol;usgin:overlayAPI,Unidata,service,@kwilcox,"Link is a THREDDS Catalog URL that provides the XML for traversing programatically. Can be used for datasets and collections of datasets.", +UNIDATA:THREDDS,http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0,THREDDS Catalog,http://www.unidata.ucar.edu/software/thredds/current/tds/catalog/InvCatalogSpec.html,srv:serviceType;gmd:protocol;usgin:overlayAPI,Unidata,service,@kwilcox,"Link is a THREDDS Catalog URL that provides the XML for traversing programmatically. Can be used for datasets and collections of datasets.", OGC:GML,http://www.opengis.net/gml,OGC Geography Markup Language,,gmd:MD_Format/gmd:name;gmd:applicationProfile,,data,@tomkralidis,Example, WWW:LINK,http://www.w3.org/TR/xlink/,Web Address (URL),,dct:references/@scheme,,information,@tomkralidis @smrazgs,Indicates that XLINK properties are encoded as key-value pairs in content of a dct:references element to provide a machine actionable link. , WWW:WSDL,http://www.w3.org/TR/wsdl,Web Service Description Language XML document describing service operation,http://www.w3.org/TR/wsdl,gmd:applicationProfile,W3C,,@smrazgs,, diff --git a/resources/metadata-ISO/md_scope_codes.csv b/resources/metadata-ISO/md_scope_codes.csv new file mode 100644 index 000000000000..5de29aad70d0 --- /dev/null +++ b/resources/metadata-ISO/md_scope_codes.csv @@ -0,0 +1,16 @@ +attribute;information applies to the attribute class +attributeType;information applies to the characteristic of a feature +collectionHardware;information applies to the collection hardware class +collectionSession;information applies to the collection session +dataset;information applies to the dataset +series;information applies to the series +nonGeographicDataset;information applies to non-geographic data +dimensionGroup;information applies to a dimension group +feature;information applies to a feature +featureType;information applies to a feature type +propertyType;information applies to a property type +fieldSession;information applies to a field session +software;information applies to a computer program or routine +service;information applies to a capability which a service provider entity makes available to a service user entity through a set of interfaces that define a behavior, such as a use case +model;information applies to a copy or imitation of an existing or hypothetical object +tile;information applies to a tile, a spatial subset of geographic data diff --git a/resources/metadata-ISO/mime.csv b/resources/metadata-ISO/mime.csv new file mode 100644 index 000000000000..d31a828dcc8c --- /dev/null +++ b/resources/metadata-ISO/mime.csv @@ -0,0 +1,25 @@ +application/octet-stream +application/pdf +application/xhtml+xml +application/json +application/xml +application/zip +image/gif +image/jpeg +image/png +image/tiff +image/svg+xml +text/csv +text/html +text/plain +text/xml +application/vnd.oasis.opendocument.text +application/vnd.oasis.opendocument.spreadsheet +application/vnd.oasis.opendocument.presentation +application/vnd.oasis.opendocument.graphics +application/vnd.ms-excel +application/vnd.openxmlformats-officedocument.spreadsheetml.sheet +application/vnd.ms-powerpoint +application/vnd.openxmlformats-officedocument.presentationml.presentation +application/msword +application/vnd.openxmlformats-officedocument.wordprocessingml.document diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index 6e1a7163bb6d..f398e46bbf1f 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -157,6 +157,9 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg */ static QMap parseTypes(); + /** + * Saves the metadata to the layer. + */ void acceptMetadata(); private: @@ -174,13 +177,28 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg void syncFromCategoriesTabToKeywordsTab(); }; +#ifndef SIP_RUN + +/** + * \ingroup gui + * \class LinkItemDelegate + * \brief Special delegate for the link view in the metadata wizard. + * + * \since QGIS 3.0 + */ + class LinkItemDelegate : public QStyledItemDelegate { Q_OBJECT public: + + /** + * Create a special editor with a QCombobox in the link view. + */ QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const; }; #endif +#endif diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui index 36dbb56e7c8b..7ea0658d4e97 100644 --- a/src/ui/qgsmetadatawidget.ui +++ b/src/ui/qgsmetadatawidget.ui @@ -63,7 +63,7 @@ - This page describes the basic attribution of the dataset. Please use the tooltips for more informations. + This page describes the basic attribution of the dataset. Please use the tooltips for more information. true @@ -1042,7 +1042,7 @@ a list of online resources associated with the resource. - Links describe ancilliary resources and information related to this dataset. + Links describe ancillary resources and information related to this dataset. From 4460fc23ee8597d32a9f57777b62bbdcee02bd8b Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 7 Sep 2017 13:15:21 +0200 Subject: [PATCH 29/39] fix conflicts on the UI file --- src/ui/qgsvectorlayerpropertiesbase.ui | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/ui/qgsvectorlayerpropertiesbase.ui b/src/ui/qgsvectorlayerpropertiesbase.ui index 782a779fa8f4..23f93548328a 100755 --- a/src/ui/qgsvectorlayerpropertiesbase.ui +++ b/src/ui/qgsvectorlayerpropertiesbase.ui @@ -99,6 +99,15 @@ :/images/themes/default/propertyicons/metadata.svg:/images/themes/default/propertyicons/metadata.svg + + + MetadataNG + + + + :/images/themes/default/propertyicons/editmetadata.svg:/images/themes/default/propertyicons/editmetadata.svg + + Source @@ -316,6 +325,20 @@ + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + From e4f70bd7078b80144ead6ef7c7b2288b151ae31b Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 7 Sep 2017 14:02:42 +0200 Subject: [PATCH 30/39] add const in for loop --- src/gui/qgsmetadatawidget.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 405ebcbe8742..2a92ef93cce2 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -248,7 +248,7 @@ void QgsMetadataWidget::fillComboBox() comboType->clear(); QMap types = parseTypes(); int i = 0; - for ( QString type : types.keys() ) + for ( const QString type : types.keys() ) { comboType->insertItem( i, type ); comboType->setItemData( i, types.value( type ), Qt::ToolTipRole ); @@ -261,7 +261,7 @@ void QgsMetadataWidget::fillComboBox() comboLanguage->clear(); QMap countries = parseLanguages(); i = 0; - for ( QString countryCode : countries.keys() ) + for ( const QString countryCode : countries.keys() ) { comboLanguage->insertItem( i, countryCode ); comboLanguage->setItemData( i, countries.value( countryCode ), Qt::ToolTipRole ); @@ -335,7 +335,7 @@ void QgsMetadataWidget::setPropertiesFromLayer() // Licenses tabLicenses->setRowCount( 0 ); - for ( QString licence : mMetadata.licenses() ) + for ( const QString licence : mMetadata.licenses() ) { int currentRow = tabLicenses->rowCount(); tabLicenses->setRowCount( currentRow + 1 ); @@ -358,7 +358,7 @@ void QgsMetadataWidget::setPropertiesFromLayer() } // Links - for ( QgsLayerMetadata::Link link : mMetadata.links() ) + for ( const QgsLayerMetadata::Link link : mMetadata.links() ) { int row = mLinksModel->rowCount(); mLinksModel->setItem( row, 0, new QStandardItem( link.name ) ); @@ -438,7 +438,7 @@ bool QgsMetadataWidget::checkMetadata() if ( results == false ) { errors = QStringLiteral(); - for ( QgsMetadataValidator::ValidationResult result : validationResults ) + for ( const QgsMetadataValidator::ValidationResult result : validationResults ) { errors += QLatin1String( "" ) % result.section; if ( ! result.identifier.isNull() ) From 99cebd95abfa437f8a672bb47e80b4087f19c73e Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 13 Sep 2017 18:20:34 +0200 Subject: [PATCH 31/39] cleaning the code about the metadata editor --- python/gui/qgsmetadatawidget.sip | 30 ++++++------ src/gui/qgsmetadatawidget.cpp | 78 ++++++++++++++------------------ src/gui/qgsmetadatawidget.h | 38 ++++++++-------- 3 files changed, 67 insertions(+), 79 deletions(-) diff --git a/python/gui/qgsmetadatawidget.sip b/python/gui/qgsmetadatawidget.sip index a7d605ec044a..2e6aa6342f83 100644 --- a/python/gui/qgsmetadatawidget.sip +++ b/python/gui/qgsmetadatawidget.sip @@ -29,17 +29,17 @@ class QgsMetadataWidget : QWidget %End ~QgsMetadataWidget(); - void setAutoSource(); + void setAutoSource() const; %Docstring Set the source field from the layer. %End - void addVocabulary(); + void addVocabulary() const; %Docstring Add a new vocabulary. %End - void removeVocabulary(); + void removeVocabulary() const; %Docstring Remove a selected vocabulary. %End @@ -49,7 +49,7 @@ class QgsMetadataWidget : QWidget Add a new licence. %End - void removeLicence(); + void removeLicence() const; %Docstring Remove a selected licence. %End @@ -59,57 +59,57 @@ class QgsMetadataWidget : QWidget Add a new right. %End - void removeRight(); + void removeRight() const; %Docstring Remove a selected right. %End - void setAutoCrs(); + void setAutoCrs() const; %Docstring Set the CRS field from the layer. %End - void addContact(); + void addContact() const; %Docstring Add a new contact. %End - void removeContact(); + void removeContact() const; %Docstring Remove a selected contact. %End - void updateContactDetails(); + void updateContactDetails() const; %Docstring Update the contact details according to the selection in the contact list. %End - void addLink(); + void addLink() const; %Docstring Add a new link. %End - void removeLink(); + void removeLink() const; %Docstring Remove a selected link. %End - void fillComboBox(); + void fillComboBox() const; %Docstring Function to fill combobox like language, type. %End - void setPropertiesFromLayer(); + void setPropertiesFromLayer() const; %Docstring Fill the wizard from values in the layer metadata object. %End - void saveMetadata( QgsLayerMetadata &layerMetadata ); + void saveMetadata( QgsLayerMetadata &layerMetadata ) const; %Docstring Save all fields in a QgsLayerMetadata object. %End - bool checkMetadata(); + bool checkMetadata() const; %Docstring Check if values in the wizard are correct. :rtype: bool diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 2a92ef93cce2..1e6f85370aec 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -92,19 +92,19 @@ QgsMetadataWidget::~QgsMetadataWidget() { } -void QgsMetadataWidget::setAutoSource() +void QgsMetadataWidget::setAutoSource() const { lineEditIdentifier->setText( mLayer->publicSource() ); } -void QgsMetadataWidget::addVocabulary() +void QgsMetadataWidget::addVocabulary() const { int row = tabKeywords->rowCount(); tabKeywords->setRowCount( row + 1 ); - QTableWidgetItem *pCell; + QTableWidgetItem *pCell = nullptr; // Vocabulary - pCell = new QTableWidgetItem( QString( "undefined %1" ).arg( row + 1 ) ); + pCell = new QTableWidgetItem( QString( tr( "undefined %1" ) ).arg( row + 1 ) ); tabKeywords->setItem( row, 0, pCell ); // Keywords @@ -112,7 +112,7 @@ void QgsMetadataWidget::addVocabulary() tabKeywords->setItem( row, 1, pCell ); } -void QgsMetadataWidget::removeVocabulary() +void QgsMetadataWidget::removeVocabulary() const { QItemSelectionModel *selectionModel = tabKeywords->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); @@ -134,7 +134,7 @@ void QgsMetadataWidget::addLicence() } } -void QgsMetadataWidget::removeLicence() +void QgsMetadataWidget::removeLicence() const { QItemSelectionModel *selectionModel = tabLicenses->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); @@ -155,7 +155,7 @@ void QgsMetadataWidget::addRight() } } -void QgsMetadataWidget::removeRight() +void QgsMetadataWidget::removeRight() const { QItemSelectionModel *selection = listRights->selectionModel(); if ( selection->hasSelection() ) @@ -169,19 +169,19 @@ void QgsMetadataWidget::removeRight() } } -void QgsMetadataWidget::setAutoCrs() +void QgsMetadataWidget::setAutoCrs() const { selectionCrs->setCrs( mLayer->crs() ); } -void QgsMetadataWidget::addContact() +void QgsMetadataWidget::addContact() const { int row = tabContacts->rowCount(); tabContacts->setRowCount( row + 1 ); QTableWidgetItem *pCell; // Name - pCell = new QTableWidgetItem( QString( "unnamed %1" ).arg( row + 1 ) ); + pCell = new QTableWidgetItem( QString( tr( "unnamed %1" ) ).arg( row + 1 ) ); tabContacts->setItem( row, 0, pCell ); // Organization @@ -192,7 +192,7 @@ void QgsMetadataWidget::addContact() tabContacts->selectRow( row ); } -void QgsMetadataWidget::removeContact() +void QgsMetadataWidget::removeContact() const { QItemSelectionModel *selectionModel = tabContacts->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); @@ -202,7 +202,7 @@ void QgsMetadataWidget::removeContact() } } -void QgsMetadataWidget::updateContactDetails() +void QgsMetadataWidget::updateContactDetails() const { QItemSelectionModel *selectionModel = tabContacts->selectionModel(); QModelIndexList selectedRows = selectionModel->selectedRows(); @@ -221,10 +221,10 @@ void QgsMetadataWidget::updateContactDetails() } } -void QgsMetadataWidget::addLink() +void QgsMetadataWidget::addLink() const { int row = mLinksModel->rowCount(); - mLinksModel->setItem( row, 0, new QStandardItem( QString( "undefined %1" ).arg( row + 1 ) ) ); + mLinksModel->setItem( row, 0, new QStandardItem( QString( tr( "undefined %1" ) ).arg( row + 1 ) ) ); mLinksModel->setItem( row, 1, new QStandardItem() ); mLinksModel->setItem( row, 2, new QStandardItem() ); mLinksModel->setItem( row, 3, new QStandardItem() ); @@ -233,13 +233,13 @@ void QgsMetadataWidget::addLink() mLinksModel->setItem( row, 6, new QStandardItem() ); } -void QgsMetadataWidget::removeLink() +void QgsMetadataWidget::removeLink() const { QModelIndexList selectedRows = tabLinks->selectionModel()->selectedRows(); mLinksModel->removeRow( selectedRows[0].row() ); } -void QgsMetadataWidget::fillComboBox() +void QgsMetadataWidget::fillComboBox() const { // Set default values in type combobox // It is advised to use the ISO 19115 MD_ScopeCode values. E.g. 'dataset' or 'series'. @@ -247,8 +247,9 @@ void QgsMetadataWidget::fillComboBox() comboType->setEditable( true ); comboType->clear(); QMap types = parseTypes(); + const QStringList &keys = types.keys(); int i = 0; - for ( const QString type : types.keys() ) + for ( const QString &type : keys ) { comboType->insertItem( i, type ); comboType->setItemData( i, types.value( type ), Qt::ToolTipRole ); @@ -260,8 +261,9 @@ void QgsMetadataWidget::fillComboBox() comboLanguage->setEditable( true ); comboLanguage->clear(); QMap countries = parseLanguages(); + const QStringList &k = types.keys(); i = 0; - for ( const QString countryCode : countries.keys() ) + for ( const QString &countryCode : k ) { comboLanguage->insertItem( i, countryCode ); comboLanguage->setItemData( i, countries.value( countryCode ), Qt::ToolTipRole ); @@ -269,15 +271,8 @@ void QgsMetadataWidget::fillComboBox() } } -void QgsMetadataWidget::setPropertiesFromLayer() +void QgsMetadataWidget::setPropertiesFromLayer() const { - // Set all properties USING THE OLD API - lineEditTitle->setText( mLayer->name() ); - textEditAbstract->setPlainText( mLayer->abstract() ); - - // Set all properties USING THE NEW API - // It will overwrite existing settings - // Parent ID lineEditParentId->setText( mMetadata.parentIdentifier() ); @@ -313,6 +308,7 @@ void QgsMetadataWidget::setPropertiesFromLayer() comboLanguage->setCurrentIndex( comboLanguage->findText( mMetadata.language() ) ); } + // Abstract textEditAbstract->setPlainText( mMetadata.abstract() ); // Categories @@ -335,7 +331,8 @@ void QgsMetadataWidget::setPropertiesFromLayer() // Licenses tabLicenses->setRowCount( 0 ); - for ( const QString licence : mMetadata.licenses() ) + const QStringList &licenses = mMetadata.licenses(); + for ( const QString &licence : licenses ) { int currentRow = tabLicenses->rowCount(); tabLicenses->setRowCount( currentRow + 1 ); @@ -358,7 +355,8 @@ void QgsMetadataWidget::setPropertiesFromLayer() } // Links - for ( const QgsLayerMetadata::Link link : mMetadata.links() ) + const QList &links = mMetadata.links(); + for ( const QgsLayerMetadata::Link &link : links ) { int row = mLinksModel->rowCount(); mLinksModel->setItem( row, 0, new QStandardItem( link.name ) ); @@ -371,7 +369,7 @@ void QgsMetadataWidget::setPropertiesFromLayer() } } -void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) +void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) const { layerMetadata.setParentIdentifier( lineEditParentId->text() ); layerMetadata.setIdentifier( lineEditIdentifier->text() ); @@ -426,7 +424,7 @@ void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) layerMetadata.setLinks( links ); } -bool QgsMetadataWidget::checkMetadata() +bool QgsMetadataWidget::checkMetadata() const { QgsLayerMetadata metadata = QgsLayerMetadata(); saveMetadata( metadata ); @@ -438,7 +436,7 @@ bool QgsMetadataWidget::checkMetadata() if ( results == false ) { errors = QStringLiteral(); - for ( const QgsMetadataValidator::ValidationResult result : validationResults ) + for ( const QgsMetadataValidator::ValidationResult &result : validationResults ) { errors += QLatin1String( "" ) % result.section; if ( ! result.identifier.isNull() ) @@ -564,24 +562,14 @@ QMap QgsMetadataWidget::parseTypes() void QgsMetadataWidget::acceptMetadata() { - // OLD API (to remove later) - mLayer->setName( lineEditTitle->text() ); - mLayer->setAbstract( textEditAbstract->toPlainText() ); - - // New Metadata API saveMetadata( mMetadata ); // Save layer metadata properties mLayer->setMetadata( mMetadata ); - - QgsNativeMetadataValidator validator; - QList validationResults; - validator.validate( mMetadata, validationResults ); - hide(); } -void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() +void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() const { if ( mCategoriesModel->rowCount() > 0 ) { @@ -602,7 +590,7 @@ void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() } } -void QgsMetadataWidget::updatePanel() +void QgsMetadataWidget::updatePanel() const { int index = tabWidget->currentIndex(); QString currentTabText = tabWidget->widget( index )->objectName(); @@ -651,7 +639,7 @@ void QgsMetadataWidget::addNewCategory() } } -void QgsMetadataWidget::addDefaultCategory() +void QgsMetadataWidget::addDefaultCategory() const { QItemSelectionModel *selection = listDefaultCategories->selectionModel(); if ( selection->hasSelection() ) @@ -671,7 +659,7 @@ void QgsMetadataWidget::addDefaultCategory() } -void QgsMetadataWidget::removeCategory() +void QgsMetadataWidget::removeCategory() const { QItemSelectionModel *selection = listCategories->selectionModel(); if ( selection->hasSelection() ) diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index f398e46bbf1f..b8f94cb09ab0 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -48,17 +48,17 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg /** * Set the source field from the layer. */ - void setAutoSource(); + void setAutoSource() const; /** * Add a new vocabulary. */ - void addVocabulary(); + void addVocabulary() const; /** * Remove a selected vocabulary. */ - void removeVocabulary(); + void removeVocabulary() const; /** * Add a new licence. @@ -68,7 +68,7 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg /** * Remove a selected licence. */ - void removeLicence(); + void removeLicence() const; /** * Add a new right. @@ -78,57 +78,57 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg /** * Remove a selected right. */ - void removeRight(); + void removeRight() const; /** * Set the CRS field from the layer. */ - void setAutoCrs(); + void setAutoCrs() const; /** * Add a new contact. */ - void addContact(); + void addContact() const; /** * Remove a selected contact. */ - void removeContact(); + void removeContact() const; /** * Update the contact details according to the selection in the contact list. */ - void updateContactDetails(); + void updateContactDetails() const; /** * Add a new link. */ - void addLink(); + void addLink() const; /** * Remove a selected link. */ - void removeLink(); + void removeLink() const; /** * Function to fill combobox like language, type. */ - void fillComboBox(); + void fillComboBox() const; /** * Fill the wizard from values in the layer metadata object. */ - void setPropertiesFromLayer(); + void setPropertiesFromLayer() const; /** * Save all fields in a QgsLayerMetadata object. */ - void saveMetadata( QgsLayerMetadata &layerMetadata ); + void saveMetadata( QgsLayerMetadata &layerMetadata ) const; /** * Check if values in the wizard are correct. */ - bool checkMetadata(); + bool checkMetadata() const; /** * Returns a list of languages available by default in the wizard. @@ -163,10 +163,10 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg void acceptMetadata(); private: - void updatePanel(); - void addDefaultCategory(); + void updatePanel() const; + void addDefaultCategory() const; void addNewCategory(); - void removeCategory(); + void removeCategory() const; QStringList mDefaultCategories; QgsMapLayer *mLayer = nullptr; QgsLayerMetadata mMetadata; @@ -174,7 +174,7 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg QStringListModel *mCategoriesModel = nullptr; QStringListModel *mDefaultCategoriesModel = nullptr; QStringListModel *mRightsModel = nullptr; - void syncFromCategoriesTabToKeywordsTab(); + void syncFromCategoriesTabToKeywordsTab() const; }; #ifndef SIP_RUN From 5eb85f1c65a3f0b2d7a86288c3e4a320ff8c4cc5 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 14 Sep 2017 11:19:52 +0200 Subject: [PATCH 32/39] add constraints in metadata editor --- python/gui/qgsmetadatawidget.sip | 10 +++++ src/gui/qgsmetadatawidget.cpp | 69 ++++++++++++++++++++++++++++++-- src/gui/qgsmetadatawidget.h | 32 ++++++++++++++- src/ui/qgsmetadatawidget.ui | 65 ++++++++++++++++++++++++++++-- 4 files changed, 168 insertions(+), 8 deletions(-) diff --git a/python/gui/qgsmetadatawidget.sip b/python/gui/qgsmetadatawidget.sip index 2e6aa6342f83..356fa8dd1cc2 100644 --- a/python/gui/qgsmetadatawidget.sip +++ b/python/gui/qgsmetadatawidget.sip @@ -64,6 +64,16 @@ class QgsMetadataWidget : QWidget Remove a selected right. %End + void addConstraint() const; +%Docstring + Add a new constraint. +%End + + void removeConstraint() const; +%Docstring + Remove a constraint. +%End + void setAutoCrs() const; %Docstring Set the CRS field from the layer. diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 1e6f85370aec..b259231ddb7d 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -33,8 +33,9 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) { setupUi( this ); mMetadata = layer->metadata(); + tabWidget->setCurrentIndex( 0 ); - // Disable the encoding + // Disable the encoding and contacts encodingFrame->setHidden( true ); tabWidget->removeTab( 5 ); @@ -47,14 +48,21 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) listDefaultCategories->setModel( mDefaultCategoriesModel ); // Categories - mCategoriesModel = new QStringListModel(); + mCategoriesModel = new QStringListModel( ); listCategories->setModel( mCategoriesModel ); // Rights - mRightsModel = new QStringListModel(); + mRightsModel = new QStringListModel( ); listRights->setModel( mRightsModel ); - tabWidget->setCurrentIndex( 0 ); + // Setup the constraints view + mConstraintsModel = new QStandardItemModel(); + mConstraintsModel->setColumnCount( 2 ); + QStringList constraintheaders; + constraintheaders << tr( "Type" ) << tr( "Constraint" ); + mConstraintsModel->setHorizontalHeaderLabels( constraintheaders ); + tabConstraints->setModel( mConstraintsModel ); + tabConstraints->setItemDelegate( new ConstraintItemDelegate() ); // Setup the link view mLinksModel = new QStandardItemModel(); @@ -73,6 +81,8 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) connect( btnRemoveRight, &QPushButton::clicked, this, &QgsMetadataWidget::removeRight ); connect( btnAddLicence, &QPushButton::clicked, this, &QgsMetadataWidget::addLicence ); connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWidget::removeLicence ); + connect( btnAddConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::addConstraint ); + connect( btnRemoveConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::removeConstraint ); connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWidget::setAutoCrs ); connect( btnAddContact, &QPushButton::clicked, this, &QgsMetadataWidget::addContact ); connect( btnRemoveContact, &QPushButton::clicked, this, &QgsMetadataWidget::removeContact ); @@ -169,6 +179,19 @@ void QgsMetadataWidget::removeRight() const } } +void QgsMetadataWidget::addConstraint() const +{ + int row = mConstraintsModel->rowCount(); + 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 ) ) ); +} + +void QgsMetadataWidget::removeConstraint() const +{ + QModelIndexList selectedRows = tabConstraints->selectionModel()->selectedRows(); + mConstraintsModel->removeRow( selectedRows[0].row() ); +} + void QgsMetadataWidget::setAutoCrs() const { selectionCrs->setCrs( mLayer->crs() ); @@ -348,6 +371,15 @@ void QgsMetadataWidget::setPropertiesFromLayer() const // Rights mRightsModel->setStringList( mMetadata.rights() ); + // Constraints + const QList &constraints = mMetadata.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 if ( mMetadata.crs().isValid() ) { @@ -401,6 +433,17 @@ void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) const // Rights layerMetadata.setRights( mRightsModel->stringList() ); + // Constraints + QList constraints; + for ( int row = 0 ; row < mConstraintsModel->rowCount() ; row++ ) + { + struct QgsLayerMetadata::Constraint constraint = QgsLayerMetadata::Constraint(); + constraint.type = mConstraintsModel->item( row, 0 )->text(); + constraint.constraint = mConstraintsModel->item( row, 1 )->text(); + constraints.append( constraint ); + } + layerMetadata.setConstraints( constraints ); + // CRS if ( selectionCrs->crs().isValid() ) { @@ -706,3 +749,21 @@ QWidget *LinkItemDelegate::createEditor( QWidget *parent, const QStyleOptionView return QStyledItemDelegate::createEditor( parent, option, index ); } + +QWidget *ConstraintItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const +{ + if ( index.column() == 0 ) + { + // Constraint type + QComboBox *typeEditor = new QComboBox( parent ); + typeEditor->setEditable( true ); + QStringList types; + types << QString( "access" ) << QString( "use" ) << QString( "other" ); + QStringListModel *model = new QStringListModel( parent ); + model->setStringList( types ); + typeEditor->setModel( model ); + return typeEditor; + } + + return QStyledItemDelegate::createEditor( parent, option, index ); +} diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index b8f94cb09ab0..56ca42995c42 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -80,6 +80,16 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg */ void removeRight() const; + /** + * Add a new constraint. + */ + void addConstraint() const; + + /** + * Remove a constraint. + */ + void removeConstraint() const; + /** * Set the CRS field from the layer. */ @@ -170,6 +180,7 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg QStringList mDefaultCategories; QgsMapLayer *mLayer = nullptr; QgsLayerMetadata mMetadata; + QStandardItemModel *mConstraintsModel = nullptr; QStandardItemModel *mLinksModel = nullptr; QStringListModel *mCategoriesModel = nullptr; QStringListModel *mDefaultCategoriesModel = nullptr; @@ -186,7 +197,6 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg * * \since QGIS 3.0 */ - class LinkItemDelegate : public QStyledItemDelegate { @@ -200,5 +210,25 @@ class LinkItemDelegate : public QStyledItemDelegate QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const; }; +/** + * \ingroup gui + * \class ConstraintItemDelegate + * \brief Special delegate for the constraint view in the metadata wizard. + * + * \since QGIS 3.0 + */ +class ConstraintItemDelegate : public QStyledItemDelegate +{ + + Q_OBJECT + + public: + + /** + * Create a special editor with a QCombobox in the constraint view. + */ + QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const; +}; + #endif #endif diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui index 7ea0658d4e97..6503a1cd6dac 100644 --- a/src/ui/qgsmetadatawidget.ui +++ b/src/ui/qgsmetadatawidget.ui @@ -23,7 +23,7 @@ QTabWidget::Rounded - 7 + 3 @@ -54,7 +54,7 @@ 0 - 0 + -104 752 625 @@ -241,7 +241,7 @@ - + 0 @@ -713,6 +713,65 @@ + + + + + + Constraints + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Add Right + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + + + + + Remove Right + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + From faa142187d32323cff1936c4871c9e373c15d151 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 14 Sep 2017 11:33:54 +0200 Subject: [PATCH 33/39] rename false setters --- python/gui/qgsmetadatawidget.sip | 8 ++++---- src/gui/qgsmetadatawidget.cpp | 8 ++++---- src/gui/qgsmetadatawidget.h | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/python/gui/qgsmetadatawidget.sip b/python/gui/qgsmetadatawidget.sip index 356fa8dd1cc2..106501e9e311 100644 --- a/python/gui/qgsmetadatawidget.sip +++ b/python/gui/qgsmetadatawidget.sip @@ -29,9 +29,9 @@ class QgsMetadataWidget : QWidget %End ~QgsMetadataWidget(); - void setAutoSource() const; + void fillSourceFromLayer() const; %Docstring - Set the source field from the layer. + Fill the source field from the layer. %End void addVocabulary() const; @@ -74,9 +74,9 @@ class QgsMetadataWidget : QWidget Remove a constraint. %End - void setAutoCrs() const; + void fillCrsFromLayer() const; %Docstring - Set the CRS field from the layer. + Fill the CRS field from the layer. %End void addContact() const; diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index b259231ddb7d..fb90b0e13dd2 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -74,7 +74,7 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) tabLinks->setItemDelegate( new LinkItemDelegate() ); connect( tabWidget, &QTabWidget::currentChanged, this, &QgsMetadataWidget::updatePanel ); - connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWidget::setAutoSource ); + connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWidget::fillSourceFromLayer ); connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::addVocabulary ); connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::removeVocabulary ); connect( btnAddRight, &QPushButton::clicked, this, &QgsMetadataWidget::addRight ); @@ -83,7 +83,7 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWidget::removeLicence ); connect( btnAddConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::addConstraint ); connect( btnRemoveConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::removeConstraint ); - connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWidget::setAutoCrs ); + connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWidget::fillCrsFromLayer ); connect( btnAddContact, &QPushButton::clicked, this, &QgsMetadataWidget::addContact ); connect( btnRemoveContact, &QPushButton::clicked, this, &QgsMetadataWidget::removeContact ); connect( tabContacts, &QTableWidget::itemSelectionChanged, this, &QgsMetadataWidget::updateContactDetails ); @@ -102,7 +102,7 @@ QgsMetadataWidget::~QgsMetadataWidget() { } -void QgsMetadataWidget::setAutoSource() const +void QgsMetadataWidget::fillSourceFromLayer() const { lineEditIdentifier->setText( mLayer->publicSource() ); } @@ -192,7 +192,7 @@ void QgsMetadataWidget::removeConstraint() const mConstraintsModel->removeRow( selectedRows[0].row() ); } -void QgsMetadataWidget::setAutoCrs() const +void QgsMetadataWidget::fillCrsFromLayer() const { selectionCrs->setCrs( mLayer->crs() ); } diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index 56ca42995c42..cab507863f34 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -46,9 +46,9 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg ~QgsMetadataWidget(); /** - * Set the source field from the layer. + * Fill the source field from the layer. */ - void setAutoSource() const; + void fillSourceFromLayer() const; /** * Add a new vocabulary. @@ -91,9 +91,9 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg void removeConstraint() const; /** - * Set the CRS field from the layer. + * Fill the CRS field from the layer. */ - void setAutoCrs() const; + void fillCrsFromLayer() const; /** * Add a new contact. From 6a41b02cd3c0d59a48aeea6118fe69c869a56891 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 14 Sep 2017 12:17:00 +0200 Subject: [PATCH 34/39] add history in the metadata editor --- python/gui/qgsmetadatawidget.sip | 10 +++++ src/gui/qgsmetadatawidget.cpp | 38 ++++++++++++++++++ src/gui/qgsmetadatawidget.h | 11 +++++ src/ui/qgsmetadatawidget.ui | 69 +++++++++++++++++++++++++++++++- 4 files changed, 126 insertions(+), 2 deletions(-) diff --git a/python/gui/qgsmetadatawidget.sip b/python/gui/qgsmetadatawidget.sip index 106501e9e311..39d28f7d75db 100644 --- a/python/gui/qgsmetadatawidget.sip +++ b/python/gui/qgsmetadatawidget.sip @@ -104,6 +104,16 @@ class QgsMetadataWidget : QWidget Remove a selected link. %End + void addHistory(); +%Docstring + Add a new history. +%End + + void removeHistory() const; +%Docstring + Remove a selected history. +%End + void fillComboBox() const; %Docstring Function to fill combobox like language, type. diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index fb90b0e13dd2..0d0af7aefcb9 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -73,6 +73,11 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) tabLinks->setModel( mLinksModel ); tabLinks->setItemDelegate( new LinkItemDelegate() ); + // History + mHistoryModel = new QStringListModel(); + listHistory->setModel( mHistoryModel ); + + // Connect signals and slots connect( tabWidget, &QTabWidget::currentChanged, this, &QgsMetadataWidget::updatePanel ); connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWidget::fillSourceFromLayer ); connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::addVocabulary ); @@ -89,6 +94,8 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) connect( tabContacts, &QTableWidget::itemSelectionChanged, this, &QgsMetadataWidget::updateContactDetails ); connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWidget::addLink ); connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWidget::removeLink ); + connect( btnAddHistory, &QPushButton::clicked, this, &QgsMetadataWidget::addHistory ); + connect( btnRemoveHistory, &QPushButton::clicked, this, &QgsMetadataWidget::removeHistory ); connect( btnNewCategory, &QPushButton::clicked, this, &QgsMetadataWidget::addNewCategory ); connect( btnAddDefaultCategory, &QPushButton::clicked, this, &QgsMetadataWidget::addDefaultCategory ); connect( btnRemoveCategory, &QPushButton::clicked, this, &QgsMetadataWidget::removeCategory ); @@ -262,6 +269,31 @@ void QgsMetadataWidget::removeLink() const mLinksModel->removeRow( selectedRows[0].row() ); } +void QgsMetadataWidget::addHistory() +{ + QString newHistory = QInputDialog::getText( this, tr( "New History" ), tr( "New History" ) ); + QStringList existingHistory = mHistoryModel->stringList(); + if ( ! existingHistory.contains( newHistory ) ) + { + existingHistory.append( newHistory ); + mHistoryModel->setStringList( existingHistory ); + } +} + +void QgsMetadataWidget::removeHistory() const +{ + QItemSelectionModel *selection = listHistory->selectionModel(); + if ( selection->hasSelection() ) + { + QModelIndex indexElementSelectionne = selection->currentIndex(); + + QVariant item = mHistoryModel->data( indexElementSelectionne, Qt::DisplayRole ); + QStringList list = mHistoryModel->stringList(); + list.removeOne( item.toString() ); + mHistoryModel->setStringList( list ); + } +} + void QgsMetadataWidget::fillComboBox() const { // Set default values in type combobox @@ -399,6 +431,9 @@ void QgsMetadataWidget::setPropertiesFromLayer() const mLinksModel->setItem( row, 5, new QStandardItem( link.mimeType ) ); mLinksModel->setItem( row, 6, new QStandardItem( link.size ) ); } + + // History + mHistoryModel->setStringList( mMetadata.history() ); } void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) const @@ -465,6 +500,9 @@ void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) const links.append( link ); } layerMetadata.setLinks( links ); + + // History + layerMetadata.setHistory( mHistoryModel->stringList() ); } bool QgsMetadataWidget::checkMetadata() const diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index cab507863f34..9dbd715ca23c 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -120,6 +120,16 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg */ void removeLink() const; + /** + * Add a new history. + */ + void addHistory(); + + /** + * Remove a selected history. + */ + void removeHistory() const; + /** * Function to fill combobox like language, type. */ @@ -185,6 +195,7 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg QStringListModel *mCategoriesModel = nullptr; QStringListModel *mDefaultCategoriesModel = nullptr; QStringListModel *mRightsModel = nullptr; + QStringListModel *mHistoryModel = nullptr; void syncFromCategoriesTabToKeywordsTab() const; }; diff --git a/src/ui/qgsmetadatawidget.ui b/src/ui/qgsmetadatawidget.ui index 6503a1cd6dac..64ace9cf0b70 100644 --- a/src/ui/qgsmetadatawidget.ui +++ b/src/ui/qgsmetadatawidget.ui @@ -23,7 +23,7 @@ QTabWidget::Rounded - 3 + 7 @@ -54,7 +54,7 @@ 0 - -104 + 0 752 625 @@ -1165,6 +1165,71 @@ + + + History + + + + + + History about the dataset. + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Adds a list of descriptive keywords for a specified vocabulary. + + + + :/images/themes/default/symbologyAdd.svg:/images/themes/default/symbologyAdd.svg + + + false + + + + + + + Removes a specified vocabulary. + + + + :/images/themes/default/symbologyRemove.svg:/images/themes/default/symbologyRemove.svg + + + false + + + + + + + + + + Validation From ce5a18946e183c4f880ff1ad7bbd464f84ea718e Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 14 Sep 2017 13:07:52 +0200 Subject: [PATCH 35/39] fix strange behaviours in the layer properties dialog --- src/app/qgsrasterlayerproperties.cpp | 1 + src/app/qgsvectorlayerproperties.cpp | 1 + src/gui/qgsmetadatawidget.cpp | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp index 563ccc14c542..ff7f910763e2 100644 --- a/src/app/qgsrasterlayerproperties.cpp +++ b/src/app/qgsrasterlayerproperties.cpp @@ -837,6 +837,7 @@ void QgsRasterLayerProperties::apply() } mMetadataWidget->acceptMetadata(); + mMetadataFilled = false; //transparency settings QgsRasterRenderer *rasterRenderer = mRasterLayer->renderer(); diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index cfd6588f59b1..e151f743843b 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -499,6 +499,7 @@ void QgsVectorLayerProperties::apply() // save metadata mMetadataWidget->acceptMetadata(); + mMetadataFilled = false; // // Set up sql subset query if applicable diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 0d0af7aefcb9..24abd5e7442e 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -647,7 +647,6 @@ void QgsMetadataWidget::acceptMetadata() // Save layer metadata properties mLayer->setMetadata( mMetadata ); - hide(); } void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() const From cd73a4255dd48dec4c59c0ed2ab6ec34f8afd3b0 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Wed, 20 Sep 2017 09:25:48 +0700 Subject: [PATCH 36/39] fix conflict on UI files --- src/ui/qgsrasterlayerpropertiesbase.ui | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ui/qgsrasterlayerpropertiesbase.ui b/src/ui/qgsrasterlayerpropertiesbase.ui index c3ae1bdc4f1e..691a7f499230 100755 --- a/src/ui/qgsrasterlayerpropertiesbase.ui +++ b/src/ui/qgsrasterlayerpropertiesbase.ui @@ -110,6 +110,15 @@ :/images/themes/default/propertyicons/system.svg:/images/themes/default/propertyicons/system.svg + + + Metadata + + + + :/images/themes/default/propertyicons/editmetadata.svg:/images/themes/default/propertyicons/editmetadata.svg + + Style @@ -227,7 +236,7 @@ - 1 + 2 @@ -342,6 +351,20 @@ border-radius: 2px; + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + From 60eafddd7e1c9849e5002e1a587ce49a631f3b87 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 21 Sep 2017 16:18:41 +0700 Subject: [PATCH 37/39] fixing comments from the PR: QStringliteral, memory leaks... --- python/core/qgsapplication.sip | 3 +- python/gui/qgsmetadatawidget.sip | 105 +-------------------- src/app/qgsrasterlayerproperties.cpp | 1 + src/app/qgsrasterlayerproperties.h | 2 +- src/app/qgsvectorlayerproperties.cpp | 1 + src/app/qgsvectorlayerproperties.h | 2 +- src/core/qgsapplication.h | 4 +- src/gui/qgsmetadatawidget.cpp | 119 +++++++++++++----------- src/gui/qgsmetadatawidget.h | 134 +++++++-------------------- 9 files changed, 111 insertions(+), 260 deletions(-) diff --git a/python/core/qgsapplication.sip b/python/core/qgsapplication.sip index 25dc3bc4255a..12215b38145e 100644 --- a/python/core/qgsapplication.sip +++ b/python/core/qgsapplication.sip @@ -231,7 +231,8 @@ Returns the path to the translation directory. static QString metadataPath(); %Docstring -Returns the path to the metadata directory. + Returns the path to the metadata directory. +.. versionadded:: 3.0 :rtype: str %End diff --git a/python/gui/qgsmetadatawidget.sip b/python/gui/qgsmetadatawidget.sip index 39d28f7d75db..a565f417e283 100644 --- a/python/gui/qgsmetadatawidget.sip +++ b/python/gui/qgsmetadatawidget.sip @@ -29,101 +29,6 @@ class QgsMetadataWidget : QWidget %End ~QgsMetadataWidget(); - void fillSourceFromLayer() const; -%Docstring - Fill the source field from the layer. -%End - - void addVocabulary() const; -%Docstring - Add a new vocabulary. -%End - - void removeVocabulary() const; -%Docstring - Remove a selected vocabulary. -%End - - void addLicence(); -%Docstring - Add a new licence. -%End - - void removeLicence() const; -%Docstring - Remove a selected licence. -%End - - void addRight(); -%Docstring - Add a new right. -%End - - void removeRight() const; -%Docstring - Remove a selected right. -%End - - void addConstraint() const; -%Docstring - Add a new constraint. -%End - - void removeConstraint() const; -%Docstring - Remove a constraint. -%End - - void fillCrsFromLayer() const; -%Docstring - Fill the CRS field from the layer. -%End - - void addContact() const; -%Docstring - Add a new contact. -%End - - void removeContact() const; -%Docstring - Remove a selected contact. -%End - - void updateContactDetails() const; -%Docstring - Update the contact details according to the selection in the contact list. -%End - - void addLink() const; -%Docstring - Add a new link. -%End - - void removeLink() const; -%Docstring - Remove a selected link. -%End - - void addHistory(); -%Docstring - Add a new history. -%End - - void removeHistory() const; -%Docstring - Remove a selected history. -%End - - void fillComboBox() const; -%Docstring - Function to fill combobox like language, type. -%End - - void setPropertiesFromLayer() const; -%Docstring - Fill the wizard from values in the layer metadata object. -%End - void saveMetadata( QgsLayerMetadata &layerMetadata ) const; %Docstring Save all fields in a QgsLayerMetadata object. @@ -135,6 +40,11 @@ class QgsMetadataWidget : QWidget :rtype: bool %End + void acceptMetadata(); +%Docstring + Saves the metadata to the layer. +%End + static QMap parseLanguages(); %Docstring Returns a list of languages available by default in the wizard. @@ -167,11 +77,6 @@ class QgsMetadataWidget : QWidget :rtype: QMap %End - void acceptMetadata(); -%Docstring - Saves the metadata to the layer. -%End - }; /************************************************************************ diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp index ff7f910763e2..6426c1a85fa7 100644 --- a/src/app/qgsrasterlayerproperties.cpp +++ b/src/app/qgsrasterlayerproperties.cpp @@ -31,6 +31,7 @@ #include "qgsmaplayerstyleguiutils.h" #include "qgsmaptoolemitpoint.h" #include "qgsmaptopixel.h" +#include "qgsmetadatawidget.h" #include "qgsmultibandcolorrenderer.h" #include "qgsmultibandcolorrendererwidget.h" #include "qgspalettedrendererwidget.h" diff --git a/src/app/qgsrasterlayerproperties.h b/src/app/qgsrasterlayerproperties.h index 1e4238a4a5c2..3f18191913dc 100644 --- a/src/app/qgsrasterlayerproperties.h +++ b/src/app/qgsrasterlayerproperties.h @@ -22,7 +22,6 @@ #include "qgsoptionsdialogbase.h" #include "ui_qgsrasterlayerpropertiesbase.h" #include "qgsguiutils.h" -#include "qgsmetadatawidget.h" #include "qgshelp.h" #include "qgsmaplayerstylemanager.h" #include "qgis_app.h" @@ -32,6 +31,7 @@ class QgsMapLayer; class QgsMapCanvas; class QgsRasterLayer; class QgsMapToolEmitPoint; +class QgsMetadataWidget; class QgsRasterRenderer; class QgsRasterRendererWidget; class QgsRasterHistogramWidget; diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index e151f743843b..7d9d8d0aae80 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -37,6 +37,7 @@ #include "qgsmapcanvas.h" #include "qgsmaplayerconfigwidgetfactory.h" #include "qgsmaplayerstyleguiutils.h" +#include "qgsmetadatawidget.h" #include "qgspluginmetadata.h" #include "qgspluginregistry.h" #include "qgsproject.h" diff --git a/src/app/qgsvectorlayerproperties.h b/src/app/qgsvectorlayerproperties.h index 1c1315b70600..7dfc7d294c82 100644 --- a/src/app/qgsvectorlayerproperties.h +++ b/src/app/qgsvectorlayerproperties.h @@ -24,7 +24,6 @@ #include "qgsguiutils.h" #include "qgshelp.h" #include "qgsmaplayerstylemanager.h" -#include "qgsmetadatawidget.h" #include "qgsvectorlayer.h" #include "qgsvectorlayerjoininfo.h" #include "layertree/qgslayertree.h" @@ -43,6 +42,7 @@ class QgsFieldsProperties; class QgsRendererPropertiesDialog; class QgsMapLayerConfigWidgetFactory; class QgsMapLayerConfigWidget; +class QgsMetadataWidget; class QgsPanelWidget; class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private Ui::QgsVectorLayerPropertiesBase, private QgsExpressionContextGenerator diff --git a/src/core/qgsapplication.h b/src/core/qgsapplication.h index e5bca1cd2250..3da119dc594d 100644 --- a/src/core/qgsapplication.h +++ b/src/core/qgsapplication.h @@ -237,7 +237,9 @@ class CORE_EXPORT QgsApplication : public QApplication //! Returns the path to the translation directory. static QString i18nPath(); - //! Returns the path to the metadata directory. + /** Returns the path to the metadata directory. + * \since QGIS 3.0 + */ static QString metadataPath(); //! Returns the path to the master qgis.db file. diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 24abd5e7442e..19f2b48667bd 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -29,7 +29,8 @@ #include "qgsapplication.h" QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) - : QWidget( parent ), mLayer( layer ) + : QWidget( parent ), + mLayer( layer ) { setupUi( this ); mMetadata = layer->metadata(); @@ -39,7 +40,7 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) encodingFrame->setHidden( true ); tabWidget->removeTab( 5 ); - // Default categories + // Default categories, we want them translated, so we are not using a CSV. mDefaultCategories << tr( "Farming" ) << tr( "Climatology Meteorology Atmosphere" ) << tr( "Location" ) << tr( "Intelligence Military" ) << tr( "Transportation" ) << tr( "Structure" ) << tr( "Boundaries" ); mDefaultCategories << tr( "Inland Waters" ) << tr( "Planning Cadastre" ) << tr( "Geoscientific Information" ) << tr( "Elevation" ) << tr( "Health" ) << tr( "Biota" ) << tr( "Oceans" ) << tr( "Environment" ); mDefaultCategories << tr( "Utilities Communication" ) << tr( "Economy" ) << tr( "Society" ) << tr( "Imagery Base Maps Earth Cover" ); @@ -48,15 +49,15 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) listDefaultCategories->setModel( mDefaultCategoriesModel ); // Categories - mCategoriesModel = new QStringListModel( ); + mCategoriesModel = new QStringListModel( listCategories ); listCategories->setModel( mCategoriesModel ); // Rights - mRightsModel = new QStringListModel( ); + mRightsModel = new QStringListModel( listRights ); listRights->setModel( mRightsModel ); // Setup the constraints view - mConstraintsModel = new QStandardItemModel(); + mConstraintsModel = new QStandardItemModel( tabConstraints ); mConstraintsModel->setColumnCount( 2 ); QStringList constraintheaders; constraintheaders << tr( "Type" ) << tr( "Constraint" ); @@ -65,7 +66,7 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) tabConstraints->setItemDelegate( new ConstraintItemDelegate() ); // Setup the link view - mLinksModel = new QStandardItemModel(); + mLinksModel = new QStandardItemModel( tabLinks ); mLinksModel->setColumnCount( 7 ); QStringList headers = QStringList(); headers << tr( "Name" ) << tr( "Type" ) << tr( "URL" ) << tr( "Description" ) << tr( "Format" ) << tr( "MIME" ) << tr( "Size" ); @@ -74,31 +75,31 @@ QgsMetadataWidget::QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer ) tabLinks->setItemDelegate( new LinkItemDelegate() ); // History - mHistoryModel = new QStringListModel(); + mHistoryModel = new QStringListModel( listHistory ); listHistory->setModel( mHistoryModel ); // Connect signals and slots connect( tabWidget, &QTabWidget::currentChanged, this, &QgsMetadataWidget::updatePanel ); connect( btnAutoSource, &QPushButton::clicked, this, &QgsMetadataWidget::fillSourceFromLayer ); connect( btnAddVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::addVocabulary ); - connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::removeVocabulary ); + connect( btnRemoveVocabulary, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedVocabulary ); connect( btnAddRight, &QPushButton::clicked, this, &QgsMetadataWidget::addRight ); - connect( btnRemoveRight, &QPushButton::clicked, this, &QgsMetadataWidget::removeRight ); + connect( btnRemoveRight, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedRight ); connect( btnAddLicence, &QPushButton::clicked, this, &QgsMetadataWidget::addLicence ); - connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWidget::removeLicence ); + connect( btnRemoveLicence, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedLicence ); connect( btnAddConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::addConstraint ); - connect( btnRemoveConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::removeConstraint ); + connect( btnRemoveConstraint, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedConstraint ); connect( btnAutoCrs, &QPushButton::clicked, this, &QgsMetadataWidget::fillCrsFromLayer ); connect( btnAddContact, &QPushButton::clicked, this, &QgsMetadataWidget::addContact ); - connect( btnRemoveContact, &QPushButton::clicked, this, &QgsMetadataWidget::removeContact ); + connect( btnRemoveContact, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedContact ); connect( tabContacts, &QTableWidget::itemSelectionChanged, this, &QgsMetadataWidget::updateContactDetails ); connect( btnAddLink, &QPushButton::clicked, this, &QgsMetadataWidget::addLink ); - connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWidget::removeLink ); + connect( btnRemoveLink, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedLink ); connect( btnAddHistory, &QPushButton::clicked, this, &QgsMetadataWidget::addHistory ); - connect( btnRemoveHistory, &QPushButton::clicked, this, &QgsMetadataWidget::removeHistory ); + connect( btnRemoveHistory, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedHistory ); connect( btnNewCategory, &QPushButton::clicked, this, &QgsMetadataWidget::addNewCategory ); connect( btnAddDefaultCategory, &QPushButton::clicked, this, &QgsMetadataWidget::addDefaultCategory ); - connect( btnRemoveCategory, &QPushButton::clicked, this, &QgsMetadataWidget::removeCategory ); + connect( btnRemoveCategory, &QPushButton::clicked, this, &QgsMetadataWidget::removeSelectedCategory ); fillComboBox(); setPropertiesFromLayer(); @@ -129,10 +130,10 @@ void QgsMetadataWidget::addVocabulary() const tabKeywords->setItem( row, 1, pCell ); } -void QgsMetadataWidget::removeVocabulary() const +void QgsMetadataWidget::removeSelectedVocabulary() const { QItemSelectionModel *selectionModel = tabKeywords->selectionModel(); - QModelIndexList selectedRows = selectionModel->selectedRows(); + const QModelIndexList selectedRows = selectionModel->selectedRows(); for ( int i = 0 ; i < selectedRows.size() ; i++ ) { tabKeywords->model()->removeRow( selectedRows[i].row() ); @@ -151,10 +152,10 @@ void QgsMetadataWidget::addLicence() } } -void QgsMetadataWidget::removeLicence() const +void QgsMetadataWidget::removeSelectedLicence() const { QItemSelectionModel *selectionModel = tabLicenses->selectionModel(); - QModelIndexList selectedRows = selectionModel->selectedRows(); + const QModelIndexList selectedRows = selectionModel->selectedRows(); for ( int i = 0 ; i < selectedRows.size() ; i++ ) { tabLicenses->model()->removeRow( selectedRows[i].row() ); @@ -172,7 +173,7 @@ void QgsMetadataWidget::addRight() } } -void QgsMetadataWidget::removeRight() const +void QgsMetadataWidget::removeSelectedRight() const { QItemSelectionModel *selection = listRights->selectionModel(); if ( selection->hasSelection() ) @@ -193,9 +194,9 @@ void QgsMetadataWidget::addConstraint() const mConstraintsModel->setItem( row, 1, new QStandardItem( QString( tr( "undefined %1" ) ).arg( row + 1 ) ) ); } -void QgsMetadataWidget::removeConstraint() const +void QgsMetadataWidget::removeSelectedConstraint() const { - QModelIndexList selectedRows = tabConstraints->selectionModel()->selectedRows(); + const QModelIndexList selectedRows = tabConstraints->selectionModel()->selectedRows(); mConstraintsModel->removeRow( selectedRows[0].row() ); } @@ -222,10 +223,10 @@ void QgsMetadataWidget::addContact() const tabContacts->selectRow( row ); } -void QgsMetadataWidget::removeContact() const +void QgsMetadataWidget::removeSelectedContact() const { QItemSelectionModel *selectionModel = tabContacts->selectionModel(); - QModelIndexList selectedRows = selectionModel->selectedRows(); + const QModelIndexList selectedRows = selectionModel->selectedRows(); for ( int i = 0 ; i < selectedRows.size() ; i++ ) { tabContacts->model()->removeRow( selectedRows[i].row() ); @@ -235,9 +236,9 @@ void QgsMetadataWidget::removeContact() const void QgsMetadataWidget::updateContactDetails() const { QItemSelectionModel *selectionModel = tabContacts->selectionModel(); - QModelIndexList selectedRows = selectionModel->selectedRows(); + const QModelIndexList selectedRows = selectionModel->selectedRows(); - if ( selectedRows.size() > 0 ) + if ( ! selectedRows.isEmpty() ) { panelDetails->setDisabled( false ); lineEditContactName->setText( tabContacts->item( selectedRows[0].row(), 0 )->text() ); @@ -263,9 +264,9 @@ void QgsMetadataWidget::addLink() const mLinksModel->setItem( row, 6, new QStandardItem() ); } -void QgsMetadataWidget::removeLink() const +void QgsMetadataWidget::removeSelectedLink() const { - QModelIndexList selectedRows = tabLinks->selectionModel()->selectedRows(); + const QModelIndexList selectedRows = tabLinks->selectionModel()->selectedRows(); mLinksModel->removeRow( selectedRows[0].row() ); } @@ -280,7 +281,7 @@ void QgsMetadataWidget::addHistory() } } -void QgsMetadataWidget::removeHistory() const +void QgsMetadataWidget::removeSelectedHistory() const { QItemSelectionModel *selection = listHistory->selectionModel(); if ( selection->hasSelection() ) @@ -450,7 +451,7 @@ void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) const QMap keywords; for ( int i = 0 ; i < tabKeywords->rowCount() ; i++ ) { - 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 ); @@ -480,10 +481,7 @@ void QgsMetadataWidget::saveMetadata( QgsLayerMetadata &layerMetadata ) const layerMetadata.setConstraints( constraints ); // CRS - if ( selectionCrs->crs().isValid() ) - { - layerMetadata.setCrs( selectionCrs->crs() ); - } + layerMetadata.setCrs( selectionCrs->crs() ); // Links QList links; @@ -529,7 +527,7 @@ bool QgsMetadataWidget::checkMetadata() const } else { - errors = QStringLiteral( "Ok, it seems valid." ); + errors = QString( tr( "Ok, it seems valid according to the QGIS Schema." ) ); } QString myStyle = QgsApplication::reportStyleSheet(); @@ -543,15 +541,17 @@ bool QgsMetadataWidget::checkMetadata() const QMap QgsMetadataWidget::parseLanguages() { - QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "country_code_ISO_3166.csv" ) ); + QMap countries; + countries.insert( QString(), QString() ); // We add an empty line, because it's not compulsory. + + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QStringLiteral( "country_code_ISO_3166.csv" ) ); QFile file( path ); if ( !file.open( QIODevice::ReadOnly ) ) { QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + return countries; } - QMap countries; - countries.insert( "", "" ); // We add an empty line, because it's not compulsory. // Skip the first line of the CSV file.readLine(); while ( !file.atEnd() ) @@ -565,14 +565,17 @@ QMap QgsMetadataWidget::parseLanguages() QStringList QgsMetadataWidget::parseLicenses() { - QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "licenses.csv" ) ); + QStringList wordList; + wordList.append( QString() ); // We add an empty line, because it's not compulsory. + + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QStringLiteral( "licenses.csv" ) ); QFile file( path ); if ( !file.open( QIODevice::ReadOnly ) ) { QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + return wordList; } - QStringList wordList; // Skip the first line of the CSV file.readLine(); while ( !file.atEnd() ) @@ -585,14 +588,17 @@ QStringList QgsMetadataWidget::parseLicenses() QStringList QgsMetadataWidget::parseLinkTypes() { - QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "LinkPropertyLookupTable.csv" ) ); + QStringList wordList; + wordList.append( QString() ); // We add an empty line, because it's not compulsory. + + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QStringLiteral( "LinkPropertyLookupTable.csv" ) ); QFile file( path ); if ( !file.open( QIODevice::ReadOnly ) ) { QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + return wordList; } - QStringList wordList; // Skip the first line of the CSV file.readLine(); while ( !file.atEnd() ) @@ -605,14 +611,17 @@ QStringList QgsMetadataWidget::parseLinkTypes() QStringList QgsMetadataWidget::parseMimeTypes() { + QStringList wordList; + wordList.append( QString() ); // We add an empty line, because it's not compulsory. + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "mime.csv" ) ); QFile file( path ); if ( !file.open( QIODevice::ReadOnly ) ) { QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + return wordList; } - QStringList wordList; while ( !file.atEnd() ) { QByteArray line = file.readLine(); @@ -623,15 +632,17 @@ QStringList QgsMetadataWidget::parseMimeTypes() QMap QgsMetadataWidget::parseTypes() { - QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QString( "md_scope_codes.csv" ) ); + QMap types; + types.insert( QString(), QString() ); // We add an empty line, because it's not compulsory. + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QStringLiteral( "md_scope_codes.csv" ) ); QFile file( path ); if ( !file.open( QIODevice::ReadOnly ) ) { QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + return types; } - QMap types; - types.insert( "", "" ); // We add an empty line, because it's not compulsory. + types.insert( QString(), QString() ); // We add an empty line, because it's not compulsory. while ( !file.atEnd() ) { QByteArray line = file.readLine(); @@ -653,7 +664,7 @@ void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() const { if ( mCategoriesModel->rowCount() > 0 ) { - QList categories = tabKeywords->findItems( "gmd:topicCategory", Qt::MatchExactly ); + QList categories = tabKeywords->findItems( QStringLiteral( "gmd:topicCategory" ), Qt::MatchExactly ); int row; if ( !categories.isEmpty() ) { @@ -664,7 +675,7 @@ void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab() const // Create a new line with 'gmd:topicCategory' addVocabulary(); row = tabKeywords->rowCount() - 1; - tabKeywords->item( row, 0 )->setText( "gmd:topicCategory" ); + tabKeywords->item( row, 0 )->setText( QStringLiteral( "gmd:topicCategory" ) ); } tabKeywords->item( row, 1 )->setText( mCategoriesModel->stringList().join( "," ) ); } @@ -674,11 +685,11 @@ void QgsMetadataWidget::updatePanel() const { int index = tabWidget->currentIndex(); QString currentTabText = tabWidget->widget( index )->objectName(); - if ( currentTabText == "tabCategoriesDialog" ) + if ( currentTabText == QStringLiteral( "tabCategoriesDialog" ) ) { // Categories tab // We need to take keywords and insert them into the list - QList categories = tabKeywords->findItems( "gmd:topicCategory", Qt::MatchExactly ); + QList categories = tabKeywords->findItems( QStringLiteral( "gmd:topicCategory" ), Qt::MatchExactly ); if ( !categories.isEmpty() ) { int row = categories.at( 0 )->row(); @@ -689,13 +700,13 @@ void QgsMetadataWidget::updatePanel() const mCategoriesModel->setStringList( QStringList() ); } } - else if ( currentTabText == "tabKeywordsDialog" ) + else if ( currentTabText == QStringLiteral( "tabKeywordsDialog" ) ) { // Keywords tab // We need to take categories and insert them into the table syncFromCategoriesTabToKeywordsTab(); } - else if ( currentTabText == "tabValidationDialog" ) + else if ( currentTabText == QStringLiteral( "tabValidationDialog" ) ) { checkMetadata(); } @@ -706,7 +717,7 @@ void QgsMetadataWidget::addNewCategory() bool ok; QString text = QInputDialog::getText( this, tr( "New Category" ), tr( "New Category:" ), QLineEdit::Normal, - QString( "" ), &ok ); + QString(), &ok ); if ( ok && !text.isEmpty() ) { QStringList list = mCategoriesModel->stringList(); @@ -739,7 +750,7 @@ void QgsMetadataWidget::addDefaultCategory() const } -void QgsMetadataWidget::removeCategory() const +void QgsMetadataWidget::removeSelectedCategory() const { QItemSelectionModel *selection = listCategories->selectionModel(); if ( selection->hasSelection() ) diff --git a/src/gui/qgsmetadatawidget.h b/src/gui/qgsmetadatawidget.h index 9dbd715ca23c..f4e6a3af29f9 100644 --- a/src/gui/qgsmetadatawidget.h +++ b/src/gui/qgsmetadatawidget.h @@ -45,101 +45,6 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg QgsMetadataWidget( QWidget *parent, QgsMapLayer *layer = nullptr ); ~QgsMetadataWidget(); - /** - * Fill the source field from the layer. - */ - void fillSourceFromLayer() const; - - /** - * Add a new vocabulary. - */ - void addVocabulary() const; - - /** - * Remove a selected vocabulary. - */ - void removeVocabulary() const; - - /** - * Add a new licence. - */ - void addLicence(); - - /** - * Remove a selected licence. - */ - void removeLicence() const; - - /** - * Add a new right. - */ - void addRight(); - - /** - * Remove a selected right. - */ - void removeRight() const; - - /** - * Add a new constraint. - */ - void addConstraint() const; - - /** - * Remove a constraint. - */ - void removeConstraint() const; - - /** - * Fill the CRS field from the layer. - */ - void fillCrsFromLayer() const; - - /** - * Add a new contact. - */ - void addContact() const; - - /** - * Remove a selected contact. - */ - void removeContact() const; - - /** - * Update the contact details according to the selection in the contact list. - */ - void updateContactDetails() const; - - /** - * Add a new link. - */ - void addLink() const; - - /** - * Remove a selected link. - */ - void removeLink() const; - - /** - * Add a new history. - */ - void addHistory(); - - /** - * Remove a selected history. - */ - void removeHistory() const; - - /** - * Function to fill combobox like language, type. - */ - void fillComboBox() const; - - /** - * Fill the wizard from values in the layer metadata object. - */ - void setPropertiesFromLayer() const; - /** * Save all fields in a QgsLayerMetadata object. */ @@ -150,6 +55,11 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg */ bool checkMetadata() const; + /** + * Saves the metadata to the layer. + */ + void acceptMetadata(); + /** * Returns a list of languages available by default in the wizard. */ @@ -177,16 +87,31 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg */ static QMap parseTypes(); - /** - * Saves the metadata to the layer. - */ - void acceptMetadata(); - private: void updatePanel() const; + void fillSourceFromLayer() const; + void fillCrsFromLayer() const; void addDefaultCategory() const; void addNewCategory(); - void removeCategory() const; + void removeSelectedCategory() const; + void addVocabulary() const; + void removeSelectedVocabulary() const; + void addLicence(); + void removeSelectedLicence() const; + void addRight(); + void removeSelectedRight() const; + void addConstraint() const; + void removeSelectedConstraint() const; + void addContact() const; + void removeSelectedContact() const; + void addLink() const; + void removeSelectedLink() const; + void addHistory(); + void removeSelectedHistory() const; + void updateContactDetails() const; + void fillComboBox() const; + void setPropertiesFromLayer() const; + void syncFromCategoriesTabToKeywordsTab() const; QStringList mDefaultCategories; QgsMapLayer *mLayer = nullptr; QgsLayerMetadata mMetadata; @@ -196,12 +121,13 @@ class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidg QStringListModel *mDefaultCategoriesModel = nullptr; QStringListModel *mRightsModel = nullptr; QStringListModel *mHistoryModel = nullptr; - void syncFromCategoriesTabToKeywordsTab() const; }; #ifndef SIP_RUN + /** + \\\@cond PRIVATE * \ingroup gui * \class LinkItemDelegate * \brief Special delegate for the link view in the metadata wizard. @@ -241,5 +167,9 @@ class ConstraintItemDelegate : public QStyledItemDelegate QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const; }; +/** + \\\@endcond + */ + #endif #endif From b90564b6777a908a27073ecc7001a27faf7d1b35 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 21 Sep 2017 17:43:07 +0700 Subject: [PATCH 38/39] add ISO 639 --- .../metadata-ISO/language_codes_ISO_639.csv | 185 ++++++++++++++++++ src/gui/qgsmetadatawidget.cpp | 35 +++- 2 files changed, 214 insertions(+), 6 deletions(-) create mode 100644 resources/metadata-ISO/language_codes_ISO_639.csv diff --git a/resources/metadata-ISO/language_codes_ISO_639.csv b/resources/metadata-ISO/language_codes_ISO_639.csv new file mode 100644 index 000000000000..cbfde1506458 --- /dev/null +++ b/resources/metadata-ISO/language_codes_ISO_639.csv @@ -0,0 +1,185 @@ +alpha2,English +aa,Afar +ab,Abkhazian +ae,Avestan +af,Afrikaans +ak,Akan +am,Amharic +an,Aragonese +ar,Arabic +as,Assamese +av,Avaric +ay,Aymara +az,Azerbaijani +ba,Bashkir +be,Belarusian +bg,Bulgarian +bh,Bihari languages +bi,Bislama +bm,Bambara +bn,Bengali +bo,Tibetan +br,Breton +bs,Bosnian +ca,Catalan; Valencian +ce,Chechen +ch,Chamorro +co,Corsican +cr,Cree +cs,Czech +cu,Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic +cv,Chuvash +cy,Welsh +da,Danish +de,German +dv,Divehi; Dhivehi; Maldivian +dz,Dzongkha +ee,Ewe +el,"Greek, Modern (1453-)" +en,English +eo,Esperanto +es,Spanish; Castilian +et,Estonian +eu,Basque +fa,Persian +ff,Fulah +fi,Finnish +fj,Fijian +fo,Faroese +fr,French +fy,Western Frisian +ga,Irish +gd,Gaelic; Scottish Gaelic +gl,Galician +gn,Guarani +gu,Gujarati +gv,Manx +ha,Hausa +he,Hebrew +hi,Hindi +ho,Hiri Motu +hr,Croatian +ht,Haitian; Haitian Creole +hu,Hungarian +hy,Armenian +hz,Herero +ia,Interlingua (International Auxiliary Language Association) +id,Indonesian +ie,Interlingue; Occidental +ig,Igbo +ii,Sichuan Yi; Nuosu +ik,Inupiaq +io,Ido +is,Icelandic +it,Italian +iu,Inuktitut +ja,Japanese +jv,Javanese +ka,Georgian +kg,Kongo +ki,Kikuyu; Gikuyu +kj,Kuanyama; Kwanyama +kk,Kazakh +kl,Kalaallisut; Greenlandic +km,Central Khmer +kn,Kannada +ko,Korean +kr,Kanuri +ks,Kashmiri +ku,Kurdish +kv,Komi +kw,Cornish +ky,Kirghiz; Kyrgyz +la,Latin +lb,Luxembourgish; Letzeburgesch +lg,Ganda +li,Limburgan; Limburger; Limburgish +ln,Lingala +lo,Lao +lt,Lithuanian +lu,Luba-Katanga +lv,Latvian +mg,Malagasy +mh,Marshallese +mi,Maori +mk,Macedonian +ml,Malayalam +mn,Mongolian +mr,Marathi +ms,Malay +mt,Maltese +my,Burmese +na,Nauru +nb,"Bokmål, Norwegian; Norwegian Bokmål" +nd,"Ndebele, North; North Ndebele" +ne,Nepali +ng,Ndonga +nl,Dutch; Flemish +nn,"Norwegian Nynorsk; Nynorsk, Norwegian" +no,Norwegian +nr,"Ndebele, South; South Ndebele" +nv,Navajo; Navaho +ny,Chichewa; Chewa; Nyanja +oc,Occitan (post 1500); Provençal +oj,Ojibwa +om,Oromo +or,Oriya +os,Ossetian; Ossetic +pa,Panjabi; Punjabi +pi,Pali +pl,Polish +ps,Pushto; Pashto +pt,Portuguese +qu,Quechua +rm,Romansh +rn,Rundi +ro,Romanian; Moldavian; Moldovan +ru,Russian +rw,Kinyarwanda +sa,Sanskrit +sc,Sardinian +sd,Sindhi +se,Northern Sami +sg,Sango +si,Sinhala; Sinhalese +sk,Slovak +sl,Slovenian +sm,Samoan +sn,Shona +so,Somali +sq,Albanian +sr,Serbian +ss,Swati +st,"Sotho, Southern" +su,Sundanese +sv,Swedish +sw,Swahili +ta,Tamil +te,Telugu +tg,Tajik +th,Thai +ti,Tigrinya +tk,Turkmen +tl,Tagalog +tn,Tswana +to,Tonga (Tonga Islands) +tr,Turkish +ts,Tsonga +tt,Tatar +tw,Twi +ty,Tahitian +ug,Uighur; Uyghur +uk,Ukrainian +ur,Urdu +uz,Uzbek +ve,Venda +vi,Vietnamese +vo,Volapük +wa,Walloon +wo,Wolof +xh,Xhosa +yi,Yiddish +yo,Yoruba +za,Zhuang; Chuang +zh,Chinese +zu,Zulu diff --git a/src/gui/qgsmetadatawidget.cpp b/src/gui/qgsmetadatawidget.cpp index 19f2b48667bd..6bb2e9b9c29a 100644 --- a/src/gui/qgsmetadatawidget.cpp +++ b/src/gui/qgsmetadatawidget.cpp @@ -317,7 +317,7 @@ void QgsMetadataWidget::fillComboBox() const comboLanguage->setEditable( true ); comboLanguage->clear(); QMap countries = parseLanguages(); - const QStringList &k = types.keys(); + const QStringList &k = countries.keys(); i = 0; for ( const QString &countryCode : k ) { @@ -544,7 +544,7 @@ QMap QgsMetadataWidget::parseLanguages() QMap countries; countries.insert( QString(), QString() ); // We add an empty line, because it's not compulsory. - QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QStringLiteral( "country_code_ISO_3166.csv" ) ); + QString path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QStringLiteral( "language_codes_ISO_639.csv" ) ); QFile file( path ); if ( !file.open( QIODevice::ReadOnly ) ) { @@ -558,8 +558,27 @@ QMap QgsMetadataWidget::parseLanguages() { QByteArray line = file.readLine(); QList items = line.split( ',' ); - countries.insert( items.at( 2 ).constData(), items.at( 0 ).constData() ); + countries.insert( QString( items.at( 0 ).constData() ).trimmed(), QString( items.at( 1 ).constData() ).trimmed() ); } + file.close(); + + path = QDir( QgsApplication::metadataPath() ).absoluteFilePath( QStringLiteral( "country_code_ISO_3166.csv" ) ); + QFile secondFile( path ); + if ( !secondFile.open( QIODevice::ReadOnly ) ) + { + QgsDebugMsg( QString( "Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) ); + return countries; + } + + // Skip the first line of the CSV + secondFile.readLine(); + while ( !secondFile.atEnd() ) + { + QByteArray line = secondFile.readLine(); + QList items = line.split( ',' ); + countries.insert( QString( items.at( 2 ).constData() ).trimmed(), QString( items.at( 0 ).constData() ).trimmed() ); + } + secondFile.close(); return countries; } @@ -581,8 +600,9 @@ QStringList QgsMetadataWidget::parseLicenses() while ( !file.atEnd() ) { QByteArray line = file.readLine(); - wordList.append( line.split( ',' ).at( 0 ) ); + wordList.append( line.split( ',' ).at( 0 ).trimmed() ); } + file.close(); return wordList; } @@ -604,8 +624,9 @@ QStringList QgsMetadataWidget::parseLinkTypes() while ( !file.atEnd() ) { QByteArray line = file.readLine(); - wordList.append( line.split( ',' ).at( 0 ) ); + wordList.append( line.split( ',' ).at( 0 ).trimmed() ); } + file.close(); return wordList; } @@ -625,8 +646,9 @@ QStringList QgsMetadataWidget::parseMimeTypes() while ( !file.atEnd() ) { QByteArray line = file.readLine(); - wordList.append( line.split( ',' ).at( 0 ) ); + wordList.append( line.split( ',' ).at( 0 ).trimmed() ); } + file.close(); return wordList; } @@ -649,6 +671,7 @@ QMap QgsMetadataWidget::parseTypes() QList items = line.split( ';' ); types.insert( items.at( 0 ).constData(), items.at( 1 ).constData() ); } + file.close(); return types; } From 6deaa9b7c5bdc83f71a9e678223b1a923b5fd3e3 Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Sat, 23 Sep 2017 01:12:16 +0700 Subject: [PATCH 39/39] fix conflict on UI file --- src/ui/qgsvectorlayerpropertiesbase.ui | 381 ++++++++++++++++++++----- 1 file changed, 312 insertions(+), 69 deletions(-) diff --git a/src/ui/qgsvectorlayerpropertiesbase.ui b/src/ui/qgsvectorlayerpropertiesbase.ui index 23f93548328a..247cdf992613 100755 --- a/src/ui/qgsvectorlayerpropertiesbase.ui +++ b/src/ui/qgsvectorlayerpropertiesbase.ui @@ -46,7 +46,16 @@ QFrame::Raised - + + 0 + + + 0 + + + 0 + + 0 @@ -101,23 +110,23 @@ - MetadataNG + Source + + + Source - :/images/themes/default/propertyicons/editmetadata.svg:/images/themes/default/propertyicons/editmetadata.svg + :/images/themes/default/propertyicons/system.svg:/images/themes/default/propertyicons/system.svg - Source - - - Source + Metadata - :/images/themes/default/propertyicons/system.svg:/images/themes/default/propertyicons/system.svg + :/images/themes/default/propertyicons/editmetadata.svg:/images/themes/default/propertyicons/editmetadata.svg @@ -282,7 +291,16 @@ QFrame::Raised - + + 0 + + + 0 + + + 0 + + 0 @@ -294,11 +312,20 @@ - 5 + 2 - + + 0 + + + 0 + + + 0 + + 0 @@ -310,7 +337,16 @@ QFrame::Raised - + + 0 + + + 0 + + + 0 + + 0 @@ -325,23 +361,18 @@ - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - + + 0 + + + 0 + + + 0 + + 0 @@ -357,12 +388,21 @@ 0 0 - 651 - 537 + 644 + 522 - + + 0 + + + 0 + + + 0 + + 0 @@ -417,7 +457,16 @@ border-radius: 2px; QFrame::Raised - + + 0 + + + 0 + + + 0 + + 0 @@ -466,7 +515,7 @@ border-radius: 2px; false - + vectorgeneral @@ -481,7 +530,7 @@ border-radius: 2px; - + Qt::StrongFocus @@ -587,9 +636,32 @@ border-radius: 2px; + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + - + + 0 + + + 0 + + + 0 + + 0 @@ -605,12 +677,21 @@ border-radius: 2px; 0 0 - 651 - 537 + 644 + 522 - + + 0 + + + 0 + + + 0 + + 0 @@ -640,7 +721,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -663,7 +753,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -679,12 +778,21 @@ border-radius: 2px; 0 0 - 651 - 537 + 644 + 522 - + + 0 + + + 0 + + + 0 + + 0 @@ -705,7 +813,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -721,12 +838,21 @@ border-radius: 2px; 0 0 - 651 - 537 + 673 + 507 - + + 0 + + + 0 + + + 0 + + 0 @@ -739,7 +865,7 @@ border-radius: 2px; - + Qt::StrongFocus @@ -1003,7 +1129,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -1012,7 +1147,16 @@ border-radius: 2px; true - + + 0 + + + 0 + + + 0 + + 0 @@ -1023,7 +1167,7 @@ border-radius: 2px; - + Qt::StrongFocus @@ -1074,7 +1218,7 @@ border-radius: 2px; - + Qt::StrongFocus @@ -1093,7 +1237,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -1114,7 +1267,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -1141,7 +1303,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -1157,12 +1328,21 @@ border-radius: 2px; 0 0 - 128 - 116 + 199 + 123 - + + 0 + + + 0 + + + 0 + + 0 @@ -1246,7 +1426,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -1269,7 +1458,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -1292,7 +1490,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -1311,7 +1518,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -1367,7 +1583,16 @@ border-radius: 2px; - + + 0 + + + 0 + + + 0 + + 0 @@ -1383,12 +1608,21 @@ border-radius: 2px; 0 0 - 651 - 537 + 359 + 527 - + + 0 + + + 0 + + + 0 + + 0 @@ -1396,7 +1630,7 @@ border-radius: 2px; Description - + vectormeta @@ -1538,7 +1772,7 @@ border-radius: 2px; Attribution - + vectormeta @@ -1584,7 +1818,7 @@ border-radius: 2px; MetadataUrl - + vectormeta @@ -1782,7 +2016,16 @@ border-radius: 2px; QFrame::Raised - + + 0 + + + 0 + + + 0 + + 0