Skip to content
Permalink
Browse files

apply #3232

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14777 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 28, 2010
1 parent 632ad13 commit 096e55b7f2d9cd95343d9b287e1a550f2a82b5a5
@@ -27,6 +27,7 @@
#include <QComboBox>
#include <QLineEdit>
#include <QDockWidget>
#include <QPushButton>


class QgsSnappingDock : public QDockWidget
@@ -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();

@@ -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;

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


void QgsSnappingDialog::connectUpdate( QgsMapLayer * theMapLayer )
{
connect( theMapLayer, SIGNAL( destroyed() ), this, SLOT( update() ) );
update();
}
@@ -18,6 +18,7 @@
#ifndef QGSSNAPPINGDIALOG_H
#define QGSSNAPPINGDIALOG_H

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

class QDockWidget;
@@ -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
@@ -67,6 +68,10 @@ class QgsSnappingDialog: public QDialog, private Ui::QgsSnappingDialogBase
QgsMapCanvas* mMapCanvas;

QDockWidget *mDock;

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

#endif
@@ -111,6 +111,7 @@ void QgsMapLayerRegistry::removeAllMapLayers()
{
emit layerWillBeRemoved( it.key() );
delete it.value(); // delete the map layer
mMapLayers.remove( it.key() );
}
mMapLayers.clear();

@@ -30,7 +30,7 @@
</property>
<column>
<property name="text">
<string> </string>
<string/>
</property>
</column>
<column>
@@ -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>

0 comments on commit 096e55b

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