Skip to content
Permalink
Browse files

Toggle remove duplicate nodes when precision is changed

As soon as a precision is set, duplicate nodes are removed automatically. By
disabling the option and checking it in this scenario, this behavior is much
more transparent to the user.
  • Loading branch information
m-kuhn committed Dec 21, 2018
1 parent 308b46e commit db77b45225f57cebe6081b02afc250c3c326ce6a
Showing with 22 additions and 1 deletion.
  1. +20 −1 src/app/qgsvectorlayerproperties.cpp
  2. +2 −0 src/app/qgsvectorlayerproperties.h
@@ -408,14 +408,33 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
mGeometryPrecisionLineEdit->setEnabled( true );
mGeometryPrecisionLineEdit->setValidator( new QDoubleValidator( mGeometryPrecisionLineEdit ) );

mRemoveDuplicateNodesCheckbox->setChecked( mLayer->geometryOptions()->removeDuplicateNodes() );
double precision( mLayer->geometryOptions()->geometryPrecision() );
bool ok = true;
QString precisionStr( QLocale().toString( precision, ok ) );
if ( precision == 0.0 || ! ok )
precisionStr = QString();
mGeometryPrecisionLineEdit->setText( precisionStr );

mRemoveDuplicateNodesManuallyActivated = mLayer->geometryOptions()->removeDuplicateNodes();
mRemoveDuplicateNodesCheckbox->setChecked( mRemoveDuplicateNodesManuallyActivated );
if ( !precisionStr.isNull() )
mRemoveDuplicateNodesCheckbox->setEnabled( false );
connect( mGeometryPrecisionLineEdit, &QLineEdit::textChanged, this, [this]
{
if ( !mGeometryPrecisionLineEdit->text().isEmpty() )
{
if ( mRemoveDuplicateNodesCheckbox->isEnabled() )
mRemoveDuplicateNodesManuallyActivated = mRemoveDuplicateNodesCheckbox->isChecked();
mRemoveDuplicateNodesCheckbox->setEnabled( false );
mRemoveDuplicateNodesCheckbox->setChecked( true );
}
else
{
mRemoveDuplicateNodesCheckbox->setEnabled( true );
mRemoveDuplicateNodesCheckbox->setChecked( mRemoveDuplicateNodesManuallyActivated );
}
} );

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

QLayout *geometryCheckLayout = new QVBoxLayout();
@@ -245,6 +245,8 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private

QHash<QCheckBox *, QString> mGeometryCheckFactoriesGroupBoxes;

bool mRemoveDuplicateNodesManuallyActivated = false;

private slots:
void openPanel( QgsPanelWidget *panel );

0 comments on commit db77b45

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