22#include <QInputDialog>
23#include <QStringListModel>
39 tabWidget->setCurrentIndex( 0 );
42 encodingFrame->setHidden(
true );
44 spinBoxZMinimum->setClearValue( 0 );
45 spinBoxZMaximum->setClearValue( 0 );
48 mDefaultCategories << tr(
"Farming" ) << tr(
"Climatology Meteorology Atmosphere" ) << tr(
"Location" ) << tr(
"Intelligence Military" ) << tr(
"Transportation" ) << tr(
"Structure" ) << tr(
"Boundaries" );
49 mDefaultCategories << tr(
"Inland Waters" ) << tr(
"Planning Cadastre" ) << tr(
"Geoscientific Information" ) << tr(
"Elevation" ) << tr(
"Health" ) << tr(
"Biota" ) << tr(
"Oceans" ) << tr(
"Environment" );
50 mDefaultCategories << tr(
"Utilities Communication" ) << tr(
"Economy" ) << tr(
"Society" ) << tr(
"Imagery Base Maps Earth Cover" );
51 mDefaultCategoriesModel =
new QStringListModel( mDefaultCategories,
this );
52 mDefaultCategoriesModel->sort( 0 );
53 listDefaultCategories->setModel( mDefaultCategoriesModel );
56 mCategoriesModel =
new QStringListModel( listCategories );
57 listCategories->setModel( mCategoriesModel );
60 mRightsModel =
new QStringListModel( listRights );
61 listRights->setModel( mRightsModel );
64 mConstraintsModel =
new QStandardItemModel( tabConstraints );
65 mConstraintsModel->setColumnCount( 2 );
66 QStringList constraintheaders;
67 constraintheaders << tr(
"Type" ) << tr(
"Constraint" );
68 mConstraintsModel->setHorizontalHeaderLabels( constraintheaders );
69 tabConstraints->setModel( mConstraintsModel );
70 tabConstraints->setItemDelegate(
new ConstraintItemDelegate(
this ) );
73 dateTimeFrom->setAllowNull(
true );
74 dateTimeTo->setAllowNull(
true );
77 mLinksModel =
new QStandardItemModel( tabLinks );
78 mLinksModel->setColumnCount( 7 );
79 QStringList headers = QStringList();
80 headers << tr(
"Name" ) << tr(
"Type" ) << tr(
"URL" ) << tr(
"Description" ) << tr(
"Format" ) << tr(
"MIME" ) << tr(
"Size" );
81 mLinksModel->setHorizontalHeaderLabels( headers );
82 tabLinks->setModel( mLinksModel );
83 tabLinks->setItemDelegate(
new LinkItemDelegate(
this ) );
86 mHistoryModel =
new QStringListModel( listHistory );
87 listHistory->setModel( mHistoryModel );
91 mCreationDateTimeEdit,
92 mCreationDateTimeEdit2,
93 mPublishedDateTimeEdit,
95 mSupersededDateTimeEdit
98 w->setAllowNull(
true );
99 w->setNullRepresentation( tr(
"Not set" ) );
103 connect( tabWidget, &QTabWidget::currentChanged,
this, &QgsMetadataWidget::updatePanel );
104 connect( btnAutoSource, &QPushButton::clicked,
this, &QgsMetadataWidget::fillSourceFromLayer );
105 connect( btnAddVocabulary, &QPushButton::clicked,
this, &QgsMetadataWidget::addVocabulary );
106 connect( btnRemoveVocabulary, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedVocabulary );
107 connect( btnAddRight, &QPushButton::clicked,
this, &QgsMetadataWidget::addRight );
108 connect( btnRemoveRight, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedRight );
109 connect( btnAddLicence, &QPushButton::clicked,
this, &QgsMetadataWidget::addLicence );
110 connect( btnRemoveLicence, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedLicence );
111 connect( btnAddConstraint, &QPushButton::clicked,
this, &QgsMetadataWidget::addConstraint );
112 connect( btnRemoveConstraint, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedConstraint );
113 connect( btnSetCrsFromLayer, &QPushButton::clicked,
this, &QgsMetadataWidget::fillCrsFromLayer );
114 connect( btnSetCrsFromProvider, &QPushButton::clicked,
this, &QgsMetadataWidget::fillCrsFromProvider );
115 connect( btnAddAddress, &QPushButton::clicked,
this, &QgsMetadataWidget::addAddress );
116 connect( btnRemoveAddress, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedAddress );
117 connect( btnAddLink, &QPushButton::clicked,
this, &QgsMetadataWidget::addLink );
118 connect( btnRemoveLink, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedLink );
119 connect( btnAddHistory, &QPushButton::clicked,
this, &QgsMetadataWidget::addHistory );
120 connect( btnRemoveHistory, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedHistory );
121 connect( btnNewCategory, &QPushButton::clicked,
this, &QgsMetadataWidget::addNewCategory );
122 connect( btnAddDefaultCategory, &QPushButton::clicked,
this, &QgsMetadataWidget::addDefaultCategories );
123 connect( btnRemoveCategory, &QPushButton::clicked,
this, &QgsMetadataWidget::removeSelectedCategories );
128 btnAutoSource->setEnabled(
false );
129 btnAutoEncoding->setEnabled(
false );
130 btnSetCrsFromLayer->setEnabled(
false );
151 type = tr(
"dataset" );
152 typeUpper = tr(
"Dataset" );
153 mEncodingFrame->show();
154 mAuthorFrame->hide();
155 btnAutoSource->setEnabled( mLayer );
159 type = tr(
"project" );
160 typeUpper = tr(
"Project" );
161 mEncodingFrame->hide();
162 mAuthorFrame->show();
163 tabWidget->removeTab( 4 );
164 tabWidget->removeTab( 3 );
165 btnAutoSource->setEnabled(
true );
168 connect( mCreationDateTimeEdit, &QDateTimeEdit::dateTimeChanged,
this, [ = ](
const QDateTime & value )
170 if ( value.isValid() )
171 mCreationDateTimeEdit2->setDateTime( value );
172 else if ( mCreationDateTimeEdit2->dateTime().isValid() )
173 mCreationDateTimeEdit2->clear();
175 connect( mCreationDateTimeEdit2, &QDateTimeEdit::dateTimeChanged,
this, [ = ](
const QDateTime & value )
177 if ( value.isValid() )
178 mCreationDateTimeEdit->setDateTime( value );
179 else if ( mCreationDateTimeEdit->dateTime().isValid() )
180 mCreationDateTimeEdit->clear();
186 mIdLabel->setText( tr(
"This page describes the basic attribution of the %1. Please use the tooltips for more information." ).arg( type ) );
187 mLabelCategories->setText( tr(
"%1 categories." ).arg( typeUpper ) );
188 mLabelContact->setText( tr(
"Contacts related to the %1." ).arg( type ) );
189 mLabelLinks->setText( tr(
"Links describe ancillary resources and information related to this %1." ).arg( type ) );
190 mLabelHistory->setText( tr(
"History about the %1." ).arg( type ) );
191 labelKeywords->setText( tr(
"<html><head/><body><p>Keywords are optional, and provide a way to provide additional descriptive information about "
192 "the %1. Edits made in the categories tab will update the category entry below. For the concept, we suggest "
193 "to use a standard based vocabulary such as <a href=\"https://www.eionet.europa.eu/gemet/en/inspire-themes/\">"
194 "<span style=\" text-decoration: underline; color:#0000ff;\">GEMET.</span></a></p></body></html>" ).arg( type ) );
195 btnAutoSource->setText( tr(
"Set from %1" ).arg( mMode ==
LayerMetadata ? tr(
"layer" ) : tr(
"project" ) ) );
214 std::unique_ptr< QgsAbstractMetadataBase > md;
218 md = std::make_unique< QgsLayerMetadata >();
222 md = std::make_unique< QgsProjectMetadata >();
230void QgsMetadataWidget::fillSourceFromLayer()
248void QgsMetadataWidget::addVocabulary()
250 const int row = tabKeywords->rowCount();
251 tabKeywords->setRowCount( row + 1 );
252 QTableWidgetItem *pCell =
nullptr;
255 pCell =
new QTableWidgetItem( tr(
"undefined %1" ).arg( row + 1 ) );
256 tabKeywords->setItem( row, 0, pCell );
259 pCell =
new QTableWidgetItem();
260 tabKeywords->setItem( row, 1, pCell );
263void QgsMetadataWidget::removeSelectedVocabulary()
265 QItemSelectionModel *selectionModel = tabKeywords->selectionModel();
266 const QModelIndexList selectedRows = selectionModel->selectedRows();
267 for (
int i = 0; i < selectedRows.size() ; i++ )
269 tabKeywords->model()->removeRow( selectedRows[i].row() );
273void QgsMetadataWidget::addLicence()
275 QString newLicence = QInputDialog::getItem(
this, tr(
"New Licence" ), tr(
"New Licence" ),
parseLicenses(), 0,
true );
276 if ( tabLicenses->findItems( newLicence, Qt::MatchExactly ).isEmpty() )
278 const int row = tabLicenses->rowCount();
279 tabLicenses->setRowCount( row + 1 );
280 QTableWidgetItem *pCell =
new QTableWidgetItem( newLicence );
281 tabLicenses->setItem( row, 0, pCell );
285void QgsMetadataWidget::removeSelectedLicence()
287 QItemSelectionModel *selectionModel = tabLicenses->selectionModel();
288 const QModelIndexList selectedRows = selectionModel->selectedRows();
289 for (
int i = 0; i < selectedRows.size() ; i++ )
291 tabLicenses->model()->removeRow( selectedRows[i].row() );
295void QgsMetadataWidget::addRight()
297 QString newRight = QInputDialog::getText(
this, tr(
"New Right" ), tr(
"New Right" ) );
298 QStringList existingRights = mRightsModel->stringList();
299 if ( ! existingRights.contains( newRight ) )
301 existingRights.append( newRight );
302 mRightsModel->setStringList( existingRights );
306void QgsMetadataWidget::removeSelectedRight()
308 QItemSelectionModel *selection = listRights->selectionModel();
309 if ( selection->hasSelection() )
311 QModelIndex indexElementSelectionne = selection->currentIndex();
313 QVariant item = mRightsModel->data( indexElementSelectionne, Qt::DisplayRole );
314 QStringList list = mRightsModel->stringList();
315 list.removeOne( item.toString() );
316 mRightsModel->setStringList( list );
320void QgsMetadataWidget::addConstraint()
322 const int row = mConstraintsModel->rowCount();
323 mConstraintsModel->setItem( row, 0,
new QStandardItem( tr(
"undefined %1" ).arg( row + 1 ) ) );
324 mConstraintsModel->setItem( row, 1,
new QStandardItem( tr(
"undefined %1" ).arg( row + 1 ) ) );
327void QgsMetadataWidget::removeSelectedConstraint()
329 const QModelIndexList selectedRows = tabConstraints->selectionModel()->selectedRows();
330 if ( selectedRows.empty() )
332 mConstraintsModel->removeRow( selectedRows[0].row() );
337 if ( ( mCrs.
isValid() ) && ( mLayer ) )
340 spatialExtentSelector->setEnabled(
true );
341 spatialExtentSelector->setOutputCrs( mCrs );
345 lblCurrentCrsStatus->setText( tr(
"Same as layer properties and provider." ) );
349 lblCurrentCrsStatus->setText( tr(
"Same as layer properties but different than the provider." ) );
353 lblCurrentCrsStatus->setText( tr(
"Same as the provider but different than the layer properties." ) );
357 lblCurrentCrsStatus->setText( tr(
"Does not match either layer properties or the provider." ) );
362 lblCurrentCrs->setText( tr(
"CRS: Not set." ) );
363 lblCurrentCrsStatus->setText( QString() );
364 spatialExtentSelector->setEnabled(
false );
368void QgsMetadataWidget::addAddress()
370 const int row = tabAddresses->rowCount();
371 tabAddresses->setRowCount( row + 1 );
372 QTableWidgetItem *pCell =
nullptr;
375 pCell =
new QTableWidgetItem( tr(
"postal" ) );
376 tabAddresses->setItem( row, 0, pCell );
379 tabAddresses->setItem( row, 1,
new QTableWidgetItem() );
382 tabAddresses->setItem( row, 2,
new QTableWidgetItem() );
385 tabAddresses->setItem( row, 3,
new QTableWidgetItem() );
388 tabAddresses->setItem( row, 4,
new QTableWidgetItem() );
391 tabAddresses->setItem( row, 5,
new QTableWidgetItem() );
394void QgsMetadataWidget::removeSelectedAddress()
396 QItemSelectionModel *selectionModel = tabAddresses->selectionModel();
397 const QModelIndexList selectedRows = selectionModel->selectedRows();
398 for (
int i = 0; i < selectedRows.size() ; i++ )
400 tabAddresses->model()->removeRow( selectedRows[i].row() );
404void QgsMetadataWidget::fillCrsFromLayer()
406 mCrs = mLayer->
crs();
410void QgsMetadataWidget::fillCrsFromProvider()
416void QgsMetadataWidget::addLink()
418 const int row = mLinksModel->rowCount();
419 mLinksModel->setItem( row, 0,
new QStandardItem( tr(
"undefined %1" ).arg( row + 1 ) ) );
420 mLinksModel->setItem( row, 1,
new QStandardItem() );
421 mLinksModel->setItem( row, 2,
new QStandardItem() );
422 mLinksModel->setItem( row, 3,
new QStandardItem() );
423 mLinksModel->setItem( row, 4,
new QStandardItem() );
424 mLinksModel->setItem( row, 5,
new QStandardItem() );
425 mLinksModel->setItem( row, 6,
new QStandardItem() );
428void QgsMetadataWidget::removeSelectedLink()
430 const QModelIndexList selectedRows = tabLinks->selectionModel()->selectedRows();
431 if ( selectedRows.empty() )
434 mLinksModel->removeRow( selectedRows[0].row() );
437void QgsMetadataWidget::addHistory()
439 QString newHistory = QInputDialog::getText(
this, tr(
"New History" ), tr(
"New History" ) );
440 QStringList existingHistory = mHistoryModel->stringList();
441 if ( ! existingHistory.contains( newHistory ) )
443 existingHistory.append( newHistory );
444 mHistoryModel->setStringList( existingHistory );
448void QgsMetadataWidget::removeSelectedHistory()
450 QItemSelectionModel *selection = listHistory->selectionModel();
451 if ( selection->hasSelection() )
453 QModelIndex indexElementSelectionne = selection->currentIndex();
455 QVariant item = mHistoryModel->data( indexElementSelectionne, Qt::DisplayRole );
456 QStringList list = mHistoryModel->stringList();
457 list.removeOne( item.toString() );
458 mHistoryModel->setStringList( list );
462void QgsMetadataWidget::fillComboBox()
467 comboType->setEditable(
true );
470 const QStringList &keys = types.keys();
472 for (
const QString &type : keys )
474 comboType->insertItem( i, type );
475 comboType->setItemData( i, types.value( type ), Qt::ToolTipRole );
481 comboLanguage->setEditable(
true );
482 comboLanguage->clear();
484 const QStringList &k = countries.keys();
486 for (
const QString &countryCode : k )
488 comboLanguage->insertItem( i, countryCode );
489 comboLanguage->setItemData( i, countries.value( countryCode ), Qt::ToolTipRole );
494void QgsMetadataWidget::setUiFromMetadata()
497 lineEditParentId->setText( mMetadata->parentIdentifier() );
500 if ( ! mMetadata->identifier().isEmpty() )
502 lineEditIdentifier->setText( mMetadata->identifier() );
506 if ( ! mMetadata->title().isEmpty() )
508 whileBlocking( lineEditTitle )->setText( mMetadata->title() );
512 if ( ! mMetadata->type().isEmpty() )
514 if ( comboType->findText( mMetadata->type() ) == -1 )
516 comboType->addItem( mMetadata->type() );
518 comboType->setCurrentIndex( comboType->findText( mMetadata->type() ) );
522 if ( ! mMetadata->language().isEmpty() )
524 if ( comboLanguage->findText( mMetadata->language() ) == -1 )
526 comboLanguage->addItem( mMetadata->language() );
528 comboLanguage->setCurrentIndex( comboLanguage->findText( mMetadata->language() ) );
532 textEditAbstract->setPlainText( mMetadata->abstract() );
535 mCategoriesModel->setStringList( mMetadata->categories() );
538 tabKeywords->setRowCount( 0 );
539 QMapIterator<QString, QStringList> i( mMetadata->keywords() );
540 while ( i.hasNext() )
544 int currentRow = tabKeywords->rowCount() - 1;
545 tabKeywords->item( currentRow, 0 )->setText( i.key() );
546 tabKeywords->item( currentRow, 1 )->setText( i.value().join( QLatin1Char(
',' ) ) );
552 comboEncoding->setCurrentText( layerMetadata->encoding() );
555 lineEditFees->setText( layerMetadata->fees() );
558 tabLicenses->setRowCount( 0 );
559 const QStringList &licenses = layerMetadata->licenses();
560 for (
const QString &licence : licenses )
562 int currentRow = tabLicenses->rowCount();
563 tabLicenses->setRowCount( currentRow + 1 );
564 QTableWidgetItem *pCell = tabLicenses->item( currentRow, 0 );
567 pCell =
new QTableWidgetItem;
568 tabLicenses->setItem( currentRow, 0, pCell );
570 pCell->setText( licence );
574 mRightsModel->setStringList( layerMetadata->rights() );
577 mConstraintsModel->clear();
578 const QList<QgsLayerMetadata::Constraint> &constraints = layerMetadata->constraints();
581 const int row = mConstraintsModel->rowCount();
582 mConstraintsModel->setItem( row, 0,
new QStandardItem( constraint.type ) );
583 mConstraintsModel->setItem( row, 1,
new QStandardItem( constraint.constraint ) );
587 mCrs = layerMetadata->crs();
591 const QList<QgsLayerMetadata::SpatialExtent> &spatialExtents = layerMetadata->extent().spatialExtents();
592 if ( ! spatialExtents.isEmpty() )
595 spatialExtentSelector->setOutputCrs( spatialExtents.at( 0 ).extentCrs );
596 spatialExtentSelector->setOriginalExtent( spatialExtents.at( 0 ).bounds.toRectangle(), spatialExtents.at( 0 ).extentCrs );
597 spatialExtentSelector->setOutputExtentFromOriginal();
598 spinBoxZMaximum->setValue( spatialExtents.at( 0 ).bounds.zMaximum() );
599 spinBoxZMinimum->setValue( spatialExtents.at( 0 ).bounds.zMinimum() );
603 const QList<QgsDateTimeRange> &temporalExtents = layerMetadata->extent().temporalExtents();
604 if ( ! temporalExtents.isEmpty() )
607 dateTimeFrom->setDateTime( temporalExtents.at( 0 ).begin() );
608 dateTimeTo->setDateTime( temporalExtents.at( 0 ).end() );
612 dateTimeFrom->clear();
618 mLineEditAuthor->setText( projectMetadata->author() );
622 const QList<QgsAbstractMetadataBase::Contact> &contacts = mMetadata->contacts();
623 if ( ! contacts.isEmpty() )
627 lineEditContactName->setText( contact.
name );
628 lineEditContactEmail->setText( contact.
email );
629 lineEditContactFax->setText( contact.
fax );
630 lineEditContactOrganization->setText( contact.
organization );
631 lineEditContactPosition->setText( contact.
position );
632 lineEditContactVoice->setText( contact.
voice );
633 if ( comboContactRole->findText( contact.
role ) == -1 )
635 comboContactRole->addItem( contact.
role );
637 comboContactRole->setCurrentIndex( comboContactRole->findText( contact.
role ) );
638 tabAddresses->setRowCount( 0 );
639 const QList<QgsAbstractMetadataBase::Address> &addresses = contact.
addresses;
642 int currentRow = tabAddresses->rowCount();
643 tabAddresses->setRowCount( currentRow + 1 );
644 tabAddresses->setItem( currentRow, 0,
new QTableWidgetItem( address.type ) );
645 tabAddresses->setItem( currentRow, 1,
new QTableWidgetItem( address.address ) );
646 tabAddresses->setItem( currentRow, 2,
new QTableWidgetItem( address.postalCode ) );
647 tabAddresses->setItem( currentRow, 3,
new QTableWidgetItem( address.city ) );
648 tabAddresses->setItem( currentRow, 4,
new QTableWidgetItem( address.administrativeArea ) );
649 tabAddresses->setItem( currentRow, 5,
new QTableWidgetItem( address.country ) );
654 const QList<QgsAbstractMetadataBase::Link> &links = mMetadata->links();
655 mLinksModel->setRowCount( 0 );
658 const int row = mLinksModel->rowCount();
659 mLinksModel->setItem( row, 0,
new QStandardItem( link.name ) );
660 mLinksModel->setItem( row, 1,
new QStandardItem( link.type ) );
661 mLinksModel->setItem( row, 2,
new QStandardItem( link.url ) );
662 mLinksModel->setItem( row, 3,
new QStandardItem( link.description ) );
663 mLinksModel->setItem( row, 4,
new QStandardItem( link.format ) );
664 mLinksModel->setItem( row, 5,
new QStandardItem( link.mimeType ) );
665 mLinksModel->setItem( row, 6,
new QStandardItem( link.size ) );
669 mHistoryModel->setStringList( mMetadata->history() );
675 mCreationDateTimeEdit2->clear();
680 mPublishedDateTimeEdit->clear();
685 mRevisedDateTimeEdit->clear();
690 mSupersededDateTimeEdit->clear();
706 syncFromCategoriesTabToKeywordsTab();
707 QMap<QString, QStringList> keywords;
708 for (
int i = 0; i < tabKeywords->rowCount() ; i++ )
710 keywords.insert( tabKeywords->item( i, 0 )->text(), tabKeywords->item( i, 1 )->text().split(
',' ) );
720 layerMetadata->
setFees( lineEditFees->text() );
723 QStringList licenses;
724 for (
int i = 0; i < tabLicenses->rowCount() ; i++ )
726 licenses.append( tabLicenses->item( i, 0 )->text() );
731 layerMetadata->
setRights( mRightsModel->stringList() );
734 layerMetadata->
setEncoding( comboEncoding->currentText() );
737 QList<QgsLayerMetadata::Constraint> constraints;
738 for (
int row = 0; row < mConstraintsModel->rowCount() ; row++ )
741 constraint.
type = mConstraintsModel->item( row, 0 )->text();
742 constraint.
constraint = mConstraintsModel->item( row, 1 )->text();
743 constraints.append( constraint );
750 layerMetadata->
setCrs( mCrs );
755 spatialExtent.
bounds =
QgsBox3D( spatialExtentSelector->outputExtent() );
758 spatialExtent.
extentCrs = spatialExtentSelector->outputCrs();
759 QList<QgsLayerMetadata::SpatialExtent> spatialExtents;
760 spatialExtents.append( spatialExtent );
761 QList<QgsDateTimeRange> temporalExtents;
762 temporalExtents.append(
QgsDateTimeRange( dateTimeFrom->dateTime(), dateTimeTo->dateTime() ) );
773 projectMetadata->
setAuthor( mLineEditAuthor->text() );
780 QList<QgsAbstractMetadataBase::Contact> contacts = mMetadata->contacts();
781 if ( contacts.size() > 0 )
782 contacts.removeFirst();
784 contact.
email = lineEditContactEmail->text();
785 contact.
position = lineEditContactPosition->text();
786 contact.
fax = lineEditContactFax->text();
787 contact.
voice = lineEditContactVoice->text();
788 contact.
name = lineEditContactName->text();
789 contact.
organization = lineEditContactOrganization->text();
790 contact.
role = comboContactRole->currentText();
791 QList<QgsAbstractMetadataBase::Address> addresses;
792 for (
int i = 0; i < tabAddresses->rowCount() ; i++ )
795 address.
type = tabAddresses->item( i, 0 )->text();
796 address.
address = tabAddresses->item( i, 1 )->text();
797 address.
postalCode = tabAddresses->item( i, 2 )->text();
798 address.
city = tabAddresses->item( i, 3 )->text();
800 address.
country = tabAddresses->item( i, 5 )->text();
801 addresses.append( address );
804 contacts.insert( 0, contact );
808 QList<QgsAbstractMetadataBase::Link> links;
809 for (
int row = 0; row < mLinksModel->rowCount() ; row++ )
812 link.
name = mLinksModel->item( row, 0 )->text();
813 link.
type = mLinksModel->item( row, 1 )->text();
814 link.
url = mLinksModel->item( row, 2 )->text();
815 link.
description = mLinksModel->item( row, 3 )->text();
816 link.
format = mLinksModel->item( row, 4 )->text();
817 link.
mimeType = mLinksModel->item( row, 5 )->text();
818 link.
size = mLinksModel->item( row, 6 )->text();
819 links.append( link );
835 std::unique_ptr< QgsAbstractMetadataBase > md(
metadata() );
837 std::unique_ptr< QgsNativeMetadataBaseValidator > validator;
841 validator = std::make_unique< QgsNativeMetadataValidator>();
845 validator = std::make_unique< QgsNativeProjectMetadataValidator>();
849 QList<QgsAbstractMetadataBaseValidator::ValidationResult> validationResults;
850 bool results = validator->validate( md.get(), validationResults );
857 errors += QLatin1String(
"<b>" ) % result.section;
860 errors += QLatin1Char(
' ' ) % QVariant( result.identifier().toInt() + 1 ).toString();
862 errors += QLatin1String(
"</b>: " ) % result.note % QLatin1String(
"<br />" );
867 errors = tr(
"Ok, it seems valid according to the QGIS Schema." );
871 myStyle.append( QStringLiteral(
"body { margin: 10px; }\n " ) );
872 resultsCheckMetadata->clear();
873 resultsCheckMetadata->document()->setDefaultStyleSheet( myStyle );
874 resultsCheckMetadata->setHtml( errors );
881 QMap<QString, QString> countries;
882 countries.insert( QString(), QString() );
886 if ( !file.open( QIODevice::ReadOnly ) )
888 QgsDebugError( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
894 while ( !file.atEnd() )
896 QByteArray line = file.readLine();
897 QList<QByteArray> items = line.split(
',' );
898 countries.insert( QString( items.at( 0 ).constData() ).trimmed(), QString( items.at( 1 ).constData() ).trimmed() );
903 QFile secondFile( path );
904 if ( !secondFile.open( QIODevice::ReadOnly ) )
906 QgsDebugError( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
911 secondFile.readLine();
912 while ( !secondFile.atEnd() )
914 QByteArray line = secondFile.readLine();
915 QList<QByteArray> items = line.split(
',' );
916 countries.insert( QString( items.at( 2 ).constData() ).trimmed(), QString( items.at( 0 ).constData() ).trimmed() );
924 QStringList wordList;
925 wordList.append( QString() );
929 if ( !file.open( QIODevice::ReadOnly ) )
931 QgsDebugError( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
937 while ( !file.atEnd() )
939 QByteArray line = file.readLine();
940 wordList.append( line.split(
',' ).at( 0 ).trimmed() );
948 QStringList wordList;
949 wordList.append( QString() );
953 if ( !file.open( QIODevice::ReadOnly ) )
955 QgsDebugError( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
961 while ( !file.atEnd() )
963 QByteArray line = file.readLine();
964 wordList.append( line.split(
',' ).at( 0 ).trimmed() );
972 QStringList wordList;
973 wordList.append( QString() );
977 if ( !file.open( QIODevice::ReadOnly ) )
979 QgsDebugError( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
983 while ( !file.atEnd() )
985 QByteArray line = file.readLine();
986 wordList.append( line.split(
',' ).at( 0 ).trimmed() );
994 QMap<QString, QString> types;
995 types.insert( QString(), QString() );
998 if ( !file.open( QIODevice::ReadOnly ) )
1000 QgsDebugError( QStringLiteral(
"Error while opening the CSV file: %1, %2 " ).arg( path, file.errorString() ) );
1004 types.insert( QString(), QString() );
1005 while ( !file.atEnd() )
1007 QByteArray line = file.readLine();
1008 QList<QByteArray> items = line.split(
';' );
1009 types.insert( items.at( 0 ).constData(), items.at( 1 ).constData() );
1023 return lineEditTitle->text();
1028 if (
title != lineEditTitle->text() )
1054void QgsMetadataWidget::syncFromCategoriesTabToKeywordsTab()
1056 if ( mCategoriesModel->rowCount() > 0 )
1058 QList<QTableWidgetItem *> categories = tabKeywords->findItems( QStringLiteral(
"gmd:topicCategory" ), Qt::MatchExactly );
1060 if ( !categories.isEmpty() )
1062 row = categories.at( 0 )->row();
1068 row = tabKeywords->rowCount() - 1;
1069 tabKeywords->item( row, 0 )->setText( QStringLiteral(
"gmd:topicCategory" ) );
1071 tabKeywords->item( row, 1 )->setText( mCategoriesModel->stringList().join( QLatin1Char(
',' ) ) );
1075void QgsMetadataWidget::updatePanel()
1077 int index = tabWidget->currentIndex();
1078 QString currentTabText = tabWidget->widget( index )->objectName();
1079 if ( currentTabText == QLatin1String(
"tabCategoriesDialog" ) )
1083 QList<QTableWidgetItem *> categories = tabKeywords->findItems( QStringLiteral(
"gmd:topicCategory" ), Qt::MatchExactly );
1084 if ( !categories.isEmpty() )
1086 const int row = categories.at( 0 )->row();
1087 mCategoriesModel->setStringList( tabKeywords->item( row, 1 )->text().split(
',' ) );
1091 mCategoriesModel->setStringList( QStringList() );
1094 else if ( currentTabText == QLatin1String(
"tabKeywordsDialog" ) )
1098 syncFromCategoriesTabToKeywordsTab();
1100 else if ( currentTabText == QLatin1String(
"tabValidationDialog" ) )
1106void QgsMetadataWidget::addNewCategory()
1109 QString text = QInputDialog::getText(
this, tr(
"New Category" ),
1110 tr(
"New Category:" ), QLineEdit::Normal,
1112 if ( ok && !text.isEmpty() )
1114 QStringList list = mCategoriesModel->stringList();
1115 if ( ! list.contains( text ) )
1117 list.append( text );
1118 mCategoriesModel->setStringList( list );
1119 mCategoriesModel->sort( 0 );
1124void QgsMetadataWidget::addDefaultCategories()
1126 const QModelIndexList selectedIndexes = listDefaultCategories->selectionModel()->selectedIndexes();
1127 QStringList defaultCategoriesList = mDefaultCategoriesModel->stringList();
1128 QStringList selectedCategories = mCategoriesModel->stringList();
1130 for (
const QModelIndex &selection : selectedIndexes )
1132 QVariant item = mDefaultCategoriesModel->data( selection, Qt::DisplayRole );
1133 defaultCategoriesList.removeOne( item.toString() );
1135 selectedCategories.append( item.toString() );
1138 mDefaultCategoriesModel->setStringList( defaultCategoriesList );
1139 mCategoriesModel->setStringList( selectedCategories );
1140 mCategoriesModel->sort( 0 );
1143void QgsMetadataWidget::removeSelectedCategories()
1145 const QModelIndexList selectedIndexes = listCategories->selectionModel()->selectedIndexes();
1146 QStringList categories = mCategoriesModel->stringList();
1147 QStringList defaultList = mDefaultCategoriesModel->stringList();
1149 for (
const QModelIndex &selection : selectedIndexes )
1151 QVariant item = mCategoriesModel->data( selection, Qt::DisplayRole );
1152 categories.removeOne( item.toString() );
1154 if ( mDefaultCategories.contains( item.toString() ) )
1156 defaultList.append( item.toString() );
1159 mCategoriesModel->setStringList( categories );
1161 mDefaultCategoriesModel->setStringList( defaultList );
1162 mDefaultCategoriesModel->sort( 0 );
1166LinkItemDelegate::LinkItemDelegate( QObject *parent )
1167 : QStyledItemDelegate( parent )
1172QWidget *LinkItemDelegate::createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const
1174 if ( index.column() == 1 )
1177 QComboBox *typeEditor =
new QComboBox( parent );
1178 typeEditor->setEditable(
true );
1179 QStringListModel *model =
new QStringListModel( parent );
1181 typeEditor->setModel( model );
1184 else if ( index.column() == 5 )
1187 QComboBox *mimeEditor =
new QComboBox( parent );
1188 mimeEditor->setEditable(
true );
1189 QStringListModel *model =
new QStringListModel( parent );
1191 mimeEditor->setModel( model );
1195 return QStyledItemDelegate::createEditor( parent, option, index );
1198ConstraintItemDelegate::ConstraintItemDelegate( QObject *parent )
1199 : QStyledItemDelegate( parent )
1204QWidget *ConstraintItemDelegate::createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const
1206 if ( index.column() == 0 )
1209 QComboBox *typeEditor =
new QComboBox( parent );
1210 typeEditor->setEditable(
true );
1212 types << QStringLiteral(
"access" ) << QStringLiteral(
"use" ) << QStringLiteral(
"other" );
1213 QStringListModel *model =
new QStringListModel( parent );
1214 model->setStringList( types );
1215 typeEditor->setModel( model );
1219 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)
Sets the minimum z value.
void setZMaximum(double z)
Sets the maximum z value.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString userFriendlyIdentifier(Qgis::CrsIdentifierType type=Qgis::CrsIdentifierType::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.
QgsCoordinateReferenceSystem crs
QgsLayerMetadata metadata
QString publicSource(bool hidePassword=false) const
Gets a version of the internal layer definition that has sensitive bits removed (for example,...
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, bool silenceNullWarnings=false)
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.
#define QgsDebugError(str)
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.