Add configuration interface for allowed gaps

This commit is contained in:
Matthias Kuhn 2019-07-29 18:35:27 +02:00
parent 650f79617c
commit dc7169e2df
2 changed files with 36 additions and 0 deletions

View File

@ -462,6 +462,27 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
cb->setChecked( activeChecks.contains( factory->id() ) );
mGeometryCheckFactoriesGroupBoxes.insert( cb, factory->id() );
topologyCheckLayout->addWidget( cb );
QString id = factory->id();
if ( factory->id() == QStringLiteral( "QgsGeometryGapCheck" ) )
{
const QVariantMap gapCheckConfig = mLayer->geometryOptions()->checkConfiguration( QStringLiteral( "QgsGeometryGapCheck" ) );
mGapCheckAllowExceptionsActivatedCheckBox = new QgsCollapsibleGroupBox( tr( "Allowed gaps" ) );
mGapCheckAllowExceptionsActivatedCheckBox->setCheckable( true );
mGapCheckAllowExceptionsActivatedCheckBox->setChecked( gapCheckConfig.value( QStringLiteral( "allowedGapsEnabled" ), false ).toBool() );
QFormLayout *layout = new QFormLayout();
mGapCheckAllowExceptionsActivatedCheckBox->setLayout( layout );
topologyCheckLayout->addWidget( mGapCheckAllowExceptionsActivatedCheckBox );
mGapCheckAllowExceptionsLayerComboBox = new QgsMapLayerComboBox();
mGapCheckAllowExceptionsLayerComboBox->setFilters( QgsMapLayerProxyModel::PolygonLayer );
mGapCheckAllowExceptionsLayerComboBox->setLayer( QgsProject::instance()->mapLayer( gapCheckConfig.value( QStringLiteral( "allowedGapsLayer" ) ).toString() ) );
layout->addRow( new QLabel( tr( "Layer" ) ), mGapCheckAllowExceptionsLayerComboBox );
mGapCheckAllowExceptionsBufferLineEdit = new QLineEdit();
mGapCheckAllowExceptionsBufferLineEdit->setInputMethodHints( Qt::ImhFormattedNumbersOnly );
mGapCheckAllowExceptionsBufferLineEdit->setPlaceholderText( QStringLiteral( "0" ) );
mGapCheckAllowExceptionsBufferLineEdit->setText( gapCheckConfig.value( QStringLiteral( "allowedGapsBuffer" ) ).toString() );
layout->addRow( new QLabel( tr( "Buffer" ) ), mGapCheckAllowExceptionsBufferLineEdit );
}
}
mTopologyChecksGroupBox->setLayout( topologyCheckLayout );
mTopologyChecksGroupBox->setVisible( !topologyCheckFactories.isEmpty() );
@ -845,6 +866,16 @@ void QgsVectorLayerProperties::apply()
}
mLayer->geometryOptions()->setGeometryChecks( activeChecks );
if ( mGapCheckAllowExceptionsActivatedCheckBox )
{
QVariantMap gapCheckConfig;
gapCheckConfig.insert( QStringLiteral( "allowedGapsEnabled" ), mGapCheckAllowExceptionsActivatedCheckBox->isChecked() );
QgsMapLayer *currentLayer = mGapCheckAllowExceptionsLayerComboBox->currentLayer();
gapCheckConfig.insert( QStringLiteral( "allowedGapsLayer" ), currentLayer ? currentLayer->id() : QString() );
gapCheckConfig.insert( QStringLiteral( "allowedGapsBuffer" ), mGapCheckAllowExceptionsBufferLineEdit->text() );
mLayer->geometryOptions()->setCheckConfiguration( QStringLiteral( "QgsGeometryGapCheck" ), gapCheckConfig );
}
mLayer->triggerRepaint();
// notify the project we've made a change
QgsProject::instance()->setDirty( true );

View File

@ -45,6 +45,7 @@ class QgsMapLayerConfigWidget;
class QgsMetadataWidget;
class QgsPanelWidget;
class QgsVectorLayer3DRendererWidget;
class QgsMapLayerComboBox;
class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private Ui::QgsVectorLayerPropertiesBase, private QgsExpressionContextGenerator
{
@ -247,6 +248,10 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
bool mRemoveDuplicateNodesManuallyActivated = false;
QgsCollapsibleGroupBox *mGapCheckAllowExceptionsActivatedCheckBox = nullptr;
QgsMapLayerComboBox *mGapCheckAllowExceptionsLayerComboBox = nullptr;
QLineEdit *mGapCheckAllowExceptionsBufferLineEdit = nullptr;
private slots:
void openPanel( QgsPanelWidget *panel );