77#include <QColorDialog>
79#include <QDesktopServices>
88#include <QRegularExpressionValidator>
92#include "moc_qgsvectorlayerproperties.cpp"
94using namespace Qt::StringLiterals;
98 , mMessageBar( messageBar )
100 , mOriginalSubsetSQL( lyr->subsetString() )
103 connect( pbnQueryBuilder, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnQueryBuilder_clicked );
104 connect( pbnIndex, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnIndex_clicked );
106 connect( pbnUpdateExtents, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnUpdateExtents_clicked );
107 connect( mButtonAddJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonAddJoin_clicked );
108 connect( mButtonEditJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonEditJoin_clicked );
109 connect( mJoinTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsVectorLayerProperties::mJoinTreeWidget_itemDoubleClicked );
110 connect( mButtonRemoveJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonRemoveJoin_clicked );
111 connect( mButtonAddWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonAddWmsDimension_clicked );
112 connect( mButtonEditWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonEditWmsDimension_clicked );
113 connect( mWmsDimensionsTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsVectorLayerProperties::mWmsDimensionsTreeWidget_itemDoubleClicked );
114 connect( mButtonRemoveWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonRemoveWmsDimension_clicked );
115 connect( mSimplifyDrawingGroupBox, &QGroupBox::toggled,
this, &QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled );
116 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsVectorLayerProperties::showHelp );
125 mBtnStyle =
new QPushButton( tr(
"Style" ),
this );
126 QMenu *menuStyle =
new QMenu(
this );
127 mActionLoadStyle =
new QAction( tr(
"Load Style…" ),
this );
130 mActionSaveStyle =
new QAction( tr(
"Save Current Style…" ),
this );
133 mActionSaveMultipleStyles =
new QAction( tr(
"Save Multiple Styles…" ),
this );
134 connect( mActionSaveMultipleStyles, &QAction::triggered,
this, &QgsVectorLayerProperties::saveMultipleStylesAs );
136 mSourceGroupBox->hide();
139 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsVectorLayerProperties::aboutToShowStyleMenu );
140 buttonBox->addButton(
mBtnStyle, QDialogButtonBox::ResetRole );
150 mContext =
mCanvas->createExpressionContext();
162 mMapTipFieldComboBox->setLayer( lyr );
163 mDisplayExpressionWidget->setLayer( lyr );
164 mDisplayExpressionWidget->registerExpressionContextGenerator(
this );
167 mFeaturesSortOrderExpressionWidget->setLayer( lyr );
168 mFeaturesSortOrderExpressionWidget->registerExpressionContextGenerator(
this );
169 connect( mFeaturesSortOrderDirectionButton, &QAbstractButton::clicked,
this, [
this]() {
170 mFeaturesSortOrderDirectionButton->setArrowType( mFeaturesSortOrderDirectionButton->arrowType() == Qt::UpArrow ? Qt::DownArrow : Qt::UpArrow );
173 connect( mMapTipInsertFieldButton, &QAbstractButton::clicked,
this, &QgsVectorLayerProperties::insertField );
174 connect( mMapTipInsertExpressionButton, &QAbstractButton::clicked,
this, &QgsVectorLayerProperties::insertOrEditExpression );
179 mEnableMapTips->setChecked( mLayer->mapTipsEnabled() );
181 QVBoxLayout *layout =
nullptr;
183 if ( mLayer->isSpatial() )
186 layout =
new QVBoxLayout( labelingFrame );
187 layout->setContentsMargins( 0, 0, 0, 0 );
189 labelingDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
191 layout->addWidget( labelingDialog );
192 labelingFrame->setLayout( layout );
195 layout =
new QVBoxLayout( mMaskingFrame );
196 layout->setContentsMargins( 0, 0, 0, 0 );
197 mMaskingWidget =
new QgsMaskingWidget( mMaskingFrame );
198 mMaskingWidget->setLayer( mLayer );
199 mMaskingWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
200 layout->addWidget( mMaskingWidget );
201 mMaskingFrame->setLayout( layout );
205 labelingDialog =
nullptr;
206 mOptsPage_Labels->setEnabled(
false );
207 mOptsPage_Masks->setEnabled(
false );
208 mGeomGroupBox->setEnabled(
false );
209 mGeomGroupBox->setVisible(
false );
210 mCrsGroupBox->setEnabled(
false );
211 mCrsGroupBox->setVisible(
false );
215 QVBoxLayout *actionLayout =
new QVBoxLayout( actionOptionsFrame );
216 actionLayout->setContentsMargins( 0, 0, 0, 0 );
218 mActionDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
219 actionLayout->addWidget( mActionDialog );
222 mSourceFieldsPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
223 mSourceFieldsFrame->setLayout(
new QVBoxLayout( mSourceFieldsFrame ) );
224 mSourceFieldsFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
225 mSourceFieldsFrame->layout()->addWidget( mSourceFieldsPropertiesDialog );
230 mAttributesFormPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
231 mAttributesFormFrame->setLayout(
new QVBoxLayout( mAttributesFormFrame ) );
232 mAttributesFormFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
233 mAttributesFormFrame->layout()->addWidget( mAttributesFormPropertiesDialog );
236 QVBoxLayout *metadataLayout =
new QVBoxLayout( metadataFrame );
237 metadataLayout->setContentsMargins( 0, 0, 0, 0 );
239 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
240 mMetadataWidget->setMapCanvas(
mCanvas );
241 metadataLayout->addWidget( mMetadataWidget );
242 metadataFrame->setLayout( metadataLayout );
244 QVBoxLayout *temporalLayout =
new QVBoxLayout( temporalFrame );
245 temporalLayout->setContentsMargins( 0, 0, 0, 0 );
247 temporalLayout->addWidget( mTemporalWidget );
251 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
252 QMenu *menuMetadata =
new QMenu(
this );
255 menuMetadata->addSeparator();
259 buttonBox->addButton(
mBtnMetadata, QDialogButtonBox::ResetRole );
261 mSelectionColorButton->setAllowOpacity(
true );
262 mSelectionColorButton->setColorDialogTitle( tr(
"Override Selection Color" ) );
265 mSelectionColorButton->setColor(
mCanvas->selectionColor() );
266 mSelectionColorButton->setDefaultColor(
mCanvas->selectionColor() );
268 connect( mRadioOverrideSelectionColor, &QRadioButton::toggled, mSelectionColorButton, &QWidget::setEnabled );
269 mSelectionColorButton->setEnabled(
false );
270 connect( mRadioOverrideSelectionSymbol, &QRadioButton::toggled, mSelectionSymbolButton, &QWidget::setEnabled );
271 switch ( mLayer->geometryType() )
287 mSelectionSymbolButton->setEnabled(
false );
288 mRadioDefaultSelectionColor->setChecked(
true );
291 QVBoxLayout *diagLayout =
new QVBoxLayout( mDiagramFrame );
292 diagLayout->setContentsMargins( 0, 0, 0, 0 );
294 diagramPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
296 diagLayout->addWidget( diagramPropertiesDialog );
297 mDiagramFrame->setLayout( diagLayout );
301 if ( mLayer->dataProvider() )
307 pbnIndex->setEnabled(
false );
311 pbnIndex->setEnabled(
false );
312 pbnIndex->setText( tr(
"Spatial Index Exists" ) );
318 QString enc = mLayer->dataProvider()->encoding();
319 int encindex = cboProviderEncoding->findText( enc );
322 cboProviderEncoding->insertItem( 0, enc );
325 cboProviderEncoding->setCurrentIndex( encindex );
327 else if ( mLayer->providerType() ==
"ogr"_L1 )
331 cboProviderEncoding->addItem( mLayer->dataProvider()->encoding() );
332 cboProviderEncoding->setEnabled(
false );
337 mDataSourceEncodingFrame->hide();
341 mCrsSelector->setCrs( mLayer->crs() );
344 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
347 addJoinToTreeWidget( join );
350 mOldJoins = mLayer->vectorJoins();
353 mLegendWidget->setMapCanvas(
mCanvas );
354 mLegendWidget->setLayer( mLayer );
355 mLegendConfigEmbeddedWidget->setLayer( mLayer );
359 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &wmsDims = serverProperties->
wmsDimensions();
362 addWmsDimensionInfoToTreeWidget( dim );
366 myStyle.append( u
"body { margin: 10px; }\n "_s );
367 teMetadataViewer->clear();
368 teMetadataViewer->document()->setDefaultStyleSheet( myStyle );
369 teMetadataViewer->setOpenLinks(
false );
375 if ( !settings.
contains( u
"/Windows/VectorLayerProperties/tab"_s ) )
380 QList<QgsMapLayer *> dependencySources;
381 const QSet<QgsMapLayerDependency> constDependencies = mLayer->dependencies();
386 dependencySources << layer;
391 mLayersDependenciesTreeModel->setCheckedLayers( dependencySources );
392 connect(
QgsProject::instance(), &QObject::destroyed,
this, [
this] { mLayersDependenciesTreeView->setModel(
nullptr ); } );
393 mLayersDependenciesTreeView->setModel( mLayersDependenciesTreeModel );
395 mRefreshSettingsWidget->setLayer( mLayer );
396 mMapLayerServerPropertiesWidget->setHasWfsTitle(
true );
397 mMapLayerServerPropertiesWidget->setServerProperties( mLayer->serverProperties() );
400 QMenu *menu =
new QMenu(
this );
402 mAuxiliaryLayerActionNew =
new QAction( tr(
"Create" ),
this );
403 menu->addAction( mAuxiliaryLayerActionNew );
404 connect( mAuxiliaryLayerActionNew, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerNew );
406 mAuxiliaryLayerActionClear =
new QAction( tr(
"Clear" ),
this );
407 menu->addAction( mAuxiliaryLayerActionClear );
408 connect( mAuxiliaryLayerActionClear, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerClear );
410 mAuxiliaryLayerActionDelete =
new QAction( tr(
"Delete" ),
this );
411 menu->addAction( mAuxiliaryLayerActionDelete );
412 connect( mAuxiliaryLayerActionDelete, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerDelete );
414 mAuxiliaryLayerActionExport =
new QAction( tr(
"Export" ),
this );
415 menu->addAction( mAuxiliaryLayerActionExport );
416 connect( mAuxiliaryLayerActionExport, &QAction::triggered,
this, [
this] { emit
exportAuxiliaryLayer( mLayer->auxiliaryLayer() ); } );
418 mAuxiliaryStorageActions->setMenu( menu );
420 connect( mAuxiliaryStorageFieldsDeleteBtn, &QPushButton::clicked,
this, &QgsVectorLayerProperties::onAuxiliaryLayerDeleteField );
421 connect( mAuxiliaryStorageFieldsAddBtn, &QPushButton::clicked,
this, &QgsVectorLayerProperties::onAuxiliaryLayerAddField );
423 updateAuxiliaryStoragePage();
425 mOptsPage_Information->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#information-properties"_s );
426 mOptsPage_Source->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#source-properties"_s );
427 mOptsPage_Style->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#symbology-properties"_s );
428 mOptsPage_Labels->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#labels-properties"_s );
429 mOptsPage_Masks->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#masks-properties"_s );
430 mOptsPage_Diagrams->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#diagrams-properties"_s );
431 mOptsPage_SourceFields->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#fields-properties"_s );
432 mOptsPage_AttributesForm->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#attributes-form-properties"_s );
433 mOptsPage_Joins->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#joins-properties"_s );
434 mOptsPage_AuxiliaryStorage->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#auxiliary-storage-properties"_s );
435 mOptsPage_Actions->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#actions-properties"_s );
436 mOptsPage_Display->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#display-properties"_s );
437 mOptsPage_Rendering->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#rendering-properties"_s );
438 mOptsPage_Temporal->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#temporal-properties"_s );
439 mOptsPage_Variables->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#variables-properties"_s );
440 mOptsPage_Metadata->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#metadata-properties"_s );
441 mOptsPage_DataDependencies->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#dependencies-properties"_s );
442 mOptsPage_Legend->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#legend-properties"_s );
443 mOptsPage_Server->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#qgis-server-properties"_s );
458 setPbnQueryBuilderEnabled();
461void QgsVectorLayerProperties::insertField()
465 if ( mMapTipFieldComboBox->currentField().isEmpty() )
467 QString expression = u
"[%\""_s;
468 expression += mMapTipFieldComboBox->currentField();
469 expression +=
"\"%]"_L1;
471 mMapTipWidget->insertText( expression );
474void QgsVectorLayerProperties::insertOrEditExpression()
477 int selectionStart = mMapTipWidget->selectionStart();
478 int selectionEnd = mMapTipWidget->selectionEnd();
482 QgsExpressionBuilderDialog exprDlg( mLayer, expression,
this, u
"generic"_s, context );
484 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
485 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
486 mMapTipWidget->insertText(
"[%" + exprDlg.expressionText().trimmed() +
"%]" );
488 mMapTipWidget->setLinearSelection( selectionStart, selectionEnd );
493 if ( !mSourceWidget )
498 QHBoxLayout *layout =
new QHBoxLayout();
499 layout->addWidget( mSourceWidget );
500 mSourceGroupBox->setLayout( layout );
501 if ( !mSourceWidget->groupTitle().isEmpty() )
502 mSourceGroupBox->setTitle( mSourceWidget->groupTitle() );
504 mSourceGroupBox->show();
507 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
508 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
515 mSourceWidget->setMapCanvas(
mCanvas );
516 mSourceWidget->setSourceUri( mLayer->source() );
520 mLayerOrigNameLineEdit->setText( mLayer->name() );
521 mBackupCrs = mLayer->crs();
524 mSubsetGroupBox->setEnabled(
true );
525 txtSubsetSQL->setText( mLayer->subsetString() );
531 txtSubsetSQL->setReadOnly(
true );
532 txtSubsetSQL->setCaretWidth( 0 );
533 txtSubsetSQL->setCaretLineVisible(
false );
534 setPbnQueryBuilderEnabled();
535 if ( mLayer->dataProvider() && !mLayer->dataProvider()->supportsSubsetString() )
538 mSubsetGroupBox->hide();
541 mDisplayExpressionWidget->setField( mLayer->displayExpression() );
542 mEnableMapTips->setChecked( mLayer->mapTipsEnabled() );
543 mMapTipWidget->setText( mLayer->mapTipTemplate() );
545 mFeaturesSortOrderExpressionWidget->setField( mLayer->attributeTableConfig().sortExpression() );
546 mFeaturesSortOrderDirectionButton->setArrowType( mLayer->attributeTableConfig().sortOrder() == Qt::AscendingOrder ? Qt::UpArrow : Qt::DownArrow );
549 mScaleRangeWidget->setScaleRange( mLayer->minimumScale(), mLayer->maximumScale() );
550 mScaleVisibilityGroupBox->setChecked( mLayer->hasScaleBasedVisibility() );
551 mScaleRangeWidget->setMapCanvas(
mCanvas );
553 mUseReferenceScaleGroupBox->setChecked( mLayer->renderer() && mLayer->renderer()->referenceScale() > 0 );
554 mReferenceScaleWidget->setShowCurrentScaleButton(
true );
555 mReferenceScaleWidget->setMapCanvas(
mCanvas );
556 if ( mUseReferenceScaleGroupBox->isChecked() )
557 mReferenceScaleWidget->setScale( mLayer->renderer()->referenceScale() );
559 mReferenceScaleWidget->setScale(
mCanvas->scale() );
564 mSimplifyDrawingSpinBox->setValue( simplifyMethod.
threshold() );
565 mSimplifyDrawingSpinBox->setClearValue( 1.0 );
570 mSelectionColorButton->setColor( selectionProperties->
selectionColor() );
574 mSelectionSymbolButton->setSymbol( symbol->clone() );
579 mRadioDefaultSelectionColor->setChecked(
true );
586 mRadioOverrideSelectionColor->setChecked(
true );
590 mRadioDefaultSelectionColor->setChecked(
true );
598 mRadioOverrideSelectionSymbol->setChecked(
true );
602 mRadioDefaultSelectionColor->setChecked(
true );
607 QString remark = u
" (%1)"_s.arg( tr(
"Not supported" ) );
611 mSimplifyDrawingAtProvider->setChecked(
false );
612 mSimplifyDrawingAtProvider->setEnabled(
false );
613 if ( !mSimplifyDrawingAtProvider->text().endsWith( remark ) )
614 mSimplifyDrawingAtProvider->setText( mSimplifyDrawingAtProvider->text().append( remark ) );
619 mSimplifyDrawingAtProvider->setEnabled( mSimplifyDrawingGroupBox->isChecked() );
620 if ( mSimplifyDrawingAtProvider->text().endsWith( remark ) )
622 QString newText = mSimplifyDrawingAtProvider->text();
623 newText.chop( remark.size() );
624 mSimplifyDrawingAtProvider->setText( newText );
631 mSimplifyDrawingGroupBox->setChecked(
false );
632 mSimplifyDrawingGroupBox->setEnabled(
false );
639 mSimplifyAlgorithmComboBox->setCurrentIndex( mSimplifyAlgorithmComboBox->findData( QVariant::fromValue( simplifyMethod.
simplifyAlgorithm() ) ) );
642 myScalesList.append( u
"1:1"_s );
643 mSimplifyMaximumScaleComboBox->updateScales( myScalesList );
644 mSimplifyMaximumScaleComboBox->setScale( simplifyMethod.
maximumScale() );
646 mForceRasterCheckBox->setChecked( mLayer->renderer() && mLayer->renderer()->forceRasterRender() );
648 mRefreshSettingsWidget->syncToLayer();
649 mMapLayerServerPropertiesWidget->sync();
651 mRefreshLayerNotificationCheckBox->setChecked( mLayer->isRefreshOnNotifyEnabled() );
652 mNotificationMessageCheckBox->setChecked( !mLayer->refreshOnNotifyMessage().isEmpty() );
653 mNotifyMessageValueLineEdit->setText( mLayer->refreshOnNotifyMessage() );
657 updateSymbologyPage();
659 mActionDialog->init( *mLayer->actions(), mLayer->attributeTableConfig() );
661 if ( labelingDialog )
662 labelingDialog->adaptToLayer();
664 mSourceFieldsPropertiesDialog->init();
665 mAttributesFormPropertiesDialog->init();
668 updateVariableEditor();
670 if ( diagramPropertiesDialog )
671 diagramPropertiesDialog->syncToOwnLayer();
676 page->syncToLayer( mLayer );
679 mMetadataWidget->setMetadata( &mLayer->metadata() );
681 mTemporalWidget->syncToLayer();
683 mLegendWidget->setLayer( mLayer );
688 if ( labelingDialog )
690 labelingDialog->writeSettingsToLayer();
692 mBackupCrs = mLayer->crs();
694 mLegendWidget->applyToLayer();
695 mLegendConfigEmbeddedWidget->applyToLayer();
698 mMetadataWidget->acceptMetadata();
699 mMetadataFilled =
false;
702 if ( mMaskingWidget )
703 mMaskingWidget->apply();
706 mLayer->setScaleBasedVisibility( mScaleVisibilityGroupBox->isChecked() );
707 mLayer->setMaximumScale( mScaleRangeWidget->maximumScale() );
708 mLayer->setMinimumScale( mScaleRangeWidget->minimumScale() );
711 if ( mLayer->dataProvider() )
715 mLayer->setProviderEncoding( cboProviderEncoding->currentText() );
719 mLayer->setDisplayExpression( mDisplayExpressionWidget->asExpression() );
720 mLayer->setMapTipsEnabled( mEnableMapTips->isChecked() );
721 mLayer->setMapTipTemplate( mMapTipWidget->text() );
725 config.
setSortOrder( mFeaturesSortOrderDirectionButton->arrowType() == Qt::UpArrow ? Qt::AscendingOrder : Qt::DescendingOrder );
726 mLayer->setAttributeTableConfig( config );
728 mLayer->actions()->clearActions();
729 const auto constActions = mActionDialog->actions();
730 for (
const QgsAction &action : constActions )
732 mLayer->actions()->addAction( action );
735 attributeTableConfig.
update( mLayer->fields() );
737 QVector<QgsAttributeTableConfig::ColumnConfig> columns = attributeTableConfig.
columns();
739 for (
int i = 0; i < columns.size(); ++i )
743 columns[i].hidden = !mActionDialog->showWidgetInAttributeTable();
749 mLayer->setAttributeTableConfig( attributeTableConfig );
751 mLayer->setName( mLayerOrigNameLineEdit->text() );
753 mAttributesFormPropertiesDialog->apply();
754 mSourceFieldsPropertiesDialog->apply();
757 mTemporalWidget->saveTemporalProperties();
759 if ( mLayer->renderer() )
766 diagramPropertiesDialog->apply();
774 if ( mMapLayerServerPropertiesWidget->save() )
775 mMetadataFilled =
false;
779 if ( mSimplifyDrawingGroupBox->isChecked() )
782 if ( mSimplifyDrawingSpinBox->value() > 1 )
788 simplifyMethod.
setThreshold( mSimplifyDrawingSpinBox->value() );
790 simplifyMethod.
setMaximumScale( mSimplifyMaximumScaleComboBox->scale() );
791 mLayer->setSimplifyMethod( simplifyMethod );
793 if ( mLayer->renderer() )
795 mLayer->renderer()->setForceRasterRender( mForceRasterCheckBox->isChecked() );
796 mLayer->renderer()->setReferenceScale( mUseReferenceScaleGroupBox->isChecked() ? mReferenceScaleWidget->scale() : -1 );
800 if ( mSelectionColorButton->color() != mSelectionColorButton->defaultColor() )
804 if (
QgsSymbol *symbol = mSelectionSymbolButton->symbol() )
807 if ( mRadioOverrideSelectionSymbol->isChecked() )
811 else if ( mRadioOverrideSelectionColor->isChecked() )
820 mRefreshSettingsWidget->saveToLayer();
822 mLayer->setRefreshOnNotifyEnabled( mRefreshLayerNotificationCheckBox->isChecked() );
823 mLayer->setRefreshOnNofifyMessage( mNotificationMessageCheckBox->isChecked() ? mNotifyMessageValueLineEdit->text() : QString() );
825 mOldJoins = mLayer->vectorJoins();
829 updateVariableEditor();
832 QSet<QgsMapLayerDependency> deps;
833 const auto checkedLayers = mLayersDependenciesTreeModel->checkedLayers();
836 if ( !mLayer->setDependencies( deps ) )
838 QMessageBox::warning(
nullptr, tr(
"Save Dependency" ), tr(
"This configuration introduces a cycle in data dependencies and will be ignored." ) );
847 bool dialogNeedsResync =
false;
850 const QString newSource = mSourceWidget->sourceUri();
851 if ( newSource != mLayer->source() )
858 dialogNeedsResync =
true;
864 mSubsetGroupBox->setEnabled(
true );
865 if ( txtSubsetSQL->text() != mLayer->subsetString() )
868 mLayer->setSubsetString( txtSubsetSQL->text() );
869 mMetadataFilled =
false;
871 dialogNeedsResync =
true;
873 mOriginalSubsetSQL = mLayer->subsetString();
875 if ( dialogNeedsResync )
878 mLayer->triggerRepaint();
880 mProjectDirtyBlocker.reset();
887 if ( mOldJoins != mLayer->vectorJoins() )
892 const auto constVectorJoins = mLayer->vectorJoins();
894 mLayer->removeJoin( info.joinLayerId() );
897 mLayer->addJoin( info );
900 if ( mOriginalSubsetSQL != mLayer->subsetString() )
905 mLayer->setSubsetString( mOriginalSubsetSQL );
914 if ( backupCrs != mLayer->crs() )
915 mLayer->setCrs( backupCrs );
918void QgsVectorLayerProperties::pbnQueryBuilder_clicked()
927 if ( dialog->exec() )
940void QgsVectorLayerProperties::pbnIndex_clicked()
942 QgsVectorDataProvider *pr = mLayer->dataProvider();
945 setCursor( Qt::WaitCursor );
947 setCursor( Qt::ArrowCursor );
950 pbnIndex->setEnabled(
false );
951 pbnIndex->setText( tr(
"Spatial Index Exists" ) );
952 QMessageBox::information(
this, tr(
"Spatial Index" ), tr(
"Creation of spatial index successful" ) );
956 QMessageBox::warning(
this, tr(
"Spatial Index" ), tr(
"Creation of spatial index failed" ) );
961QString QgsVectorLayerProperties::htmlMetadata()
963 return mLayer->htmlMetadata();
969 mLayer->setCrs( crs );
970 mMetadataFilled =
false;
971 mMetadataWidget->crsChanged();
974void QgsVectorLayerProperties::saveMultipleStylesAs()
976 QgsMapLayerSaveStyleDialog dlg( mLayer );
977 dlg.setSaveOnlyCurrentStyle(
false );
978 QgsSettings settings;
985 const QString originalStyle { mLayer->styleManager()->currentStyle() };
986 const QListWidget *stylesWidget { dlg.stylesWidget() };
989 QStringList stylesSelected;
990 for (
int i = 0; i < stylesWidget->count(); i++ )
992 if ( stylesWidget->item( i )->checkState() == Qt::CheckState::Checked )
994 stylesSelected.push_back( stylesWidget->item( i )->text() );
998 if ( !stylesSelected.isEmpty() )
1001 for (
const QString &styleName : std::as_const( stylesSelected ) )
1003 bool defaultLoadedFlag =
false;
1005 StyleType type = dlg.currentStyleType();
1006 mLayer->styleManager()->setCurrentStyle( styleName );
1013 const QString filePath { dlg.outputFilePath() };
1014 const QFileInfo fi { filePath };
1016 if ( styleIndex > 0 && stylesSelected.count() > 1 )
1019 while ( QFile::exists( safePath ) )
1021 const QFileInfo fi { safePath };
1022 safePath = QString( safePath ).replace(
'.' + fi.completeSuffix(), u
"_%1.%2"_s.arg( QString::number( i ), fi.completeSuffix() ) );
1027 message = mLayer->saveNamedStyle( safePath, defaultLoadedFlag, dlg.styleCategories() );
1029 message = mLayer->saveSldStyle( safePath, defaultLoadedFlag );
1032 if ( defaultLoadedFlag )
1039 QMessageBox::information(
this, tr(
"Save Style" ), message );
1046 QString infoWindowTitle = QObject::tr(
"Save style '%1' to DB (%2)" ).arg( styleName, mLayer->providerType() );
1049 QgsMapLayerSaveStyleDialog::SaveToDbSettings dbSettings = dlg.saveToDbSettings();
1052 QString name { dbSettings.
name };
1053 if ( name.isEmpty() )
1059 name += u
"_%1"_s.arg( styleName );
1060 QStringList ids, names, descriptions;
1061 mLayer->listStylesInDatabase( ids, names, descriptions, msgError );
1063 while ( names.contains( name ) )
1065 name = u
"%1 %2"_s.arg( name, QString::number( i ) );
1070 QString errorMessage;
1074 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 )
1075 == QMessageBox::No )
1080 else if ( !errorMessage.isEmpty() )
1082 QMessageBox::warning(
this, infoWindowTitle, errorMessage );
1088 if ( !msgError.isNull() )
1090 QMessageBox::warning(
this, infoWindowTitle, msgError );
1094 QMessageBox::information(
this, infoWindowTitle, tr(
"Style '%1' saved" ).arg( styleName ) );
1104 mLayer->styleManager()->setCurrentStyle( originalStyle );
1109void QgsVectorLayerProperties::aboutToShowStyleMenu()
1112 QMenu *m = qobject_cast<QMenu *>( sender() );
1115 m->addAction( mActionLoadStyle );
1116 m->addAction( mActionSaveStyle );
1119 if ( mLayer->styleManager()->styles().count() > 1 )
1121 mActionSaveStyle->setText( tr(
"Save Current Style…" ) );
1122 m->addAction( mActionSaveMultipleStyles );
1126 mActionSaveStyle->setText( tr(
"Save Style…" ) );
1138void QgsVectorLayerProperties::mButtonAddJoin_clicked()
1143 QList<QgsMapLayer *> joinedLayers;
1144 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
1145 joinedLayers.reserve( joins.size() );
1146 for (
int i = 0; i < joins.size(); ++i )
1148 joinedLayers.append( joins[i].joinLayer() );
1151 QgsJoinDialog d( mLayer, joinedLayers );
1152 if ( d.exec() == QDialog::Accepted )
1154 QgsVectorLayerJoinInfo info = d.joinInfo();
1156 if ( d.createAttributeIndex() )
1158 QgsVectorLayer *joinLayer = info.
joinLayer();
1164 mLayer->addJoin( info );
1165 addJoinToTreeWidget( info );
1166 setPbnQueryBuilderEnabled();
1167 mSourceFieldsPropertiesDialog->init();
1168 mAttributesFormPropertiesDialog->init();
1172void QgsVectorLayerProperties::mButtonEditJoin_clicked()
1174 QTreeWidgetItem *currentJoinItem = mJoinTreeWidget->currentItem();
1175 mJoinTreeWidget_itemDoubleClicked( currentJoinItem, 0 );
1178void QgsVectorLayerProperties::mJoinTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int )
1180 if ( !mLayer || !item )
1186 QTreeWidgetItem *currentJoinItem = item;
1187 if ( item->parent() )
1189 currentJoinItem = item->parent();
1193 QList<QgsMapLayer *> joinedLayers;
1194 QString joinLayerId = currentJoinItem->data( 0, Qt::UserRole ).toString();
1195 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
1197 for (
int i = 0; i < joins.size(); ++i )
1199 QgsVectorLayer *joinLayer = joins[i].joinLayer();
1203 if ( joinLayer->
id() == joinLayerId )
1210 joinedLayers.append( joinLayer );
1218 QgsJoinDialog d( mLayer, joinedLayers );
1219 d.setWindowTitle( tr(
"Edit Vector Join" ) );
1220 d.setJoinInfo( joins[j] );
1222 if ( d.exec() == QDialog::Accepted )
1224 QgsVectorLayerJoinInfo info = d.joinInfo();
1227 mLayer->removeJoin( joinLayerId );
1228 int idx = mJoinTreeWidget->indexOfTopLevelItem( item );
1229 mJoinTreeWidget->takeTopLevelItem( idx );
1234 if ( d.createAttributeIndex() )
1236 QgsVectorLayer *joinLayer = info.
joinLayer();
1242 mLayer->addJoin( info );
1243 addJoinToTreeWidget( info, idx );
1245 setPbnQueryBuilderEnabled();
1246 mSourceFieldsPropertiesDialog->init();
1247 mAttributesFormPropertiesDialog->init();
1251void QgsVectorLayerProperties::addJoinToTreeWidget(
const QgsVectorLayerJoinInfo &join,
const int insertIndex )
1253 QTreeWidgetItem *joinItem =
new QTreeWidgetItem();
1254 joinItem->setFlags( Qt::ItemIsEnabled );
1256 QgsVectorLayer *joinLayer = join.
joinLayer();
1257 if ( !mLayer || !joinLayer )
1262 joinItem->setText( 0, tr(
"Join layer" ) );
1263 if ( mLayer->auxiliaryLayer() && mLayer->auxiliaryLayer()->id() == join.
joinLayerId() )
1268 joinItem->setText( 1, joinLayer->
name() );
1270 QFont f = joinItem->font( 0 );
1272 joinItem->setFont( 0, f );
1273 joinItem->setFont( 1, f );
1275 joinItem->setData( 0, Qt::UserRole, join.
joinLayerId() );
1277 QTreeWidgetItem *childJoinField =
new QTreeWidgetItem();
1278 childJoinField->setText( 0, tr(
"Join field" ) );
1280 childJoinField->setFlags( Qt::ItemIsEnabled );
1281 joinItem->addChild( childJoinField );
1283 QTreeWidgetItem *childTargetField =
new QTreeWidgetItem();
1284 childTargetField->setText( 0, tr(
"Target field" ) );
1286 joinItem->addChild( childTargetField );
1288 QTreeWidgetItem *childMemCache =
new QTreeWidgetItem();
1289 childMemCache->setText( 0, tr(
"Cache join layer in virtual memory" ) );
1291 childMemCache->setText( 1, QChar( 0x2714 ) );
1292 joinItem->addChild( childMemCache );
1294 QTreeWidgetItem *childDynForm =
new QTreeWidgetItem();
1295 childDynForm->setText( 0, tr(
"Dynamic form" ) );
1297 childDynForm->setText( 1, QChar( 0x2714 ) );
1298 joinItem->addChild( childDynForm );
1300 QTreeWidgetItem *childEditable =
new QTreeWidgetItem();
1301 childEditable->setText( 0, tr(
"Editable join layer" ) );
1303 childEditable->setText( 1, QChar( 0x2714 ) );
1304 joinItem->addChild( childEditable );
1306 QTreeWidgetItem *childUpsert =
new QTreeWidgetItem();
1307 childUpsert->setText( 0, tr(
"Upsert on edit" ) );
1309 childUpsert->setText( 1, QChar( 0x2714 ) );
1310 joinItem->addChild( childUpsert );
1312 QTreeWidgetItem *childCascade =
new QTreeWidgetItem();
1313 childCascade->setText( 0, tr(
"Delete cascade" ) );
1315 childCascade->setText( 1, QChar( 0x2714 ) );
1316 joinItem->addChild( childCascade );
1318 QTreeWidgetItem *childPrefix =
new QTreeWidgetItem();
1319 childPrefix->setText( 0, tr(
"Custom field name prefix" ) );
1320 childPrefix->setText( 1, join.
prefix() );
1321 joinItem->addChild( childPrefix );
1323 QTreeWidgetItem *childFields =
new QTreeWidgetItem();
1324 childFields->setText( 0, tr(
"Joined fields" ) );
1327 childFields->setText( 1, QLocale().toString( list->count() ) );
1329 childFields->setText( 1, tr(
"all" ) );
1330 joinItem->addChild( childFields );
1332 if ( insertIndex >= 0 )
1333 mJoinTreeWidget->insertTopLevelItem( insertIndex, joinItem );
1335 mJoinTreeWidget->addTopLevelItem( joinItem );
1337 mJoinTreeWidget->setCurrentItem( joinItem );
1338 mJoinTreeWidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
1348 QDialog *dlg =
new QDialog();
1349 QString key = u
"/UI/paneldialog/%1"_s.arg( panel->
panelTitle() );
1350 QgsSettings settings;
1351 dlg->restoreGeometry( settings.
value( key ).toByteArray() );
1353 dlg->setLayout(
new QVBoxLayout() );
1354 dlg->layout()->addWidget( panel );
1355 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok );
1356 connect( buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept );
1357 dlg->layout()->addWidget( buttonBox );
1359 settings.
setValue( key, dlg->saveGeometry() );
1363void QgsVectorLayerProperties::mButtonRemoveJoin_clicked()
1365 QTreeWidgetItem *currentJoinItem = mJoinTreeWidget->currentItem();
1367 if ( currentJoinItem && currentJoinItem->parent() )
1369 currentJoinItem = currentJoinItem->parent();
1372 if ( !mLayer || !currentJoinItem )
1377 mLayer->removeJoin( currentJoinItem->data( 0, Qt::UserRole ).toString() );
1378 mJoinTreeWidget->takeTopLevelItem( mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem ) );
1379 setPbnQueryBuilderEnabled();
1380 mSourceFieldsPropertiesDialog->init();
1381 mAttributesFormPropertiesDialog->init();
1385void QgsVectorLayerProperties::mButtonAddWmsDimension_clicked()
1391 QStringList alreadyDefinedDimensions;
1392 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1393 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &dims = serverProperties->
wmsDimensions();
1394 for (
const QgsMapLayerServerProperties::WmsDimensionInfo &dim : dims )
1396 alreadyDefinedDimensions << dim.name;
1399 QgsWmsDimensionDialog d( mLayer, alreadyDefinedDimensions );
1400 if ( d.exec() == QDialog::Accepted )
1402 QgsMapLayerServerProperties::WmsDimensionInfo info = d.info();
1405 addWmsDimensionInfoToTreeWidget( info );
1409void QgsVectorLayerProperties::mButtonEditWmsDimension_clicked()
1411 QTreeWidgetItem *currentWmsDimensionItem = mWmsDimensionsTreeWidget->currentItem();
1412 mWmsDimensionsTreeWidget_itemDoubleClicked( currentWmsDimensionItem, 0 );
1415void QgsVectorLayerProperties::mWmsDimensionsTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int )
1417 if ( !mLayer || !item )
1422 QString wmsDimName = item->data( 0, Qt::UserRole ).toString();
1423 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1424 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &dims = serverProperties->
wmsDimensions();
1425 QStringList alreadyDefinedDimensions;
1427 for (
int i = 0; i < dims.size(); ++i )
1429 QString dimName = dims[i].name;
1430 if ( dimName == wmsDimName )
1436 alreadyDefinedDimensions << dimName;
1444 QgsWmsDimensionDialog d( mLayer, alreadyDefinedDimensions );
1445 d.setWindowTitle( tr(
"Edit WMS Dimension" ) );
1446 d.setInfo( dims[j] );
1448 if ( d.exec() == QDialog::Accepted )
1450 QgsMapLayerServerProperties::WmsDimensionInfo info = d.info();
1453 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1455 int idx = mWmsDimensionsTreeWidget->indexOfTopLevelItem( item );
1456 mWmsDimensionsTreeWidget->takeTopLevelItem( idx );
1460 addWmsDimensionInfoToTreeWidget( info, idx );
1466 QTreeWidgetItem *wmsDimensionItem =
new QTreeWidgetItem();
1467 wmsDimensionItem->setFlags( Qt::ItemIsEnabled );
1469 wmsDimensionItem->setText( 0, tr(
"Dimension" ) );
1470 wmsDimensionItem->setText( 1, wmsDim.
name );
1472 QFont f = wmsDimensionItem->font( 0 );
1474 wmsDimensionItem->setFont( 0, f );
1475 wmsDimensionItem->setFont( 1, f );
1477 wmsDimensionItem->setData( 0, Qt::UserRole, wmsDim.
name );
1479 QTreeWidgetItem *childWmsDimensionField =
new QTreeWidgetItem();
1480 childWmsDimensionField->setText( 0, tr(
"Field" ) );
1481 childWmsDimensionField->setText( 1, wmsDim.
fieldName );
1482 childWmsDimensionField->setFlags( Qt::ItemIsEnabled );
1483 wmsDimensionItem->addChild( childWmsDimensionField );
1485 QTreeWidgetItem *childWmsDimensionEndField =
new QTreeWidgetItem();
1486 childWmsDimensionEndField->setText( 0, tr(
"End field" ) );
1487 childWmsDimensionEndField->setText( 1, wmsDim.
endFieldName );
1488 childWmsDimensionEndField->setFlags( Qt::ItemIsEnabled );
1489 wmsDimensionItem->addChild( childWmsDimensionEndField );
1491 QTreeWidgetItem *childWmsDimensionUnits =
new QTreeWidgetItem();
1492 childWmsDimensionUnits->setText( 0, tr(
"Units" ) );
1493 childWmsDimensionUnits->setText( 1, wmsDim.
units );
1494 childWmsDimensionUnits->setFlags( Qt::ItemIsEnabled );
1495 wmsDimensionItem->addChild( childWmsDimensionUnits );
1497 QTreeWidgetItem *childWmsDimensionUnitSymbol =
new QTreeWidgetItem();
1498 childWmsDimensionUnitSymbol->setText( 0, tr(
"Unit symbol" ) );
1499 childWmsDimensionUnitSymbol->setText( 1, wmsDim.
unitSymbol );
1500 childWmsDimensionUnitSymbol->setFlags( Qt::ItemIsEnabled );
1501 wmsDimensionItem->addChild( childWmsDimensionUnitSymbol );
1503 QTreeWidgetItem *childWmsDimensionDefaultValue =
new QTreeWidgetItem();
1504 childWmsDimensionDefaultValue->setText( 0, tr(
"Default display" ) );
1506 childWmsDimensionDefaultValue->setFlags( Qt::ItemIsEnabled );
1507 wmsDimensionItem->addChild( childWmsDimensionDefaultValue );
1509 QTreeWidgetItem *childWmsDimensionRefValue =
new QTreeWidgetItem();
1510 childWmsDimensionRefValue->setText( 0, tr(
"Reference value" ) );
1511 childWmsDimensionRefValue->setText( 1, wmsDim.
referenceValue().toString() );
1512 childWmsDimensionRefValue->setFlags( Qt::ItemIsEnabled );
1513 wmsDimensionItem->addChild( childWmsDimensionRefValue );
1515 if ( insertIndex >= 0 )
1516 mWmsDimensionsTreeWidget->insertTopLevelItem( insertIndex, wmsDimensionItem );
1518 mWmsDimensionsTreeWidget->addTopLevelItem( wmsDimensionItem );
1520 mWmsDimensionsTreeWidget->setCurrentItem( wmsDimensionItem );
1521 mWmsDimensionsTreeWidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
1524void QgsVectorLayerProperties::mButtonRemoveWmsDimension_clicked()
1526 QTreeWidgetItem *currentWmsDimensionItem = mWmsDimensionsTreeWidget->currentItem();
1527 if ( !mLayer || !currentWmsDimensionItem )
1532 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1533 serverProperties->
removeWmsDimension( currentWmsDimensionItem->data( 0, Qt::UserRole ).toString() );
1534 mWmsDimensionsTreeWidget->takeTopLevelItem( mWmsDimensionsTreeWidget->indexOfTopLevelItem( currentWmsDimensionItem ) );
1538void QgsVectorLayerProperties::updateSymbologyPage()
1541 delete mRendererDialog;
1542 mRendererDialog =
nullptr;
1544 if ( mLayer->renderer() )
1547 mRendererDialog->setDockMode(
false );
1548 QgsSymbolWidgetContext context;
1551 mRendererDialog->setContext( context );
1558 mOptsPage_Style->setEnabled(
false );
1561 if ( mRendererDialog )
1563 mRendererDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
1564 widgetStackRenderers->addWidget( mRendererDialog );
1565 widgetStackRenderers->setCurrentWidget( mRendererDialog );
1566 widgetStackRenderers->currentWidget()->layout()->setContentsMargins( 0, 0, 0, 0 );
1570void QgsVectorLayerProperties::setPbnQueryBuilderEnabled()
1572 pbnQueryBuilder->setEnabled( mLayer && mLayer->dataProvider() && mLayer->dataProvider()->supportsSubsetString() && !mLayer->isEditable() );
1574 if ( mLayer && mLayer->isEditable() )
1576 pbnQueryBuilder->setToolTip( tr(
"Stop editing mode to enable this." ) );
1580void QgsVectorLayerProperties::pbnUpdateExtents_clicked()
1582 mLayer->updateExtents(
true );
1583 mMetadataFilled =
false;
1590 if ( index ==
mOptStackedWidget->indexOf( mOptsPage_Information ) && !mMetadataFilled )
1593 teMetadataViewer->clear();
1594 teMetadataViewer->setHtml( htmlMetadata() );
1595 mMetadataFilled =
true;
1600 mAttributesFormPropertiesDialog->store();
1605 if ( mActionDialog )
1607 mAttributesFormPropertiesDialog->initAvailableWidgetsActions( mActionDialog->actions() );
1614void QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled(
bool checked )
1619 mSimplifyDrawingAtProvider->setEnabled(
false );
1623 mSimplifyDrawingAtProvider->setEnabled( checked );
1627void QgsVectorLayerProperties::updateVariableEditor()
1629 QgsExpressionContext context;
1630 mVariableEditor->setContext( &context );
1634 mVariableEditor->reloadContext();
1635 mVariableEditor->setEditableScopeIndex( 2 );
1638void QgsVectorLayerProperties::showHelp()
1640 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
1642 if ( helpPage.isValid() )
1652void QgsVectorLayerProperties::updateAuxiliaryStoragePage()
1654 const QgsAuxiliaryLayer *alayer = mLayer->auxiliaryLayer();
1659 mAuxiliaryStorageInformationGrpBox->setEnabled(
true );
1660 mAuxiliaryStorageFieldsGrpBox->setEnabled(
true );
1667 mAuxiliaryStorageFeaturesLineEdit->setText( QLocale().toString( features ) );
1670 mAuxiliaryLayerActionClear->setEnabled(
true );
1671 mAuxiliaryLayerActionDelete->setEnabled(
true );
1672 mAuxiliaryLayerActionExport->setEnabled(
true );
1673 mAuxiliaryLayerActionNew->setEnabled(
false );
1679 mAuxiliaryStorageFieldsLineEdit->setText( QLocale().toString( fields ) );
1682 mAuxiliaryStorageFieldsTree->clear();
1686 QTreeWidgetItem *item =
new QTreeWidgetItem();
1688 item->setText( 0, prop.
origin() );
1689 item->setText( 1, prop.
name() );
1690 item->setText( 2, prop.
comment() );
1691 item->setText( 3, field.typeName() );
1692 item->setText( 4, field.name() );
1694 mAuxiliaryStorageFieldsTree->addTopLevelItem( item );
1700 mAuxiliaryStorageInformationGrpBox->setEnabled(
false );
1701 mAuxiliaryStorageFieldsGrpBox->setEnabled(
false );
1703 mAuxiliaryLayerActionClear->setEnabled(
false );
1704 mAuxiliaryLayerActionDelete->setEnabled(
false );
1705 mAuxiliaryLayerActionExport->setEnabled(
false );
1706 mAuxiliaryLayerActionNew->setEnabled(
true );
1708 mAuxiliaryStorageFieldsTree->clear();
1709 mAuxiliaryStorageKeyLineEdit->setText( QString() );
1710 mAuxiliaryStorageFieldsLineEdit->setText( QString() );
1711 mAuxiliaryStorageFeaturesLineEdit->setText( QString() );
1715void QgsVectorLayerProperties::onAuxiliaryLayerNew()
1722 QgsNewAuxiliaryLayerDialog dlg( mLayer,
this );
1723 if ( dlg.exec() == QDialog::Accepted )
1725 updateAuxiliaryStoragePage();
1729void QgsVectorLayerProperties::onAuxiliaryLayerClear()
1736 const QString msg = tr(
"Are you sure you want to clear auxiliary data for %1?" ).arg( mLayer->name() );
1737 QMessageBox::StandardButton reply;
1738 reply = QMessageBox::question(
this,
"Clear Auxiliary Data", msg, QMessageBox::Yes | QMessageBox::No );
1740 if ( reply == QMessageBox::Yes )
1742 QApplication::setOverrideCursor( Qt::WaitCursor );
1744 QApplication::restoreOverrideCursor();
1745 updateAuxiliaryStoragePage();
1746 mLayer->triggerRepaint();
1750void QgsVectorLayerProperties::onAuxiliaryLayerDelete()
1756 const QString msg = tr(
"Are you sure you want to delete auxiliary storage for %1?" ).arg( mLayer->name() );
1757 QMessageBox::StandardButton reply;
1758 reply = QMessageBox::question(
this,
"Delete Auxiliary Storage", msg, QMessageBox::Yes | QMessageBox::No );
1760 if ( reply == QMessageBox::Yes )
1762 QApplication::setOverrideCursor( Qt::WaitCursor );
1763 QgsDataSourceUri uri( alayer->
source() );
1773 mLayer->setAuxiliaryLayer();
1775 QApplication::restoreOverrideCursor();
1776 updateAuxiliaryStoragePage();
1777 mLayer->triggerRepaint();
1781void QgsVectorLayerProperties::onAuxiliaryLayerDeleteField()
1787 QList<QTreeWidgetItem *> items = mAuxiliaryStorageFieldsTree->selectedItems();
1788 if ( items.count() < 1 )
1792 const QTreeWidgetItem *item = items[0];
1793 QgsPropertyDefinition def;
1795 def.
setName( item->text( 1 ) );
1800 const int index = mLayer->auxiliaryLayer()->fields().indexOf( fieldName );
1805 const QString msg = tr(
"Are you sure you want to delete auxiliary field %1 for %2?" ).arg( item->text( 1 ), item->text( 0 ) );
1807 QMessageBox::StandardButton reply;
1808 const QString title = QObject::tr(
"Delete Auxiliary Field" );
1809 reply = QMessageBox::question(
this, title, msg, QMessageBox::Yes | QMessageBox::No );
1811 if ( reply == QMessageBox::Yes )
1813 QApplication::setOverrideCursor( Qt::WaitCursor );
1814 deleteAuxiliaryField( index );
1815 mLayer->triggerRepaint();
1816 QApplication::restoreOverrideCursor();
1820void QgsVectorLayerProperties::onAuxiliaryLayerAddField()
1826 QgsNewAuxiliaryFieldDialog dlg( QgsPropertyDefinition(), mLayer,
false );
1827 if ( dlg.exec() == QDialog::Accepted )
1829 updateAuxiliaryStoragePage();
1833void QgsVectorLayerProperties::deleteAuxiliaryField(
int index )
1835 if ( !mLayer->auxiliaryLayer() )
1838 int key = mLayer->auxiliaryLayer()->propertyFromIndex( index );
1839 QgsPropertyDefinition def = mLayer->auxiliaryLayer()->propertyDefinitionFromIndex( index );
1841 if ( mLayer->auxiliaryLayer()->deleteAttribute( index ) )
1843 mLayer->updateFields();
1846 if ( key >= 0 && def.
origin().compare(
"labeling", Qt::CaseInsensitive ) == 0 && labelingDialog && labelingDialog->labelingGui() )
1851 updateAuxiliaryStoragePage();
1852 mSourceFieldsPropertiesDialog->init();
1856 const QString title = QObject::tr(
"Delete Auxiliary Field" );
1857 const QString errors = mLayer->auxiliaryLayer()->commitErrors().join(
"\n "_L1 );
1858 const QString msg = QObject::tr(
"Unable to remove auxiliary field (%1)" ).arg( errors );
1866 if ( obj == mMapTipPreviewContainer && ev->type() == QEvent::Resize )
1870 return QgsOptionsDialogBase::eventFilter( obj, ev );
1873void QgsVectorLayerProperties::initMapTipPreview()
1876 mMapTipSplitter->setSizes( { 400, 200 } );
1878 mMapTipPreviewContainer->installEventFilter(
this );
1882 mMapTipPreview =
new QgsWebView( mMapTipPreviewContainer );
1883 mMapTipPreviewLayout->addWidget( mMapTipPreview );
1885 mMapTipPreview->setOpenExternalLinks(
true );
1886 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
1887 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled,
true );
1888 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::LocalStorageEnabled,
true );
1891 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
1892 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
1895 connect( mMapTipWidget, &QgsCodeEditorHTML::textChanged,
this, &QgsVectorLayerProperties::updateMapTipPreview );
1899void QgsVectorLayerProperties::updateMapTipPreview()
1901 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1903 mMapTipPreview->setHtml( htmlContent );
1906void QgsVectorLayerProperties::resizeMapTip()
1909 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1910 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 std::unique_ptr< QgsExpressionContextScope > globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
static std::unique_ptr< QgsExpressionContextScope > layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static void setLayerVariables(QgsMapLayer *layer, const QVariantMap &variables)
Sets all layer context variables.
static std::unique_ptr< QgsExpressionContextScope > mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static std::unique_ptr< QgsExpressionContextScope > atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static std::unique_ptr< QgsExpressionContextScope > projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
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.
bool addWmsDimension(const QgsServerWmsDimensionProperties::WmsDimensionInfo &wmsDimInfo)
Adds a QGIS Server WMS Dimension.
static QMap< Qgis::WmsDimensionDefaultDisplay, QString > wmsDimensionDefaultDisplayDescriptions()
Returns WMS Dimension default display descriptions.
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.
Qgis::WmsDimensionDefaultDisplay defaultDisplayType
QVariant referenceValue() const
Returns reference value used when default display type is Qgis::WmsDimensionDefaultDisplay::Reference...