75#include "moc_qgsvectorlayerproperties.cpp"
81#include <QDesktopServices>
91#include <QColorDialog>
94#include <QRegularExpressionValidator>
105 , mMessageBar( messageBar )
107 , mOriginalSubsetSQL( lyr->subsetString() )
110 connect( pbnQueryBuilder, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnQueryBuilder_clicked );
111 connect( pbnIndex, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnIndex_clicked );
113 connect( pbnUpdateExtents, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnUpdateExtents_clicked );
114 connect( mButtonAddJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonAddJoin_clicked );
115 connect( mButtonEditJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonEditJoin_clicked );
116 connect( mJoinTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsVectorLayerProperties::mJoinTreeWidget_itemDoubleClicked );
117 connect( mButtonRemoveJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonRemoveJoin_clicked );
118 connect( mButtonAddWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonAddWmsDimension_clicked );
119 connect( mButtonEditWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonEditWmsDimension_clicked );
120 connect( mWmsDimensionsTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsVectorLayerProperties::mWmsDimensionsTreeWidget_itemDoubleClicked );
121 connect( mButtonRemoveWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonRemoveWmsDimension_clicked );
122 connect( mSimplifyDrawingGroupBox, &QGroupBox::toggled,
this, &QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled );
123 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsVectorLayerProperties::showHelp );
132 mBtnStyle =
new QPushButton( tr(
"Style" ),
this );
133 QMenu *menuStyle =
new QMenu(
this );
134 mActionLoadStyle =
new QAction( tr(
"Load Style…" ),
this );
137 mActionSaveStyle =
new QAction( tr(
"Save Current Style…" ),
this );
140 mActionSaveMultipleStyles =
new QAction( tr(
"Save Multiple Styles…" ),
this );
141 connect( mActionSaveMultipleStyles, &QAction::triggered,
this, &QgsVectorLayerProperties::saveMultipleStylesAs );
143 mSourceGroupBox->hide();
146 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsVectorLayerProperties::aboutToShowStyleMenu );
147 buttonBox->addButton(
mBtnStyle, QDialogButtonBox::ResetRole );
157 mContext =
mCanvas->createExpressionContext();
168 mMapTipFieldComboBox->setLayer( lyr );
169 mDisplayExpressionWidget->setLayer( lyr );
170 mDisplayExpressionWidget->registerExpressionContextGenerator(
this );
173 mFeaturesSortOrderExpressionWidget->setLayer( lyr );
174 mFeaturesSortOrderExpressionWidget->registerExpressionContextGenerator(
this );
175 connect( mFeaturesSortOrderDirectionButton, &QAbstractButton::clicked,
this, [
this]() {
176 mFeaturesSortOrderDirectionButton->setArrowType( mFeaturesSortOrderDirectionButton->arrowType() == Qt::UpArrow ? Qt::DownArrow : Qt::UpArrow );
179 connect( mMapTipInsertFieldButton, &QAbstractButton::clicked,
this, &QgsVectorLayerProperties::insertField );
180 connect( mMapTipInsertExpressionButton, &QAbstractButton::clicked,
this, &QgsVectorLayerProperties::insertOrEditExpression );
185 mEnableMapTips->setChecked( mLayer->mapTipsEnabled() );
187 QVBoxLayout *layout =
nullptr;
189 if ( mLayer->isSpatial() )
192 layout =
new QVBoxLayout( labelingFrame );
193 layout->setContentsMargins( 0, 0, 0, 0 );
195 labelingDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
197 layout->addWidget( labelingDialog );
198 labelingFrame->setLayout( layout );
201 layout =
new QVBoxLayout( mMaskingFrame );
202 layout->setContentsMargins( 0, 0, 0, 0 );
203 mMaskingWidget =
new QgsMaskingWidget( mMaskingFrame );
204 mMaskingWidget->setLayer( mLayer );
205 mMaskingWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
206 layout->addWidget( mMaskingWidget );
207 mMaskingFrame->setLayout( layout );
211 labelingDialog =
nullptr;
212 mOptsPage_Labels->setEnabled(
false );
213 mOptsPage_Masks->setEnabled(
false );
214 mGeomGroupBox->setEnabled(
false );
215 mGeomGroupBox->setVisible(
false );
216 mCrsGroupBox->setEnabled(
false );
217 mCrsGroupBox->setVisible(
false );
221 QVBoxLayout *actionLayout =
new QVBoxLayout( actionOptionsFrame );
222 actionLayout->setContentsMargins( 0, 0, 0, 0 );
224 mActionDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
225 actionLayout->addWidget( mActionDialog );
228 mSourceFieldsPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
229 mSourceFieldsFrame->setLayout(
new QVBoxLayout( mSourceFieldsFrame ) );
230 mSourceFieldsFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
231 mSourceFieldsFrame->layout()->addWidget( mSourceFieldsPropertiesDialog );
236 mAttributesFormPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
237 mAttributesFormFrame->setLayout(
new QVBoxLayout( mAttributesFormFrame ) );
238 mAttributesFormFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
239 mAttributesFormFrame->layout()->addWidget( mAttributesFormPropertiesDialog );
242 QVBoxLayout *metadataLayout =
new QVBoxLayout( metadataFrame );
243 metadataLayout->setContentsMargins( 0, 0, 0, 0 );
245 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
246 mMetadataWidget->setMapCanvas(
mCanvas );
247 metadataLayout->addWidget( mMetadataWidget );
248 metadataFrame->setLayout( metadataLayout );
250 QVBoxLayout *temporalLayout =
new QVBoxLayout( temporalFrame );
251 temporalLayout->setContentsMargins( 0, 0, 0, 0 );
253 temporalLayout->addWidget( mTemporalWidget );
257 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
258 QMenu *menuMetadata =
new QMenu(
this );
261 menuMetadata->addSeparator();
265 buttonBox->addButton(
mBtnMetadata, QDialogButtonBox::ResetRole );
267 mSelectionColorButton->setAllowOpacity(
true );
268 mSelectionColorButton->setColorDialogTitle( tr(
"Override Selection Color" ) );
271 mSelectionColorButton->setColor(
mCanvas->selectionColor() );
272 mSelectionColorButton->setDefaultColor(
mCanvas->selectionColor() );
274 connect( mRadioOverrideSelectionColor, &QRadioButton::toggled, mSelectionColorButton, &QWidget::setEnabled );
275 mSelectionColorButton->setEnabled(
false );
276 connect( mRadioOverrideSelectionSymbol, &QRadioButton::toggled, mSelectionSymbolButton, &QWidget::setEnabled );
277 switch ( mLayer->geometryType() )
293 mSelectionSymbolButton->setEnabled(
false );
294 mRadioDefaultSelectionColor->setChecked(
true );
297 QVBoxLayout *diagLayout =
new QVBoxLayout( mDiagramFrame );
298 diagLayout->setContentsMargins( 0, 0, 0, 0 );
300 diagramPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
302 diagLayout->addWidget( diagramPropertiesDialog );
303 mDiagramFrame->setLayout( diagLayout );
307 if ( mLayer->dataProvider() )
313 pbnIndex->setEnabled(
false );
317 pbnIndex->setEnabled(
false );
318 pbnIndex->setText( tr(
"Spatial Index Exists" ) );
324 QString enc = mLayer->dataProvider()->encoding();
325 int encindex = cboProviderEncoding->findText( enc );
328 cboProviderEncoding->insertItem( 0, enc );
331 cboProviderEncoding->setCurrentIndex( encindex );
333 else if ( mLayer->providerType() == QLatin1String(
"ogr" ) )
337 cboProviderEncoding->addItem( mLayer->dataProvider()->encoding() );
338 cboProviderEncoding->setEnabled(
false );
343 mDataSourceEncodingFrame->hide();
347 mCrsSelector->setCrs( mLayer->crs() );
350 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
353 addJoinToTreeWidget( join );
356 mOldJoins = mLayer->vectorJoins();
359 mLegendWidget->setMapCanvas(
mCanvas );
360 mLegendWidget->setLayer( mLayer );
361 mLegendConfigEmbeddedWidget->setLayer( mLayer );
365 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &wmsDims = serverProperties->
wmsDimensions();
368 addWmsDimensionInfoToTreeWidget( dim );
372 myStyle.append( QStringLiteral(
"body { margin: 10px; }\n " ) );
373 teMetadataViewer->clear();
374 teMetadataViewer->document()->setDefaultStyleSheet( myStyle );
375 teMetadataViewer->setOpenLinks(
false );
381 if ( !settings.
contains( QStringLiteral(
"/Windows/VectorLayerProperties/tab" ) ) )
383 settings.
setValue( QStringLiteral(
"Windows/VectorLayerProperties/tab" ),
mOptStackedWidget->indexOf( mOptsPage_Style ) );
386 QList<QgsMapLayer *> dependencySources;
387 const QSet<QgsMapLayerDependency> constDependencies = mLayer->dependencies();
392 dependencySources << layer;
397 mLayersDependenciesTreeModel->setCheckedLayers( dependencySources );
398 connect(
QgsProject::instance(), &QObject::destroyed,
this, [
this] { mLayersDependenciesTreeView->setModel(
nullptr ); } );
399 mLayersDependenciesTreeView->setModel( mLayersDependenciesTreeModel );
401 mRefreshSettingsWidget->setLayer( mLayer );
402 mMapLayerServerPropertiesWidget->setHasWfsTitle(
true );
403 mMapLayerServerPropertiesWidget->setServerProperties( mLayer->serverProperties() );
406 QMenu *menu =
new QMenu(
this );
408 mAuxiliaryLayerActionNew =
new QAction( tr(
"Create" ),
this );
409 menu->addAction( mAuxiliaryLayerActionNew );
410 connect( mAuxiliaryLayerActionNew, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerNew );
412 mAuxiliaryLayerActionClear =
new QAction( tr(
"Clear" ),
this );
413 menu->addAction( mAuxiliaryLayerActionClear );
414 connect( mAuxiliaryLayerActionClear, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerClear );
416 mAuxiliaryLayerActionDelete =
new QAction( tr(
"Delete" ),
this );
417 menu->addAction( mAuxiliaryLayerActionDelete );
418 connect( mAuxiliaryLayerActionDelete, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerDelete );
420 mAuxiliaryLayerActionExport =
new QAction( tr(
"Export" ),
this );
421 menu->addAction( mAuxiliaryLayerActionExport );
422 connect( mAuxiliaryLayerActionExport, &QAction::triggered,
this, [
this] { emit
exportAuxiliaryLayer( mLayer->auxiliaryLayer() ); } );
424 mAuxiliaryStorageActions->setMenu( menu );
426 connect( mAuxiliaryStorageFieldsDeleteBtn, &QPushButton::clicked,
this, &QgsVectorLayerProperties::onAuxiliaryLayerDeleteField );
427 connect( mAuxiliaryStorageFieldsAddBtn, &QPushButton::clicked,
this, &QgsVectorLayerProperties::onAuxiliaryLayerAddField );
429 updateAuxiliaryStoragePage();
431 mOptsPage_Information->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#information-properties" ) );
432 mOptsPage_Source->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#source-properties" ) );
433 mOptsPage_Style->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#symbology-properties" ) );
434 mOptsPage_Labels->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#labels-properties" ) );
435 mOptsPage_Masks->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#masks-properties" ) );
436 mOptsPage_Diagrams->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#diagrams-properties" ) );
437 mOptsPage_SourceFields->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#fields-properties" ) );
438 mOptsPage_AttributesForm->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#attributes-form-properties" ) );
439 mOptsPage_Joins->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#joins-properties" ) );
440 mOptsPage_AuxiliaryStorage->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#auxiliary-storage-properties" ) );
441 mOptsPage_Actions->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#actions-properties" ) );
442 mOptsPage_Display->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#display-properties" ) );
443 mOptsPage_Rendering->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#rendering-properties" ) );
444 mOptsPage_Temporal->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#temporal-properties" ) );
445 mOptsPage_Variables->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#variables-properties" ) );
446 mOptsPage_Metadata->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#metadata-properties" ) );
447 mOptsPage_DataDependencies->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#dependencies-properties" ) );
448 mOptsPage_Legend->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#legend-properties" ) );
449 mOptsPage_Server->setProperty(
"helpPage", QStringLiteral(
"working_with_vector/vector_properties.html#qgis-server-properties" ) );
464 setPbnQueryBuilderEnabled();
467void QgsVectorLayerProperties::insertField()
471 if ( mMapTipFieldComboBox->currentField().isEmpty() )
473 QString expression = QStringLiteral(
"[%\"" );
474 expression += mMapTipFieldComboBox->currentField();
475 expression += QLatin1String(
"\"%]" );
477 mMapTipWidget->insertText( expression );
480void QgsVectorLayerProperties::insertOrEditExpression()
483 int selectionStart = mMapTipWidget->selectionStart();
484 int selectionEnd = mMapTipWidget->selectionEnd();
488 QgsExpressionBuilderDialog exprDlg( mLayer, expression,
this, QStringLiteral(
"generic" ), context );
490 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
491 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
492 mMapTipWidget->insertText(
"[%" + exprDlg.expressionText().trimmed() +
"%]" );
494 mMapTipWidget->setLinearSelection( selectionStart, selectionEnd );
499 if ( !mSourceWidget )
504 QHBoxLayout *layout =
new QHBoxLayout();
505 layout->addWidget( mSourceWidget );
506 mSourceGroupBox->setLayout( layout );
507 if ( !mSourceWidget->groupTitle().isEmpty() )
508 mSourceGroupBox->setTitle( mSourceWidget->groupTitle() );
510 mSourceGroupBox->show();
513 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
514 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
521 mSourceWidget->setMapCanvas(
mCanvas );
522 mSourceWidget->setSourceUri( mLayer->source() );
526 mLayerOrigNameLineEdit->setText( mLayer->name() );
527 mBackupCrs = mLayer->crs();
530 mSubsetGroupBox->setEnabled(
true );
531 txtSubsetSQL->setText( mLayer->subsetString() );
537 txtSubsetSQL->setReadOnly(
true );
538 txtSubsetSQL->setCaretWidth( 0 );
539 txtSubsetSQL->setCaretLineVisible(
false );
540 setPbnQueryBuilderEnabled();
541 if ( mLayer->dataProvider() && !mLayer->dataProvider()->supportsSubsetString() )
544 mSubsetGroupBox->hide();
547 mDisplayExpressionWidget->setField( mLayer->displayExpression() );
548 mEnableMapTips->setChecked( mLayer->mapTipsEnabled() );
549 mMapTipWidget->setText( mLayer->mapTipTemplate() );
551 mFeaturesSortOrderExpressionWidget->setField( mLayer->attributeTableConfig().sortExpression() );
552 mFeaturesSortOrderDirectionButton->setArrowType( mLayer->attributeTableConfig().sortOrder() == Qt::AscendingOrder ? Qt::UpArrow : Qt::DownArrow );
555 mScaleRangeWidget->setScaleRange( mLayer->minimumScale(), mLayer->maximumScale() );
556 mScaleVisibilityGroupBox->setChecked( mLayer->hasScaleBasedVisibility() );
557 mScaleRangeWidget->setMapCanvas(
mCanvas );
559 mUseReferenceScaleGroupBox->setChecked( mLayer->renderer() && mLayer->renderer()->referenceScale() > 0 );
560 mReferenceScaleWidget->setShowCurrentScaleButton(
true );
561 mReferenceScaleWidget->setMapCanvas(
mCanvas );
562 if ( mUseReferenceScaleGroupBox->isChecked() )
563 mReferenceScaleWidget->setScale( mLayer->renderer()->referenceScale() );
565 mReferenceScaleWidget->setScale(
mCanvas->scale() );
570 mSimplifyDrawingSpinBox->setValue( simplifyMethod.
threshold() );
571 mSimplifyDrawingSpinBox->setClearValue( 1.0 );
576 mSelectionColorButton->setColor( selectionProperties->
selectionColor() );
580 mSelectionSymbolButton->setSymbol( symbol->clone() );
585 mRadioDefaultSelectionColor->setChecked(
true );
592 mRadioOverrideSelectionColor->setChecked(
true );
596 mRadioDefaultSelectionColor->setChecked(
true );
604 mRadioOverrideSelectionSymbol->setChecked(
true );
608 mRadioDefaultSelectionColor->setChecked(
true );
613 QString remark = QStringLiteral(
" (%1)" ).arg( tr(
"Not supported" ) );
617 mSimplifyDrawingAtProvider->setChecked(
false );
618 mSimplifyDrawingAtProvider->setEnabled(
false );
619 if ( !mSimplifyDrawingAtProvider->text().endsWith( remark ) )
620 mSimplifyDrawingAtProvider->setText( mSimplifyDrawingAtProvider->text().append( remark ) );
625 mSimplifyDrawingAtProvider->setEnabled( mSimplifyDrawingGroupBox->isChecked() );
626 if ( mSimplifyDrawingAtProvider->text().endsWith( remark ) )
628 QString newText = mSimplifyDrawingAtProvider->text();
629 newText.chop( remark.size() );
630 mSimplifyDrawingAtProvider->setText( newText );
637 mSimplifyDrawingGroupBox->setChecked(
false );
638 mSimplifyDrawingGroupBox->setEnabled(
false );
645 mSimplifyAlgorithmComboBox->setCurrentIndex( mSimplifyAlgorithmComboBox->findData( QVariant::fromValue( simplifyMethod.
simplifyAlgorithm() ) ) );
648 myScalesList.append( QStringLiteral(
"1:1" ) );
649 mSimplifyMaximumScaleComboBox->updateScales( myScalesList );
650 mSimplifyMaximumScaleComboBox->setScale( simplifyMethod.
maximumScale() );
652 mForceRasterCheckBox->setChecked( mLayer->renderer() && mLayer->renderer()->forceRasterRender() );
654 mRefreshSettingsWidget->syncToLayer();
655 mMapLayerServerPropertiesWidget->sync();
657 mRefreshLayerNotificationCheckBox->setChecked( mLayer->isRefreshOnNotifyEnabled() );
658 mNotificationMessageCheckBox->setChecked( !mLayer->refreshOnNotifyMessage().isEmpty() );
659 mNotifyMessageValueLineEdit->setText( mLayer->refreshOnNotifyMessage() );
663 updateSymbologyPage();
665 mActionDialog->init( *mLayer->actions(), mLayer->attributeTableConfig() );
667 if ( labelingDialog )
668 labelingDialog->adaptToLayer();
670 mSourceFieldsPropertiesDialog->init();
671 mAttributesFormPropertiesDialog->init();
674 updateVariableEditor();
676 if ( diagramPropertiesDialog )
677 diagramPropertiesDialog->syncToOwnLayer();
682 page->syncToLayer( mLayer );
685 mMetadataWidget->setMetadata( &mLayer->metadata() );
687 mTemporalWidget->syncToLayer();
689 mLegendWidget->setLayer( mLayer );
694 if ( labelingDialog )
696 labelingDialog->writeSettingsToLayer();
698 mBackupCrs = mLayer->crs();
700 mLegendWidget->applyToLayer();
701 mLegendConfigEmbeddedWidget->applyToLayer();
704 mMetadataWidget->acceptMetadata();
705 mMetadataFilled =
false;
708 if ( mMaskingWidget )
709 mMaskingWidget->apply();
712 mLayer->setScaleBasedVisibility( mScaleVisibilityGroupBox->isChecked() );
713 mLayer->setMaximumScale( mScaleRangeWidget->maximumScale() );
714 mLayer->setMinimumScale( mScaleRangeWidget->minimumScale() );
717 if ( mLayer->dataProvider() )
721 mLayer->setProviderEncoding( cboProviderEncoding->currentText() );
725 mLayer->setDisplayExpression( mDisplayExpressionWidget->asExpression() );
726 mLayer->setMapTipsEnabled( mEnableMapTips->isChecked() );
727 mLayer->setMapTipTemplate( mMapTipWidget->text() );
731 config.
setSortOrder( mFeaturesSortOrderDirectionButton->arrowType() == Qt::UpArrow ? Qt::AscendingOrder : Qt::DescendingOrder );
732 mLayer->setAttributeTableConfig( config );
734 mLayer->actions()->clearActions();
735 const auto constActions = mActionDialog->actions();
736 for (
const QgsAction &action : constActions )
738 mLayer->actions()->addAction( action );
741 attributeTableConfig.
update( mLayer->fields() );
743 QVector<QgsAttributeTableConfig::ColumnConfig> columns = attributeTableConfig.
columns();
745 for (
int i = 0; i < columns.size(); ++i )
749 columns[i].hidden = !mActionDialog->showWidgetInAttributeTable();
755 mLayer->setAttributeTableConfig( attributeTableConfig );
757 mLayer->setName( mLayerOrigNameLineEdit->text() );
759 mAttributesFormPropertiesDialog->apply();
760 mSourceFieldsPropertiesDialog->apply();
763 mTemporalWidget->saveTemporalProperties();
765 if ( mLayer->renderer() )
772 diagramPropertiesDialog->apply();
780 if ( mMapLayerServerPropertiesWidget->save() )
781 mMetadataFilled =
false;
785 if ( mSimplifyDrawingGroupBox->isChecked() )
788 if ( mSimplifyDrawingSpinBox->value() > 1 )
794 simplifyMethod.
setThreshold( mSimplifyDrawingSpinBox->value() );
796 simplifyMethod.
setMaximumScale( mSimplifyMaximumScaleComboBox->scale() );
797 mLayer->setSimplifyMethod( simplifyMethod );
799 if ( mLayer->renderer() )
801 mLayer->renderer()->setForceRasterRender( mForceRasterCheckBox->isChecked() );
802 mLayer->renderer()->setReferenceScale( mUseReferenceScaleGroupBox->isChecked() ? mReferenceScaleWidget->scale() : -1 );
806 if ( mSelectionColorButton->color() != mSelectionColorButton->defaultColor() )
810 if (
QgsSymbol *symbol = mSelectionSymbolButton->symbol() )
813 if ( mRadioOverrideSelectionSymbol->isChecked() )
817 else if ( mRadioOverrideSelectionColor->isChecked() )
826 mRefreshSettingsWidget->saveToLayer();
828 mLayer->setRefreshOnNotifyEnabled( mRefreshLayerNotificationCheckBox->isChecked() );
829 mLayer->setRefreshOnNofifyMessage( mNotificationMessageCheckBox->isChecked() ? mNotifyMessageValueLineEdit->text() : QString() );
831 mOldJoins = mLayer->vectorJoins();
835 updateVariableEditor();
838 QSet<QgsMapLayerDependency> deps;
839 const auto checkedLayers = mLayersDependenciesTreeModel->checkedLayers();
842 if ( !mLayer->setDependencies( deps ) )
844 QMessageBox::warning(
nullptr, tr(
"Save Dependency" ), tr(
"This configuration introduces a cycle in data dependencies and will be ignored." ) );
853 bool dialogNeedsResync =
false;
856 const QString newSource = mSourceWidget->sourceUri();
857 if ( newSource != mLayer->source() )
864 dialogNeedsResync =
true;
870 mSubsetGroupBox->setEnabled(
true );
871 if ( txtSubsetSQL->text() != mLayer->subsetString() )
874 mLayer->setSubsetString( txtSubsetSQL->text() );
875 mMetadataFilled =
false;
877 dialogNeedsResync =
true;
879 mOriginalSubsetSQL = mLayer->subsetString();
881 if ( dialogNeedsResync )
884 mLayer->triggerRepaint();
886 mProjectDirtyBlocker.reset();
893 if ( mOldJoins != mLayer->vectorJoins() )
898 const auto constVectorJoins = mLayer->vectorJoins();
900 mLayer->removeJoin( info.joinLayerId() );
903 mLayer->addJoin( info );
906 if ( mOriginalSubsetSQL != mLayer->subsetString() )
911 mLayer->setSubsetString( mOriginalSubsetSQL );
920 if ( backupCrs != mLayer->crs() )
921 mLayer->setCrs( backupCrs );
924void QgsVectorLayerProperties::pbnQueryBuilder_clicked()
933 if ( dialog->exec() )
946void QgsVectorLayerProperties::pbnIndex_clicked()
948 QgsVectorDataProvider *pr = mLayer->dataProvider();
951 setCursor( Qt::WaitCursor );
953 setCursor( Qt::ArrowCursor );
956 pbnIndex->setEnabled(
false );
957 pbnIndex->setText( tr(
"Spatial Index Exists" ) );
958 QMessageBox::information(
this, tr(
"Spatial Index" ), tr(
"Creation of spatial index successful" ) );
962 QMessageBox::warning(
this, tr(
"Spatial Index" ), tr(
"Creation of spatial index failed" ) );
967QString QgsVectorLayerProperties::htmlMetadata()
969 return mLayer->htmlMetadata();
975 mLayer->setCrs( crs );
976 mMetadataFilled =
false;
977 mMetadataWidget->crsChanged();
980void QgsVectorLayerProperties::saveMultipleStylesAs()
982 QgsMapLayerSaveStyleDialog dlg( mLayer );
983 dlg.setSaveOnlyCurrentStyle(
false );
984 QgsSettings settings;
991 const QString originalStyle { mLayer->styleManager()->currentStyle() };
992 const QListWidget *stylesWidget { dlg.stylesWidget() };
995 QStringList stylesSelected;
996 for (
int i = 0; i < stylesWidget->count(); i++ )
998 if ( stylesWidget->item( i )->checkState() == Qt::CheckState::Checked )
1000 stylesSelected.push_back( stylesWidget->item( i )->text() );
1004 if ( !stylesSelected.isEmpty() )
1007 for (
const QString &styleName : std::as_const( stylesSelected ) )
1009 bool defaultLoadedFlag =
false;
1011 StyleType type = dlg.currentStyleType();
1012 mLayer->styleManager()->setCurrentStyle( styleName );
1019 const QString filePath { dlg.outputFilePath() };
1020 const QFileInfo fi { filePath };
1022 if ( styleIndex > 0 && stylesSelected.count() > 1 )
1025 while ( QFile::exists( safePath ) )
1027 const QFileInfo fi { safePath };
1028 safePath = QString( safePath ).replace(
'.' + fi.completeSuffix(), QStringLiteral(
"_%1.%2" ).arg( QString::number( i ), fi.completeSuffix() ) );
1033 message = mLayer->saveNamedStyle( safePath, defaultLoadedFlag, dlg.styleCategories() );
1035 message = mLayer->saveSldStyle( safePath, defaultLoadedFlag );
1038 if ( defaultLoadedFlag )
1045 QMessageBox::information(
this, tr(
"Save Style" ), message );
1052 QString infoWindowTitle = QObject::tr(
"Save style '%1' to DB (%2)" )
1053 .arg( styleName, mLayer->providerType() );
1056 QgsMapLayerSaveStyleDialog::SaveToDbSettings dbSettings = dlg.saveToDbSettings();
1059 QString name { dbSettings.
name };
1060 if ( name.isEmpty() )
1066 name += QStringLiteral(
"_%1" ).arg( styleName );
1067 QStringList ids, names, descriptions;
1068 mLayer->listStylesInDatabase( ids, names, descriptions, msgError );
1070 while ( names.contains( name ) )
1072 name = QStringLiteral(
"%1 %2" ).arg( name, QString::number( i ) );
1077 QString errorMessage;
1080 if ( QMessageBox::question(
nullptr, QObject::tr(
"Save style in database" ), QObject::tr(
"A matching style already exists in the database for this layer. Do you want to overwrite it?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No )
1085 else if ( !errorMessage.isEmpty() )
1087 QMessageBox::warning(
this, infoWindowTitle, errorMessage );
1093 if ( !msgError.isNull() )
1095 QMessageBox::warning(
this, infoWindowTitle, msgError );
1099 QMessageBox::information(
this, infoWindowTitle, tr(
"Style '%1' saved" ).arg( styleName ) );
1109 mLayer->styleManager()->setCurrentStyle( originalStyle );
1114void QgsVectorLayerProperties::aboutToShowStyleMenu()
1117 QMenu *m = qobject_cast<QMenu *>( sender() );
1120 m->addAction( mActionLoadStyle );
1121 m->addAction( mActionSaveStyle );
1124 if ( mLayer->styleManager()->styles().count() > 1 )
1126 mActionSaveStyle->setText( tr(
"Save Current Style…" ) );
1127 m->addAction( mActionSaveMultipleStyles );
1131 mActionSaveStyle->setText( tr(
"Save Style…" ) );
1143void QgsVectorLayerProperties::mButtonAddJoin_clicked()
1148 QList<QgsMapLayer *> joinedLayers;
1149 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
1150 joinedLayers.reserve( joins.size() );
1151 for (
int i = 0; i < joins.size(); ++i )
1153 joinedLayers.append( joins[i].joinLayer() );
1156 QgsJoinDialog d( mLayer, joinedLayers );
1157 if ( d.exec() == QDialog::Accepted )
1159 QgsVectorLayerJoinInfo info = d.joinInfo();
1161 if ( d.createAttributeIndex() )
1163 QgsVectorLayer *joinLayer = info.
joinLayer();
1169 mLayer->addJoin( info );
1170 addJoinToTreeWidget( info );
1171 setPbnQueryBuilderEnabled();
1172 mSourceFieldsPropertiesDialog->init();
1173 mAttributesFormPropertiesDialog->init();
1177void QgsVectorLayerProperties::mButtonEditJoin_clicked()
1179 QTreeWidgetItem *currentJoinItem = mJoinTreeWidget->currentItem();
1180 mJoinTreeWidget_itemDoubleClicked( currentJoinItem, 0 );
1183void QgsVectorLayerProperties::mJoinTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int )
1185 if ( !mLayer || !item )
1191 QTreeWidgetItem *currentJoinItem = item;
1192 if ( item->parent() )
1194 currentJoinItem = item->parent();
1198 QList<QgsMapLayer *> joinedLayers;
1199 QString joinLayerId = currentJoinItem->data( 0, Qt::UserRole ).toString();
1200 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
1202 for (
int i = 0; i < joins.size(); ++i )
1204 QgsVectorLayer *joinLayer = joins[i].joinLayer();
1208 if ( joinLayer->
id() == joinLayerId )
1215 joinedLayers.append( joinLayer );
1223 QgsJoinDialog d( mLayer, joinedLayers );
1224 d.setWindowTitle( tr(
"Edit Vector Join" ) );
1225 d.setJoinInfo( joins[j] );
1227 if ( d.exec() == QDialog::Accepted )
1229 QgsVectorLayerJoinInfo info = d.joinInfo();
1232 mLayer->removeJoin( joinLayerId );
1233 int idx = mJoinTreeWidget->indexOfTopLevelItem( item );
1234 mJoinTreeWidget->takeTopLevelItem( idx );
1239 if ( d.createAttributeIndex() )
1241 QgsVectorLayer *joinLayer = info.
joinLayer();
1247 mLayer->addJoin( info );
1248 addJoinToTreeWidget( info, idx );
1250 setPbnQueryBuilderEnabled();
1251 mSourceFieldsPropertiesDialog->init();
1252 mAttributesFormPropertiesDialog->init();
1256void QgsVectorLayerProperties::addJoinToTreeWidget(
const QgsVectorLayerJoinInfo &join,
const int insertIndex )
1258 QTreeWidgetItem *joinItem =
new QTreeWidgetItem();
1259 joinItem->setFlags( Qt::ItemIsEnabled );
1261 QgsVectorLayer *joinLayer = join.
joinLayer();
1262 if ( !mLayer || !joinLayer )
1267 joinItem->setText( 0, tr(
"Join layer" ) );
1268 if ( mLayer->auxiliaryLayer() && mLayer->auxiliaryLayer()->id() == join.
joinLayerId() )
1273 joinItem->setText( 1, joinLayer->
name() );
1275 QFont f = joinItem->font( 0 );
1277 joinItem->setFont( 0, f );
1278 joinItem->setFont( 1, f );
1280 joinItem->setData( 0, Qt::UserRole, join.
joinLayerId() );
1282 QTreeWidgetItem *childJoinField =
new QTreeWidgetItem();
1283 childJoinField->setText( 0, tr(
"Join field" ) );
1285 childJoinField->setFlags( Qt::ItemIsEnabled );
1286 joinItem->addChild( childJoinField );
1288 QTreeWidgetItem *childTargetField =
new QTreeWidgetItem();
1289 childTargetField->setText( 0, tr(
"Target field" ) );
1291 joinItem->addChild( childTargetField );
1293 QTreeWidgetItem *childMemCache =
new QTreeWidgetItem();
1294 childMemCache->setText( 0, tr(
"Cache join layer in virtual memory" ) );
1296 childMemCache->setText( 1, QChar( 0x2714 ) );
1297 joinItem->addChild( childMemCache );
1299 QTreeWidgetItem *childDynForm =
new QTreeWidgetItem();
1300 childDynForm->setText( 0, tr(
"Dynamic form" ) );
1302 childDynForm->setText( 1, QChar( 0x2714 ) );
1303 joinItem->addChild( childDynForm );
1305 QTreeWidgetItem *childEditable =
new QTreeWidgetItem();
1306 childEditable->setText( 0, tr(
"Editable join layer" ) );
1308 childEditable->setText( 1, QChar( 0x2714 ) );
1309 joinItem->addChild( childEditable );
1311 QTreeWidgetItem *childUpsert =
new QTreeWidgetItem();
1312 childUpsert->setText( 0, tr(
"Upsert on edit" ) );
1314 childUpsert->setText( 1, QChar( 0x2714 ) );
1315 joinItem->addChild( childUpsert );
1317 QTreeWidgetItem *childCascade =
new QTreeWidgetItem();
1318 childCascade->setText( 0, tr(
"Delete cascade" ) );
1320 childCascade->setText( 1, QChar( 0x2714 ) );
1321 joinItem->addChild( childCascade );
1323 QTreeWidgetItem *childPrefix =
new QTreeWidgetItem();
1324 childPrefix->setText( 0, tr(
"Custom field name prefix" ) );
1325 childPrefix->setText( 1, join.
prefix() );
1326 joinItem->addChild( childPrefix );
1328 QTreeWidgetItem *childFields =
new QTreeWidgetItem();
1329 childFields->setText( 0, tr(
"Joined fields" ) );
1332 childFields->setText( 1, QLocale().toString( list->count() ) );
1334 childFields->setText( 1, tr(
"all" ) );
1335 joinItem->addChild( childFields );
1337 if ( insertIndex >= 0 )
1338 mJoinTreeWidget->insertTopLevelItem( insertIndex, joinItem );
1340 mJoinTreeWidget->addTopLevelItem( joinItem );
1342 mJoinTreeWidget->setCurrentItem( joinItem );
1343 mJoinTreeWidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
1353 QDialog *dlg =
new QDialog();
1354 QString key = QStringLiteral(
"/UI/paneldialog/%1" ).arg( panel->
panelTitle() );
1355 QgsSettings settings;
1356 dlg->restoreGeometry( settings.
value( key ).toByteArray() );
1358 dlg->setLayout(
new QVBoxLayout() );
1359 dlg->layout()->addWidget( panel );
1360 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok );
1361 connect( buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept );
1362 dlg->layout()->addWidget( buttonBox );
1364 settings.
setValue( key, dlg->saveGeometry() );
1368void QgsVectorLayerProperties::mButtonRemoveJoin_clicked()
1370 QTreeWidgetItem *currentJoinItem = mJoinTreeWidget->currentItem();
1372 if ( currentJoinItem && currentJoinItem->parent() )
1374 currentJoinItem = currentJoinItem->parent();
1377 if ( !mLayer || !currentJoinItem )
1382 mLayer->removeJoin( currentJoinItem->data( 0, Qt::UserRole ).toString() );
1383 mJoinTreeWidget->takeTopLevelItem( mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem ) );
1384 setPbnQueryBuilderEnabled();
1385 mSourceFieldsPropertiesDialog->init();
1386 mAttributesFormPropertiesDialog->init();
1390void QgsVectorLayerProperties::mButtonAddWmsDimension_clicked()
1396 QStringList alreadyDefinedDimensions;
1397 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1398 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &dims = serverProperties->
wmsDimensions();
1399 for (
const QgsMapLayerServerProperties::WmsDimensionInfo &dim : dims )
1401 alreadyDefinedDimensions << dim.name;
1404 QgsWmsDimensionDialog d( mLayer, alreadyDefinedDimensions );
1405 if ( d.exec() == QDialog::Accepted )
1407 QgsMapLayerServerProperties::WmsDimensionInfo info = d.info();
1410 addWmsDimensionInfoToTreeWidget( info );
1414void QgsVectorLayerProperties::mButtonEditWmsDimension_clicked()
1416 QTreeWidgetItem *currentWmsDimensionItem = mWmsDimensionsTreeWidget->currentItem();
1417 mWmsDimensionsTreeWidget_itemDoubleClicked( currentWmsDimensionItem, 0 );
1420void QgsVectorLayerProperties::mWmsDimensionsTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int )
1422 if ( !mLayer || !item )
1427 QString wmsDimName = item->data( 0, Qt::UserRole ).toString();
1428 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1429 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &dims = serverProperties->
wmsDimensions();
1430 QStringList alreadyDefinedDimensions;
1432 for (
int i = 0; i < dims.size(); ++i )
1434 QString dimName = dims[i].name;
1435 if ( dimName == wmsDimName )
1441 alreadyDefinedDimensions << dimName;
1449 QgsWmsDimensionDialog d( mLayer, alreadyDefinedDimensions );
1450 d.setWindowTitle( tr(
"Edit WMS Dimension" ) );
1451 d.setInfo( dims[j] );
1453 if ( d.exec() == QDialog::Accepted )
1455 QgsMapLayerServerProperties::WmsDimensionInfo info = d.info();
1458 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1460 int idx = mWmsDimensionsTreeWidget->indexOfTopLevelItem( item );
1461 mWmsDimensionsTreeWidget->takeTopLevelItem( idx );
1465 addWmsDimensionInfoToTreeWidget( info, idx );
1471 QTreeWidgetItem *wmsDimensionItem =
new QTreeWidgetItem();
1472 wmsDimensionItem->setFlags( Qt::ItemIsEnabled );
1474 wmsDimensionItem->setText( 0, tr(
"Dimension" ) );
1475 wmsDimensionItem->setText( 1, wmsDim.
name );
1477 QFont f = wmsDimensionItem->font( 0 );
1479 wmsDimensionItem->setFont( 0, f );
1480 wmsDimensionItem->setFont( 1, f );
1482 wmsDimensionItem->setData( 0, Qt::UserRole, wmsDim.
name );
1484 QTreeWidgetItem *childWmsDimensionField =
new QTreeWidgetItem();
1485 childWmsDimensionField->setText( 0, tr(
"Field" ) );
1486 childWmsDimensionField->setText( 1, wmsDim.
fieldName );
1487 childWmsDimensionField->setFlags( Qt::ItemIsEnabled );
1488 wmsDimensionItem->addChild( childWmsDimensionField );
1490 QTreeWidgetItem *childWmsDimensionEndField =
new QTreeWidgetItem();
1491 childWmsDimensionEndField->setText( 0, tr(
"End field" ) );
1492 childWmsDimensionEndField->setText( 1, wmsDim.
endFieldName );
1493 childWmsDimensionEndField->setFlags( Qt::ItemIsEnabled );
1494 wmsDimensionItem->addChild( childWmsDimensionEndField );
1496 QTreeWidgetItem *childWmsDimensionUnits =
new QTreeWidgetItem();
1497 childWmsDimensionUnits->setText( 0, tr(
"Units" ) );
1498 childWmsDimensionUnits->setText( 1, wmsDim.
units );
1499 childWmsDimensionUnits->setFlags( Qt::ItemIsEnabled );
1500 wmsDimensionItem->addChild( childWmsDimensionUnits );
1502 QTreeWidgetItem *childWmsDimensionUnitSymbol =
new QTreeWidgetItem();
1503 childWmsDimensionUnitSymbol->setText( 0, tr(
"Unit symbol" ) );
1504 childWmsDimensionUnitSymbol->setText( 1, wmsDim.
unitSymbol );
1505 childWmsDimensionUnitSymbol->setFlags( Qt::ItemIsEnabled );
1506 wmsDimensionItem->addChild( childWmsDimensionUnitSymbol );
1508 QTreeWidgetItem *childWmsDimensionDefaultValue =
new QTreeWidgetItem();
1509 childWmsDimensionDefaultValue->setText( 0, tr(
"Default display" ) );
1511 childWmsDimensionDefaultValue->setFlags( Qt::ItemIsEnabled );
1512 wmsDimensionItem->addChild( childWmsDimensionDefaultValue );
1514 QTreeWidgetItem *childWmsDimensionRefValue =
new QTreeWidgetItem();
1515 childWmsDimensionRefValue->setText( 0, tr(
"Reference value" ) );
1516 childWmsDimensionRefValue->setText( 1, wmsDim.
referenceValue.toString() );
1517 childWmsDimensionRefValue->setFlags( Qt::ItemIsEnabled );
1518 wmsDimensionItem->addChild( childWmsDimensionRefValue );
1520 if ( insertIndex >= 0 )
1521 mWmsDimensionsTreeWidget->insertTopLevelItem( insertIndex, wmsDimensionItem );
1523 mWmsDimensionsTreeWidget->addTopLevelItem( wmsDimensionItem );
1525 mWmsDimensionsTreeWidget->setCurrentItem( wmsDimensionItem );
1526 mWmsDimensionsTreeWidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
1529void QgsVectorLayerProperties::mButtonRemoveWmsDimension_clicked()
1531 QTreeWidgetItem *currentWmsDimensionItem = mWmsDimensionsTreeWidget->currentItem();
1532 if ( !mLayer || !currentWmsDimensionItem )
1537 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1538 serverProperties->
removeWmsDimension( currentWmsDimensionItem->data( 0, Qt::UserRole ).toString() );
1539 mWmsDimensionsTreeWidget->takeTopLevelItem( mWmsDimensionsTreeWidget->indexOfTopLevelItem( currentWmsDimensionItem ) );
1543void QgsVectorLayerProperties::updateSymbologyPage()
1546 delete mRendererDialog;
1547 mRendererDialog =
nullptr;
1549 if ( mLayer->renderer() )
1552 mRendererDialog->setDockMode(
false );
1553 QgsSymbolWidgetContext context;
1556 mRendererDialog->setContext( context );
1563 mOptsPage_Style->setEnabled(
false );
1566 if ( mRendererDialog )
1568 mRendererDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
1569 widgetStackRenderers->addWidget( mRendererDialog );
1570 widgetStackRenderers->setCurrentWidget( mRendererDialog );
1571 widgetStackRenderers->currentWidget()->layout()->setContentsMargins( 0, 0, 0, 0 );
1575void QgsVectorLayerProperties::setPbnQueryBuilderEnabled()
1577 pbnQueryBuilder->setEnabled( mLayer && mLayer->dataProvider() && mLayer->dataProvider()->supportsSubsetString() && !mLayer->isEditable() );
1579 if ( mLayer && mLayer->isEditable() )
1581 pbnQueryBuilder->setToolTip( tr(
"Stop editing mode to enable this." ) );
1585void QgsVectorLayerProperties::pbnUpdateExtents_clicked()
1587 mLayer->updateExtents(
true );
1588 mMetadataFilled =
false;
1595 if ( index ==
mOptStackedWidget->indexOf( mOptsPage_Information ) && !mMetadataFilled )
1598 teMetadataViewer->clear();
1599 teMetadataViewer->setHtml( htmlMetadata() );
1600 mMetadataFilled =
true;
1605 mAttributesFormPropertiesDialog->store();
1610 if ( mActionDialog )
1612 mAttributesFormPropertiesDialog->initAvailableWidgetsActions( mActionDialog->actions() );
1619void QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled(
bool checked )
1624 mSimplifyDrawingAtProvider->setEnabled(
false );
1628 mSimplifyDrawingAtProvider->setEnabled( checked );
1632void QgsVectorLayerProperties::updateVariableEditor()
1634 QgsExpressionContext context;
1635 mVariableEditor->setContext( &context );
1639 mVariableEditor->reloadContext();
1640 mVariableEditor->setEditableScopeIndex( 2 );
1643void QgsVectorLayerProperties::showHelp()
1645 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
1647 if ( helpPage.isValid() )
1653 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html" ) );
1657void QgsVectorLayerProperties::updateAuxiliaryStoragePage()
1659 const QgsAuxiliaryLayer *alayer = mLayer->auxiliaryLayer();
1664 mAuxiliaryStorageInformationGrpBox->setEnabled(
true );
1665 mAuxiliaryStorageFieldsGrpBox->setEnabled(
true );
1672 mAuxiliaryStorageFeaturesLineEdit->setText( QLocale().toString( features ) );
1675 mAuxiliaryLayerActionClear->setEnabled(
true );
1676 mAuxiliaryLayerActionDelete->setEnabled(
true );
1677 mAuxiliaryLayerActionExport->setEnabled(
true );
1678 mAuxiliaryLayerActionNew->setEnabled(
false );
1684 mAuxiliaryStorageFieldsLineEdit->setText( QLocale().toString( fields ) );
1687 mAuxiliaryStorageFieldsTree->clear();
1691 QTreeWidgetItem *item =
new QTreeWidgetItem();
1693 item->setText( 0, prop.
origin() );
1694 item->setText( 1, prop.
name() );
1695 item->setText( 2, prop.
comment() );
1696 item->setText( 3, field.typeName() );
1697 item->setText( 4, field.name() );
1699 mAuxiliaryStorageFieldsTree->addTopLevelItem( item );
1705 mAuxiliaryStorageInformationGrpBox->setEnabled(
false );
1706 mAuxiliaryStorageFieldsGrpBox->setEnabled(
false );
1708 mAuxiliaryLayerActionClear->setEnabled(
false );
1709 mAuxiliaryLayerActionDelete->setEnabled(
false );
1710 mAuxiliaryLayerActionExport->setEnabled(
false );
1711 mAuxiliaryLayerActionNew->setEnabled(
true );
1713 mAuxiliaryStorageFieldsTree->clear();
1714 mAuxiliaryStorageKeyLineEdit->setText( QString() );
1715 mAuxiliaryStorageFieldsLineEdit->setText( QString() );
1716 mAuxiliaryStorageFeaturesLineEdit->setText( QString() );
1720void QgsVectorLayerProperties::onAuxiliaryLayerNew()
1727 QgsNewAuxiliaryLayerDialog dlg( mLayer,
this );
1728 if ( dlg.exec() == QDialog::Accepted )
1730 updateAuxiliaryStoragePage();
1734void QgsVectorLayerProperties::onAuxiliaryLayerClear()
1741 const QString msg = tr(
"Are you sure you want to clear auxiliary data for %1?" ).arg( mLayer->name() );
1742 QMessageBox::StandardButton reply;
1743 reply = QMessageBox::question(
this,
"Clear Auxiliary Data", msg, QMessageBox::Yes | QMessageBox::No );
1745 if ( reply == QMessageBox::Yes )
1747 QApplication::setOverrideCursor( Qt::WaitCursor );
1749 QApplication::restoreOverrideCursor();
1750 updateAuxiliaryStoragePage();
1751 mLayer->triggerRepaint();
1755void QgsVectorLayerProperties::onAuxiliaryLayerDelete()
1761 const QString msg = tr(
"Are you sure you want to delete auxiliary storage for %1?" ).arg( mLayer->name() );
1762 QMessageBox::StandardButton reply;
1763 reply = QMessageBox::question(
this,
"Delete Auxiliary Storage", msg, QMessageBox::Yes | QMessageBox::No );
1765 if ( reply == QMessageBox::Yes )
1767 QApplication::setOverrideCursor( Qt::WaitCursor );
1768 QgsDataSourceUri uri( alayer->
source() );
1778 mLayer->setAuxiliaryLayer();
1780 QApplication::restoreOverrideCursor();
1781 updateAuxiliaryStoragePage();
1782 mLayer->triggerRepaint();
1786void QgsVectorLayerProperties::onAuxiliaryLayerDeleteField()
1792 QList<QTreeWidgetItem *> items = mAuxiliaryStorageFieldsTree->selectedItems();
1793 if ( items.count() < 1 )
1797 const QTreeWidgetItem *item = items[0];
1798 QgsPropertyDefinition def;
1800 def.
setName( item->text( 1 ) );
1805 const int index = mLayer->auxiliaryLayer()->fields().indexOf( fieldName );
1810 const QString msg = tr(
"Are you sure you want to delete auxiliary field %1 for %2?" ).arg( item->text( 1 ), item->text( 0 ) );
1812 QMessageBox::StandardButton reply;
1813 const QString title = QObject::tr(
"Delete Auxiliary Field" );
1814 reply = QMessageBox::question(
this, title, msg, QMessageBox::Yes | QMessageBox::No );
1816 if ( reply == QMessageBox::Yes )
1818 QApplication::setOverrideCursor( Qt::WaitCursor );
1819 deleteAuxiliaryField( index );
1820 mLayer->triggerRepaint();
1821 QApplication::restoreOverrideCursor();
1825void QgsVectorLayerProperties::onAuxiliaryLayerAddField()
1831 QgsNewAuxiliaryFieldDialog dlg( QgsPropertyDefinition(), mLayer,
false );
1832 if ( dlg.exec() == QDialog::Accepted )
1834 updateAuxiliaryStoragePage();
1838void QgsVectorLayerProperties::deleteAuxiliaryField(
int index )
1840 if ( !mLayer->auxiliaryLayer() )
1843 int key = mLayer->auxiliaryLayer()->propertyFromIndex( index );
1844 QgsPropertyDefinition def = mLayer->auxiliaryLayer()->propertyDefinitionFromIndex( index );
1846 if ( mLayer->auxiliaryLayer()->deleteAttribute( index ) )
1848 mLayer->updateFields();
1851 if ( key >= 0 && def.
origin().compare(
"labeling", Qt::CaseInsensitive ) == 0
1853 && labelingDialog->labelingGui() )
1858 updateAuxiliaryStoragePage();
1859 mSourceFieldsPropertiesDialog->init();
1863 const QString title = QObject::tr(
"Delete Auxiliary Field" );
1864 const QString errors = mLayer->auxiliaryLayer()->commitErrors().join( QLatin1String(
"\n " ) );
1865 const QString msg = QObject::tr(
"Unable to remove auxiliary field (%1)" ).arg( errors );
1873 if ( obj == mMapTipPreviewContainer && ev->type() == QEvent::Resize )
1877 return QgsOptionsDialogBase::eventFilter( obj, ev );
1880void QgsVectorLayerProperties::initMapTipPreview()
1883 mMapTipSplitter->setSizes( { 400, 200 } );
1885 mMapTipPreviewContainer->installEventFilter(
this );
1889 mMapTipPreview =
new QgsWebView( mMapTipPreviewContainer );
1890 mMapTipPreviewLayout->addWidget( mMapTipPreview );
1893 mMapTipPreview->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
1894 mMapTipPreview->setContextMenuPolicy( Qt::NoContextMenu );
1895 connect( mMapTipPreview, &QWebView::loadFinished,
this, &QgsVectorLayerProperties::resizeMapTip );
1898 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
1899 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled,
true );
1900 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::LocalStorageEnabled,
true );
1903 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
1904 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
1907 connect( mMapTipWidget, &QgsCodeEditorHTML::textChanged,
this, &QgsVectorLayerProperties::updateMapTipPreview );
1911void QgsVectorLayerProperties::updateMapTipPreview()
1913 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1915 mMapTipPreview->setHtml( htmlContent );
1918void QgsVectorLayerProperties::resizeMapTip()
1921 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1924 const QWebElement container = mMapTipPreview->page()->mainFrame()->findFirstElement(
1925 QStringLiteral(
"#QgsWebViewContainer" )
1927 const int width = container.geometry().width();
1928 const int height = container.geometry().height();
1929 mMapTipPreview->resize( width, height );
1932 mMapTipPreview->move( ( mMapTipPreviewContainer->width() - mMapTipPreview->width() ) / 2, ( mMapTipPreviewContainer->height() - mMapTipPreview->height() ) / 2 );
1935 mMapTipPreview->adjustSize();
@ SimplifyGeometries
Supports simplification of geometries on provider side according to a distance tolerance.
@ SelectEncoding
Allows user to select encoding.
@ CreateSpatialIndex
Allows creation of spatial index.
QFlags< VectorRenderingSimplificationFlag > VectorRenderingSimplificationFlags
Simplification flags for vector feature rendering.
@ Present
A valid spatial index exists for the source.
@ AntialiasingSimplification
The geometries can be rendered with 'AntiAliasing' disabled because of it is '1-pixel size'.
@ NoSimplification
No simplification can be applied.
@ GeometrySimplification
The geometries can be simplified using the current map2pixel context state.
VectorSimplificationAlgorithm
Simplification algorithms for vector features.
@ Distance
The simplification uses the distance between points to remove duplicate points.
@ SnapToGrid
The simplification uses a grid (similar to ST_SnapToGrid) to remove duplicate points.
@ Visvalingam
The simplification gives each point in a line an importance weighting, so that least important points...
@ Warning
Warning message.
static QString defaultProjectScales()
A string with default project scales.
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
QFlags< VectorProviderCapability > VectorProviderCapabilities
Vector data provider capabilities.
@ CustomColor
Use default symbol with a custom selection color.
@ CustomSymbol
Use a custom symbol.
@ Default
Use default symbol and selection colors.
Utility class that encapsulates an action based on vector attributes.
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
A dialog for configuring vector layer actions.
A container for configuration of the attribute table.
void setSortExpression(const QString &sortExpression)
Set the sort expression used for sorting.
@ Action
This column represents an action widget.
QVector< QgsAttributeTableConfig::ColumnConfig > columns() const
Gets the list with all columns and their configuration.
void update(const QgsFields &fields)
Update the configuration with the given fields.
void setActionWidgetStyle(ActionWidgetStyle actionWidgetStyle)
Set the style of the action widget.
void setSortOrder(Qt::SortOrder sortOrder)
Set the sort order.
void setColumns(const QVector< QgsAttributeTableConfig::ColumnConfig > &columns)
Set the list of columns visible in the attribute table.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
static QgsPropertyDefinition propertyDefinitionFromField(const QgsField &field)
Returns the property definition from an auxiliary field.
bool clear()
Deletes all features from the layer.
QgsFields auxiliaryFields() const
Returns a list of all auxiliary fields currently managed by the layer.
QgsVectorLayerJoinInfo joinInfo() const
Returns information to use for joining with primary key and so on.
static bool deleteTable(const QgsDataSourceUri &uri)
Removes a table from the auxiliary storage.
Represents a coordinate reference system (CRS).
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
static void setLayerVariables(QgsMapLayer *layer, const QVariantMap &variables)
Sets all layer context variables.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QString findAndSelectActiveExpression(QgsCodeEditor *editor, const QString &pattern=QString())
Find the expression under the cursor in the given editor and select it.
Q_INVOKABLE int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
Q_INVOKABLE int indexOf(const QString &fieldName) const
Gets the field index from the field name.
int size() const
Returns number of items.
static QString stringToSafeFilename(const QString &string)
Converts a string to a safe filename, replacing characters which are not safe for filenames with an '...
static QgsProviderSourceWidgetProviderRegistry * sourceWidgetProviderRegistry()
Returns the registry of provider source widget providers.
static QgsSubsetStringEditorProviderRegistry * subsetStringEditorProviderRegistry()
Returns the registry of subset string editors of data providers.
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
QPushButton * mBtnStyle
Style button.
void saveMetadataToFile()
Allows the user to save the layer's metadata as a file.
virtual void rollback()
Rolls back changes made to the layer.
void optionsStackedWidget_CurrentChanged(int index) override
StyleType
Style storage type.
QList< QgsMapLayerConfigWidget * > mConfigWidgets
Layer config widgets.
void setMetadataWidget(QgsMetadataWidget *widget, QWidget *page)
Sets the metadata widget and page associated with the dialog.
void loadDefaultStyle()
Reloads the default style for the layer.
void saveStyleAs()
Saves a style when appriate button is pressed.
void loadStyle()
Triggers a dialog to load a saved style.
QgsMapCanvas * mCanvas
Associated map canvas.
void loadDefaultMetadata()
Reloads the default layer metadata for the layer.
QgsLayerPropertiesDialog(QgsMapLayer *layer, QgsMapCanvas *canvas, const QString &settingsKey, QWidget *parent=nullptr, Qt::WindowFlags fl=Qt::WindowFlags(), QgsSettings *settings=nullptr)
Constructor for QgsLayerPropertiesDialog.
void loadMetadataFromFile()
Allows the user to load layer metadata from a file.
void saveDefaultStyle()
Saves the default style when appropriate button is pressed.
QPushButton * mBtnMetadata
Metadata button.
void initialize()
Initialize the dialog.
void saveMetadataAsDefault()
Saves the current layer metadata as the default for the layer.
void openUrl(const QUrl &url)
Handles opening a url from the dialog.
A sort filter proxy model to easily reproduce the legend/layer tree in a tree view.
A model representing the layer tree, including layers and groups of layers.
Map canvas is a class for displaying all GIS data types on a canvas.
Models dependencies with or between map layers.
Manages QGIS Server properties for a map layer.
void addStyleManagerActions(QMenu *m, QgsMapLayer *layer)
adds actions to the menu in accordance to the layer
static QgsMapLayerStyleGuiUtils * instance()
returns a singleton instance of this class
void currentStyleChanged(const QString ¤tName)
Emitted when the current style has been changed.
Base class for all map layer types.
QString source() const
Returns the source for the layer.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
Contains configuration for rendering maps.
static QString vectorMapTipPreviewText(QgsMapLayer *layer, QgsMapCanvas *mapCanvas, const QString &mapTemplate, const QString &displayExpression)
Returns the html that would be displayed in a maptip for a given layer.
A bar for displaying non-blocking messages to the user.
void resizeAlltabs(int index)
Resizes all tabs when the dialog is resized.
QStackedWidget * mOptStackedWidget
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
Property
Data definable properties.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
void setDirty(bool b=true)
Flag the project as dirty (modified).
QString comment() const
Returns the comment of the property.
void setOrigin(const QString &origin)
Sets the origin of the property.
QString name() const
Returns the name of the property.
void setName(const QString &name)
Sets the name of the property.
QString origin() const
Returns the origin of the property.
void setComment(const QString &comment)
Sets comment of the property.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
A dialog for configuring vector layer renderers.
void showPanel(QgsPanelWidget *panel)
Emit when you require a panel to be show in the interface.
void apply()
Apply the changes from the dialog to the layer.
void layerVariablesChanged()
Emitted when expression context variables on the associated vector layers have been changed.
void widgetChanged()
Emitted when something on the widget has changed.
static QMap< int, QString > wmsDimensionDefaultDisplayLabels()
Returns WMS Dimension default display labels.
bool addWmsDimension(const QgsServerWmsDimensionProperties::WmsDimensionInfo &wmsDimInfo)
Adds a QGIS Server WMS Dimension.
bool removeWmsDimension(const QString &wmsDimName)
Removes a QGIS Server WMS Dimension.
const QList< QgsServerWmsDimensionProperties::WmsDimensionInfo > wmsDimensions() const
Returns the QGIS Server WMS Dimension list.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
A widget which displays information about vector layer fields, and allows some configuration of them.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
Interface for a dialog that can edit subset strings.
virtual QString subsetString() const =0
Returns the subset string entered in the dialog.
virtual void setSubsetString(const QString &subsetString)=0
Sets a subset string into the dialog.
QgsSubsetStringEditorInterface * createDialog(QgsVectorLayer *layer, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
Creates a new dialog to edit the subset string of the provided layer.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
Abstract base class for all rendered symbols.
Base class for vector data providers.
static QStringList availableEncodings()
Returns a list of available encodings.
virtual bool createSpatialIndex()
Creates a spatial index on the datasource (if supported by the provider type).
virtual Q_INVOKABLE Qgis::VectorProviderCapabilities capabilities() const
Returns flags containing the supported capabilities.
virtual bool createAttributeIndex(int field)
Create an attribute index on the datasource.
Defines left outer join from our vector layer to some other vector layer.
bool hasCascadedDelete() const
Returns whether a feature deleted on the target layer has to impact the joined layer by deleting the ...
bool isDynamicFormEnabled() const
Returns whether the form has to be dynamically updated with joined fields when a feature is being cre...
bool hasUpsertOnEdit() const
Returns whether a feature created on the target layer has to impact the joined layer by creating a ne...
bool isEditable() const
Returns whether joined fields may be edited through the form of the target layer.
bool isUsingMemoryCache() const
Returns whether values from the joined layer should be cached in memory to speed up lookups.
QString prefix() const
Returns prefix of fields from the joined layer. If nullptr, joined layer's name will be used.
static QStringList joinFieldNamesSubset(const QgsVectorLayerJoinInfo &info, bool blocklisted=true)
Returns the list of field names to use for joining considering blocklisted fields and subset.
QString joinFieldName() const
Returns name of the field of joined layer that will be used for join.
QString targetFieldName() const
Returns name of the field of our layer that will be used for join.
QString joinLayerId() const
ID of the joined layer - may be used to resolve reference to the joined layer.
QgsVectorLayer * joinLayer() const
Returns joined layer (may be nullptr if the reference was set by layer ID and not resolved yet).
bool eventFilter(QObject *obj, QEvent *ev) override
QgsVectorLayerProperties(QgsMapCanvas *canvas, QgsMessageBar *messageBar, QgsVectorLayer *lyr=nullptr, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
void optionsStackedWidget_CurrentChanged(int index) final
void toggleEditing(QgsMapLayer *)
void exportAuxiliaryLayer(QgsAuxiliaryLayer *layer)
Implementation of layer selection properties for vector layers.
void setSelectionSymbol(QgsSymbol *symbol)
Sets the symbol used to render selected features in the layer.
Qgis::SelectionRenderingMode selectionRenderingMode
QgsSymbol * selectionSymbol() const
Returns the symbol used to render selected features in the layer.
void setSelectionColor(const QColor &color)
Sets the color to use for rendering selected features in the layer.
void setSelectionRenderingMode(Qgis::SelectionRenderingMode mode)
Sets the selection rendering mode to use for selected features in the layer.
Represents a vector layer which manages a vector based dataset.
long long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
QgsVectorDataProvider * dataProvider() final
Returns the layer's data provider, it may be nullptr.
Contains settings for simplifying geometries fetched from a vector layer.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported,...
Qgis::VectorRenderingSimplificationFlags simplifyHints() const
Gets the simplification hints of the vector layer managed.
float maximumScale() const
Gets the maximum scale at which the layer should be simplified.
Qgis::VectorSimplificationAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
void setThreshold(float threshold)
Sets the simplification threshold of the vector layer managed.
void setForceLocalOptimization(bool localOptimization)
Sets where the simplification executes, after fetch the geometries from provider, or when supported,...
void setSimplifyHints(Qgis::VectorRenderingSimplificationFlags simplifyHints)
Sets the simplification hints of the vector layer managed.
float threshold() const
Gets the simplification threshold of the vector layer managed.
void setMaximumScale(float maximumScale)
Sets the maximum scale at which the layer should be simplified.
void setSimplifyAlgorithm(Qgis::VectorSimplificationAlgorithm simplifyAlgorithm)
Sets the local simplification algorithm of the vector layer managed.
Setting options for creating vector data providers.
Setting to define QGIS Server WMS Dimension.