Skip to content

Commit

Permalink
Toggle remove duplicate nodes when precision is changed
Browse files Browse the repository at this point in the history
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 db77b45
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -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();
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

QHash<QCheckBox *, QString> mGeometryCheckFactoriesGroupBoxes;

bool mRemoveDuplicateNodesManuallyActivated = false;

private slots:
void openPanel( QgsPanelWidget *panel );

Expand Down

0 comments on commit db77b45

Please sign in to comment.