[QGIS Commit] r14777 - in trunk/qgis/src: app core ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Nov 28 12:22:47 EST 2010
Author: jef
Date: 2010-11-28 09:22:46 -0800 (Sun, 28 Nov 2010)
New Revision: 14777
Modified:
trunk/qgis/src/app/qgssnappingdialog.cpp
trunk/qgis/src/app/qgssnappingdialog.h
trunk/qgis/src/core/qgsmaplayerregistry.cpp
trunk/qgis/src/ui/qgssnappingdialogbase.ui
Log:
apply #3232
Modified: trunk/qgis/src/app/qgssnappingdialog.cpp
===================================================================
--- trunk/qgis/src/app/qgssnappingdialog.cpp 2010-11-28 12:46:06 UTC (rev 14776)
+++ trunk/qgis/src/app/qgssnappingdialog.cpp 2010-11-28 17:22:46 UTC (rev 14777)
@@ -27,6 +27,7 @@
#include <QComboBox>
#include <QLineEdit>
#include <QDockWidget>
+#include <QPushButton>
class QgsSnappingDock : public QDockWidget
@@ -63,9 +64,9 @@
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 @@
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 @@
else
QDialog::show();
}
+
+
+void QgsSnappingDialog::connectUpdate( QgsMapLayer * theMapLayer )
+{
+ connect( theMapLayer, SIGNAL( destroyed() ), this, SLOT( update() ) );
+ update();
+}
Modified: trunk/qgis/src/app/qgssnappingdialog.h
===================================================================
--- trunk/qgis/src/app/qgssnappingdialog.h 2010-11-28 12:46:06 UTC (rev 14776)
+++ trunk/qgis/src/app/qgssnappingdialog.h 2010-11-28 17:22:46 UTC (rev 14777)
@@ -18,6 +18,7 @@
#ifndef QGSSNAPPINGDIALOG_H
#define QGSSNAPPINGDIALOG_H
+#include "qgsmaplayer.h"
#include "ui_qgssnappingdialogbase.h"
class QDockWidget;
@@ -41,12 +42,12 @@
//! 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 @@
QgsMapCanvas* mMapCanvas;
QDockWidget *mDock;
+
+ private slots:
+ //! update the Dialog
+ void update();
};
#endif
Modified: trunk/qgis/src/core/qgsmaplayerregistry.cpp
===================================================================
--- trunk/qgis/src/core/qgsmaplayerregistry.cpp 2010-11-28 12:46:06 UTC (rev 14776)
+++ trunk/qgis/src/core/qgsmaplayerregistry.cpp 2010-11-28 17:22:46 UTC (rev 14777)
@@ -111,6 +111,7 @@
{
emit layerWillBeRemoved( it.key() );
delete it.value(); // delete the map layer
+ mMapLayers.remove( it.key() );
}
mMapLayers.clear();
Modified: trunk/qgis/src/ui/qgssnappingdialogbase.ui
===================================================================
--- trunk/qgis/src/ui/qgssnappingdialogbase.ui 2010-11-28 12:46:06 UTC (rev 14776)
+++ trunk/qgis/src/ui/qgssnappingdialogbase.ui 2010-11-28 17:22:46 UTC (rev 14777)
@@ -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>
More information about the QGIS-commit
mailing list