Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 e2e23f0
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 302 deletions.
30 changes: 0 additions & 30 deletions python/core/qgsproject.sip
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions src/app/qgssnappingdialog.cpp
Expand Up @@ -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();

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


void QgsSnappingDialog::apply()
{
QString snapMode;
Expand Down Expand Up @@ -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.