patch_fot_bug_1747_a.txt

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

Download (2.34 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,18 @@
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
+          mResults->done( 0 ); // close the window
29
+      }
30
+    }
31
+  }
32
+}
33
\ No newline at end of file
34
Index: src/app/qgsmaptoolidentify.h
35
===================================================================
36
--- src/app/qgsmaptoolidentify.h    (revisión: 10966)
37
+++ src/app/qgsmaptoolidentify.h    (copia de trabajo)
38
@@ -112,6 +112,8 @@
39
     // Let us know when the QgsIdentifyResults dialog box has been closed
40
     void resultsDialogGone();
41

    
42
+    // Check if the mLayer is removing from canvas to close the results dialog
43
+    void removeLayer( QString );
44

    
45
 };
46

    
47
Index: src/app/qgisapp.cpp
48
===================================================================
49
--- src/app/qgisapp.cpp (revisión: 10966)
50
+++ src/app/qgisapp.cpp (copia de trabajo)
51
@@ -1178,7 +1178,7 @@
52
   mEditMenu->addAction( mActionSplitFeatures );
53
   mEditMenu->addAction( mActionMergeFeatures );
54
   mEditMenu->addAction( mActionNodeTool );
55
-
56
+
57
   if ( layout == QDialogButtonBox::GnomeLayout || layout == QDialogButtonBox::MacLayout )
58
   {
59
     mActionEditSeparator3 = mEditMenu->addSeparator();
60
@@ -1660,6 +1660,9 @@
61
   connect( mMapLegend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
62
            mUndoWidget, SLOT( layerChanged( QgsMapLayer* ) ) );
63

    
64
+  // connect map layer registry signal to identify
65
+  connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ),
66
+           mMapTools.mIdentify, SLOT( removeLayer( QString ) ) );
67

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