76#include <QColorDialog>
78#include <QDesktopServices>
87#include <QRegularExpressionValidator>
91#include "moc_qgsvectorlayerproperties.cpp"
93using namespace Qt::StringLiterals;
103 , mMessageBar( messageBar )
105 , mOriginalSubsetSQL( lyr->subsetString() )
108 connect( pbnQueryBuilder, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnQueryBuilder_clicked );
109 connect( pbnIndex, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnIndex_clicked );
111 connect( pbnUpdateExtents, &QPushButton::clicked,
this, &QgsVectorLayerProperties::pbnUpdateExtents_clicked );
112 connect( mButtonAddJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonAddJoin_clicked );
113 connect( mButtonEditJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonEditJoin_clicked );
114 connect( mJoinTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsVectorLayerProperties::mJoinTreeWidget_itemDoubleClicked );
115 connect( mButtonRemoveJoin, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonRemoveJoin_clicked );
116 connect( mButtonAddWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonAddWmsDimension_clicked );
117 connect( mButtonEditWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonEditWmsDimension_clicked );
118 connect( mWmsDimensionsTreeWidget, &QTreeWidget::itemDoubleClicked,
this, &QgsVectorLayerProperties::mWmsDimensionsTreeWidget_itemDoubleClicked );
119 connect( mButtonRemoveWmsDimension, &QPushButton::clicked,
this, &QgsVectorLayerProperties::mButtonRemoveWmsDimension_clicked );
120 connect( mSimplifyDrawingGroupBox, &QGroupBox::toggled,
this, &QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled );
121 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsVectorLayerProperties::showHelp );
130 mBtnStyle =
new QPushButton( tr(
"Style" ),
this );
131 QMenu *menuStyle =
new QMenu(
this );
132 mActionLoadStyle =
new QAction( tr(
"Load Style…" ),
this );
135 mActionSaveStyle =
new QAction( tr(
"Save Current Style…" ),
this );
138 mActionSaveMultipleStyles =
new QAction( tr(
"Save Multiple Styles…" ),
this );
139 connect( mActionSaveMultipleStyles, &QAction::triggered,
this, &QgsVectorLayerProperties::saveMultipleStylesAs );
141 mSourceGroupBox->hide();
144 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsVectorLayerProperties::aboutToShowStyleMenu );
145 buttonBox->addButton(
mBtnStyle, QDialogButtonBox::ResetRole );
155 mContext =
mCanvas->createExpressionContext();
166 mMapTipFieldComboBox->setLayer( lyr );
167 mDisplayExpressionWidget->setLayer( lyr );
168 mDisplayExpressionWidget->registerExpressionContextGenerator(
this );
171 mFeaturesSortOrderExpressionWidget->setLayer( lyr );
172 mFeaturesSortOrderExpressionWidget->registerExpressionContextGenerator(
this );
173 connect( mFeaturesSortOrderDirectionButton, &QAbstractButton::clicked,
this, [
this]() {
174 mFeaturesSortOrderDirectionButton->setArrowType( mFeaturesSortOrderDirectionButton->arrowType() == Qt::UpArrow ? Qt::DownArrow : Qt::UpArrow );
177 connect( mMapTipInsertFieldButton, &QAbstractButton::clicked,
this, &QgsVectorLayerProperties::insertField );
178 connect( mMapTipInsertExpressionButton, &QAbstractButton::clicked,
this, &QgsVectorLayerProperties::insertOrEditExpression );
183 mEnableMapTips->setChecked( mLayer->mapTipsEnabled() );
185 QVBoxLayout *layout =
nullptr;
187 if ( mLayer->isSpatial() )
190 layout =
new QVBoxLayout( labelingFrame );
191 layout->setContentsMargins( 0, 0, 0, 0 );
193 labelingDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
195 layout->addWidget( labelingDialog );
196 labelingFrame->setLayout( layout );
199 layout =
new QVBoxLayout( mMaskingFrame );
200 layout->setContentsMargins( 0, 0, 0, 0 );
201 mMaskingWidget =
new QgsMaskingWidget( mMaskingFrame );
202 mMaskingWidget->setLayer( mLayer );
203 mMaskingWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
204 layout->addWidget( mMaskingWidget );
205 mMaskingFrame->setLayout( layout );
209 labelingDialog =
nullptr;
210 mOptsPage_Labels->setEnabled(
false );
211 mOptsPage_Masks->setEnabled(
false );
212 mGeomGroupBox->setEnabled(
false );
213 mGeomGroupBox->setVisible(
false );
214 mCrsGroupBox->setEnabled(
false );
215 mCrsGroupBox->setVisible(
false );
219 QVBoxLayout *actionLayout =
new QVBoxLayout( actionOptionsFrame );
220 actionLayout->setContentsMargins( 0, 0, 0, 0 );
222 mActionDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
223 actionLayout->addWidget( mActionDialog );
226 mSourceFieldsPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
227 mSourceFieldsFrame->setLayout(
new QVBoxLayout( mSourceFieldsFrame ) );
228 mSourceFieldsFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
229 mSourceFieldsFrame->layout()->addWidget( mSourceFieldsPropertiesDialog );
234 mAttributesFormPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
235 mAttributesFormFrame->setLayout(
new QVBoxLayout( mAttributesFormFrame ) );
236 mAttributesFormFrame->layout()->setContentsMargins( 0, 0, 0, 0 );
237 mAttributesFormFrame->layout()->addWidget( mAttributesFormPropertiesDialog );
240 QVBoxLayout *metadataLayout =
new QVBoxLayout( metadataFrame );
241 metadataLayout->setContentsMargins( 0, 0, 0, 0 );
243 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
244 mMetadataWidget->setMapCanvas(
mCanvas );
245 metadataLayout->addWidget( mMetadataWidget );
246 metadataFrame->setLayout( metadataLayout );
248 QVBoxLayout *temporalLayout =
new QVBoxLayout( temporalFrame );
249 temporalLayout->setContentsMargins( 0, 0, 0, 0 );
251 temporalLayout->addWidget( mTemporalWidget );
255 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
256 QMenu *menuMetadata =
new QMenu(
this );
259 menuMetadata->addSeparator();
263 buttonBox->addButton(
mBtnMetadata, QDialogButtonBox::ResetRole );
265 mSelectionColorButton->setAllowOpacity(
true );
266 mSelectionColorButton->setColorDialogTitle( tr(
"Override Selection Color" ) );
269 mSelectionColorButton->setColor(
mCanvas->selectionColor() );
270 mSelectionColorButton->setDefaultColor(
mCanvas->selectionColor() );
272 connect( mRadioOverrideSelectionColor, &QRadioButton::toggled, mSelectionColorButton, &QWidget::setEnabled );
273 mSelectionColorButton->setEnabled(
false );
274 connect( mRadioOverrideSelectionSymbol, &QRadioButton::toggled, mSelectionSymbolButton, &QWidget::setEnabled );
275 switch ( mLayer->geometryType() )
291 mSelectionSymbolButton->setEnabled(
false );
292 mRadioDefaultSelectionColor->setChecked(
true );
295 QVBoxLayout *diagLayout =
new QVBoxLayout( mDiagramFrame );
296 diagLayout->setContentsMargins( 0, 0, 0, 0 );
298 diagramPropertiesDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
300 diagLayout->addWidget( diagramPropertiesDialog );
301 mDiagramFrame->setLayout( diagLayout );
305 if ( mLayer->dataProvider() )
311 pbnIndex->setEnabled(
false );
315 pbnIndex->setEnabled(
false );
316 pbnIndex->setText( tr(
"Spatial Index Exists" ) );
322 QString enc = mLayer->dataProvider()->encoding();
323 int encindex = cboProviderEncoding->findText( enc );
326 cboProviderEncoding->insertItem( 0, enc );
329 cboProviderEncoding->setCurrentIndex( encindex );
331 else if ( mLayer->providerType() ==
"ogr"_L1 )
335 cboProviderEncoding->addItem( mLayer->dataProvider()->encoding() );
336 cboProviderEncoding->setEnabled(
false );
341 mDataSourceEncodingFrame->hide();
345 mCrsSelector->setCrs( mLayer->crs() );
348 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
351 addJoinToTreeWidget( join );
354 mOldJoins = mLayer->vectorJoins();
357 mLegendWidget->setMapCanvas(
mCanvas );
358 mLegendWidget->setLayer( mLayer );
359 mLegendConfigEmbeddedWidget->setLayer( mLayer );
363 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &wmsDims = serverProperties->
wmsDimensions();
366 addWmsDimensionInfoToTreeWidget( dim );
370 myStyle.append( u
"body { margin: 10px; }\n "_s );
371 teMetadataViewer->clear();
372 teMetadataViewer->document()->setDefaultStyleSheet( myStyle );
373 teMetadataViewer->setOpenLinks(
false );
379 if ( !settings.
contains( u
"/Windows/VectorLayerProperties/tab"_s ) )
384 QList<QgsMapLayer *> dependencySources;
385 const QSet<QgsMapLayerDependency> constDependencies = mLayer->dependencies();
390 dependencySources << layer;
395 mLayersDependenciesTreeModel->setCheckedLayers( dependencySources );
396 connect(
QgsProject::instance(), &QObject::destroyed,
this, [
this] { mLayersDependenciesTreeView->setModel(
nullptr ); } );
397 mLayersDependenciesTreeView->setModel( mLayersDependenciesTreeModel );
399 mRefreshSettingsWidget->setLayer( mLayer );
400 mMapLayerServerPropertiesWidget->setHasWfsTitle(
true );
401 mMapLayerServerPropertiesWidget->setServerProperties( mLayer->serverProperties() );
404 QMenu *menu =
new QMenu(
this );
406 mAuxiliaryLayerActionNew =
new QAction( tr(
"Create" ),
this );
407 menu->addAction( mAuxiliaryLayerActionNew );
408 connect( mAuxiliaryLayerActionNew, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerNew );
410 mAuxiliaryLayerActionClear =
new QAction( tr(
"Clear" ),
this );
411 menu->addAction( mAuxiliaryLayerActionClear );
412 connect( mAuxiliaryLayerActionClear, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerClear );
414 mAuxiliaryLayerActionDelete =
new QAction( tr(
"Delete" ),
this );
415 menu->addAction( mAuxiliaryLayerActionDelete );
416 connect( mAuxiliaryLayerActionDelete, &QAction::triggered,
this, &QgsVectorLayerProperties::onAuxiliaryLayerDelete );
418 mAuxiliaryLayerActionExport =
new QAction( tr(
"Export" ),
this );
419 menu->addAction( mAuxiliaryLayerActionExport );
420 connect( mAuxiliaryLayerActionExport, &QAction::triggered,
this, [
this] { emit
exportAuxiliaryLayer( mLayer->auxiliaryLayer() ); } );
422 mAuxiliaryStorageActions->setMenu( menu );
424 connect( mAuxiliaryStorageFieldsDeleteBtn, &QPushButton::clicked,
this, &QgsVectorLayerProperties::onAuxiliaryLayerDeleteField );
425 connect( mAuxiliaryStorageFieldsAddBtn, &QPushButton::clicked,
this, &QgsVectorLayerProperties::onAuxiliaryLayerAddField );
427 updateAuxiliaryStoragePage();
429 mOptsPage_Information->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#information-properties"_s );
430 mOptsPage_Source->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#source-properties"_s );
431 mOptsPage_Style->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#symbology-properties"_s );
432 mOptsPage_Labels->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#labels-properties"_s );
433 mOptsPage_Masks->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#masks-properties"_s );
434 mOptsPage_Diagrams->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#diagrams-properties"_s );
435 mOptsPage_SourceFields->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#fields-properties"_s );
436 mOptsPage_AttributesForm->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#attributes-form-properties"_s );
437 mOptsPage_Joins->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#joins-properties"_s );
438 mOptsPage_AuxiliaryStorage->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#auxiliary-storage-properties"_s );
439 mOptsPage_Actions->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#actions-properties"_s );
440 mOptsPage_Display->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#display-properties"_s );
441 mOptsPage_Rendering->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#rendering-properties"_s );
442 mOptsPage_Temporal->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#temporal-properties"_s );
443 mOptsPage_Variables->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#variables-properties"_s );
444 mOptsPage_Metadata->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#metadata-properties"_s );
445 mOptsPage_DataDependencies->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#dependencies-properties"_s );
446 mOptsPage_Legend->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#legend-properties"_s );
447 mOptsPage_Server->setProperty(
"helpPage", u
"working_with_vector/vector_properties.html#qgis-server-properties"_s );
462 setPbnQueryBuilderEnabled();
465void QgsVectorLayerProperties::insertField()
469 if ( mMapTipFieldComboBox->currentField().isEmpty() )
471 QString expression = u
"[%\""_s;
472 expression += mMapTipFieldComboBox->currentField();
473 expression +=
"\"%]"_L1;
475 mMapTipWidget->insertText( expression );
478void QgsVectorLayerProperties::insertOrEditExpression()
481 int selectionStart = mMapTipWidget->selectionStart();
482 int selectionEnd = mMapTipWidget->selectionEnd();
486 QgsExpressionBuilderDialog exprDlg( mLayer, expression,
this, u
"generic"_s, context );
488 exprDlg.setWindowTitle( tr(
"Insert Expression" ) );
489 if ( exprDlg.exec() == QDialog::Accepted && !exprDlg.expressionText().trimmed().isEmpty() )
490 mMapTipWidget->insertText(
"[%" + exprDlg.expressionText().trimmed() +
"%]" );
492 mMapTipWidget->setLinearSelection( selectionStart, selectionEnd );
497 if ( !mSourceWidget )
502 QHBoxLayout *layout =
new QHBoxLayout();
503 layout->addWidget( mSourceWidget );
504 mSourceGroupBox->setLayout( layout );
505 if ( !mSourceWidget->groupTitle().isEmpty() )
506 mSourceGroupBox->setTitle( mSourceWidget->groupTitle() );
508 mSourceGroupBox->show();
511 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
512 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
519 mSourceWidget->setMapCanvas(
mCanvas );
520 mSourceWidget->setSourceUri( mLayer->source() );
524 mLayerOrigNameLineEdit->setText( mLayer->name() );
525 mBackupCrs = mLayer->crs();
528 mSubsetGroupBox->setEnabled(
true );
529 txtSubsetSQL->setText( mLayer->subsetString() );
535 txtSubsetSQL->setReadOnly(
true );
536 txtSubsetSQL->setCaretWidth( 0 );
537 txtSubsetSQL->setCaretLineVisible(
false );
538 setPbnQueryBuilderEnabled();
539 if ( mLayer->dataProvider() && !mLayer->dataProvider()->supportsSubsetString() )
542 mSubsetGroupBox->hide();
545 mDisplayExpressionWidget->setField( mLayer->displayExpression() );
546 mEnableMapTips->setChecked( mLayer->mapTipsEnabled() );
547 mMapTipWidget->setText( mLayer->mapTipTemplate() );
549 mFeaturesSortOrderExpressionWidget->setField( mLayer->attributeTableConfig().sortExpression() );
550 mFeaturesSortOrderDirectionButton->setArrowType( mLayer->attributeTableConfig().sortOrder() == Qt::AscendingOrder ? Qt::UpArrow : Qt::DownArrow );
553 mScaleRangeWidget->setScaleRange( mLayer->minimumScale(), mLayer->maximumScale() );
554 mScaleVisibilityGroupBox->setChecked( mLayer->hasScaleBasedVisibility() );
555 mScaleRangeWidget->setMapCanvas(
mCanvas );
557 mUseReferenceScaleGroupBox->setChecked( mLayer->renderer() && mLayer->renderer()->referenceScale() > 0 );
558 mReferenceScaleWidget->setShowCurrentScaleButton(
true );
559 mReferenceScaleWidget->setMapCanvas(
mCanvas );
560 if ( mUseReferenceScaleGroupBox->isChecked() )
561 mReferenceScaleWidget->setScale( mLayer->renderer()->referenceScale() );
563 mReferenceScaleWidget->setScale(
mCanvas->scale() );
568 mSimplifyDrawingSpinBox->setValue( simplifyMethod.
threshold() );
569 mSimplifyDrawingSpinBox->setClearValue( 1.0 );
574 mSelectionColorButton->setColor( selectionProperties->
selectionColor() );
578 mSelectionSymbolButton->setSymbol( symbol->clone() );
583 mRadioDefaultSelectionColor->setChecked(
true );
590 mRadioOverrideSelectionColor->setChecked(
true );
594 mRadioDefaultSelectionColor->setChecked(
true );
602 mRadioOverrideSelectionSymbol->setChecked(
true );
606 mRadioDefaultSelectionColor->setChecked(
true );
611 QString remark = u
" (%1)"_s.arg( tr(
"Not supported" ) );
615 mSimplifyDrawingAtProvider->setChecked(
false );
616 mSimplifyDrawingAtProvider->setEnabled(
false );
617 if ( !mSimplifyDrawingAtProvider->text().endsWith( remark ) )
618 mSimplifyDrawingAtProvider->setText( mSimplifyDrawingAtProvider->text().append( remark ) );
623 mSimplifyDrawingAtProvider->setEnabled( mSimplifyDrawingGroupBox->isChecked() );
624 if ( mSimplifyDrawingAtProvider->text().endsWith( remark ) )
626 QString newText = mSimplifyDrawingAtProvider->text();
627 newText.chop( remark.size() );
628 mSimplifyDrawingAtProvider->setText( newText );
635 mSimplifyDrawingGroupBox->setChecked(
false );
636 mSimplifyDrawingGroupBox->setEnabled(
false );
643 mSimplifyAlgorithmComboBox->setCurrentIndex( mSimplifyAlgorithmComboBox->findData( QVariant::fromValue( simplifyMethod.
simplifyAlgorithm() ) ) );
646 myScalesList.append( u
"1:1"_s );
647 mSimplifyMaximumScaleComboBox->updateScales( myScalesList );
648 mSimplifyMaximumScaleComboBox->setScale( simplifyMethod.
maximumScale() );
650 mForceRasterCheckBox->setChecked( mLayer->renderer() && mLayer->renderer()->forceRasterRender() );
652 mRefreshSettingsWidget->syncToLayer();
653 mMapLayerServerPropertiesWidget->sync();
655 mRefreshLayerNotificationCheckBox->setChecked( mLayer->isRefreshOnNotifyEnabled() );
656 mNotificationMessageCheckBox->setChecked( !mLayer->refreshOnNotifyMessage().isEmpty() );
657 mNotifyMessageValueLineEdit->setText( mLayer->refreshOnNotifyMessage() );
661 updateSymbologyPage();
663 mActionDialog->init( *mLayer->actions(), mLayer->attributeTableConfig() );
665 if ( labelingDialog )
666 labelingDialog->adaptToLayer();
668 mSourceFieldsPropertiesDialog->init();
669 mAttributesFormPropertiesDialog->init();
672 updateVariableEditor();
674 if ( diagramPropertiesDialog )
675 diagramPropertiesDialog->syncToOwnLayer();
680 page->syncToLayer( mLayer );
683 mMetadataWidget->setMetadata( &mLayer->metadata() );
685 mTemporalWidget->syncToLayer();
687 mLegendWidget->setLayer( mLayer );
692 if ( labelingDialog )
694 labelingDialog->writeSettingsToLayer();
696 mBackupCrs = mLayer->crs();
698 mLegendWidget->applyToLayer();
699 mLegendConfigEmbeddedWidget->applyToLayer();
702 mMetadataWidget->acceptMetadata();
703 mMetadataFilled =
false;
706 if ( mMaskingWidget )
707 mMaskingWidget->apply();
710 mLayer->setScaleBasedVisibility( mScaleVisibilityGroupBox->isChecked() );
711 mLayer->setMaximumScale( mScaleRangeWidget->maximumScale() );
712 mLayer->setMinimumScale( mScaleRangeWidget->minimumScale() );
715 if ( mLayer->dataProvider() )
719 mLayer->setProviderEncoding( cboProviderEncoding->currentText() );
723 mLayer->setDisplayExpression( mDisplayExpressionWidget->asExpression() );
724 mLayer->setMapTipsEnabled( mEnableMapTips->isChecked() );
725 mLayer->setMapTipTemplate( mMapTipWidget->text() );
729 config.
setSortOrder( mFeaturesSortOrderDirectionButton->arrowType() == Qt::UpArrow ? Qt::AscendingOrder : Qt::DescendingOrder );
730 mLayer->setAttributeTableConfig( config );
732 mLayer->actions()->clearActions();
733 const auto constActions = mActionDialog->actions();
734 for (
const QgsAction &action : constActions )
736 mLayer->actions()->addAction( action );
739 attributeTableConfig.
update( mLayer->fields() );
741 QVector<QgsAttributeTableConfig::ColumnConfig> columns = attributeTableConfig.
columns();
743 for (
int i = 0; i < columns.size(); ++i )
747 columns[i].hidden = !mActionDialog->showWidgetInAttributeTable();
753 mLayer->setAttributeTableConfig( attributeTableConfig );
755 mLayer->setName( mLayerOrigNameLineEdit->text() );
757 mAttributesFormPropertiesDialog->apply();
758 mSourceFieldsPropertiesDialog->apply();
761 mTemporalWidget->saveTemporalProperties();
763 if ( mLayer->renderer() )
770 diagramPropertiesDialog->apply();
778 if ( mMapLayerServerPropertiesWidget->save() )
779 mMetadataFilled =
false;
783 if ( mSimplifyDrawingGroupBox->isChecked() )
786 if ( mSimplifyDrawingSpinBox->value() > 1 )
792 simplifyMethod.
setThreshold( mSimplifyDrawingSpinBox->value() );
794 simplifyMethod.
setMaximumScale( mSimplifyMaximumScaleComboBox->scale() );
795 mLayer->setSimplifyMethod( simplifyMethod );
797 if ( mLayer->renderer() )
799 mLayer->renderer()->setForceRasterRender( mForceRasterCheckBox->isChecked() );
800 mLayer->renderer()->setReferenceScale( mUseReferenceScaleGroupBox->isChecked() ? mReferenceScaleWidget->scale() : -1 );
804 if ( mSelectionColorButton->color() != mSelectionColorButton->defaultColor() )
808 if (
QgsSymbol *symbol = mSelectionSymbolButton->symbol() )
811 if ( mRadioOverrideSelectionSymbol->isChecked() )
815 else if ( mRadioOverrideSelectionColor->isChecked() )
824 mRefreshSettingsWidget->saveToLayer();
826 mLayer->setRefreshOnNotifyEnabled( mRefreshLayerNotificationCheckBox->isChecked() );
827 mLayer->setRefreshOnNofifyMessage( mNotificationMessageCheckBox->isChecked() ? mNotifyMessageValueLineEdit->text() : QString() );
829 mOldJoins = mLayer->vectorJoins();
833 updateVariableEditor();
836 QSet<QgsMapLayerDependency> deps;
837 const auto checkedLayers = mLayersDependenciesTreeModel->checkedLayers();
840 if ( !mLayer->setDependencies( deps ) )
842 QMessageBox::warning(
nullptr, tr(
"Save Dependency" ), tr(
"This configuration introduces a cycle in data dependencies and will be ignored." ) );
851 bool dialogNeedsResync =
false;
854 const QString newSource = mSourceWidget->sourceUri();
855 if ( newSource != mLayer->source() )
862 dialogNeedsResync =
true;
868 mSubsetGroupBox->setEnabled(
true );
869 if ( txtSubsetSQL->text() != mLayer->subsetString() )
872 mLayer->setSubsetString( txtSubsetSQL->text() );
873 mMetadataFilled =
false;
875 dialogNeedsResync =
true;
877 mOriginalSubsetSQL = mLayer->subsetString();
879 if ( dialogNeedsResync )
882 mLayer->triggerRepaint();
884 mProjectDirtyBlocker.reset();
891 if ( mOldJoins != mLayer->vectorJoins() )
896 const auto constVectorJoins = mLayer->vectorJoins();
898 mLayer->removeJoin( info.joinLayerId() );
901 mLayer->addJoin( info );
904 if ( mOriginalSubsetSQL != mLayer->subsetString() )
909 mLayer->setSubsetString( mOriginalSubsetSQL );
918 if ( backupCrs != mLayer->crs() )
919 mLayer->setCrs( backupCrs );
922void QgsVectorLayerProperties::pbnQueryBuilder_clicked()
931 if ( dialog->exec() )
944void QgsVectorLayerProperties::pbnIndex_clicked()
946 QgsVectorDataProvider *pr = mLayer->dataProvider();
949 setCursor( Qt::WaitCursor );
951 setCursor( Qt::ArrowCursor );
954 pbnIndex->setEnabled(
false );
955 pbnIndex->setText( tr(
"Spatial Index Exists" ) );
956 QMessageBox::information(
this, tr(
"Spatial Index" ), tr(
"Creation of spatial index successful" ) );
960 QMessageBox::warning(
this, tr(
"Spatial Index" ), tr(
"Creation of spatial index failed" ) );
965QString QgsVectorLayerProperties::htmlMetadata()
967 return mLayer->htmlMetadata();
973 mLayer->setCrs( crs );
974 mMetadataFilled =
false;
975 mMetadataWidget->crsChanged();
978void QgsVectorLayerProperties::saveMultipleStylesAs()
980 QgsMapLayerSaveStyleDialog dlg( mLayer );
981 dlg.setSaveOnlyCurrentStyle(
false );
982 QgsSettings settings;
989 const QString originalStyle { mLayer->styleManager()->currentStyle() };
990 const QListWidget *stylesWidget { dlg.stylesWidget() };
993 QStringList stylesSelected;
994 for (
int i = 0; i < stylesWidget->count(); i++ )
996 if ( stylesWidget->item( i )->checkState() == Qt::CheckState::Checked )
998 stylesSelected.push_back( stylesWidget->item( i )->text() );
1002 if ( !stylesSelected.isEmpty() )
1005 for (
const QString &styleName : std::as_const( stylesSelected ) )
1007 bool defaultLoadedFlag =
false;
1009 StyleType type = dlg.currentStyleType();
1010 mLayer->styleManager()->setCurrentStyle( styleName );
1017 const QString filePath { dlg.outputFilePath() };
1018 const QFileInfo fi { filePath };
1020 if ( styleIndex > 0 && stylesSelected.count() > 1 )
1023 while ( QFile::exists( safePath ) )
1025 const QFileInfo fi { safePath };
1026 safePath = QString( safePath ).replace(
'.' + fi.completeSuffix(), u
"_%1.%2"_s.arg( QString::number( i ), fi.completeSuffix() ) );
1031 message = mLayer->saveNamedStyle( safePath, defaultLoadedFlag, dlg.styleCategories() );
1033 message = mLayer->saveSldStyle( safePath, defaultLoadedFlag );
1036 if ( defaultLoadedFlag )
1043 QMessageBox::information(
this, tr(
"Save Style" ), message );
1050 QString infoWindowTitle = QObject::tr(
"Save style '%1' to DB (%2)" )
1051 .arg( styleName, mLayer->providerType() );
1054 QgsMapLayerSaveStyleDialog::SaveToDbSettings dbSettings = dlg.saveToDbSettings();
1057 QString name { dbSettings.
name };
1058 if ( name.isEmpty() )
1064 name += u
"_%1"_s.arg( styleName );
1065 QStringList ids, names, descriptions;
1066 mLayer->listStylesInDatabase( ids, names, descriptions, msgError );
1068 while ( names.contains( name ) )
1070 name = u
"%1 %2"_s.arg( name, QString::number( i ) );
1075 QString errorMessage;
1078 if ( QMessageBox::question(
nullptr, QObject::tr(
"Save style in database" ), QObject::tr(
"A matching style already exists in the database for this layer. Do you want to overwrite it?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No )
1083 else if ( !errorMessage.isEmpty() )
1085 QMessageBox::warning(
this, infoWindowTitle, errorMessage );
1091 if ( !msgError.isNull() )
1093 QMessageBox::warning(
this, infoWindowTitle, msgError );
1097 QMessageBox::information(
this, infoWindowTitle, tr(
"Style '%1' saved" ).arg( styleName ) );
1107 mLayer->styleManager()->setCurrentStyle( originalStyle );
1112void QgsVectorLayerProperties::aboutToShowStyleMenu()
1115 QMenu *m = qobject_cast<QMenu *>( sender() );
1118 m->addAction( mActionLoadStyle );
1119 m->addAction( mActionSaveStyle );
1122 if ( mLayer->styleManager()->styles().count() > 1 )
1124 mActionSaveStyle->setText( tr(
"Save Current Style…" ) );
1125 m->addAction( mActionSaveMultipleStyles );
1129 mActionSaveStyle->setText( tr(
"Save Style…" ) );
1141void QgsVectorLayerProperties::mButtonAddJoin_clicked()
1146 QList<QgsMapLayer *> joinedLayers;
1147 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
1148 joinedLayers.reserve( joins.size() );
1149 for (
int i = 0; i < joins.size(); ++i )
1151 joinedLayers.append( joins[i].joinLayer() );
1154 QgsJoinDialog d( mLayer, joinedLayers );
1155 if ( d.exec() == QDialog::Accepted )
1157 QgsVectorLayerJoinInfo info = d.joinInfo();
1159 if ( d.createAttributeIndex() )
1161 QgsVectorLayer *joinLayer = info.
joinLayer();
1167 mLayer->addJoin( info );
1168 addJoinToTreeWidget( info );
1169 setPbnQueryBuilderEnabled();
1170 mSourceFieldsPropertiesDialog->init();
1171 mAttributesFormPropertiesDialog->init();
1175void QgsVectorLayerProperties::mButtonEditJoin_clicked()
1177 QTreeWidgetItem *currentJoinItem = mJoinTreeWidget->currentItem();
1178 mJoinTreeWidget_itemDoubleClicked( currentJoinItem, 0 );
1181void QgsVectorLayerProperties::mJoinTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int )
1183 if ( !mLayer || !item )
1189 QTreeWidgetItem *currentJoinItem = item;
1190 if ( item->parent() )
1192 currentJoinItem = item->parent();
1196 QList<QgsMapLayer *> joinedLayers;
1197 QString joinLayerId = currentJoinItem->data( 0, Qt::UserRole ).toString();
1198 const QList<QgsVectorLayerJoinInfo> &joins = mLayer->vectorJoins();
1200 for (
int i = 0; i < joins.size(); ++i )
1202 QgsVectorLayer *joinLayer = joins[i].joinLayer();
1206 if ( joinLayer->
id() == joinLayerId )
1213 joinedLayers.append( joinLayer );
1221 QgsJoinDialog d( mLayer, joinedLayers );
1222 d.setWindowTitle( tr(
"Edit Vector Join" ) );
1223 d.setJoinInfo( joins[j] );
1225 if ( d.exec() == QDialog::Accepted )
1227 QgsVectorLayerJoinInfo info = d.joinInfo();
1230 mLayer->removeJoin( joinLayerId );
1231 int idx = mJoinTreeWidget->indexOfTopLevelItem( item );
1232 mJoinTreeWidget->takeTopLevelItem( idx );
1237 if ( d.createAttributeIndex() )
1239 QgsVectorLayer *joinLayer = info.
joinLayer();
1245 mLayer->addJoin( info );
1246 addJoinToTreeWidget( info, idx );
1248 setPbnQueryBuilderEnabled();
1249 mSourceFieldsPropertiesDialog->init();
1250 mAttributesFormPropertiesDialog->init();
1254void QgsVectorLayerProperties::addJoinToTreeWidget(
const QgsVectorLayerJoinInfo &join,
const int insertIndex )
1256 QTreeWidgetItem *joinItem =
new QTreeWidgetItem();
1257 joinItem->setFlags( Qt::ItemIsEnabled );
1259 QgsVectorLayer *joinLayer = join.
joinLayer();
1260 if ( !mLayer || !joinLayer )
1265 joinItem->setText( 0, tr(
"Join layer" ) );
1266 if ( mLayer->auxiliaryLayer() && mLayer->auxiliaryLayer()->id() == join.
joinLayerId() )
1271 joinItem->setText( 1, joinLayer->
name() );
1273 QFont f = joinItem->font( 0 );
1275 joinItem->setFont( 0, f );
1276 joinItem->setFont( 1, f );
1278 joinItem->setData( 0, Qt::UserRole, join.
joinLayerId() );
1280 QTreeWidgetItem *childJoinField =
new QTreeWidgetItem();
1281 childJoinField->setText( 0, tr(
"Join field" ) );
1283 childJoinField->setFlags( Qt::ItemIsEnabled );
1284 joinItem->addChild( childJoinField );
1286 QTreeWidgetItem *childTargetField =
new QTreeWidgetItem();
1287 childTargetField->setText( 0, tr(
"Target field" ) );
1289 joinItem->addChild( childTargetField );
1291 QTreeWidgetItem *childMemCache =
new QTreeWidgetItem();
1292 childMemCache->setText( 0, tr(
"Cache join layer in virtual memory" ) );
1294 childMemCache->setText( 1, QChar( 0x2714 ) );
1295 joinItem->addChild( childMemCache );
1297 QTreeWidgetItem *childDynForm =
new QTreeWidgetItem();
1298 childDynForm->setText( 0, tr(
"Dynamic form" ) );
1300 childDynForm->setText( 1, QChar( 0x2714 ) );
1301 joinItem->addChild( childDynForm );
1303 QTreeWidgetItem *childEditable =
new QTreeWidgetItem();
1304 childEditable->setText( 0, tr(
"Editable join layer" ) );
1306 childEditable->setText( 1, QChar( 0x2714 ) );
1307 joinItem->addChild( childEditable );
1309 QTreeWidgetItem *childUpsert =
new QTreeWidgetItem();
1310 childUpsert->setText( 0, tr(
"Upsert on edit" ) );
1312 childUpsert->setText( 1, QChar( 0x2714 ) );
1313 joinItem->addChild( childUpsert );
1315 QTreeWidgetItem *childCascade =
new QTreeWidgetItem();
1316 childCascade->setText( 0, tr(
"Delete cascade" ) );
1318 childCascade->setText( 1, QChar( 0x2714 ) );
1319 joinItem->addChild( childCascade );
1321 QTreeWidgetItem *childPrefix =
new QTreeWidgetItem();
1322 childPrefix->setText( 0, tr(
"Custom field name prefix" ) );
1323 childPrefix->setText( 1, join.
prefix() );
1324 joinItem->addChild( childPrefix );
1326 QTreeWidgetItem *childFields =
new QTreeWidgetItem();
1327 childFields->setText( 0, tr(
"Joined fields" ) );
1330 childFields->setText( 1, QLocale().toString( list->count() ) );
1332 childFields->setText( 1, tr(
"all" ) );
1333 joinItem->addChild( childFields );
1335 if ( insertIndex >= 0 )
1336 mJoinTreeWidget->insertTopLevelItem( insertIndex, joinItem );
1338 mJoinTreeWidget->addTopLevelItem( joinItem );
1340 mJoinTreeWidget->setCurrentItem( joinItem );
1341 mJoinTreeWidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
1351 QDialog *dlg =
new QDialog();
1352 QString key = u
"/UI/paneldialog/%1"_s.arg( panel->
panelTitle() );
1353 QgsSettings settings;
1354 dlg->restoreGeometry( settings.
value( key ).toByteArray() );
1356 dlg->setLayout(
new QVBoxLayout() );
1357 dlg->layout()->addWidget( panel );
1358 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok );
1359 connect( buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept );
1360 dlg->layout()->addWidget( buttonBox );
1362 settings.
setValue( key, dlg->saveGeometry() );
1366void QgsVectorLayerProperties::mButtonRemoveJoin_clicked()
1368 QTreeWidgetItem *currentJoinItem = mJoinTreeWidget->currentItem();
1370 if ( currentJoinItem && currentJoinItem->parent() )
1372 currentJoinItem = currentJoinItem->parent();
1375 if ( !mLayer || !currentJoinItem )
1380 mLayer->removeJoin( currentJoinItem->data( 0, Qt::UserRole ).toString() );
1381 mJoinTreeWidget->takeTopLevelItem( mJoinTreeWidget->indexOfTopLevelItem( currentJoinItem ) );
1382 setPbnQueryBuilderEnabled();
1383 mSourceFieldsPropertiesDialog->init();
1384 mAttributesFormPropertiesDialog->init();
1388void QgsVectorLayerProperties::mButtonAddWmsDimension_clicked()
1394 QStringList alreadyDefinedDimensions;
1395 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1396 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &dims = serverProperties->
wmsDimensions();
1397 for (
const QgsMapLayerServerProperties::WmsDimensionInfo &dim : dims )
1399 alreadyDefinedDimensions << dim.name;
1402 QgsWmsDimensionDialog d( mLayer, alreadyDefinedDimensions );
1403 if ( d.exec() == QDialog::Accepted )
1405 QgsMapLayerServerProperties::WmsDimensionInfo info = d.info();
1408 addWmsDimensionInfoToTreeWidget( info );
1412void QgsVectorLayerProperties::mButtonEditWmsDimension_clicked()
1414 QTreeWidgetItem *currentWmsDimensionItem = mWmsDimensionsTreeWidget->currentItem();
1415 mWmsDimensionsTreeWidget_itemDoubleClicked( currentWmsDimensionItem, 0 );
1418void QgsVectorLayerProperties::mWmsDimensionsTreeWidget_itemDoubleClicked( QTreeWidgetItem *item,
int )
1420 if ( !mLayer || !item )
1425 QString wmsDimName = item->data( 0, Qt::UserRole ).toString();
1426 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1427 const QList<QgsMapLayerServerProperties::WmsDimensionInfo> &dims = serverProperties->
wmsDimensions();
1428 QStringList alreadyDefinedDimensions;
1430 for (
int i = 0; i < dims.size(); ++i )
1432 QString dimName = dims[i].name;
1433 if ( dimName == wmsDimName )
1439 alreadyDefinedDimensions << dimName;
1447 QgsWmsDimensionDialog d( mLayer, alreadyDefinedDimensions );
1448 d.setWindowTitle( tr(
"Edit WMS Dimension" ) );
1449 d.setInfo( dims[j] );
1451 if ( d.exec() == QDialog::Accepted )
1453 QgsMapLayerServerProperties::WmsDimensionInfo info = d.info();
1456 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1458 int idx = mWmsDimensionsTreeWidget->indexOfTopLevelItem( item );
1459 mWmsDimensionsTreeWidget->takeTopLevelItem( idx );
1463 addWmsDimensionInfoToTreeWidget( info, idx );
1469 QTreeWidgetItem *wmsDimensionItem =
new QTreeWidgetItem();
1470 wmsDimensionItem->setFlags( Qt::ItemIsEnabled );
1472 wmsDimensionItem->setText( 0, tr(
"Dimension" ) );
1473 wmsDimensionItem->setText( 1, wmsDim.
name );
1475 QFont f = wmsDimensionItem->font( 0 );
1477 wmsDimensionItem->setFont( 0, f );
1478 wmsDimensionItem->setFont( 1, f );
1480 wmsDimensionItem->setData( 0, Qt::UserRole, wmsDim.
name );
1482 QTreeWidgetItem *childWmsDimensionField =
new QTreeWidgetItem();
1483 childWmsDimensionField->setText( 0, tr(
"Field" ) );
1484 childWmsDimensionField->setText( 1, wmsDim.
fieldName );
1485 childWmsDimensionField->setFlags( Qt::ItemIsEnabled );
1486 wmsDimensionItem->addChild( childWmsDimensionField );
1488 QTreeWidgetItem *childWmsDimensionEndField =
new QTreeWidgetItem();
1489 childWmsDimensionEndField->setText( 0, tr(
"End field" ) );
1490 childWmsDimensionEndField->setText( 1, wmsDim.
endFieldName );
1491 childWmsDimensionEndField->setFlags( Qt::ItemIsEnabled );
1492 wmsDimensionItem->addChild( childWmsDimensionEndField );
1494 QTreeWidgetItem *childWmsDimensionUnits =
new QTreeWidgetItem();
1495 childWmsDimensionUnits->setText( 0, tr(
"Units" ) );
1496 childWmsDimensionUnits->setText( 1, wmsDim.
units );
1497 childWmsDimensionUnits->setFlags( Qt::ItemIsEnabled );
1498 wmsDimensionItem->addChild( childWmsDimensionUnits );
1500 QTreeWidgetItem *childWmsDimensionUnitSymbol =
new QTreeWidgetItem();
1501 childWmsDimensionUnitSymbol->setText( 0, tr(
"Unit symbol" ) );
1502 childWmsDimensionUnitSymbol->setText( 1, wmsDim.
unitSymbol );
1503 childWmsDimensionUnitSymbol->setFlags( Qt::ItemIsEnabled );
1504 wmsDimensionItem->addChild( childWmsDimensionUnitSymbol );
1506 QTreeWidgetItem *childWmsDimensionDefaultValue =
new QTreeWidgetItem();
1507 childWmsDimensionDefaultValue->setText( 0, tr(
"Default display" ) );
1509 childWmsDimensionDefaultValue->setFlags( Qt::ItemIsEnabled );
1510 wmsDimensionItem->addChild( childWmsDimensionDefaultValue );
1512 QTreeWidgetItem *childWmsDimensionRefValue =
new QTreeWidgetItem();
1513 childWmsDimensionRefValue->setText( 0, tr(
"Reference value" ) );
1514 childWmsDimensionRefValue->setText( 1, wmsDim.
referenceValue.toString() );
1515 childWmsDimensionRefValue->setFlags( Qt::ItemIsEnabled );
1516 wmsDimensionItem->addChild( childWmsDimensionRefValue );
1518 if ( insertIndex >= 0 )
1519 mWmsDimensionsTreeWidget->insertTopLevelItem( insertIndex, wmsDimensionItem );
1521 mWmsDimensionsTreeWidget->addTopLevelItem( wmsDimensionItem );
1523 mWmsDimensionsTreeWidget->setCurrentItem( wmsDimensionItem );
1524 mWmsDimensionsTreeWidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
1527void QgsVectorLayerProperties::mButtonRemoveWmsDimension_clicked()
1529 QTreeWidgetItem *currentWmsDimensionItem = mWmsDimensionsTreeWidget->currentItem();
1530 if ( !mLayer || !currentWmsDimensionItem )
1535 QgsMapLayerServerProperties *serverProperties =
static_cast<QgsMapLayerServerProperties *
>( mLayer->serverProperties() );
1536 serverProperties->
removeWmsDimension( currentWmsDimensionItem->data( 0, Qt::UserRole ).toString() );
1537 mWmsDimensionsTreeWidget->takeTopLevelItem( mWmsDimensionsTreeWidget->indexOfTopLevelItem( currentWmsDimensionItem ) );
1541void QgsVectorLayerProperties::updateSymbologyPage()
1544 delete mRendererDialog;
1545 mRendererDialog =
nullptr;
1547 if ( mLayer->renderer() )
1550 mRendererDialog->setDockMode(
false );
1551 QgsSymbolWidgetContext context;
1554 mRendererDialog->setContext( context );
1561 mOptsPage_Style->setEnabled(
false );
1564 if ( mRendererDialog )
1566 mRendererDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
1567 widgetStackRenderers->addWidget( mRendererDialog );
1568 widgetStackRenderers->setCurrentWidget( mRendererDialog );
1569 widgetStackRenderers->currentWidget()->layout()->setContentsMargins( 0, 0, 0, 0 );
1573void QgsVectorLayerProperties::setPbnQueryBuilderEnabled()
1575 pbnQueryBuilder->setEnabled( mLayer && mLayer->dataProvider() && mLayer->dataProvider()->supportsSubsetString() && !mLayer->isEditable() );
1577 if ( mLayer && mLayer->isEditable() )
1579 pbnQueryBuilder->setToolTip( tr(
"Stop editing mode to enable this." ) );
1583void QgsVectorLayerProperties::pbnUpdateExtents_clicked()
1585 mLayer->updateExtents(
true );
1586 mMetadataFilled =
false;
1593 if ( index ==
mOptStackedWidget->indexOf( mOptsPage_Information ) && !mMetadataFilled )
1596 teMetadataViewer->clear();
1597 teMetadataViewer->setHtml( htmlMetadata() );
1598 mMetadataFilled =
true;
1603 mAttributesFormPropertiesDialog->store();
1608 if ( mActionDialog )
1610 mAttributesFormPropertiesDialog->initAvailableWidgetsActions( mActionDialog->actions() );
1617void QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled(
bool checked )
1622 mSimplifyDrawingAtProvider->setEnabled(
false );
1626 mSimplifyDrawingAtProvider->setEnabled( checked );
1630void QgsVectorLayerProperties::updateVariableEditor()
1632 QgsExpressionContext context;
1633 mVariableEditor->setContext( &context );
1637 mVariableEditor->reloadContext();
1638 mVariableEditor->setEditableScopeIndex( 2 );
1641void QgsVectorLayerProperties::showHelp()
1643 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
1645 if ( helpPage.isValid() )
1655void QgsVectorLayerProperties::updateAuxiliaryStoragePage()
1657 const QgsAuxiliaryLayer *alayer = mLayer->auxiliaryLayer();
1662 mAuxiliaryStorageInformationGrpBox->setEnabled(
true );
1663 mAuxiliaryStorageFieldsGrpBox->setEnabled(
true );
1670 mAuxiliaryStorageFeaturesLineEdit->setText( QLocale().toString( features ) );
1673 mAuxiliaryLayerActionClear->setEnabled(
true );
1674 mAuxiliaryLayerActionDelete->setEnabled(
true );
1675 mAuxiliaryLayerActionExport->setEnabled(
true );
1676 mAuxiliaryLayerActionNew->setEnabled(
false );
1682 mAuxiliaryStorageFieldsLineEdit->setText( QLocale().toString( fields ) );
1685 mAuxiliaryStorageFieldsTree->clear();
1689 QTreeWidgetItem *item =
new QTreeWidgetItem();
1691 item->setText( 0, prop.
origin() );
1692 item->setText( 1, prop.
name() );
1693 item->setText( 2, prop.
comment() );
1694 item->setText( 3, field.typeName() );
1695 item->setText( 4, field.name() );
1697 mAuxiliaryStorageFieldsTree->addTopLevelItem( item );
1703 mAuxiliaryStorageInformationGrpBox->setEnabled(
false );
1704 mAuxiliaryStorageFieldsGrpBox->setEnabled(
false );
1706 mAuxiliaryLayerActionClear->setEnabled(
false );
1707 mAuxiliaryLayerActionDelete->setEnabled(
false );
1708 mAuxiliaryLayerActionExport->setEnabled(
false );
1709 mAuxiliaryLayerActionNew->setEnabled(
true );
1711 mAuxiliaryStorageFieldsTree->clear();
1712 mAuxiliaryStorageKeyLineEdit->setText( QString() );
1713 mAuxiliaryStorageFieldsLineEdit->setText( QString() );
1714 mAuxiliaryStorageFeaturesLineEdit->setText( QString() );
1718void QgsVectorLayerProperties::onAuxiliaryLayerNew()
1725 QgsNewAuxiliaryLayerDialog dlg( mLayer,
this );
1726 if ( dlg.exec() == QDialog::Accepted )
1728 updateAuxiliaryStoragePage();
1732void QgsVectorLayerProperties::onAuxiliaryLayerClear()
1739 const QString msg = tr(
"Are you sure you want to clear auxiliary data for %1?" ).arg( mLayer->name() );
1740 QMessageBox::StandardButton reply;
1741 reply = QMessageBox::question(
this,
"Clear Auxiliary Data", msg, QMessageBox::Yes | QMessageBox::No );
1743 if ( reply == QMessageBox::Yes )
1745 QApplication::setOverrideCursor( Qt::WaitCursor );
1747 QApplication::restoreOverrideCursor();
1748 updateAuxiliaryStoragePage();
1749 mLayer->triggerRepaint();
1753void QgsVectorLayerProperties::onAuxiliaryLayerDelete()
1759 const QString msg = tr(
"Are you sure you want to delete auxiliary storage for %1?" ).arg( mLayer->name() );
1760 QMessageBox::StandardButton reply;
1761 reply = QMessageBox::question(
this,
"Delete Auxiliary Storage", msg, QMessageBox::Yes | QMessageBox::No );
1763 if ( reply == QMessageBox::Yes )
1765 QApplication::setOverrideCursor( Qt::WaitCursor );
1766 QgsDataSourceUri uri( alayer->
source() );
1776 mLayer->setAuxiliaryLayer();
1778 QApplication::restoreOverrideCursor();
1779 updateAuxiliaryStoragePage();
1780 mLayer->triggerRepaint();
1784void QgsVectorLayerProperties::onAuxiliaryLayerDeleteField()
1790 QList<QTreeWidgetItem *> items = mAuxiliaryStorageFieldsTree->selectedItems();
1791 if ( items.count() < 1 )
1795 const QTreeWidgetItem *item = items[0];
1796 QgsPropertyDefinition def;
1798 def.
setName( item->text( 1 ) );
1803 const int index = mLayer->auxiliaryLayer()->fields().indexOf( fieldName );
1808 const QString msg = tr(
"Are you sure you want to delete auxiliary field %1 for %2?" ).arg( item->text( 1 ), item->text( 0 ) );
1810 QMessageBox::StandardButton reply;
1811 const QString title = QObject::tr(
"Delete Auxiliary Field" );
1812 reply = QMessageBox::question(
this, title, msg, QMessageBox::Yes | QMessageBox::No );
1814 if ( reply == QMessageBox::Yes )
1816 QApplication::setOverrideCursor( Qt::WaitCursor );
1817 deleteAuxiliaryField( index );
1818 mLayer->triggerRepaint();
1819 QApplication::restoreOverrideCursor();
1823void QgsVectorLayerProperties::onAuxiliaryLayerAddField()
1829 QgsNewAuxiliaryFieldDialog dlg( QgsPropertyDefinition(), mLayer,
false );
1830 if ( dlg.exec() == QDialog::Accepted )
1832 updateAuxiliaryStoragePage();
1836void QgsVectorLayerProperties::deleteAuxiliaryField(
int index )
1838 if ( !mLayer->auxiliaryLayer() )
1841 int key = mLayer->auxiliaryLayer()->propertyFromIndex( index );
1842 QgsPropertyDefinition def = mLayer->auxiliaryLayer()->propertyDefinitionFromIndex( index );
1844 if ( mLayer->auxiliaryLayer()->deleteAttribute( index ) )
1846 mLayer->updateFields();
1849 if ( key >= 0 && def.
origin().compare(
"labeling", Qt::CaseInsensitive ) == 0
1851 && labelingDialog->labelingGui() )
1856 updateAuxiliaryStoragePage();
1857 mSourceFieldsPropertiesDialog->init();
1861 const QString title = QObject::tr(
"Delete Auxiliary Field" );
1862 const QString errors = mLayer->auxiliaryLayer()->commitErrors().join(
"\n "_L1 );
1863 const QString msg = QObject::tr(
"Unable to remove auxiliary field (%1)" ).arg( errors );
1871 if ( obj == mMapTipPreviewContainer && ev->type() == QEvent::Resize )
1875 return QgsOptionsDialogBase::eventFilter( obj, ev );
1878void QgsVectorLayerProperties::initMapTipPreview()
1881 mMapTipSplitter->setSizes( { 400, 200 } );
1883 mMapTipPreviewContainer->installEventFilter(
this );
1887 mMapTipPreview =
new QgsWebView( mMapTipPreviewContainer );
1888 mMapTipPreviewLayout->addWidget( mMapTipPreview );
1890 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled,
true );
1891 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled,
true );
1892 mMapTipPreview->page()->settings()->setAttribute( QWebSettings::LocalStorageEnabled,
true );
1895 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
1896 mMapTipPreview->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
1899 connect( mMapTipWidget, &QgsCodeEditorHTML::textChanged,
this, &QgsVectorLayerProperties::updateMapTipPreview );
1903void QgsVectorLayerProperties::updateMapTipPreview()
1905 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1907 mMapTipPreview->setHtml( htmlContent );
1910void QgsVectorLayerProperties::resizeMapTip()
1913 mMapTipPreview->setMaximumSize( mMapTipPreviewContainer->width(), mMapTipPreviewContainer->height() );
1914 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.