Skip to content
Permalink
Browse files
snapping dialog: block signals when reloading snapping options
QgsProject: also apply default when property is not available and not only if
an existing one is invalid

fixes #12192
  • Loading branch information
jef-n committed Feb 15, 2015
1 parent ccdf452 commit e2e23f0c8efaf755b0a131cc4a69b4caa3a29c2d
Showing with 176 additions and 302 deletions.
  1. +0 −30 python/core/qgsproject.sip
  2. +8 −2 src/app/qgssnappingdialog.cpp
  3. +168 −270 src/core/qgsproject.cpp
@@ -132,36 +132,6 @@ class QgsProject : QObject
bool write();
//@}


/// syntactic sugar for property lists
// DEPRECATED typedef QPair< QString, QVariant > PropertyValue;
// DEPRECATED typedef QValueList< PropertyValue > Properties;

/** extra properties, typically added by plug-ins

This allows for extra properties to be associated with projects. Think
of it as a registry bound to a project.

Properties are arbitrary values keyed by a name and associated with a
scope. The scope would presumably refer to your plug-in.
E.g., "openmodeller".

@note

E.g., open modeller might use:

<code>"QgsProject::instance()->properties("openmodeller")["foo"]</code>.

@todo "properties" is, overall, a good name; but that might imply that
the qgis specific state properites are different since they aren't
accessible here. Actually, what if we make "qgis" yet another
scope that stores its state in the properties list? E.g.,
QgsProject::instance()->properties()["qgis"]?


*/
// DEPRECATED Properties & properties( QString const & scope );

/**
removes all project properties

@@ -133,15 +133,21 @@ void QgsSnappingDialog::reload()
idx = 0;
else // off
idx = 3;
mDefaultSnapToComboBox->blockSignals( true );
mDefaultSnapToComboBox->setCurrentIndex( idx );
mDefaultSnapToComboBox->blockSignals( false );

double tolerance = settings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
tolerance = QgsProject::instance()->readDoubleEntry( "Digitizing", "/DefaultSnapTolerance", tolerance );
mDefaultSnappingToleranceSpinBox->blockSignals( true );
mDefaultSnappingToleranceSpinBox->setValue( tolerance );
mDefaultSnappingToleranceSpinBox->blockSignals( false );

int unit = settings.value( "/qgis/digitizing/default_snapping_tolerance_unit", QgsTolerance::ProjectUnits ).toInt();
unit = QgsProject::instance()->readNumEntry( "Digitizing", "/DefaultSnapToleranceUnit", unit );
mDefaultSnappingToleranceComboBox->blockSignals( true );
mDefaultSnappingToleranceComboBox->setCurrentIndex( unit == QgsTolerance::Pixels ? 1 : 0 );
mDefaultSnappingToleranceComboBox->blockSignals( false );

mLayerTreeWidget->clear();

@@ -202,7 +208,6 @@ void QgsSnappingDialog::closeEvent( QCloseEvent* event )
}
}


void QgsSnappingDialog::apply()
{
QString snapMode;
@@ -492,12 +497,13 @@ void QgsSnappingDialog::setIntersectionSnappingState()

void QgsSnappingDialog::setSnappingMode()
{
mSnapModeComboBox->blockSignals( true );
QString snapMode = QgsProject::instance()->readEntry( "Digitizing", "/SnappingMode" );
if ( snapMode == "current_layer" )
mSnapModeComboBox->setCurrentIndex( 0 );
else if ( snapMode == "all_layers" )
mSnapModeComboBox->setCurrentIndex( 1 );
else // "advanced" or empty (backward compatibility)
mSnapModeComboBox->setCurrentIndex( 2 );
mSnapModeComboBox->blockSignals( false );
}

0 comments on commit e2e23f0

Please sign in to comment.