patch_for_1716_revised-20090804.txt

revised patch (r11258 is base) - Steven Mizuno, 2009-08-04 07:06 PM

Download (5.75 KB)

 
1
Index: python/gui/qgsmapcanvas.sip
2
===================================================================
3
--- python/gui/qgsmapcanvas.sip	(revision 11258)
4
+++ python/gui/qgsmapcanvas.sip	(working copy)
5
@@ -93,6 +93,9 @@
6
     //! Zoom to the next extent (view)
7
     void zoomToNextExtent();
8
 
9
+    // ! Clears the list of extents and sets current extent as first item
10
+    void clearExtentHistory();
11
+ 
12
     /** Zoom to the extent of the selected features of current (vector) layer.
13
       Added in version 1.2: optionally specify different than current layer */
14
     void zoomToSelected(QgsVectorLayer* layer = NULL);
15
@@ -255,6 +258,12 @@
16
     //! Emit map tool changed event
17
     void mapToolSet(QgsMapTool *tool);
18
 
19
+    //! Emitted when zoom last status changed
20
+    void zoomLastStatusChanged( bool );
21
+
22
+    //! Emitted when zoom next status changed
23
+    void zoomNextStatusChanged( bool );
24
+
25
   protected:
26
 
27
     //! Overridden key press event
28
Index: src/app/legend/qgslegend.cpp
29
===================================================================
30
--- src/app/legend/qgslegend.cpp	(revision 11258)
31
+++ src/app/legend/qgslegend.cpp	(working copy)
32
@@ -603,7 +603,10 @@
33
 
34
   // first layer?
35
   if ( mMapCanvas->layerCount() == 1 )
36
+  {
37
     mMapCanvas->zoomToFullExtent();
38
+    mMapCanvas->clearExtentHistory(); 
39
+  }
40
   setCurrentItem( llayer );
41
   //make the QTreeWidget item up-to-date
42
   doItemsLayout();
43
Index: src/app/qgisapp.cpp
44
===================================================================
45
--- src/app/qgisapp.cpp	(revision 11258)
46
+++ src/app/qgisapp.cpp	(working copy)
47
@@ -454,6 +454,7 @@
48
   //finally show all the application settings as initialised above
49
   QgsApplication::showSettings();
50
   mMapCanvas->freeze( false );
51
+  mMapCanvas->clearExtentHistory();	// reset zoomnext/zoomlast
52
 } // QgisApp ctor
53
 
54
 
55
@@ -1694,6 +1695,10 @@
56
   connect( mActionUndo, SIGNAL( triggered() ), mUndoWidget, SLOT( undo() ) );
57
   connect( mActionRedo, SIGNAL( triggered() ), mUndoWidget, SLOT( redo() ) );
58
   connect( mUndoWidget, SIGNAL( undoStackChanged() ), this, SLOT( updateUndoActions() ) );
59
+
60
+  // Connect status from ZoomLast/ZoomNext to corresponding action
61
+  connect( mMapCanvas, SIGNAL( zoomLastStatusChanged( bool ) ), mActionZoomLast, SLOT( setEnabled( bool ) ) );
62
+  connect( mMapCanvas, SIGNAL( zoomNextStatusChanged( bool ) ), mActionZoomNext, SLOT( setEnabled( bool ) ) );
63
 }
64
 
65
 void QgisApp::createCanvas()
66
@@ -3104,6 +3109,7 @@
67
 
68
   mMapCanvas->freeze( false );
69
   mMapCanvas->refresh();
70
+  mMapCanvas->clearExtentHistory();
71
 
72
   mMapCanvas->mapRenderer()->setProjectionsEnabled( FALSE );
73
 
74
Index: src/gui/qgsmapcanvas.cpp
75
===================================================================
76
--- src/gui/qgsmapcanvas.cpp	(revision 11258)
77
+++ src/gui/qgsmapcanvas.cpp	(working copy)
78
@@ -507,6 +507,9 @@
79
 
80
   mLastExtent.append( extent() ) ;
81
   mLastExtentIndex = mLastExtent.size() - 1;
82
+  // update controls' enabled state
83
+  emit zoomLastStatusChanged( mLastExtentIndex > 0 );
84
+  emit zoomNextStatusChanged( mLastExtentIndex < mLastExtent.size() - 1 );
85
   // notify canvas items of change
86
   updateCanvasItemPositions();
87
 
88
@@ -558,7 +561,7 @@
89
     return;
90
   }
91
 
92
-  if ( mLastExtentIndex > 1 )
93
+  if ( mLastExtentIndex > 0 )
94
   {
95
     mLastExtentIndex--;
96
     mMapRenderer->setExtent( mLastExtent[mLastExtentIndex] );
97
@@ -566,9 +569,12 @@
98
     updateScale();
99
     if ( mMapOverview )
100
       mMapOverview->drawExtentRect();
101
+    refresh();
102
+    // update controls' enabled state
103
+    emit zoomLastStatusChanged( mLastExtentIndex > 0 );
104
+    emit zoomNextStatusChanged( mLastExtentIndex < mLastExtent.size() - 1 );
105
   }
106
 
107
-  refresh();
108
 } // zoomToPreviousExtent
109
 
110
 void QgsMapCanvas::zoomToNextExtent()
111
@@ -585,10 +591,22 @@
112
     updateScale();
113
     if ( mMapOverview )
114
       mMapOverview->drawExtentRect();
115
+    refresh();
116
+    // update controls' enabled state
117
+    emit zoomLastStatusChanged( mLastExtentIndex > 0 );
118
+    emit zoomNextStatusChanged( mLastExtentIndex < mLastExtent.size() - 1 );
119
   }
120
-  refresh();
121
 }// zoomToNextExtent
122
 
123
+void QgsMapCanvas::clearExtentHistory()
124
+{
125
+  mLastExtent.clear();	// clear the zoom history list
126
+  mLastExtent.append( extent() ) ;	// set the current extent in the list
127
+  mLastExtentIndex = mLastExtent.size() - 1;
128
+  // update controls' enabled state
129
+  emit zoomLastStatusChanged( mLastExtentIndex > 0 );
130
+  emit zoomNextStatusChanged( mLastExtentIndex < mLastExtent.size() - 1 );
131
+}// clearExtentHistory
132
 
133
 
134
 bool QgsMapCanvas::hasCrsTransformEnabled()
135
@@ -1344,6 +1362,7 @@
136
   {
137
     QDomNode node = nodes.item( 0 );
138
     mMapRenderer->readXML( node );
139
+    clearExtentHistory();	// clear the extent history on project load
140
   }
141
   else
142
   {
143
Index: src/gui/qgsmapcanvas.h
144
===================================================================
145
--- src/gui/qgsmapcanvas.h	(revision 11258)
146
+++ src/gui/qgsmapcanvas.h	(working copy)
147
@@ -147,6 +147,9 @@
148
     //! Zoom to the Next extent (view)
149
     void zoomToNextExtent();
150
 
151
+    // ! Clears the list of extents and sets current extent as first item
152
+    void clearExtentHistory();
153
+
154
     /** Zoom to the extent of the selected features of current (vector) layer.
155
       Added in version 1.2: optionally specify different than current layer */
156
     void zoomToSelected(QgsVectorLayer* layer = NULL);
157
@@ -319,6 +322,12 @@
158
     //! Emitted when selection in any layer gets changed
159
     void selectionChanged( QgsMapLayer * layer );
160
 
161
+    //! Emitted when zoom last status changed
162
+    void zoomLastStatusChanged( bool );
163
+
164
+    //! Emitted when zoom next status changed
165
+    void zoomNextStatusChanged( bool );
166
+
167
   protected:
168
     //! Overridden key press event
169
     void keyPressEvent( QKeyEvent * e );