patch_for_1716-revised-20091126.txt

minor fix, base is r12262 - Steven Mizuno, 2009-11-27 07:03 AM

Download (6.09 KB)

 
1
Index: python/gui/qgsmapcanvas.sip
2
===================================================================
3
--- python/gui/qgsmapcanvas.sip	(revision 12262)
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
@@ -257,6 +260,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 12262)
31
+++ src/app/legend/qgslegend.cpp	(working copy)
32
@@ -516,7 +516,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 12262)
46
+++ src/app/qgisapp.cpp	(working copy)
47
@@ -466,6 +466,7 @@
48
   QgsDebugMsg( QgsApplication::showSettings() );
49
   QgsDebugMsg( "\n--------------------------\n\n\n" );
50
   mMapCanvas->freeze( false );
51
+  mMapCanvas->clearExtentHistory();	// reset zoomnext/zoomlast
52
   mLastComposerId = 0;
53
 } // QgisApp ctor
54
 
55
@@ -1802,6 +1803,10 @@
56
   connect( mActionRedo, SIGNAL( triggered() ), mUndoWidget, SLOT( redo() ) );
57
   connect( mUndoWidget, SIGNAL( undoStackChanged() ), this, SLOT( updateUndoActions() ) );
58
 
59
+  // Connect status from ZoomLast/ZoomNext to corresponding action
60
+  connect( mMapCanvas, SIGNAL( zoomLastStatusChanged( bool ) ), mActionZoomLast, SLOT( setEnabled( bool ) ) );
61
+  connect( mMapCanvas, SIGNAL( zoomNextStatusChanged( bool ) ), mActionZoomNext, SLOT( setEnabled( bool ) ) );
62
+
63
   // Monitor change of project path
64
   connect( QgsProject::instance(), SIGNAL( readProject( const QDomDocument & ) ),
65
            this, SLOT( projectChanged( const QDomDocument & ) ) );
66
@@ -3193,6 +3198,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 12262)
77
+++ src/gui/qgsmapcanvas.cpp	(working copy)
78
@@ -504,9 +504,20 @@
79
     mLastExtent.removeAt( i );
80
   }
81
 
82
+  mLastExtent.append( extent() ) ;
83
 
84
-  mLastExtent.append( extent() ) ;
85
+  // adjust history to no more than 20
86
+  if ( mLastExtent.size() > 20 )
87
+  {
88
+    mLastExtent.removeAt( 0 );
89
+  }
90
+
91
+  // the last item is the current extent
92
   mLastExtentIndex = mLastExtent.size() - 1;
93
+
94
+  // update controls' enabled state
95
+  emit zoomLastStatusChanged( mLastExtentIndex > 0 );
96
+  emit zoomNextStatusChanged( mLastExtentIndex < mLastExtent.size() - 1 );
97
   // notify canvas items of change
98
   updateCanvasItemPositions();
99
 
100
@@ -558,7 +569,7 @@
101
     return;
102
   }
103
 
104
-  if ( mLastExtentIndex > 1 )
105
+  if ( mLastExtentIndex > 0 )
106
   {
107
     mLastExtentIndex--;
108
     mMapRenderer->setExtent( mLastExtent[ mLastExtentIndex ] );
109
@@ -566,9 +577,12 @@
110
     updateScale();
111
     if ( mMapOverview )
112
       mMapOverview->drawExtentRect();
113
+    refresh();
114
+    // update controls' enabled state
115
+    emit zoomLastStatusChanged( mLastExtentIndex > 0 );
116
+    emit zoomNextStatusChanged( mLastExtentIndex < mLastExtent.size() - 1 );
117
   }
118
 
119
-  refresh();
120
 } // zoomToPreviousExtent
121
 
122
 void QgsMapCanvas::zoomToNextExtent()
123
@@ -585,10 +599,22 @@
124
     updateScale();
125
     if ( mMapOverview )
126
       mMapOverview->drawExtentRect();
127
+    refresh();
128
+    // update controls' enabled state
129
+    emit zoomLastStatusChanged( mLastExtentIndex > 0 );
130
+    emit zoomNextStatusChanged( mLastExtentIndex < mLastExtent.size() - 1 );
131
   }
132
-  refresh();
133
 }// zoomToNextExtent
134
 
135
+void QgsMapCanvas::clearExtentHistory()
136
+{
137
+  mLastExtent.clear();	// clear the zoom history list
138
+  mLastExtent.append( extent() ) ;	// set the current extent in the list
139
+  mLastExtentIndex = mLastExtent.size() - 1;
140
+  // update controls' enabled state
141
+  emit zoomLastStatusChanged( mLastExtentIndex > 0 );
142
+  emit zoomNextStatusChanged( mLastExtentIndex < mLastExtent.size() - 1 );
143
+}// clearExtentHistory
144
 
145
 
146
 bool QgsMapCanvas::hasCrsTransformEnabled()
147
@@ -1340,6 +1366,7 @@
148
   {
149
     QDomNode node = nodes.item( 0 );
150
     mMapRenderer->readXML( node );
151
+    clearExtentHistory();	// clear the extent history on project load
152
   }
153
   else
154
   {
155
Index: src/gui/qgsmapcanvas.h
156
===================================================================
157
--- src/gui/qgsmapcanvas.h	(revision 12262)
158
+++ src/gui/qgsmapcanvas.h	(working copy)
159
@@ -147,6 +147,9 @@
160
     //! Zoom to the Next extent (view)
161
     void zoomToNextExtent();
162
 
163
+    // ! Clears the list of extents and sets current extent as first item
164
+    void clearExtentHistory();
165
+
166
     /** Zoom to the extent of the selected features of current (vector) layer.
167
       Added in version 1.2: optionally specify different than current layer */
168
     void zoomToSelected(QgsVectorLayer* layer = NULL);
169
@@ -321,6 +324,12 @@
170
     //! Emitted when selection in any layer gets changed
171
     void selectionChanged( QgsMapLayer * layer );
172
 
173
+    //! Emitted when zoom last status changed
174
+    void zoomLastStatusChanged( bool );
175
+
176
+    //! Emitted when zoom next status changed
177
+    void zoomNextStatusChanged( bool );
178
+
179
   protected:
180
     //! Overridden key press event
181
     void keyPressEvent( QKeyEvent * e );