Skip to content

Commit

Permalink
Update QGIS snapping dialog if settings changed via QgsProject
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 20, 2012
1 parent 1db0422 commit 1e60028
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/app/qgssnappingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgssnappingdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
*/
void closeEvent( QCloseEvent* event );

private slots:
void reloadLayers();


private:
/**Default constructor forbidden*/
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1e60028

Please sign in to comment.