Skip to content
Permalink
Browse files

activate/deactivate geometry checks in vector layer properties

  • Loading branch information
3nids authored and m-kuhn committed Sep 20, 2018
1 parent e8a7ab4 commit 0b20ae620333e7d773c636908b50edc77b271a8b
@@ -19,10 +19,11 @@

bool QgsGeometryCheckFactory::isCompatible( QgsVectorLayer *layer ) const
{
Q_UNUSED( layer );
return true;
}

QgsGeometryCheck::Flags QgsGeometryCheckFactory::flags() const
{
return nullptr;
return QgsGeometryCheck::Flags( QgsGeometryCheck::SingleGeometryCheck | QgsGeometryCheck::AvailableInValidation );
}
@@ -61,6 +61,7 @@
#include "qgslabelinggui.h"
#include "qgssymbollayer.h"
#include "qgsgeometryoptions.h"
#include "qgsgeometrycheckfactory.h"
#include "qgsvectorlayersavestyledialog.h"
#include "qgsvectorlayerloadstyledialog.h"
#include "qgsmessagebar.h"
@@ -409,6 +410,18 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
mGeometryPrecisionLineEdit->setText( QString::number( mLayer->geometryOptions()->geometryPrecision() ) );

mPrecisionUnitsLabel->setText( QStringLiteral( "[%1]" ).arg( QgsUnitTypes::toAbbreviatedString( mLayer->crs().mapUnits() ) ) );

QLayout *layout = new QVBoxLayout();
const QList<QgsGeometryCheckFactory *> factories = QgsAnalysis::instance()->geometryCheckRegistry()->geometryCheckFactories( mLayer, QgsGeometryCheck::Flag::SingleGeometryCheck );
const QStringList activeChecks = mLayer->geometryOptions()->geometryChecks();
for ( const QgsGeometryCheckFactory *factory : factories )
{
QCheckBox *cb = new QCheckBox( factory->name() );
cb->setChecked( activeChecks.contains( factory->id() ) );
mGeometryCheckFactoriesGroupBoxes.insert( cb, factory->id() );
layout->addWidget( cb );
}
mGeometryValidationGroupBox->setLayout( layout );
}
else
{
@@ -758,6 +771,15 @@ void QgsVectorLayerProperties::apply()
mLayer->geometryOptions()->setRemoveDuplicateNodes( mRemoveDuplicateNodesCheckbox->isChecked() );
mLayer->geometryOptions()->setGeometryPrecision( mGeometryPrecisionLineEdit->text().toDouble() );

QStringList activeChecks;
QHash<QCheckBox *, QString>::const_iterator it;
for ( it = mGeometryCheckFactoriesGroupBoxes.constBegin(); it != mGeometryCheckFactoriesGroupBoxes.constEnd(); ++it )
{
if ( it.key()->isChecked() )
activeChecks << it.value();
}
mLayer->geometryOptions()->setGeometryChecks( activeChecks );

// update symbology
emit refreshLegend( mLayer->id() );

@@ -245,6 +245,8 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private

QgsVectorLayer3DRendererWidget *mVector3DWidget = nullptr;

QHash<QCheckBox *, QString> mGeometryCheckFactoriesGroupBoxes;

private slots:
void openPanel( QgsPanelWidget *panel );

0 comments on commit 0b20ae6

Please sign in to comment.
You can’t perform that action at this time.