Skip to content

Commit

Permalink
apply #3232
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14777 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 28, 2010
1 parent 0e2ffec commit 4426308
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
18 changes: 14 additions & 4 deletions src/app/qgssnappingdialog.cpp
Expand Up @@ -27,6 +27,7 @@
#include <QComboBox>
#include <QLineEdit>
#include <QDockWidget>
#include <QPushButton>


class QgsSnappingDock : public QDockWidget
Expand Down Expand Up @@ -63,9 +64,9 @@ QgsSnappingDialog::QgsSnappingDialog( QWidget* parent, QgsMapCanvas* canvas ): Q
else
{
connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( apply() ) );
connect( mButtonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
}
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( update() ) );
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( update() ) );
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( connectUpdate( QgsMapLayer * ) ) );

update();

Expand Down Expand Up @@ -133,9 +134,11 @@ void QgsSnappingDialog::update()

mLayerTreeWidget->clear();

for ( int i = 0; i < mMapCanvas->layerCount(); ++i )
QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap< QString, QgsMapLayer *>::iterator it;
for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it )
{
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->layer( i ) );
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( it.value() );
if ( !currentVectorLayer )
continue;

Expand Down Expand Up @@ -262,3 +265,10 @@ void QgsSnappingDialog::show()
else
QDialog::show();
}


void QgsSnappingDialog::connectUpdate( QgsMapLayer * theMapLayer )
{
connect( theMapLayer, SIGNAL( destroyed() ), this, SLOT( update() ) );
update();
}
11 changes: 8 additions & 3 deletions src/app/qgssnappingdialog.h
Expand Up @@ -18,6 +18,7 @@
#ifndef QGSSNAPPINGDIALOG_H
#define QGSSNAPPINGDIALOG_H

#include "qgsmaplayer.h"
#include "ui_qgssnappingdialogbase.h"

class QDockWidget;
Expand All @@ -41,12 +42,12 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
//! apply the changes
void apply();

//! update the Dialog
void update();

//! show dialog or dock
void show();

//! connect to the layers destroyed() and then update()
void connectUpdate( QgsMapLayer* theMapLayer );

protected:
/**Constructor
@param canvas pointer to the map canvas (for detecting which vector layers are loaded
Expand All @@ -67,6 +68,10 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
QgsMapCanvas* mMapCanvas;

QDockWidget *mDock;

private slots:
//! update the Dialog
void update();
};

#endif
1 change: 1 addition & 0 deletions src/core/qgsmaplayerregistry.cpp
Expand Up @@ -111,6 +111,7 @@ void QgsMapLayerRegistry::removeAllMapLayers()
{
emit layerWillBeRemoved( it.key() );
delete it.value(); // delete the map layer
mMapLayers.remove( it.key() );
}
mMapLayers.clear();

Expand Down
4 changes: 2 additions & 2 deletions src/ui/qgssnappingdialogbase.ui
Expand Up @@ -30,7 +30,7 @@
</property>
<column>
<property name="text">
<string> </string>
<string/>
</property>
</column>
<column>
Expand Down Expand Up @@ -61,7 +61,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
Expand Down

0 comments on commit 4426308

Please sign in to comment.