Skip to content
Permalink
Browse files

Update QGIS snapping dialog if settings changed via QgsProject

  • Loading branch information
mhugent committed Jun 20, 2012
1 parent 1db0422 commit 1e6002885225a9fc791c27eb800ecbf719258f89
Showing with 21 additions and 1 deletion.
  1. +15 −1 src/app/qgssnappingdialog.cpp
  2. +3 −0 src/app/qgssnappingdialog.h
  3. +1 −0 src/core/qgsproject.cpp
  4. +2 −0 src/core/qgsproject.h
@@ -73,7 +73,7 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( layersWillBeRemoved( QStringList ) ) );
connect( cbxEnableTopologicalEditingCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( on_cbxEnableTopologicalEditingCheckBox_stateChanged( int ) ) );

mLayerTreeWidget->clear();
reloadLayers();

QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap< QString, QgsMapLayer *>::iterator it;
@@ -91,6 +91,7 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
mLayerTreeWidget->setSortingEnabled( true );

setTopologicalEditingState();
connect( QgsProject::instance(), SIGNAL( snapSettingsChanged() ), this, SLOT( reloadLayers() ) );
}

QgsSnappingDialog::QgsSnappingDialog()
@@ -101,6 +102,19 @@ QgsSnappingDialog::~QgsSnappingDialog()
{
}

void QgsSnappingDialog::reloadLayers()
{
mLayerTreeWidget->clear();

QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap< QString, QgsMapLayer *>::iterator it;
for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it )
{
addLayer( it.value() );
}

}

void QgsSnappingDialog::on_cbxEnableTopologicalEditingCheckBox_stateChanged( int state )
{
int topologicalEditingEnabled = ( state == Qt::Checked ) ? 1 : 0;
@@ -67,6 +67,9 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
*/
void closeEvent( QCloseEvent* event );

private slots:
void reloadLayers();


private:
/**Default constructor forbidden*/
@@ -1675,6 +1675,7 @@ void QgsProject::setSnapSettingsForLayer( const QString& layerId, bool enabled,
writeEntry( "Digitizing", "/LayerSnappingToleranceUnitList", toleranceUnitList );
writeEntry( "Digitizing", "/LayerSnapToList", snapTypeList );
writeEntry( "Digitizing", "/AvoidIntersectionsList", avoidIntersectionList );
emit snapSettingsChanged();
}

bool QgsProject::snapSettingsForLayer( const QString& layerId, bool& enabled, QgsSnapper::SnappingType &type, QgsTolerance::UnitType& units, double& tolerance,
@@ -326,6 +326,8 @@ class CORE_EXPORT QgsProject : public QObject
// @param n number of layers
void layerLoaded( int i, int n );

void snapSettingsChanged();

private:

QgsProject(); // private 'cause it's a singleton

0 comments on commit 1e60028

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