Skip to content

Commit aff0f86

Browse files
author
jef
committedJun 18, 2008
fix #958
git-svn-id: http://svn.osgeo.org/qgis/trunk@8656 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 409dcee commit aff0f86

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed
 

‎src/app/qgisapp.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4750,8 +4750,6 @@ void QgisApp::showMapTip()
47504750
// only process vector layers
47514751
if ( mypLayer->type() == QgsMapLayer::VECTOR )
47524752
{
4753-
4754-
47554753
// Show the maptip if the maptips button is depressed
47564754
if(mMapTipsVisible)
47574755
{
@@ -4849,6 +4847,8 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
48494847
return;
48504848
}
48514849

4850+
mMapCanvas->restoreMapTool();
4851+
48524852
mActionToggleEditing->setEnabled(true);
48534853
mActionRemoveLayer->setEnabled(true);
48544854
mActionInOverview->setEnabled(true);

‎src/app/qgsmaptooledit.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class QgsMapToolEdit: public QgsMapTool
2929
public:
3030
QgsMapToolEdit(QgsMapCanvas* canvas);
3131
virtual ~QgsMapToolEdit();
32+
33+
virtual bool isEditTool() { return true; }
3234

3335
protected:
3436
/**Snapper object that reads the settings from project and option

‎src/gui/qgsmapcanvas.cpp‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class QgsMapCanvas::CanvasProperties
8787
mMapOverview = NULL;
8888
mMapTool = NULL;
8989
mLastNonZoomMapTool = NULL;
90+
mNonEditMapTool = NULL;
9091

9192
mDrawing = false;
9293
mFrozen = false;
@@ -959,14 +960,32 @@ void QgsMapCanvas::setMapTool(QgsMapTool* tool)
959960
{
960961
mLastNonZoomMapTool = NULL;
961962
}
962-
963+
963964
// set new map tool and activate it
964965
mMapTool = tool;
965966
if (mMapTool)
966967
mMapTool->activate();
967968

968969
} // setMapTool
969970

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+
970989
void QgsMapCanvas::unsetMapTool(QgsMapTool* tool)
971990
{
972991
if (mMapTool && mMapTool == tool)

‎src/gui/qgsmapcanvas.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
234234
//! zooms with the factor supplied. Factor > 1 zooms in
235235
void zoom(double scaleFactor);
236236

237+
//! restore tool on toggle editing
238+
void restoreMapTool();
237239

238240
public slots:
239241

@@ -299,7 +301,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
299301

300302
//! Emit key release event
301303
void keyReleased(QKeyEvent * e);
302-
304+
303305
protected:
304306
//! Overridden key press event
305307
void keyPressEvent(QKeyEvent * e);
@@ -398,6 +400,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
398400
//! previous tool if current is for zooming/panning
399401
QgsMapTool* mLastNonZoomMapTool;
400402

403+
//! tool to restore when editing is toggled.
404+
QgsMapTool* mNonEditMapTool;
405+
401406
//! recently used extent
402407
QgsRect mLastExtent;
403408

‎src/gui/qgsmaptool.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ bool QgsMapTool::isZoomTool()
141141
return false;
142142
}
143143

144+
bool QgsMapTool::isEditTool()
145+
{
146+
return false;
147+
}
148+
144149
QgsMapCanvas* QgsMapTool::canvas()
145150
{
146151
return mCanvas;

‎src/gui/qgsmaptool.h‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ class GUI_EXPORT QgsMapTool : public QObject
7878
* If it does, we will be able to perform the zoom and then
7979
* resume operations with the original / previously used tool.*/
8080
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+
8288
//! called when set as currently active map tool
8389
virtual void activate();
8490

0 commit comments

Comments
 (0)
Please sign in to comment.