76#include <QColorDialog>
78#include <QDesktopServices>
87#include <QRegularExpressionValidator>
91#include "moc_qgsvectorlayerproperties.cpp"
93using namespace Qt::StringLiterals;
97 , mMessageBar( messageBar )
99 , mOriginalSubsetSQL( lyr->subsetString() )
102 connect( pbnQueryBuilder, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnQueryBuilder_clicked );
103 connect( pbnIndex, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnIndex_clicked );
105 connect( pbnUpdateExtents, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnUpdateExtents_clicked );
106 connect( mButtonAddJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonAddJoin_clicked );
107 connect( mButtonEditJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonEditJoin_clicked );
108 connect( mJoinTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsVectorLayerProperties::mJoinTreeWidget_itemDoubleClicked );
109 connect( mButtonRemoveJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonRemoveJoin_clicked );
110 connect( mButtonAddWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonAddWmsDimension_clicked );
111 connect( mButtonEditWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonEditWmsDimension_clicked );
112 connect( mWmsDimensionsTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsVectorLayerProperties::mWmsDimensionsTreeWidget_itemDoubleClicked );
113 connect( mButtonRemoveWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonRemoveWmsDimension_clicked );
114 connect( mSimplifyDrawingGroupBox, &QGroupBox::toggled,
this, &QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled );
115 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsVectorLayerProperties::showHelp );
124 mBtnStyle =
new QPushButton( tr(
"Style" ),
this );
125 QMenu *menuStyle =
new QMenu(
this );
126 mActionLoadStyle =
new QAction( tr(
"Load Style…" ),
this );
129 mActionSaveStyle =
new QAction( tr(
"Save Current Style…" ),
this );
132 mActionSaveMultipleStyles =
new QAction( tr(
"Save Multiple Styles…" ),
this );
133 connect( mActionSaveMultipleStyles, &QAction::triggered,
this, &QgsVectorLayerProperties::saveMultipleStylesAs );
135 mSourceGroupBox->hide();
138 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsVectorLayerProperties::aboutToShowStyleMenu );
139 buttonBox->addButton(
mBtnStyle, QDialogButtonBox::ResetRole );
149 mContext =
mCanvas->createExpressionContext();
161 mMapTipFieldComboBox->setLayer( lyr );
162 mDisplayExpressionWidget->setLayer( lyr );
163 mDisplayExpressionWidget->registerExpressionContextGenerator(
this );
166 mFeaturesSortOrderExpressionWidget->setLayer( lyr );
167 mFeaturesSortOrderExpressionWidget->registerExpressionContextGenerator(
this );
168 connect( mFeaturesSortOrderDirectionButton, &QAbstractButton::clicked,
this, [
this]() {
169 mFeaturesSortOrderDirectionButton->setArrowType( mFeaturesSortOrderDirectionButton->arrowType() == Qt::UpArrow ? Qt::DownArrow : Qt::UpArrow );
172 connect( mMapTipInsertFieldButton, &QAbstractButton::clicked,
this, &QgsVectorLayerProperties::insertField );
173 connect( mMapTipInsertExpressionButton, &QAbstractButton::clicked,
this, &QgsVectorLayerProperties::insertOrEditExpression );
178 mEnableMapTips->setChecked( mLayer->mapTipsEnabled() );
180 QVBoxLayout *layout =
nullptr;
182 if ( mLayer->isSpatial() )
185 layout =
new QVBoxLayout( labelingFrame );
186 layout->setContentsMargins( 0, 0, 0, 0 );
188 labelingDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
190 layout->addWidget( labelingDialog );
191 labelingFrame->setLayout( layout );
194 layout =
new QVBoxLayout( mMaskingFrame );
195 layout->setContentsMargins( 0, 0, 0, 0 );
196 mMaskingWidget =
new QgsMaskingWidget( mMaskingFrame );
197 mMaskingWidget->setLayer( mLayer );
198 mMaskingWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
199 layout->addWidget( mMaskingWidget );
200 mMaskingFrame->setLayout( layout );
204 labelingDialog =
nullptr;
205 mOptsPage_Labels->setEnabled(
false );
206 mOptsPage_Masks->setEnabled(
false );
207 mGeomGroupBox->setEnabled(
false );
208 mGeomGroupBox->setVisible(
false );
209 mCrsGroupBox->setEnabled(
false );
210 mCrsGroupBox->setVisible(
false );
214 QVBoxLayout *actionLayout =
new QVBoxLayout( actionOptionsFrame );
215 actionLayout->setContentsMargins( 0, 0, 0, 0 );
217 mActionDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
218 actionLayout->addWidget( mActionDialog );
221 mSourceFieldsPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
222 mSourceFieldsFrame->setLayout(
new QVBoxLayout( mSourceFieldsFrame ) );
223 mSourceFieldsFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
224 mSourceFieldsFrame->layout()->addWidget( mSourceFieldsPropertiesDialog );
229 mAttributesFormPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
230 mAttributesFormFrame->setLayout(
new QVBoxLayout( mAttributesFormFrame ) );
231 mAttributesFormFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
232 mAttributesFormFrame->layout()->addWidget( mAttributesFormPropertiesDialog );
235 QVBoxLayout *metadataLayout =
new QVBoxLayout( metadataFrame );
236 metadataLayout->setContentsMargins( 0, 0, 0, 0 );
238 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
239 mMetadataWidget->setMapCanvas(
mCanvas );
240 metadataLayout->addWidget( mMetadataWidget );
241 metadataFrame->setLayout( metadataLayout );
243 QVBoxLayout *temporalLayout =
new QVBoxLayout( temporalFrame );
244 temporalLayout->setContentsMargins( 0, 0, 0, 0 );
246 temporalLayout->addWidget( mTemporalWidget );
250 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
251 QMenu *menuMetadata =
new QMenu(
this );
254 menuMetadata->addSeparator();
258 buttonBox->addButton(
mBtnMetadata, QDialogButtonBox::ResetRole );
260 mSelectionColorButton->setAllowOpacity(
true );
261 mSelectionColorButton->setColorDialogTitle( tr(
"Override Selection Color" ) );
264 mSelectionColorButton->setColor(
mCanvas->selectionColor() );
265 mSelectionColorButton->setDefaultColor(
mCanvas->selectionColor() );
267 connect( mRadioOverrideSelectionColor, &QRadioButton::toggled, mSelectionColorButton, &QWidget::setEnabled );
268 mSelectionColorButton->setEnabled(
false );
269 connect( mRadioOverrideSelectionSymbol, &QRadioButton::toggled, mSelectionSymbolButton, &QWidget::setEnabled );
270 switch ( mLayer->geometryType() )
286 mSelectionSymbolButton->setEnabled(
false );
287 mRadioDefaultSelectionColor->setChecked(
true );
290 QVBoxLayout *diagLayout =
new QVBoxLayout( mDiagramFrame );
291 diagLayout->setContentsMargins( 0, 0, 0, 0 );
293 diagramPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
295 diagLayout->addWidget( diagramPropertiesDialog );
296 mDiagramFrame->setLayout( diagLayout );
300 if ( mLayer->dataProvider() )
306 pbnIndex->setEnabled(
false );
310 pbnIndex->setEnabled(
false );
311 pbnIndex->setText( tr(
"Spatial Index Exists" ) );
317 QString enc = mLayer->dataProvider()->encoding();
318 int encindex = cboProviderEncoding->findText( enc );
321 cboProviderEncoding->insertItem( 0, enc );
324 cboProviderEncoding->setCurrentIndex( encindex );
326 else if ( mLayer->providerType() ==
"ogr"_L1 )
330 cboProviderEncoding->addItem( mLayer->dataProvider()->encoding() );
331 cboProviderEncoding->setEnabled(
false );
336 mDataSourceEncodingFrame->hide();
340 mCrsSelector->setCrs( mLayer->crs() );
343 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
346 addJoinToTreeWidget( join );
349 mOldJoins = mLayer->vectorJoins();
352 mLegendWidget->setMapCanvas(
mCanvas );
353 mLegendWidget->setLayer( mLayer );
354 mLegendConfigEmbeddedWidget->setLayer( mLayer );
358 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &wmsDims = serverProperties->
wmsDimensions();
361 addWmsDimensionInfoToTreeWidget( dim );
365 myStyle.append( u
"body { margin: 10px; }\n "_s );
366 teMetadataViewer->clear();
367 teMetadataViewer->document()->setDefaultStyleSheet( myStyle );
368 teMetadataViewer->setOpenLinks(
false );
374 if ( !settings.
contains( u
"/Windows/VectorLayerProperties/tab"_s ) )
379 QList<QgsMapLayer *> dependencySources;
380 const QSet<QgsMapLayerDependency> constDependencies = mLayer->dependencies();
385 dependencySources << layer;
390 mLayersDependenciesTreeModel->setCheckedLayers( dependencySources );
391 connect(
QgsProject::instance(), &QObject::destroyed,
this, [
this] { mLayersDependenciesTreeView->setModel(
nullptr ); } );
392 mLayersDependenciesTreeView->setModel( mLayersDependenciesTreeModel );
394 mRefreshSettingsWidget->setLayer( mLayer );
395 mMapLayerServerPropertiesWidget->setHasWfsTitle(
true );
396 mMapLayerServerPropertiesWidget->setServerProperties( mLayer->serverProperties() );
399 QMenu *menu =
new QMenu(
this );
401 mAuxiliaryLayerActionNew =
new QAction( tr(
"Create" ),
this );
402 menu->addAction( mAuxiliaryLayerActionNew );
403 connect( mAuxiliaryLayerActionNew, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerNew );
405 mAuxiliaryLayerActionClear =
new QAction( tr(
"Clear" ),
this );
406 menu->addAction( mAuxiliaryLayerActionClear );
407 connect( mAuxiliaryLayerActionClear, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerClear );
409 mAuxiliaryLayerActionDelete =
new QAction( tr(
"Delete" ),
this );
410 menu->addAction( mAuxiliaryLayerActionDelete );
411 connect( mAuxiliaryLayerActionDelete, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerDelete );
413 mAuxiliaryLayerActionExport =
new QAction( tr(
"Export" ),
this );
414 menu->addAction( mAuxiliaryLayerActionExport );
415 connect( mAuxiliaryLayerActionExport, &QAction::triggered,
this, [
this] { emit
exportAuxiliaryLayer( mLayer->auxiliaryLayer() ); } );
417 mAuxiliaryStorageActions->setMenu( menu );
419 connect( mAuxiliaryStorageFieldsDeleteBtn, &QPushButton::clicked,
this, &QgsVectorLayerProperties::onAuxiliaryLayerDeleteField );
420 connect( mAuxiliaryStorageFieldsAddBtn, &QPushButton::clicked,
this, &QgsVectorLayerProperties::onAuxiliaryLayerAddField );
422 updateAuxiliaryStoragePage();
424 mOptsPage_Information->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#information-properties"_s );
425 mOptsPage_Source->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#source-properties"_s );
426 mOptsPage_Style->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#symbology-properties"_s );
427 mOptsPage_Labels->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#labels-properties"_s );
428 mOptsPage_Masks->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#masks-properties"_s );
429 mOptsPage_Diagrams->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#diagrams-properties"_s );
430 mOptsPage_SourceFields->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#fields-properties"_s );
431 mOptsPage_AttributesForm->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#attributes-form-properties"_s );
432 mOptsPage_Joins->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#joins-properties"_s );
433 mOptsPage_AuxiliaryStorage->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#auxiliary-storage-properties"_s );
434 mOptsPage_Actions->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#actions-properties"_s );
435 mOptsPage_Display->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#display-properties"_s );
436 mOptsPage_Rendering->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#rendering-properties"_s );
437 mOptsPage_Temporal->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#temporal-properties"_s );
438 mOptsPage_Variables->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#variables-properties"_s );
439 mOptsPage_Metadata->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#metadata-properties"_s );
440 mOptsPage_DataDependencies->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#dependencies-properties"_s );
441 mOptsPage_Legend->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#legend-properties"_s );
442 mOptsPage_Server->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#qgis-server-properties"_s );
457 setPbnQueryBuilderEnabled();
460void QgsVectorLayerProperties::insertField()
464 if ( mMapTipFieldComboBox->currentField().isEmpty() )
466 QString expression = u
"[%\""_s;
467 expression += mMapTipFieldComboBox->currentField();
468 expression +=
"\"%]"_L1;
470 mMapTipWidget->insertText( expression );
473void QgsVectorLayerProperties::insertOrEditExpression()
476 int selectionStart = mMapTipWidget->selectionStart();
477 int selectionEnd = mMapTipWidget->selectionEnd();
481 QgsExpressionBuilderDialog exprDlg( mLayer, expression,
this, u
"generic"_s, context );
483 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
484 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
485 mMapTipWidget->insertText(
"[%" + exprDlg.expressionText().trimmed() +
"%]" );
487 mMapTipWidget->setLinearSelection( selectionStart, selectionEnd );
492 if ( !mSourceWidget )
497 QHBoxLayout *layout =
new QHBoxLayout();
498 layout->addWidget( mSourceWidget );
499 mSourceGroupBox->setLayout( layout );
500 if ( !mSourceWidget->groupTitle().isEmpty() )
501 mSourceGroupBox->setTitle( mSourceWidget->groupTitle() );
503 mSourceGroupBox->show();
506 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
507 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
514 mSourceWidget->setMapCanvas(
mCanvas );
515 mSourceWidget->setSourceUri( mLayer->source() );
519 mLayerOrigNameLineEdit->setText( mLayer->name() );
520 mBackupCrs = mLayer->crs();
523 mSubsetGroupBox->setEnabled(
true );
524 txtSubsetSQL->setText( mLayer->subsetString() );
530 txtSubsetSQL->setReadOnly(
true );
531 txtSubsetSQL->setCaretWidth( 0 );
532 txtSubsetSQL->setCaretLineVisible(
false );
533 setPbnQueryBuilderEnabled();
534 if ( mLayer->dataProvider() && !mLayer->dataProvider()->supportsSubsetString() )
537 mSubsetGroupBox->hide();
540 mDisplayExpressionWidget->setField( mLayer->displayExpression() );
541 mEnableMapTips->setChecked( mLayer->mapTipsEnabled() );
542 mMapTipWidget->setText( mLayer->mapTipTemplate() );
544 mFeaturesSortOrderExpressionWidget->setField( mLayer->attributeTableConfig().sortExpression() );
545 mFeaturesSortOrderDirectionButton->setArrowType( mLayer->attributeTableConfig().sortOrder() == Qt::AscendingOrder ? Qt::UpArrow : Qt::DownArrow );
548 mScaleRangeWidget->setScaleRange( mLayer->minimumScale(), mLayer->maximumScale() );
549 mScaleVisibilityGroupBox->setChecked( mLayer->hasScaleBasedVisibility() );
550 mScaleRangeWidget->setMapCanvas(
mCanvas );
552 mUseReferenceScaleGroupBox->setChecked( mLayer->renderer() && mLayer->renderer()->referenceScale() > 0 );
553 mReferenceScaleWidget->setShowCurrentScaleButton(
true );
554 mReferenceScaleWidget->setMapCanvas(
mCanvas );
555 if ( mUseReferenceScaleGroupBox->isChecked() )
556 mReferenceScaleWidget->setScale( mLayer->renderer()->referenceScale() );
558 mReferenceScaleWidget->setScale(
mCanvas->scale() );
563 mSimplifyDrawingSpinBox->setValue( simplifyMethod.
threshold() );
564 mSimplifyDrawingSpinBox->setClearValue( 1.0 );
569 mSelectionColorButton->setColor( selectionProperties->
selectionColor() );
573 mSelectionSymbolButton->setSymbol( symbol->clone() );
578 mRadioDefaultSelectionColor->setChecked(
true );
585 mRadioOverrideSelectionColor->setChecked(
true );
589 mRadioDefaultSelectionColor->setChecked(
true );
597 mRadioOverrideSelectionSymbol->setChecked(
true );
601 mRadioDefaultSelectionColor->setChecked(
true );
606 QString remark = u
" (%1)"_s.arg( tr(
"Not supported" ) );
610 mSimplifyDrawingAtProvider->setChecked(
false );
611 mSimplifyDrawingAtProvider->setEnabled(
false );
612 if ( !mSimplifyDrawingAtProvider->text().endsWith( remark ) )
613 mSimplifyDrawingAtProvider->setText( mSimplifyDrawingAtProvider->text().append( remark ) );
618 mSimplifyDrawingAtProvider->setEnabled( mSimplifyDrawingGroupBox->isChecked() );
619 if ( mSimplifyDrawingAtProvider->text().endsWith( remark ) )
621 QString newText = mSimplifyDrawingAtProvider->text();
622 newText.chop( remark.size() );
623 mSimplifyDrawingAtProvider->setText( newText );
630 mSimplifyDrawingGroupBox->setChecked(
false );
631 mSimplifyDrawingGroupBox->setEnabled(
false );
638 mSimplifyAlgorithmComboBox->setCurrentIndex( mSimplifyAlgorithmComboBox->findData( QVariant::fromValue( simplifyMethod.
simplifyAlgorithm() ) ) );
641 myScalesList.append( u
"1:1"_s );
642 mSimplifyMaximumScaleComboBox->updateScales( myScalesList );
643 mSimplifyMaximumScaleComboBox->setScale( simplifyMethod.
maximumScale() );
645 mForceRasterCheckBox->setChecked( mLayer->renderer() && mLayer->renderer()->forceRasterRender() );
647 mRefreshSettingsWidget->syncToLayer();
648 mMapLayerServerPropertiesWidget->sync();
650 mRefreshLayerNotificationCheckBox->setChecked( mLayer->isRefreshOnNotifyEnabled() );
651 mNotificationMessageCheckBox->setChecked( !mLayer->refreshOnNotifyMessage().isEmpty() );
652 mNotifyMessageValueLineEdit->setText( mLayer->refreshOnNotifyMessage() );
656 updateSymbologyPage();
658 mActionDialog->init( *mLayer->actions(), mLayer->attributeTableConfig() );
660 if ( labelingDialog )
661 labelingDialog->adaptToLayer();
663 mSourceFieldsPropertiesDialog->init();
664 mAttributesFormPropertiesDialog->init();
667 updateVariableEditor();
669 if ( diagramPropertiesDialog )
670 diagramPropertiesDialog->syncToOwnLayer();
675 page->syncToLayer( mLayer );
678 mMetadataWidget->setMetadata( &mLayer->metadata() );
680 mTemporalWidget->syncToLayer();
682 mLegendWidget->setLayer( mLayer );
687 if ( labelingDialog )
689 labelingDialog->writeSettingsToLayer();
691 mBackupCrs = mLayer->crs();
693 mLegendWidget->applyToLayer();
694 mLegendConfigEmbeddedWidget->applyToLayer();
697 mMetadataWidget->acceptMetadata();
698 mMetadataFilled =
false;
701 if ( mMaskingWidget )
702 mMaskingWidget->apply();
705 mLayer->setScaleBasedVisibility( mScaleVisibilityGroupBox->isChecked() );
706 mLayer->setMaximumScale( mScaleRangeWidget->maximumScale() );
707 mLayer->setMinimumScale( mScaleRangeWidget->minimumScale() );
710 if ( mLayer->dataProvider() )
714 mLayer->setProviderEncoding( cboProviderEncoding->currentText() );
718 mLayer->setDisplayExpression( mDisplayExpressionWidget->asExpression() );
719 mLayer->setMapTipsEnabled( mEnableMapTips->isChecked() );
720 mLayer->setMapTipTemplate( mMapTipWidget->text() );
724 config.
setSortOrder( mFeaturesSortOrderDirectionButton->arrowType() == Qt::UpArrow ? Qt::AscendingOrder : Qt::DescendingOrder );
725 mLayer->setAttributeTableConfig( config );
727 mLayer->actions()->clearActions();
728 const auto constActions = mActionDialog->actions();
729 for (
const QgsAction &action : constActions )
731 mLayer->actions()->addAction( action );
734 attributeTableConfig.
update( mLayer->fields() );
736 QVector<QgsAttributeTableConfig::ColumnConfig> columns = attributeTableConfig.
columns();
738 for (
int i = 0; i < columns.size(); ++i )
742 columns[i].hidden = !mActionDialog->showWidgetInAttributeTable();
748 mLayer->setAttributeTableConfig( attributeTableConfig );
750 mLayer->setName( mLayerOrigNameLineEdit->text() );
752 mAttributesFormPropertiesDialog->apply();
753 mSourceFieldsPropertiesDialog->apply();
756 mTemporalWidget->saveTemporalProperties();
758 if ( mLayer->renderer() )
765 diagramPropertiesDialog->apply();
773 if ( mMapLayerServerPropertiesWidget->save() )
774 mMetadataFilled =
false;
778 if ( mSimplifyDrawingGroupBox->isChecked() )
781 if ( mSimplifyDrawingSpinBox->value() > 1 )
787 simplifyMethod.
setThreshold( mSimplifyDrawingSpinBox->value() );
789 simplifyMethod.
setMaximumScale( mSimplifyMaximumScaleComboBox->scale() );
790 mLayer->setSimplifyMethod( simplifyMethod );
792 if ( mLayer->renderer() )
794 mLayer->renderer()->setForceRasterRender( mForceRasterCheckBox->isChecked() );
795 mLayer->renderer()->setReferenceScale( mUseReferenceScaleGroupBox->isChecked() ? mReferenceScaleWidget->scale() : -1 );
799 if ( mSelectionColorButton->color() != mSelectionColorButton->defaultColor() )
803 if (
QgsSymbol *symbol = mSelectionSymbolButton->symbol() )
806 if ( mRadioOverrideSelectionSymbol->isChecked() )
810 else if ( mRadioOverrideSelectionColor->isChecked() )
819 mRefreshSettingsWidget->saveToLayer();
821 mLayer->setRefreshOnNotifyEnabled( mRefreshLayerNotificationCheckBox->isChecked() );
822 mLayer->setRefreshOnNofifyMessage( mNotificationMessageCheckBox->isChecked() ? mNotifyMessageValueLineEdit->text() : QString() );
824 mOldJoins = mLayer->vectorJoins();
828 updateVariableEditor();
831 QSet<QgsMapLayerDependency> deps;
832 const auto checkedLayers = mLayersDependenciesTreeModel->checkedLayers();
835 if ( !mLayer->setDependencies( deps ) )
837 QMessageBox::warning(
nullptr, tr(
"Save Dependency" ), tr(
"This configuration introduces a cycle in data dependencies and will be ignored." ) );
846 bool dialogNeedsResync =
false;
849 const QString newSource = mSourceWidget->sourceUri();
850 if ( newSource != mLayer->source() )
857 dialogNeedsResync =
true;
863 mSubsetGroupBox->setEnabled(
true );
864 if ( txtSubsetSQL->text() != mLayer->subsetString() )
867 mLayer->setSubsetString( txtSubsetSQL->text() );
868 mMetadataFilled =
false;
870 dialogNeedsResync =
true;
872 mOriginalSubsetSQL = mLayer->subsetString();
874 if ( dialogNeedsResync )
877 mLayer->triggerRepaint();
879 mProjectDirtyBlocker.reset();
886 if ( mOldJoins != mLayer->vectorJoins() )
891 const auto constVectorJoins = mLayer->vectorJoins();
893 mLayer->removeJoin( info.joinLayerId() );
896 mLayer->addJoin( info );
899 if ( mOriginalSubsetSQL != mLayer->subsetString() )
904 mLayer->setSubsetString( mOriginalSubsetSQL );
913 if ( backupCrs != mLayer->crs() )
914 mLayer->setCrs( backupCrs );
917void QgsVectorLayerProperties::pbnQueryBuilder_clicked()
926 if ( dialog->exec() )
939void QgsVectorLayerProperties::pbnIndex_clicked()
941 QgsVectorDataProvider *pr = mLayer->dataProvider();
944 setCursor( Qt::WaitCursor );
946 setCursor( Qt::ArrowCursor );
949 pbnIndex->setEnabled(
false );
950 pbnIndex->setText( tr(
"Spatial Index Exists" ) );
951 QMessageBox::information(
this, tr(
"Spatial Index" ), tr(
"Creation of spatial index successful" ) );
955 QMessageBox::warning(
this, tr(
"Spatial Index" ), tr(
"Creation of spatial index failed" ) );
960QString QgsVectorLayerProperties::htmlMetadata()
962 return mLayer->htmlMetadata();
968 mLayer->setCrs( crs );
969 mMetadataFilled =
false;
970 mMetadataWidget->crsChanged();
973void QgsVectorLayerProperties::saveMultipleStylesAs()
975 QgsMapLayerSaveStyleDialog dlg( mLayer );
976 dlg.setSaveOnlyCurrentStyle(
false );
977 QgsSettings settings;
984 const QString originalStyle { mLayer->styleManager()->currentStyle() };
985 const QListWidget *stylesWidget { dlg.stylesWidget() };
988 QStringList stylesSelected;
989 for (
int i = 0; i < stylesWidget->count(); i++ )
991 if ( stylesWidget->item( i )->checkState() == Qt::CheckState::Checked )
993 stylesSelected.push_back( stylesWidget->item( i )->text() );
997 if ( !stylesSelected.isEmpty() )
1000 for (
const QString &styleName : std::as_const( stylesSelected ) )
1002 bool defaultLoadedFlag =
false;
1004 StyleType type = dlg.currentStyleType();
1005 mLayer->styleManager()->setCurrentStyle( styleName );
1012 const QString filePath { dlg.outputFilePath() };
1013 const QFileInfo fi { filePath };
1015 if ( styleIndex > 0 && stylesSelected.count() > 1 )
1018 while ( QFile::exists( safePath ) )
1020 const QFileInfo fi { safePath };
1021 safePath = QString( safePath ).replace(
'.' + fi.completeSuffix(), u
"_%1.%2"_s.arg( QString::number( i ), fi.completeSuffix() ) );
1026 message = mLayer->saveNamedStyle( safePath, defaultLoadedFlag, dlg.styleCategories() );
1028 message = mLayer->saveSldStyle( safePath, defaultLoadedFlag );
1031 if ( defaultLoadedFlag )
1038 QMessageBox::information(
this, tr(
"Save Style" ), message );
1045 QString infoWindowTitle = QObject::tr(
"Save style '%1' to DB (%2)" ).arg( styleName, mLayer->providerType() );
1048 QgsMapLayerSaveStyleDialog::SaveToDbSettings dbSettings = dlg.saveToDbSettings();
1051 QString name { dbSettings.
name };
1052 if ( name.isEmpty() )
1058 name += u
"_%1"_s.arg( styleName );
1059 QStringList ids, names, descriptions;
1060 mLayer->listStylesInDatabase( ids, names, descriptions, msgError );
1062 while ( names.contains( name ) )
1064 name = u
"%1 %2"_s.arg( name, QString::number( i ) );
1069 QString errorMessage;
1073 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 )
1074 == QMessageBox::No )
1079 else if ( !errorMessage.isEmpty() )
1081 QMessageBox::warning(
this, infoWindowTitle, errorMessage );
1087 if ( !msgError.isNull() )
1089 QMessageBox::warning(
this, infoWindowTitle, msgError );
1093 QMessageBox::information(
this, infoWindowTitle, tr(
"Style '%1' saved" ).arg( styleName ) );
1103 mLayer->styleManager()->setCurrentStyle( originalStyle );
1108void QgsVectorLayerProperties::aboutToShowStyleMenu()
1111 QMenu *m = qobject_cast<QMenu *>( sender() );
1114 m->addAction( mActionLoadStyle );
1115 m->addAction( mActionSaveStyle );
1118 if ( mLayer->styleManager()->styles().count() > 1 )
1120 mActionSaveStyle->setText( tr(
"Save Current Style…" ) );
1121 m->addAction( mActionSaveMultipleStyles );
1125 mActionSaveStyle->setText( tr(
"Save Style…" ) );
1137void QgsVectorLayerProperties::mButtonAddJoin_clicked()
1142 QList<QgsMapLayer *> joinedLayers;
1143 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
1144 joinedLayers.reserve( joins.size() );
1145 for (
int i = 0; i < joins.size(); ++i )
1147 joinedLayers.append( joins[i].joinLayer() );
1150 QgsJoinDialog d( mLayer, joinedLayers );
1151 if ( d.exec() == QDialog::Accepted )
1153 QgsVectorLayerJoinInfo info = d.joinInfo();
1155 if ( d.createAttributeIndex() )
1157 QgsVectorLayer *joinLayer = info.
joinLayer();
1163 mLayer->addJoin( info );
1164 addJoinToTreeWidget( info );
1165 setPbnQueryBuilderEnabled();
1166 mSourceFieldsPropertiesDialog->init();
1167 mAttributesFormPropertiesDialog->init();
1171void QgsVectorLayerProperties::mButtonEditJoin_clicked()
1173 QTreeWidgetItem *currentJoinItem = mJoinTreeWidget->currentItem();
1174 mJoinTreeWidget_itemDoubleClicked( currentJoinItem, 0 );
1177void QgsVectorLayerProperties::mJoinTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int )
1179 if ( !mLayer || !item )
1185 QTreeWidgetItem *currentJoinItem = item;
1186 if ( item->parent() )
1188 currentJoinItem = item->parent();
1192 QList<QgsMapLayer *> joinedLayers;
1193 QString joinLayerId = currentJoinItem->data( 0, Qt::UserRole ).toString();
1194 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
1196 for (
int i = 0; i < joins.size(); ++i )
1198 QgsVectorLayer *joinLayer = joins[i].joinLayer();
1202 if ( joinLayer->
id() == joinLayerId )
1209 joinedLayers.append( joinLayer );
1217 QgsJoinDialog d( mLayer, joinedLayers );
1218 d.setWindowTitle( tr(
"Edit Vector Join" ) );
1219 d.setJoinInfo( joins[j] );
1221 if ( d.exec() == QDialog::Accepted )
1223 QgsVectorLayerJoinInfo info = d.joinInfo();
1226 mLayer->removeJoin( joinLayerId );
1227 int idx = mJoinTreeWidget->indexOfTopLevelItem( item );
1228 mJoinTreeWidget->takeTopLevelItem( idx );
1233 if ( d.createAttributeIndex() )
1235 QgsVectorLayer *joinLayer = info.
joinLayer();
1241 mLayer->addJoin( info );
1242 addJoinToTreeWidget( info, idx );
1244 setPbnQueryBuilderEnabled();
1245 mSourceFieldsPropertiesDialog->init();
1246 mAttributesFormPropertiesDialog->init();
1250void QgsVectorLayerProperties::addJoinToTreeWidget(
const QgsVectorLayerJoinInfo &join,
const int insertIndex )
1252 QTreeWidgetItem *joinItem =
new QTreeWidgetItem();
1253 joinItem->setFlags( Qt::ItemIsEnabled );
1255 QgsVectorLayer *joinLayer = join.
joinLayer();
1256 if ( !mLayer || !joinLayer )
1261 joinItem->setText( 0, tr(
"Join layer" ) );
1262 if ( mLayer->auxiliaryLayer() && mLayer->auxiliaryLayer()->id() == join.
joinLayerId() )
1267 joinItem->setText( 1, joinLayer->
name() );
1269 QFont f = joinItem->font( 0 );
1271 joinItem->setFont( 0, f );
1272 joinItem->setFont( 1, f );
1274 joinItem->setData( 0, Qt::UserRole, join.
joinLayerId() );
1276 QTreeWidgetItem *childJoinField =
new QTreeWidgetItem();
1277 childJoinField->setText( 0, tr(
"Join field" ) );
1279 childJoinField->setFlags( Qt::ItemIsEnabled );
1280 joinItem->addChild( childJoinField );
1282 QTreeWidgetItem *childTargetField =
new QTreeWidgetItem();
1283 childTargetField->setText( 0, tr(
"Target field" ) );
1285 joinItem->addChild( childTargetField );
1287 QTreeWidgetItem *childMemCache =
new QTreeWidgetItem();
1288 childMemCache->setText( 0, tr(
"Cache join layer in virtual memory" ) );
1290 childMemCache->setText( 1, QChar( 0x2714 ) );
1291 joinItem->addChild( childMemCache );
1293 QTreeWidgetItem *childDynForm =
new QTreeWidgetItem();
1294 childDynForm->setText( 0, tr(
"Dynamic form" ) );
1296 childDynForm->setText( 1, QChar( 0x2714 ) );
1297 joinItem->addChild( childDynForm );
1299 QTreeWidgetItem *childEditable =
new QTreeWidgetItem();
1300 childEditable->setText( 0, tr(
"Editable join layer" ) );
1302 childEditable->setText( 1, QChar( 0x2714 ) );
1303 joinItem->addChild( childEditable );
1305 QTreeWidgetItem *childUpsert =
new QTreeWidgetItem();
1306 childUpsert->setText( 0, tr(
"Upsert on edit" ) );
1308 childUpsert->setText( 1, QChar( 0x2714 ) );
1309 joinItem->addChild( childUpsert );
1311 QTreeWidgetItem *childCascade =
new QTreeWidgetItem();
1312 childCascade->setText( 0, tr(
"Delete cascade" ) );
1314 childCascade->setText( 1, QChar( 0x2714 ) );
1315 joinItem->addChild( childCascade );
1317 QTreeWidgetItem *childPrefix =
new QTreeWidgetItem();
1318 childPrefix->setText( 0, tr(
"Custom field name prefix" ) );
1319 childPrefix->setText( 1, join.
prefix() );
1320 joinItem->addChild( childPrefix );
1322 QTreeWidgetItem *childFields =
new QTreeWidgetItem();
1323 childFields->setText( 0, tr(
"Joined fields" ) );
1326 childFields->setText( 1, QLocale().toString( list->count() ) );
1328 childFields->setText( 1, tr(
"all" ) );
1329 joinItem->addChild( childFields );
1331 if ( insertIndex >= 0 )
1332 mJoinTreeWidget->insertTopLevelItem( insertIndex, joinItem );
1334 mJoinTreeWidget->addTopLevelItem( joinItem );
1336 mJoinTreeWidget->setCurrentItem( joinItem );
1337 mJoinTreeWidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
1347 QDialog *dlg =
new QDialog();
1348 QString key = u
"/UI/paneldialog/%1"_s.arg( panel->
panelTitle() );
1349 QgsSettings settings;
1350 dlg->restoreGeometry( settings.
value( key ).toByteArray() );
1352 dlg->setLayout(
new QVBoxLayout() );
1353 dlg->layout()->addWidget( panel );
1354 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok );
1355 connect( buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept );
1356 dlg->layout()->addWidget( buttonBox );
1358 settings.
setValue( key, dlg->saveGeometry() );
1362void QgsVectorLayerProperties::mButtonRemoveJoin_clicked()
1364 QTreeWidgetItem *currentJoinItem = mJoinTreeWidget->currentItem();
1366 if ( currentJoinItem && currentJoinItem->parent() )
1368 currentJoinItem = currentJoinItem->parent();
1371 if ( !mLayer || !currentJoinItem )
1376 mLayer->removeJoin( currentJoinItem->data( 0, Qt::UserRole ).toString() );
1377 mJoinTreeWidget->takeTopLevelItem( mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem ) );
1378 setPbnQueryBuilderEnabled();
1379 mSourceFieldsPropertiesDialog->init();
1380 mAttributesFormPropertiesDialog->init();
1384void QgsVectorLayerProperties::mButtonAddWmsDimension_clicked()
1390 QStringList alreadyDefinedDimensions;
1391 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1392 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &dims = serverProperties->
wmsDimensions();
1393 for (
const QgsMapLayerServerProperties::WmsDimensionInfo &dim : dims )
1395 alreadyDefinedDimensions << dim.name;
1398 QgsWmsDimensionDialog d( mLayer, alreadyDefinedDimensions );
1399 if ( d.exec() == QDialog::Accepted )
1401 QgsMapLayerServerProperties::WmsDimensionInfo info = d.info();
1404 addWmsDimensionInfoToTreeWidget( info );
1408void QgsVectorLayerProperties::mButtonEditWmsDimension_clicked()
1410 QTreeWidgetItem *currentWmsDimensionItem = mWmsDimensionsTreeWidget->currentItem();
1411 mWmsDimensionsTreeWidget_itemDoubleClicked( currentWmsDimensionItem, 0 );
1414void QgsVectorLayerProperties::mWmsDimensionsTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int )
1416 if ( !mLayer || !item )
1421 QString wmsDimName = item->data( 0, Qt::UserRole ).toString();
1422 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1423 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &dims = serverProperties->
wmsDimensions();
1424 QStringList alreadyDefinedDimensions;
1426 for (
int i = 0; i < dims.size(); ++i )
1428 QString dimName = dims[i].name;
1429 if ( dimName == wmsDimName )
1435 alreadyDefinedDimensions << dimName;
1443 QgsWmsDimensionDialog d( mLayer, alreadyDefinedDimensions );
1444 d.setWindowTitle( tr(
"Edit WMS Dimension" ) );
1445 d.setInfo( dims[j] );
1447 if ( d.exec() == QDialog::Accepted )
1449 QgsMapLayerServerProperties::WmsDimensionInfo info = d.info();
1452 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1454 int idx = mWmsDimensionsTreeWidget->indexOfTopLevelItem( item );
1455 mWmsDimensionsTreeWidget->takeTopLevelItem( idx );
1459 addWmsDimensionInfoToTreeWidget( info, idx );
1465 QTreeWidgetItem *wmsDimensionItem =
new QTreeWidgetItem();
1466 wmsDimensionItem->setFlags( Qt::ItemIsEnabled );
1468 wmsDimensionItem->setText( 0, tr(
"Dimension" ) );
1469 wmsDimensionItem->setText( 1, wmsDim.
name );
1471 QFont f = wmsDimensionItem->font( 0 );
1473 wmsDimensionItem->setFont( 0, f );
1474 wmsDimensionItem->setFont( 1, f );
1476 wmsDimensionItem->setData( 0, Qt::UserRole, wmsDim.
name );
1478 QTreeWidgetItem *childWmsDimensionField =
new QTreeWidgetItem();
1479 childWmsDimensionField->setText( 0, tr(
"Field" ) );
1480 childWmsDimensionField->setText( 1, wmsDim.
fieldName );
1481 childWmsDimensionField->setFlags( Qt::ItemIsEnabled );
1482 wmsDimensionItem->addChild( childWmsDimensionField );
1484 QTreeWidgetItem *childWmsDimensionEndField =
new QTreeWidgetItem();
1485 childWmsDimensionEndField->setText( 0, tr(
"End field" ) );
1486 childWmsDimensionEndField->setText( 1, wmsDim.
endFieldName );
1487 childWmsDimensionEndField->setFlags( Qt::ItemIsEnabled );
1488 wmsDimensionItem->addChild( childWmsDimensionEndField );
1490 QTreeWidgetItem *childWmsDimensionUnits =
new QTreeWidgetItem();
1491 childWmsDimensionUnits->setText( 0, tr(
"Units" ) );
1492 childWmsDimensionUnits->setText( 1, wmsDim.
units );
1493 childWmsDimensionUnits->setFlags( Qt::ItemIsEnabled );
1494 wmsDimensionItem->addChild( childWmsDimensionUnits );
1496 QTreeWidgetItem *childWmsDimensionUnitSymbol =
new QTreeWidgetItem();
1497 childWmsDimensionUnitSymbol->setText( 0, tr(
"Unit symbol" ) );
1498 childWmsDimensionUnitSymbol->setText( 1, wmsDim.
unitSymbol );
1499 childWmsDimensionUnitSymbol->setFlags( Qt::ItemIsEnabled );
1500 wmsDimensionItem->addChild( childWmsDimensionUnitSymbol );
1502 QTreeWidgetItem *childWmsDimensionDefaultValue =
new QTreeWidgetItem();
1503 childWmsDimensionDefaultValue->setText( 0, tr(
"Default display" ) );
1505 childWmsDimensionDefaultValue->setFlags( Qt::ItemIsEnabled );
1506 wmsDimensionItem->addChild( childWmsDimensionDefaultValue );
1508 QTreeWidgetItem *childWmsDimensionRefValue =
new QTreeWidgetItem();
1509 childWmsDimensionRefValue->setText( 0, tr(
"Reference value" ) );
1510 childWmsDimensionRefValue->setText( 1, wmsDim.
referenceValue.toString() );
1511 childWmsDimensionRefValue->setFlags( Qt::ItemIsEnabled );
1512 wmsDimensionItem->addChild( childWmsDimensionRefValue );
1514 if ( insertIndex >= 0 )
1515 mWmsDimensionsTreeWidget->insertTopLevelItem( insertIndex, wmsDimensionItem );
1517 mWmsDimensionsTreeWidget->addTopLevelItem( wmsDimensionItem );
1519 mWmsDimensionsTreeWidget->setCurrentItem( wmsDimensionItem );
1520 mWmsDimensionsTreeWidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
1523void QgsVectorLayerProperties::mButtonRemoveWmsDimension_clicked()
1525 QTreeWidgetItem *currentWmsDimensionItem = mWmsDimensionsTreeWidget->currentItem();
1526 if ( !mLayer || !currentWmsDimensionItem )
1531 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1532 serverProperties->
removeWmsDimension( currentWmsDimensionItem->data( 0, Qt::UserRole ).toString() );
1533 mWmsDimensionsTreeWidget->takeTopLevelItem( mWmsDimensionsTreeWidget->indexOfTopLevelItem( currentWmsDimensionItem ) );
1537void QgsVectorLayerProperties::updateSymbologyPage()
1540 delete mRendererDialog;
1541 mRendererDialog =
nullptr;
1543 if ( mLayer->renderer() )
1546 mRendererDialog->setDockMode(
false );
1547 QgsSymbolWidgetContext context;
1550 mRendererDialog->setContext( context );
1557 mOptsPage_Style->setEnabled(
false );
1560 if ( mRendererDialog )
1562 mRendererDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
1563 widgetStackRenderers->addWidget( mRendererDialog );
1564 widgetStackRenderers->setCurrentWidget( mRendererDialog );
1565 widgetStackRenderers->currentWidget()->layout()->setContentsMargins( 0, 0, 0, 0 );
1569void QgsVectorLayerProperties::setPbnQueryBuilderEnabled()
1571 pbnQueryBuilder->setEnabled( mLayer && mLayer->dataProvider() && mLayer->dataProvider()->supportsSubsetString() && !mLayer->isEditable() );
1573 if ( mLayer && mLayer->isEditable() )
1575 pbnQueryBuilder->setToolTip( tr(
"Stop editing mode to enable this." ) );
1579void QgsVectorLayerProperties::pbnUpdateExtents_clicked()
1581 mLayer->updateExtents(
true );
1582 mMetadataFilled =
false;
1589 if ( index ==
mOptStackedWidget->indexOf( mOptsPage_Information ) && !mMetadataFilled )
1592 teMetadataViewer->clear();
1593 teMetadataViewer->setHtml( htmlMetadata() );
1594 mMetadataFilled =
true;
1599 mAttributesFormPropertiesDialog->store();
1604 if ( mActionDialog )
1606 mAttributesFormPropertiesDialog->initAvailableWidgetsActions( mActionDialog->actions() );
1613void QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled(
bool checked )
1618 mSimplifyDrawingAtProvider->setEnabled(
false );
1622 mSimplifyDrawingAtProvider->setEnabled( checked );
1626void QgsVectorLayerProperties::updateVariableEditor()
1628 QgsExpressionContext context;
1629 mVariableEditor->setContext( &context );
1633 mVariableEditor->reloadContext();
1634 mVariableEditor->setEditableScopeIndex( 2 );
1637void QgsVectorLayerProperties::showHelp()
1639 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
1641 if ( helpPage.isValid() )
1651void QgsVectorLayerProperties::updateAuxiliaryStoragePage()
1653 const QgsAuxiliaryLayer *alayer = mLayer->auxiliaryLayer();
1658 mAuxiliaryStorageInformationGrpBox->setEnabled(
true );
1659 mAuxiliaryStorageFieldsGrpBox->setEnabled(
true );
1666 mAuxiliaryStorageFeaturesLineEdit->setText( QLocale().toString( features ) );
1669 mAuxiliaryLayerActionClear->setEnabled(
true );
1670 mAuxiliaryLayerActionDelete->setEnabled(
true );
1671 mAuxiliaryLayerActionExport->setEnabled(
true );
1672 mAuxiliaryLayerActionNew->setEnabled(
false );
1678 mAuxiliaryStorageFieldsLineEdit->setText( QLocale().toString( fields ) );
1681 mAuxiliaryStorageFieldsTree->clear();
1685 QTreeWidgetItem *item =
new QTreeWidgetItem();
1687 item->setText( 0, prop.
origin() );
1688 item->setText( 1, prop.
name() );
1689 item->setText( 2, prop.
comment() );
1690 item->setText( 3, field.typeName() );
1691 item->setText( 4, field.name() );
1693 mAuxiliaryStorageFieldsTree->addTopLevelItem( item );
1699 mAuxiliaryStorageInformationGrpBox->setEnabled(
false );
1700 mAuxiliaryStorageFieldsGrpBox->setEnabled(
false );
1702 mAuxiliaryLayerActionClear->setEnabled(
false );
1703 mAuxiliaryLayerActionDelete->setEnabled(
false );
1704 mAuxiliaryLayerActionExport->setEnabled(
false );
1705 mAuxiliaryLayerActionNew->setEnabled(
true );
1707 mAuxiliaryStorageFieldsTree->clear();
1708 mAuxiliaryStorageKeyLineEdit->setText( QString() );
1709 mAuxiliaryStorageFieldsLineEdit->setText( QString() );
1710 mAuxiliaryStorageFeaturesLineEdit->setText( QString() );
1714void QgsVectorLayerProperties::onAuxiliaryLayerNew()
1721 QgsNewAuxiliaryLayerDialog dlg( mLayer,
this );
1722 if ( dlg.exec() == QDialog::Accepted )
1724 updateAuxiliaryStoragePage();
1728void QgsVectorLayerProperties::onAuxiliaryLayerClear()
1735 const QString msg = tr(
"Are you sure you want to clear auxiliary data for %1?" ).arg( mLayer->name() );
1736 QMessageBox::StandardButton reply;
1737 reply = QMessageBox::question(
this,
"Clear Auxiliary Data", msg, QMessageBox::Yes | QMessageBox::No );
1739 if ( reply == QMessageBox::Yes )
1741 QApplication::setOverrideCursor( Qt::WaitCursor );
1743 QApplication::restoreOverrideCursor();
1744 updateAuxiliaryStoragePage();
1745 mLayer->triggerRepaint();
1749void QgsVectorLayerProperties::onAuxiliaryLayerDelete()
1755 const QString msg = tr(
"Are you sure you want to delete auxiliary storage for %1?" ).arg( mLayer->name() );
1756 QMessageBox::StandardButton reply;
1757 reply = QMessageBox::question(
this,
"Delete Auxiliary Storage", msg, QMessageBox::Yes | QMessageBox::No );
1759 if ( reply == QMessageBox::Yes )
1761 QApplication::setOverrideCursor( Qt::WaitCursor );
1762 QgsDataSourceUri uri( alayer->
source() );
1772 mLayer->setAuxiliaryLayer();
1774 QApplication::restoreOverrideCursor();
1775 updateAuxiliaryStoragePage();
1776 mLayer->triggerRepaint();
1780void QgsVectorLayerProperties::onAuxiliaryLayerDeleteField()
1786 QList<QTreeWidgetItem *> items = mAuxiliaryStorageFieldsTree->selectedItems();
1787 if ( items.count() < 1 )
1791 const QTreeWidgetItem *item = items[0];
1792 QgsPropertyDefinition def;
1794 def.
setName( item->text( 1 ) );
1799 const int index = mLayer->auxiliaryLayer()->fields().indexOf( fieldName );
1804 const QString msg = tr(
"Are you sure you want to delete auxiliary field %1 for %2?" ).arg( item->text( 1 ), item->text( 0 ) );
1806 QMessageBox::StandardButton reply;
1807 const QString title = QObject::tr(
"Delete Auxiliary Field" );
1808 reply = QMessageBox::question(
this, title, msg, QMessageBox::Yes | QMessageBox::No );
1810 if ( reply == QMessageBox::Yes )
1812 QApplication::setOverrideCursor( Qt::WaitCursor );
1813 deleteAuxiliaryField( index );
1814 mLayer->triggerRepaint();
1815 QApplication::restoreOverrideCursor();
1819void QgsVectorLayerProperties::onAuxiliaryLayerAddField()
1825 QgsNewAuxiliaryFieldDialog dlg( QgsPropertyDefinition(), mLayer,
false );
1826 if ( dlg.exec() == QDialog::Accepted )
1828 updateAuxiliaryStoragePage();
1832void QgsVectorLayerProperties::deleteAuxiliaryField(
int index )
1834 if ( !mLayer->auxiliaryLayer() )
1837 int key = mLayer->auxiliaryLayer()->propertyFromIndex( index );
1838 QgsPropertyDefinition def = mLayer->auxiliaryLayer()->propertyDefinitionFromIndex( index );
1840 if ( mLayer->auxiliaryLayer()->deleteAttribute( index ) )
1842 mLayer->updateFields();
1845 if ( key >= 0 && def.
origin().compare(
"labeling", Qt::CaseInsensitive ) == 0 && labelingDialog && labelingDialog->labelingGui() )
1850 updateAuxiliaryStoragePage();
1851 mSourceFieldsPropertiesDialog->init();
1855 const QString title = QObject::tr(
"Delete Auxiliary Field" );
1856 const QString errors = mLayer->auxiliaryLayer()->commitErrors().join(
"\n "_L1 );
1857 const QString msg = QObject::tr(
"Unable to remove auxiliary field (%1)" ).arg( errors );
1865 if ( obj == mMapTipPreviewContainer && ev->type() == QEvent::Resize )
1869 return QgsOptionsDialogBase::eventFilter( obj, ev );
1872void QgsVectorLayerProperties::initMapTipPreview()
1875 mMapTipSplitter->setSizes( { 400, 200 } );
1877 mMapTipPreviewContainer->installEventFilter(
this );
1881 mMapTipPreview =
new QgsWebView( mMapTipPreviewContainer );
1882 mMapTipPreviewLayout->addWidget( mMapTipPreview );
1884 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
1885 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled,
true );
1886 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::LocalStorageEnabled,
true );
1889 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
1890 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
1893 connect( mMapTipWidget, &QgsCodeEditorHTML::textChanged,
this, &QgsVectorLayerProperties::updateMapTipPreview );
1897void QgsVectorLayerProperties::updateMapTipPreview()
1899 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1901 mMapTipPreview->setHtml( htmlContent );
1904void QgsVectorLayerProperties::resizeMapTip()
1907 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1908 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.