patch_fot_bug_1747_b.txt

Patch for bug #1747, clear the identify results dialog when the active layer is remove - gcarrillo -, 2009-06-24 07:48 AM

Download (2.07 KB)

 
1
Index: src/app/qgsmaptoolidentify.cpp
2
===================================================================
3
--- src/app/qgsmaptoolidentify.cpp	(revisión: 10966)
4
+++ src/app/qgsmaptoolidentify.cpp	(copia de trabajo)
5
@@ -46,6 +46,8 @@
6
   // set cursor
7
   QPixmap myIdentifyQPixmap = QPixmap(( const char ** ) identify_cursor );
8
   mCursor = QCursor( myIdentifyQPixmap, 1, 1 );
9
+
10
+  mLayer = 0; // Initialize mLayer, useful in removeLayer SLOT
11
 }
12

    
13
 QgsMapToolIdentify::~QgsMapToolIdentify()
14
@@ -511,3 +513,22 @@
15
   delete ad;
16
   mCanvas->refresh();
17
 }
18
+
19
+void QgsMapToolIdentify::removeLayer( QString layerID )
20
+{
21
+  if ( mLayer )
22
+  {
23
+    if ( mLayer->type() == QgsMapLayer::VectorLayer )
24
+    {
25
+      if ( mLayer->getLayerID() == layerID )
26
+      {
27
+        if ( mResults )
28
+        {
29
+          mResults->clear();
30
+          delete mRubberBand;
31
+          mRubberBand = 0;
32
+        }
33
+      }
34
+    }
35
+  }
36
+}
37
\ No newline at end of file
38
Index: src/app/qgsmaptoolidentify.h
39
===================================================================
40
--- src/app/qgsmaptoolidentify.h	(revisión: 10966)
41
+++ src/app/qgsmaptoolidentify.h	(copia de trabajo)
42
@@ -112,6 +112,8 @@
43
     // Let us know when the QgsIdentifyResults dialog box has been closed
44
     void resultsDialogGone();
45

    
46
+    // Check if the mLayer is removing from canvas to clear the results dialog
47
+    void removeLayer( QString );
48

    
49
 };
50

    
51
Index: src/app/qgisapp.cpp
52
===================================================================
53
--- src/app/qgisapp.cpp	(revisión: 10966)
54
+++ src/app/qgisapp.cpp	(copia de trabajo)
55
@@ -1660,6 +1660,9 @@
56
   connect( mMapLegend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
57
            mUndoWidget, SLOT( layerChanged( QgsMapLayer* ) ) );
58

    
59
+  // connect map layer registry signal to identify
60
+  connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ),
61
+           mMapTools.mIdentify, SLOT( removeLayer( QString ) ) );
62

    
63
   //signal when mouse moved over window (coords display in status bar)
64
   connect( mMapCanvas, SIGNAL( xyCoordinates( QgsPoint & ) ), this, SLOT( showMouseCoordinate( QgsPoint & ) ) );