Skip to content

Commit

Permalink
activate/deactivate geometry checks in vector layer properties
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and m-kuhn committed Oct 15, 2018
1 parent e8a7ab4 commit 0b20ae6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Expand Up @@ -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 );
}
22 changes: 22 additions & 0 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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() );

Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsvectorlayerproperties.h
Expand Up @@ -245,6 +245,8 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private

QgsVectorLayer3DRendererWidget *mVector3DWidget = nullptr;

QHash<QCheckBox *, QString> mGeometryCheckFactoriesGroupBoxes;

private slots:
void openPanel( QgsPanelWidget *panel );

Expand Down

0 comments on commit 0b20ae6

Please sign in to comment.