22#include <QInputDialog>
23#include <QStringListModel>
39 tabWidget->setCurrentIndex( 0 );
42 encodingFrame->setHidden(
true );
45 mDefaultCategories << tr(
"Farming" ) << tr(
"Climatology Meteorology Atmosphere" ) << tr(
"Location" ) << tr(
"Intelligence Military" ) << tr(
"Transportation" ) << tr(
"Structure" ) << tr(
"Boundaries" );
46 mDefaultCategories << tr(
"Inland Waters" ) << tr(
"Planning Cadastre" ) << tr(
"Geoscientific Information" ) << tr(
"Elevation" ) << tr(
"Health" ) << tr(
"Biota" ) << tr(
"Oceans" ) << tr(
"Environment" );
47 mDefaultCategories << tr(
"Utilities Communication" ) << tr(
"Economy" ) << tr(
"Society" ) << tr(
"Imagery Base Maps Earth Cover" );
48 mDefaultCategoriesModel =
new QStringListModel( mDefaultCategories,
this );
49 mDefaultCategoriesModel->sort( 0 );
50 listDefaultCategories->setModel( mDefaultCategoriesModel );
53 mCategoriesModel =
new QStringListModel( listCategories );
54 listCategories->setModel( mCategoriesModel );
57 mRightsModel =
new QStringListModel( listRights );
58 listRights->setModel( mRightsModel );
61 mConstraintsModel =
new QStandardItemModel( tabConstraints );
62 mConstraintsModel->setColumnCount( 2 );
63 QStringList constraintheaders;
64 constraintheaders << tr(
"Type" ) << tr(
"Constraint" );
65 mConstraintsModel->setHorizontalHeaderLabels( constraintheaders );
66 tabConstraints->setModel( mConstraintsModel );
67 tabConstraints->setItemDelegate(
new ConstraintItemDelegate(
this ) );
70 dateTimeFrom->setAllowNull(
true );
71 dateTimeTo->setAllowNull(
true );
74 mLinksModel =
new QStandardItemModel( tabLinks );
75 mLinksModel->setColumnCount( 7 );
76 QStringList headers = QStringList();
77 headers << tr(
"Name" ) << tr(
"Type" ) << tr(
"URL" ) << tr(
"Description" ) << tr(
"Format" ) << tr(
"MIME" ) << tr(
"Size" );
78 mLinksModel->setHorizontalHeaderLabels( headers );
79 tabLinks->setModel( mLinksModel );
80 tabLinks->setItemDelegate(
new LinkItemDelegate(
this ) );
83 mHistoryModel =
new QStringListModel( listHistory );
84 listHistory->setModel( mHistoryModel );
88 mCreationDateTimeEdit,
89 mCreationDateTimeEdit2,
90 mPublishedDateTimeEdit,
92 mSupersededDateTimeEdit
95 w->setAllowNull(
true );
96 w->setNullRepresentation( tr(
"Not set" ) );
100 connect( tabWidget, &QTabWidget::currentChanged,
this, &QgsMetadataWidget::updatePanel );
101 connect( btnAutoSource, &QPushButton::clicked,
this, &QgsMetadataWidget::fillSourceFromLayer );
102 connect( btnAddVocabulary, &QPushButton::clicked,
this, &QgsMetadataWidget::addVocabulary );
103 connect( btnRemoveVocabulary, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedVocabulary );
104 connect( btnAddRight, &QPushButton::clicked,
this, &QgsMetadataWidget::addRight );
105 connect( btnRemoveRight, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedRight );
106 connect( btnAddLicence, &QPushButton::clicked,
this, &QgsMetadataWidget::addLicence );
107 connect( btnRemoveLicence, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedLicence );
108 connect( btnAddConstraint, &QPushButton::clicked,
this, &QgsMetadataWidget::addConstraint );
109 connect( btnRemoveConstraint, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedConstraint );
110 connect( btnSetCrsFromLayer, &QPushButton::clicked,
this, &QgsMetadataWidget::fillCrsFromLayer );
111 connect( btnSetCrsFromProvider, &QPushButton::clicked,
this, &QgsMetadataWidget::fillCrsFromProvider );
112 connect( btnAddAddress, &QPushButton::clicked,
this, &QgsMetadataWidget::addAddress );
113 connect( btnRemoveAddress, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedAddress );
114 connect( btnAddLink, &QPushButton::clicked,
this, &QgsMetadataWidget::addLink );
115 connect( btnRemoveLink, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedLink );
116 connect( btnAddHistory, &QPushButton::clicked,
this, &QgsMetadataWidget::addHistory );
117 connect( btnRemoveHistory, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedHistory );
118 connect( btnNewCategory, &QPushButton::clicked,
this, &QgsMetadataWidget::addNewCategory );
119 connect( btnAddDefaultCategory, &QPushButton::clicked,
this, &QgsMetadataWidget::addDefaultCategories );
120 connect( btnRemoveCategory, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedCategories );
125 btnAutoSource->setEnabled(
false );
126 btnAutoEncoding->setEnabled(
false );
127 btnSetCrsFromLayer->setEnabled(
false );
148 type = tr(
"dataset" );
149 typeUpper = tr(
"Dataset" );
150 mEncodingFrame->show();
151 mAuthorFrame->hide();
152 btnAutoSource->setEnabled( mLayer );
156 type = tr(
"project" );
157 typeUpper = tr(
"Project" );
158 mEncodingFrame->hide();
159 mAuthorFrame->show();
160 tabWidget->removeTab( 4 );
161 tabWidget->removeTab( 3 );
162 btnAutoSource->setEnabled(
true );
165 connect( mCreationDateTimeEdit, &QDateTimeEdit::dateTimeChanged,
this, [ = ](
const QDateTime & value )
167 if ( value.isValid() )
168 mCreationDateTimeEdit2->setDateTime( value );
169 else if ( mCreationDateTimeEdit2->dateTime().isValid() )
170 mCreationDateTimeEdit2->clear();
172 connect( mCreationDateTimeEdit2, &QDateTimeEdit::dateTimeChanged,
this, [ = ](
const QDateTime & value )
174 if ( value.isValid() )
175 mCreationDateTimeEdit->setDateTime( value );
176 else if ( mCreationDateTimeEdit->dateTime().isValid() )
177 mCreationDateTimeEdit->clear();
183 mIdLabel->setText( tr(
"This page describes the basic attribution of the %1. Please use the tooltips for more information." ).arg( type ) );
184 mLabelCategories->setText( tr(
"%1 categories." ).arg( typeUpper ) );
185 mLabelContact->setText( tr(
"Contacts related to the %1." ).arg( type ) );
186 mLabelLinks->setText( tr(
"Links describe ancillary resources and information related to this %1." ).arg( type ) );
187 mLabelHistory->setText( tr(
"History about the %1." ).arg( type ) );
188 labelKeywords->setText( tr(
"<html><head/><body><p>Keywords are optional, and provide a way to provide additional descriptive information about "
189 "the %1. Edits made in the categories tab will update the category entry below. For the concept, we suggest "
190 "to use a standard based vocabulary such as <a href=\"https://www.eionet.europa.eu/gemet/en/inspire-themes/\">"
191 "<span style=\" text-decoration: underline; color:#0000ff;\">GEMET.</span></a></p></body></html>" ).arg( type ) );
192 btnAutoSource->setText( tr(
"Set from %1" ).arg( mMode ==
LayerMetadata ? tr(
"layer" ) : tr(
"project" ) ) );
211 std::unique_ptr< QgsAbstractMetadataBase > md;
215 md = std::make_unique< QgsLayerMetadata >();
219 md = std::make_unique< QgsProjectMetadata >();
227void QgsMetadataWidget::fillSourceFromLayer()
245void QgsMetadataWidget::addVocabulary()
247 const int row = tabKeywords->rowCount();
248 tabKeywords->setRowCount( row + 1 );
249 QTableWidgetItem *pCell =
nullptr;
252 pCell =
new QTableWidgetItem( tr(
"undefined %1" ).arg( row + 1 ) );
253 tabKeywords->setItem( row, 0, pCell );
256 pCell =
new QTableWidgetItem();
257 tabKeywords->setItem( row, 1, pCell );
260void QgsMetadataWidget::removeSelectedVocabulary()
262 QItemSelectionModel *selectionModel = tabKeywords->selectionModel();
263 const QModelIndexList selectedRows = selectionModel->selectedRows();
264 for (
int i = 0; i < selectedRows.size() ; i++ )
266 tabKeywords->model()->removeRow( selectedRows[i].row() );
270void QgsMetadataWidget::addLicence()
272 QString newLicence = QInputDialog::getItem(
this, tr(
"New Licence" ), tr(
"New Licence" ),
parseLicenses(), 0,
true );
273 if ( tabLicenses->findItems( newLicence, Qt::MatchExactly ).isEmpty() )
275 const int row = tabLicenses->rowCount();
276 tabLicenses->setRowCount( row + 1 );
277 QTableWidgetItem *pCell =
new QTableWidgetItem( newLicence );
278 tabLicenses->setItem( row, 0, pCell );
282void QgsMetadataWidget::removeSelectedLicence()
284 QItemSelectionModel *selectionModel = tabLicenses->selectionModel();
285 const QModelIndexList selectedRows = selectionModel->selectedRows();
286 for (
int i = 0; i < selectedRows.size() ; i++ )
288 tabLicenses->model()->removeRow( selectedRows[i].row() );
292void QgsMetadataWidget::addRight()
294 QString newRight = QInputDialog::getText(
this, tr(
"New Right" ), tr(
"New Right" ) );
295 QStringList existingRights = mRightsModel->stringList();
296 if ( ! existingRights.contains( newRight ) )
298 existingRights.append( newRight );
299 mRightsModel->setStringList( existingRights );
303void QgsMetadataWidget::removeSelectedRight()
305 QItemSelectionModel *selection = listRights->selectionModel();
306 if ( selection->hasSelection() )
308 QModelIndex indexElementSelectionne = selection->currentIndex();
310 QVariant item = mRightsModel->data( indexElementSelectionne, Qt::DisplayRole );
311 QStringList list = mRightsModel->stringList();
312 list.removeOne( item.toString() );
313 mRightsModel->setStringList( list );
317void QgsMetadataWidget::addConstraint()
319 const int row = mConstraintsModel->rowCount();
320 mConstraintsModel->setItem( row, 0,
new QStandardItem( tr(
"undefined %1" ).arg( row + 1 ) ) );
321 mConstraintsModel->setItem( row, 1,
new QStandardItem( tr(
"undefined %1" ).arg( row + 1 ) ) );
324void QgsMetadataWidget::removeSelectedConstraint()
326 const QModelIndexList selectedRows = tabConstraints->selectionModel()->selectedRows();
327 if ( selectedRows.empty() )
329 mConstraintsModel->removeRow( selectedRows[0].row() );
334 if ( ( mCrs.
isValid() ) && ( mLayer ) )
337 spatialExtentSelector->setEnabled(
true );
338 spatialExtentSelector->setOutputCrs( mCrs );
342 lblCurrentCrsStatus->setText( tr(
"Same as layer properties and provider." ) );
346 lblCurrentCrsStatus->setText( tr(
"Same as layer properties but different than the provider." ) );
350 lblCurrentCrsStatus->setText( tr(
"Same as the provider but different than the layer properties." ) );
354 lblCurrentCrsStatus->setText( tr(
"Does not match either layer properties or the provider." ) );
359 lblCurrentCrs->setText( tr(
"CRS: Not set." ) );
360 lblCurrentCrsStatus->setText( QString() );
361 spatialExtentSelector->setEnabled(
false );
365void QgsMetadataWidget::addAddress()
367 const int row = tabAddresses->rowCount();
368 tabAddresses->setRowCount( row + 1 );
369 QTableWidgetItem *pCell =
nullptr;
372 pCell =
new QTableWidgetItem( tr(
"postal" ) );
373 tabAddresses->setItem( row, 0, pCell );
376 tabAddresses->setItem( row, 1,
new QTableWidgetItem() );
379 tabAddresses->setItem( row, 2,
new QTableWidgetItem() );
382 tabAddresses->setItem( row, 3,
new QTableWidgetItem() );
385 tabAddresses->setItem( row, 4,
new QTableWidgetItem() );
388 tabAddresses->setItem( row, 5,
new QTableWidgetItem() );
391void QgsMetadataWidget::removeSelectedAddress()
393 QItemSelectionModel *selectionModel = tabAddresses->selectionModel();
394 const QModelIndexList selectedRows = selectionModel->selectedRows();
395 for (
int i = 0; i < selectedRows.size() ; i++ )
397 tabAddresses->model()->removeRow( selectedRows[i].row() );
401void QgsMetadataWidget::fillCrsFromLayer()
403 mCrs = mLayer->
crs();
407void QgsMetadataWidget::fillCrsFromProvider()
413void QgsMetadataWidget::addLink()
415 const int row = mLinksModel->rowCount();
416 mLinksModel->setItem( row, 0,
new QStandardItem( tr(
"undefined %1" ).arg( row + 1 ) ) );
417 mLinksModel->setItem( row, 1,
new QStandardItem() );
418 mLinksModel->setItem( row, 2,
new QStandardItem() );
419 mLinksModel->setItem( row, 3,
new QStandardItem() );
420 mLinksModel->setItem( row, 4,
new QStandardItem() );
421 mLinksModel->setItem( row, 5,
new QStandardItem() );
422 mLinksModel->setItem( row, 6,
new QStandardItem() );
425void QgsMetadataWidget::removeSelectedLink()
427 const QModelIndexList selectedRows = tabLinks->selectionModel()->selectedRows();
428 if ( selectedRows.empty() )
431 mLinksModel->removeRow( selectedRows[0].row() );
434void QgsMetadataWidget::addHistory()
436 QString newHistory = QInputDialog::getText(
this, tr(
"New History" ), tr(
"New History" ) );
437 QStringList existingHistory = mHistoryModel->stringList();
438 if ( ! existingHistory.contains( newHistory ) )
440 existingHistory.append( newHistory );
441 mHistoryModel->setStringList( existingHistory );
445void QgsMetadataWidget::removeSelectedHistory()
447 QItemSelectionModel *selection = listHistory->selectionModel();
448 if ( selection->hasSelection() )
450 QModelIndex indexElementSelectionne = selection->currentIndex();
452 QVariant item = mHistoryModel->data( indexElementSelectionne, Qt::DisplayRole );
453 QStringList list = mHistoryModel->stringList();
454 list.removeOne( item.toString() );
455 mHistoryModel->setStringList( list );
459void QgsMetadataWidget::fillComboBox()
464 comboType->setEditable(
true );
467 const QStringList &keys = types.keys();
469 for (
const QString &type : keys )
471 comboType->insertItem( i, type );
472 comboType->setItemData( i, types.value( type ), Qt::ToolTipRole );
478 comboLanguage->setEditable(
true );
479 comboLanguage->clear();
481 const QStringList &k = countries.keys();
483 for (
const QString &countryCode : k )
485 comboLanguage->insertItem( i, countryCode );
486 comboLanguage->setItemData( i, countries.value( countryCode ), Qt::ToolTipRole );
491void QgsMetadataWidget::setUiFromMetadata()
494 lineEditParentId->setText( mMetadata->parentIdentifier() );
497 if ( ! mMetadata->identifier().isEmpty() )
499 lineEditIdentifier->setText( mMetadata->identifier() );
503 if ( ! mMetadata->title().isEmpty() )
505 whileBlocking( lineEditTitle )->setText( mMetadata->title() );
509 if ( ! mMetadata->type().isEmpty() )
511 if ( comboType->findText( mMetadata->type() ) == -1 )
513 comboType->addItem( mMetadata->type() );
515 comboType->setCurrentIndex( comboType->findText( mMetadata->type() ) );
519 if ( ! mMetadata->language().isEmpty() )
521 if ( comboLanguage->findText( mMetadata->language() ) == -1 )
523 comboLanguage->addItem( mMetadata->language() );
525 comboLanguage->setCurrentIndex( comboLanguage->findText( mMetadata->language() ) );
529 textEditAbstract->setPlainText( mMetadata->abstract() );
532 mCategoriesModel->setStringList( mMetadata->categories() );
535 tabKeywords->setRowCount( 0 );
536 QMapIterator<QString, QStringList> i( mMetadata->keywords() );
537 while ( i.hasNext() )
541 int currentRow = tabKeywords->rowCount() - 1;
542 tabKeywords->item( currentRow, 0 )->setText( i.key() );
543 tabKeywords->item( currentRow, 1 )->setText( i.value().join( QLatin1Char(
',' ) ) );
549 comboEncoding->setCurrentText( layerMetadata->encoding() );
552 lineEditFees->setText( layerMetadata->fees() );
555 tabLicenses->setRowCount( 0 );
556 const QStringList &licenses = layerMetadata->licenses();
557 for (
const QString &licence : licenses )
559 int currentRow = tabLicenses->rowCount();
560 tabLicenses->setRowCount( currentRow + 1 );
561 QTableWidgetItem *pCell = tabLicenses->item( currentRow, 0 );
564 pCell =
new QTableWidgetItem;
565 tabLicenses->setItem( currentRow, 0, pCell );
567 pCell->setText( licence );
571 mRightsModel->setStringList( layerMetadata->rights() );
574 mConstraintsModel->clear();
575 const QList<QgsLayerMetadata::Constraint> &constraints = layerMetadata->constraints();
578 const int row = mConstraintsModel->rowCount();
579 mConstraintsModel->setItem( row, 0,
new QStandardItem( constraint.type ) );
580 mConstraintsModel->setItem( row, 1,
new QStandardItem( constraint.constraint ) );
584 mCrs = layerMetadata->crs();
588 const QList<QgsLayerMetadata::SpatialExtent> &spatialExtents = layerMetadata->extent().spatialExtents();
589 if ( ! spatialExtents.isEmpty() )
592 spatialExtentSelector->setOutputCrs( spatialExtents.at( 0 ).extentCrs );
593 spatialExtentSelector->setOriginalExtent( spatialExtents.at( 0 ).bounds.toRectangle(), spatialExtents.at( 0 ).extentCrs );
594 spatialExtentSelector->setOutputExtentFromOriginal();
595 spinBoxZMaximum->setValue( spatialExtents.at( 0 ).bounds.zMaximum() );
596 spinBoxZMinimum->setValue( spatialExtents.at( 0 ).bounds.zMinimum() );
600 const QList<QgsDateTimeRange> &temporalExtents = layerMetadata->extent().temporalExtents();
601 if ( ! temporalExtents.isEmpty() )
604 dateTimeFrom->setDateTime( temporalExtents.at( 0 ).begin() );
605 dateTimeTo->setDateTime( temporalExtents.at( 0 ).end() );
609 dateTimeFrom->clear();
615 mLineEditAuthor->setText( projectMetadata->author() );
619 const QList<QgsAbstractMetadataBase::Contact> &contacts = mMetadata->contacts();
620 if ( ! contacts.isEmpty() )
624 lineEditContactName->setText( contact.
name );
625 lineEditContactEmail->setText( contact.
email );
626 lineEditContactFax->setText( contact.
fax );
627 lineEditContactOrganization->setText( contact.
organization );
628 lineEditContactPosition->setText( contact.
position );
629 lineEditContactVoice->setText( contact.
voice );
630 if ( comboContactRole->findText( contact.
role ) == -1 )
632 comboContactRole->addItem( contact.
role );
634 comboContactRole->setCurrentIndex( comboContactRole->findText( contact.
role ) );
635 tabAddresses->setRowCount( 0 );
636 const QList<QgsAbstractMetadataBase::Address> &addresses = contact.
addresses;
639 int currentRow = tabAddresses->rowCount();
640 tabAddresses->setRowCount( currentRow + 1 );
641 tabAddresses->setItem( currentRow, 0,
new QTableWidgetItem( address.type ) );
642 tabAddresses->setItem( currentRow, 1,
new QTableWidgetItem( address.address ) );
643 tabAddresses->setItem( currentRow, 2,
new QTableWidgetItem( address.postalCode ) );
644 tabAddresses->setItem( currentRow, 3,
new QTableWidgetItem( address.city ) );
645 tabAddresses->setItem( currentRow, 4,
new QTableWidgetItem( address.administrativeArea ) );
646 tabAddresses->setItem( currentRow, 5,
new QTableWidgetItem( address.country ) );
651 const QList<QgsAbstractMetadataBase::Link> &links = mMetadata->links();
652 mLinksModel->setRowCount( 0 );
655 const int row = mLinksModel->rowCount();
656 mLinksModel->setItem( row, 0,
new QStandardItem( link.name ) );
657 mLinksModel->setItem( row, 1,
new QStandardItem( link.type ) );
658 mLinksModel->setItem( row, 2,
new QStandardItem( link.url ) );
659 mLinksModel->setItem( row, 3,
new QStandardItem( link.description ) );
660 mLinksModel->setItem( row, 4,
new QStandardItem( link.format ) );
661 mLinksModel->setItem( row, 5,
new QStandardItem( link.mimeType ) );
662 mLinksModel->setItem( row, 6,
new QStandardItem( link.size ) );
666 mHistoryModel->setStringList( mMetadata->history() );
672 mCreationDateTimeEdit2->clear();
677 mPublishedDateTimeEdit->clear();
682 mRevisedDateTimeEdit->clear();
687 mSupersededDateTimeEdit->clear();
703 syncFromCategoriesTabToKeywordsTab();
704 QMap<QString, QStringList> keywords;
705 for (
int i = 0; i < tabKeywords->rowCount() ; i++ )
707 keywords.insert( tabKeywords->item( i, 0 )->text(), tabKeywords->item( i, 1 )->text().split(
',' ) );
717 layerMetadata->
setFees( lineEditFees->text() );
720 QStringList licenses;
721 for (
int i = 0; i < tabLicenses->rowCount() ; i++ )
723 licenses.append( tabLicenses->item( i, 0 )->text() );
728 layerMetadata->
setRights( mRightsModel->stringList() );
731 layerMetadata->
setEncoding( comboEncoding->currentText() );
734 QList<QgsLayerMetadata::Constraint> constraints;
735 for (
int row = 0; row < mConstraintsModel->rowCount() ; row++ )
738 constraint.
type = mConstraintsModel->item( row, 0 )->text();
739 constraint.
constraint = mConstraintsModel->item( row, 1 )->text();
740 constraints.append( constraint );
747 layerMetadata->
setCrs( mCrs );
752 spatialExtent.
bounds =
QgsBox3d( spatialExtentSelector->outputExtent() );
755 spatialExtent.
extentCrs = spatialExtentSelector->outputCrs();
756 QList<QgsLayerMetadata::SpatialExtent> spatialExtents;
757 spatialExtents.append( spatialExtent );
758 QList<QgsDateTimeRange> temporalExtents;
759 temporalExtents.append( QgsDateTimeRange( dateTimeFrom->dateTime(), dateTimeTo->dateTime() ) );
770 projectMetadata->
setAuthor( mLineEditAuthor->text() );
777 QList<QgsAbstractMetadataBase::Contact> contacts = mMetadata->contacts();
778 if ( contacts.size() > 0 )
779 contacts.removeFirst();
781 contact.
email = lineEditContactEmail->text();
782 contact.
position = lineEditContactPosition->text();
783 contact.
fax = lineEditContactFax->text();
784 contact.
voice = lineEditContactVoice->text();
785 contact.
name = lineEditContactName->text();
786 contact.
organization = lineEditContactOrganization->text();
787 contact.
role = comboContactRole->currentText();
788 QList<QgsAbstractMetadataBase::Address> addresses;
789 for (
int i = 0; i < tabAddresses->rowCount() ; i++ )
792 address.
type = tabAddresses->item( i, 0 )->text();
793 address.
address = tabAddresses->item( i, 1 )->text();
794 address.
postalCode = tabAddresses->item( i, 2 )->text();
795 address.
city = tabAddresses->item( i, 3 )->text();
797 address.
country = tabAddresses->item( i, 5 )->text();
798 addresses.append( address );
801 contacts.insert( 0, contact );
805 QList<QgsAbstractMetadataBase::Link> links;
806 for (
int row = 0; row < mLinksModel->rowCount() ; row++ )
809 link.
name = mLinksModel->item( row, 0 )->text();
810 link.
type = mLinksModel->item( row, 1 )->text();
811 link.
url = mLinksModel->item( row, 2 )->text();
812 link.
description = mLinksModel->item( row, 3 )->text();
813 link.
format = mLinksModel->item( row, 4 )->text();
814 link.
mimeType = mLinksModel->item( row, 5 )->text();
815 link.
size = mLinksModel->item( row, 6 )->text();
816 links.append( link );
832 std::unique_ptr< QgsAbstractMetadataBase > md(
metadata() );
834 std::unique_ptr< QgsNativeMetadataBaseValidator > validator;
838 validator = std::make_unique< QgsNativeMetadataValidator>();
842 validator = std::make_unique< QgsNativeProjectMetadataValidator>();
846 QList<QgsAbstractMetadataBaseValidator::ValidationResult> validationResults;
847 bool results = validator->validate( md.get(), validationResults );
854 errors += QLatin1String(
"<b>" ) % result.section;
857 errors += QLatin1Char(
' ' ) % QVariant( result._identifier().toInt() + 1 ).toString();
859 errors += QLatin1String(
"</b>: " ) % result.note % QLatin1String(
"<br />" );
864 errors = tr(
"Ok, it seems valid according to the QGIS Schema." );
868 myStyle.append( QStringLiteral(
"body { margin: 10px; }\n " ) );
869 resultsCheckMetadata->clear();
870 resultsCheckMetadata->document()->setDefaultStyleSheet( myStyle );
871 resultsCheckMetadata->setHtml( errors );
878 QMap<QString, QString> countries;
879 countries.insert( QString(), QString() );
883 if ( !file.open( QIODevice::ReadOnly ) )
885 QgsDebugMsg( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
891 while ( !file.atEnd() )
893 QByteArray line = file.readLine();
894 QList<QByteArray> items = line.split(
',' );
895 countries.insert( QString( items.at( 0 ).constData() ).trimmed(), QString( items.at( 1 ).constData() ).trimmed() );
900 QFile secondFile( path );
901 if ( !secondFile.open( QIODevice::ReadOnly ) )
903 QgsDebugMsg( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
908 secondFile.readLine();
909 while ( !secondFile.atEnd() )
911 QByteArray line = secondFile.readLine();
912 QList<QByteArray> items = line.split(
',' );
913 countries.insert( QString( items.at( 2 ).constData() ).trimmed(), QString( items.at( 0 ).constData() ).trimmed() );
921 QStringList wordList;
922 wordList.append( QString() );
926 if ( !file.open( QIODevice::ReadOnly ) )
928 QgsDebugMsg( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
934 while ( !file.atEnd() )
936 QByteArray line = file.readLine();
937 wordList.append( line.split(
',' ).at( 0 ).trimmed() );
945 QStringList wordList;
946 wordList.append( QString() );
950 if ( !file.open( QIODevice::ReadOnly ) )
952 QgsDebugMsg( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
958 while ( !file.atEnd() )
960 QByteArray line = file.readLine();
961 wordList.append( line.split(
',' ).at( 0 ).trimmed() );
969 QStringList wordList;
970 wordList.append( QString() );
974 if ( !file.open( QIODevice::ReadOnly ) )
976 QgsDebugMsg( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
980 while ( !file.atEnd() )
982 QByteArray line = file.readLine();
983 wordList.append( line.split(
',' ).at( 0 ).trimmed() );
991 QMap<QString, QString> types;
992 types.insert( QString(), QString() );
995 if ( !file.open( QIODevice::ReadOnly ) )
997 QgsDebugMsg( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
1001 types.insert( QString(), QString() );
1002 while ( !file.atEnd() )
1004 QByteArray line = file.readLine();
1005 QList<QByteArray> items = line.split(
';' );
1006 types.insert( items.at( 0 ).constData(), items.at( 1 ).constData() );
1020 return lineEditTitle->text();
1025 if (
title != lineEditTitle->text() )
1051void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab()
1053 if ( mCategoriesModel->rowCount() > 0 )
1055 QList<QTableWidgetItem *> categories = tabKeywords->findItems( QStringLiteral(
"gmd:topicCategory" ), Qt::MatchExactly );
1057 if ( !categories.isEmpty() )
1059 row = categories.at( 0 )->row();
1065 row = tabKeywords->rowCount() - 1;
1066 tabKeywords->item( row, 0 )->setText( QStringLiteral(
"gmd:topicCategory" ) );
1068 tabKeywords->item( row, 1 )->setText( mCategoriesModel->stringList().join( QLatin1Char(
',' ) ) );
1072void QgsMetadataWidget::updatePanel()
1074 int index = tabWidget->currentIndex();
1075 QString currentTabText = tabWidget->widget( index )->objectName();
1076 if ( currentTabText == QLatin1String(
"tabCategoriesDialog" ) )
1080 QList<QTableWidgetItem *> categories = tabKeywords->findItems( QStringLiteral(
"gmd:topicCategory" ), Qt::MatchExactly );
1081 if ( !categories.isEmpty() )
1083 const int row = categories.at( 0 )->row();
1084 mCategoriesModel->setStringList( tabKeywords->item( row, 1 )->text().split(
',' ) );
1088 mCategoriesModel->setStringList( QStringList() );
1091 else if ( currentTabText == QLatin1String(
"tabKeywordsDialog" ) )
1095 syncFromCategoriesTabToKeywordsTab();
1097 else if ( currentTabText == QLatin1String(
"tabValidationDialog" ) )
1103void QgsMetadataWidget::addNewCategory()
1106 QString text = QInputDialog::getText(
this, tr(
"New Category" ),
1107 tr(
"New Category:" ), QLineEdit::Normal,
1109 if ( ok && !text.isEmpty() )
1111 QStringList list = mCategoriesModel->stringList();
1112 if ( ! list.contains( text ) )
1114 list.append( text );
1115 mCategoriesModel->setStringList( list );
1116 mCategoriesModel->sort( 0 );
1121void QgsMetadataWidget::addDefaultCategories()
1123 const QModelIndexList selectedIndexes = listDefaultCategories->selectionModel()->selectedIndexes();
1124 QStringList defaultCategoriesList = mDefaultCategoriesModel->stringList();
1125 QStringList selectedCategories = mCategoriesModel->stringList();
1127 for (
const QModelIndex &selection : selectedIndexes )
1129 QVariant item = mDefaultCategoriesModel->data( selection, Qt::DisplayRole );
1130 defaultCategoriesList.removeOne( item.toString() );
1132 selectedCategories.append( item.toString() );
1135 mDefaultCategoriesModel->setStringList( defaultCategoriesList );
1136 mCategoriesModel->setStringList( selectedCategories );
1137 mCategoriesModel->sort( 0 );
1140void QgsMetadataWidget::removeSelectedCategories()
1142 const QModelIndexList selectedIndexes = listCategories->selectionModel()->selectedIndexes();
1143 QStringList categories = mCategoriesModel->stringList();
1144 QStringList defaultList = mDefaultCategoriesModel->stringList();
1146 for (
const QModelIndex &selection : selectedIndexes )
1148 QVariant item = mCategoriesModel->data( selection, Qt::DisplayRole );
1149 categories.removeOne( item.toString() );
1151 if ( mDefaultCategories.contains( item.toString() ) )
1153 defaultList.append( item.toString() );
1156 mCategoriesModel->setStringList( categories );
1158 mDefaultCategoriesModel->setStringList( defaultList );
1159 mDefaultCategoriesModel->sort( 0 );
1163LinkItemDelegate::LinkItemDelegate( QObject *parent )
1164 : QStyledItemDelegate( parent )
1169QWidget *LinkItemDelegate::createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const
1171 if ( index.column() == 1 )
1174 QComboBox *typeEditor =
new QComboBox( parent );
1175 typeEditor->setEditable(
true );
1176 QStringListModel *model =
new QStringListModel( parent );
1178 typeEditor->setModel( model );
1181 else if ( index.column() == 5 )
1184 QComboBox *mimeEditor =
new QComboBox( parent );
1185 mimeEditor->setEditable(
true );
1186 QStringListModel *model =
new QStringListModel( parent );
1188 mimeEditor->setModel( model );
1192 return QStyledItemDelegate::createEditor( parent, option, index );
1195ConstraintItemDelegate::ConstraintItemDelegate( QObject *parent )
1196 : QStyledItemDelegate( parent )
1201QWidget *ConstraintItemDelegate::createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const
1203 if ( index.column() == 0 )
1206 QComboBox *typeEditor =
new QComboBox( parent );
1207 typeEditor->setEditable(
true );
1209 types << QStringLiteral(
"access" ) << QStringLiteral(
"use" ) << QStringLiteral(
"other" );
1210 QStringListModel *model =
new QStringListModel( parent );
1211 model->setStringList( types );
1212 typeEditor->setModel( model );
1216 return QStyledItemDelegate::createEditor( parent, option, index );
@ Published
Date published.
@ Superseded
Date superseded.
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
static QString metadataPath()
Returns the path to the metadata directory.
A 3-dimensional box composed of x, y, z coordinates.
void setZMinimum(double z) SIP_HOLDGIL
Sets the minimum z value.
void setZMaximum(double z) SIP_HOLDGIL
Sets the maximum z value.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
Base class for all map layer types.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example,...
QgsCoordinateReferenceSystem crs
QgsLayerMetadata metadata
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setMetadata(const QgsProjectMetadata &metadata)
Sets the project's metadata store.
static bool isNull(const QVariant &variant)
Returns true if the specified variant should be considered a NULL value.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.