Skip to content

Commit

Permalink
Use a hidden setting for activating geomtery resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 18, 2019
1 parent cd33ee7 commit 24b8dcc
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 96 deletions.
23 changes: 0 additions & 23 deletions python/core/auto_generated/qgsgeometryoptions.sip.in
Expand Up @@ -116,24 +116,6 @@ Write the geometry options to the ``node``.
Read the geometry options from ``node``.

.. versionadded:: 3.4
%End

bool automaticProblemResolutionEnabled() const;
%Docstring
Automatic problem resolution offers strategies to fix errors with
a single click.
This is currently experimental

.. versionadded:: 3.8
%End

void setAutomaticProblemResolutionEnabled( bool automaticProblemResolutionEnabled );
%Docstring
Automatic problem resolution offers strategies to fix errors with
a single click.
This is currently experimental

.. versionadded:: 3.8
%End

signals:
Expand Down Expand Up @@ -166,11 +148,6 @@ Geometries which are edited on this layer will be rounded to multiples of this v
Set to 0.0 to disable.

.. versionadded:: 3.4
%End

void automaticProblemResolutionEnabledChanged();
%Docstring
Defines if the automatic fixes
%End

};
Expand Down
4 changes: 4 additions & 0 deletions resources/qgis_global_settings.ini
Expand Up @@ -87,3 +87,7 @@ maxEntriesRelationWidget=100
# A comma separated list of geometry validations to enable by default for newly added layers
# Available checks: QgsIsValidCheck,QgsGeometryGapCheck,QgsGeometryOverlapCheck,QgsGeometryMissingVertexCheck
default_checks=

# Enable problem resolution for geometry errors
# This feature is experimental and has known issues.
enable_problem_resolution=false
15 changes: 3 additions & 12 deletions src/app/qgsgeometryvalidationdock.cpp
Expand Up @@ -70,8 +70,10 @@ QgsGeometryValidationDock::QgsGeometryValidationDock( const QString &title, QgsM
mErrorLocationRubberband->setColor( QColor( 50, 255, 50, 255 ) );

mProblemDetailWidget->setVisible( false );
}

// Problem resolution is unstable and therefore disabled by default
mResolutionWidget->setVisible( QgsSettings().value( QStringLiteral( "geometry_validation/enable_problem_resolution" ) ) == QLatin1String( "true" ) );
}

QgsGeometryValidationModel *QgsGeometryValidationDock::geometryValidationModel() const
{
Expand Down Expand Up @@ -164,14 +166,6 @@ void QgsGeometryValidationDock::onRowsInserted()
setUserVisible( true );
}

void QgsGeometryValidationDock::updateResolutionWidgetVisibility()
{
if ( !mCurrentLayer )
return;

mResolutionWidget->setVisible( mCurrentLayer->geometryOptions()->automaticProblemResolutionEnabled() );
}

QgsGeometryValidationService *QgsGeometryValidationDock::geometryValidationService() const
{
return mGeometryValidationService;
Expand Down Expand Up @@ -283,8 +277,6 @@ void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
disconnect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
disconnect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
disconnect( mCurrentLayer, &QgsVectorLayer::destroyed, this, &QgsGeometryValidationDock::onLayerDestroyed );
disconnect( mCurrentLayer->geometryOptions(), &QgsGeometryOptions::automaticProblemResolutionEnabledChanged, this, &QgsGeometryValidationDock::updateResolutionWidgetVisibility );
updateResolutionWidgetVisibility();
}

mCurrentLayer = qobject_cast<QgsVectorLayer *>( layer );
Expand All @@ -294,7 +286,6 @@ void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
connect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
connect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
connect( mCurrentLayer, &QgsVectorLayer::destroyed, this, &QgsGeometryValidationDock::onLayerDestroyed );
connect( mCurrentLayer->geometryOptions(), &QgsGeometryOptions::automaticProblemResolutionEnabledChanged, this, &QgsGeometryValidationDock::updateResolutionWidgetVisibility );
}

onLayerEditingStatusChanged();
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsgeometryvalidationdock.h
Expand Up @@ -57,7 +57,6 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
void updateLayerTransform();
void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles );
void onRowsInserted();
void updateResolutionWidgetVisibility();

private:

Expand Down
3 changes: 0 additions & 3 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -463,14 +463,12 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
}
mTopologyChecksGroupBox->setLayout( topologyCheckLayout );
mTopologyChecksGroupBox->setVisible( !topologyCheckFactories.isEmpty() );
mAutomaticProblemResolutionCheckbox->setChecked( mLayer->geometryOptions()->automaticProblemResolutionEnabled() );
}
else
{
mRemoveDuplicateNodesCheckbox->setEnabled( false );
mGeometryPrecisionLineEdit->setEnabled( false );
mGeometryAutoFixesGroupBox->setEnabled( false );
mAutomaticProblemResolutionCheckbox->setEnabled( false );
}

mOptsPage_Information->setProperty( "helpPage", QStringLiteral( "working_with_vector/vector_properties.html#information-properties" ) );
Expand Down Expand Up @@ -841,7 +839,6 @@ void QgsVectorLayerProperties::apply()
activeChecks << it.value();
}
mLayer->geometryOptions()->setGeometryChecks( activeChecks );
mLayer->geometryOptions()->setAutomaticProblemResolutionEnabled( mAutomaticProblemResolutionCheckbox->isChecked() );

mLayer->triggerRepaint();
// notify the project we've made a change
Expand Down
12 changes: 0 additions & 12 deletions src/core/qgsgeometryoptions.cpp
Expand Up @@ -115,15 +115,3 @@ void QgsGeometryOptions::readXml( const QDomNode &node )
const QVariant checkConfiguration = QgsXmlUtils::readVariant( checkConfigurationElem );
mCheckConfiguration = checkConfiguration.toMap();
}

bool QgsGeometryOptions::automaticProblemResolutionEnabled() const
{
return mAutomaticProblemResolutionEnabled;
}

void QgsGeometryOptions::setAutomaticProblemResolutionEnabled( bool automaticFixesEnabled )
{
if ( automaticFixesEnabled != mAutomaticProblemResolutionEnabled )
mAutomaticProblemResolutionEnabled = automaticFixesEnabled;
emit automaticProblemResolutionEnabledChanged();
}
24 changes: 0 additions & 24 deletions src/core/qgsgeometryoptions.h
Expand Up @@ -131,24 +131,6 @@ class CORE_EXPORT QgsGeometryOptions : public QObject
*/
void readXml( const QDomNode &node );

/**
* Automatic problem resolution offers strategies to fix errors with
* a single click.
* This is currently experimental
*
* \since QGIS 3.8
*/
bool automaticProblemResolutionEnabled() const;

/**
* Automatic problem resolution offers strategies to fix errors with
* a single click.
* This is currently experimental
*
* \since QGIS 3.8
*/
void setAutomaticProblemResolutionEnabled( bool automaticProblemResolutionEnabled );

signals:

/**
Expand Down Expand Up @@ -181,11 +163,6 @@ class CORE_EXPORT QgsGeometryOptions : public QObject
*/
void geometryPrecisionChanged();

/**
* Defines if the automatic fixes
*/
void automaticProblemResolutionEnabledChanged();

private:

/**
Expand All @@ -206,7 +183,6 @@ class CORE_EXPORT QgsGeometryOptions : public QObject

QStringList mGeometryChecks;
QVariantMap mCheckConfiguration;
bool mAutomaticProblemResolutionEnabled = false;
};

#endif // QGSGEOMETRYOPTIONS_H
32 changes: 11 additions & 21 deletions src/ui/qgsvectorlayerpropertiesbase.ui
Expand Up @@ -436,8 +436,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>315</width>
<height>403</height>
<width>662</width>
<height>804</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
Expand Down Expand Up @@ -724,8 +724,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<height>30</height>
<width>662</width>
<height>804</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
Expand Down Expand Up @@ -910,8 +910,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>113</width>
<height>110</height>
<width>662</width>
<height>804</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
Expand Down Expand Up @@ -1305,8 +1305,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<height>30</height>
<width>662</width>
<height>804</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
Expand Down Expand Up @@ -1508,7 +1508,7 @@ border-radius: 2px;</string>
<x>0</x>
<y>0</y>
<width>734</width>
<height>372</height>
<height>790</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
Expand Down Expand Up @@ -1964,8 +1964,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>378</width>
<height>678</height>
<width>662</width>
<height>804</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
Expand Down Expand Up @@ -2439,16 +2439,6 @@ border-radius: 2px;</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mAutomaticProblemResolutionCheckbox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This enables additional buttons for check results that will automatically fix problems.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Experimental&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This functionality is tagged as experimental since some of the automatic fixes do not work completely reliable.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Offer automatic problem resolution (Experimental)</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
Expand Down

0 comments on commit 24b8dcc

Please sign in to comment.