File tree Expand file tree Collapse file tree 6 files changed +42
-5
lines changed Expand file tree Collapse file tree 6 files changed +42
-5
lines changed Original file line number Diff line number Diff line change @@ -4750,8 +4750,6 @@ void QgisApp::showMapTip()
4750
4750
// only process vector layers
4751
4751
if ( mypLayer->type () == QgsMapLayer::VECTOR )
4752
4752
{
4753
-
4754
-
4755
4753
// Show the maptip if the maptips button is depressed
4756
4754
if (mMapTipsVisible )
4757
4755
{
@@ -4849,6 +4847,8 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
4849
4847
return ;
4850
4848
}
4851
4849
4850
+ mMapCanvas ->restoreMapTool ();
4851
+
4852
4852
mActionToggleEditing ->setEnabled (true );
4853
4853
mActionRemoveLayer ->setEnabled (true );
4854
4854
mActionInOverview ->setEnabled (true );
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ class QgsMapToolEdit: public QgsMapTool
29
29
public:
30
30
QgsMapToolEdit (QgsMapCanvas* canvas);
31
31
virtual ~QgsMapToolEdit ();
32
+
33
+ virtual bool isEditTool () { return true ; }
32
34
33
35
protected:
34
36
/* *Snapper object that reads the settings from project and option
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ class QgsMapCanvas::CanvasProperties
87
87
mMapOverview = NULL ;
88
88
mMapTool = NULL ;
89
89
mLastNonZoomMapTool = NULL ;
90
+ mNonEditMapTool = NULL ;
90
91
91
92
mDrawing = false ;
92
93
mFrozen = false ;
@@ -959,14 +960,32 @@ void QgsMapCanvas::setMapTool(QgsMapTool* tool)
959
960
{
960
961
mLastNonZoomMapTool = NULL ;
961
962
}
962
-
963
+
963
964
// set new map tool and activate it
964
965
mMapTool = tool;
965
966
if (mMapTool )
966
967
mMapTool ->activate ();
967
968
968
969
} // setMapTool
969
970
971
+ void QgsMapCanvas::restoreMapTool ()
972
+ {
973
+ if ( !mMapTool )
974
+ return ;
975
+
976
+ if ( !mMapTool ->isEditTool () )
977
+ {
978
+ mNonEditMapTool = mMapTool ;
979
+ return ;
980
+ }
981
+
982
+ if ( mCurrentLayer && !mCurrentLayer ->isEditable () )
983
+ {
984
+ setMapTool (mNonEditMapTool );
985
+ }
986
+ }
987
+
988
+
970
989
void QgsMapCanvas::unsetMapTool (QgsMapTool* tool)
971
990
{
972
991
if (mMapTool && mMapTool == tool)
Original file line number Diff line number Diff line change @@ -234,6 +234,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
234
234
// ! zooms with the factor supplied. Factor > 1 zooms in
235
235
void zoom (double scaleFactor);
236
236
237
+ // ! restore tool on toggle editing
238
+ void restoreMapTool ();
237
239
238
240
public slots:
239
241
@@ -299,7 +301,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
299
301
300
302
// ! Emit key release event
301
303
void keyReleased (QKeyEvent * e);
302
-
304
+
303
305
protected:
304
306
// ! Overridden key press event
305
307
void keyPressEvent (QKeyEvent * e);
@@ -398,6 +400,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
398
400
// ! previous tool if current is for zooming/panning
399
401
QgsMapTool* mLastNonZoomMapTool ;
400
402
403
+ // ! tool to restore when editing is toggled.
404
+ QgsMapTool* mNonEditMapTool ;
405
+
401
406
// ! recently used extent
402
407
QgsRect mLastExtent ;
403
408
Original file line number Diff line number Diff line change @@ -141,6 +141,11 @@ bool QgsMapTool::isZoomTool()
141
141
return false ;
142
142
}
143
143
144
+ bool QgsMapTool::isEditTool ()
145
+ {
146
+ return false ;
147
+ }
148
+
144
149
QgsMapCanvas* QgsMapTool::canvas ()
145
150
{
146
151
return mCanvas ;
Original file line number Diff line number Diff line change @@ -78,7 +78,13 @@ class GUI_EXPORT QgsMapTool : public QObject
78
78
* If it does, we will be able to perform the zoom and then
79
79
* resume operations with the original / previously used tool.*/
80
80
virtual bool isZoomTool ();
81
-
81
+
82
+ /* * Check whether this MapTool performs an edit operation.
83
+ * If it does, we will deactivate it when editing is turned off and
84
+ * reactivate it when editing is turned back on.
85
+ */
86
+ virtual bool isEditTool ();
87
+
82
88
// ! called when set as currently active map tool
83
89
virtual void activate ();
84
90
You can’t perform that action at this time.
0 commit comments