Skip to content
Permalink
Browse files

fix #958

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8656 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Jun 18, 2008
1 parent 128fb33 commit 513055776347ec29bee06e62f0ce4759a7fde61e
Showing with 42 additions and 5 deletions.
  1. +2 −2 src/app/qgisapp.cpp
  2. +2 −0 src/app/qgsmaptooledit.h
  3. +20 −1 src/gui/qgsmapcanvas.cpp
  4. +6 −1 src/gui/qgsmapcanvas.h
  5. +5 −0 src/gui/qgsmaptool.cpp
  6. +7 −1 src/gui/qgsmaptool.h
@@ -4750,8 +4750,6 @@ void QgisApp::showMapTip()
// only process vector layers
if ( mypLayer->type() == QgsMapLayer::VECTOR )
{


// Show the maptip if the maptips button is depressed
if(mMapTipsVisible)
{
@@ -4849,6 +4847,8 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
return;
}

mMapCanvas->restoreMapTool();

mActionToggleEditing->setEnabled(true);
mActionRemoveLayer->setEnabled(true);
mActionInOverview->setEnabled(true);
@@ -29,6 +29,8 @@ class QgsMapToolEdit: public QgsMapTool
public:
QgsMapToolEdit(QgsMapCanvas* canvas);
virtual ~QgsMapToolEdit();

virtual bool isEditTool() { return true; }

protected:
/**Snapper object that reads the settings from project and option
@@ -87,6 +87,7 @@ class QgsMapCanvas::CanvasProperties
mMapOverview = NULL;
mMapTool = NULL;
mLastNonZoomMapTool = NULL;
mNonEditMapTool = NULL;

mDrawing = false;
mFrozen = false;
@@ -959,14 +960,32 @@ void QgsMapCanvas::setMapTool(QgsMapTool* tool)
{
mLastNonZoomMapTool = NULL;
}

// set new map tool and activate it
mMapTool = tool;
if (mMapTool)
mMapTool->activate();

} // setMapTool

void QgsMapCanvas::restoreMapTool()
{
if( !mMapTool )
return;

if( !mMapTool->isEditTool() )
{
mNonEditMapTool = mMapTool;
return;
}

if ( mCurrentLayer && !mCurrentLayer->isEditable() )
{
setMapTool(mNonEditMapTool);
}
}


void QgsMapCanvas::unsetMapTool(QgsMapTool* tool)
{
if (mMapTool && mMapTool == tool)
@@ -234,6 +234,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! zooms with the factor supplied. Factor > 1 zooms in
void zoom(double scaleFactor);

//! restore tool on toggle editing
void restoreMapTool();

public slots:

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

//! Emit key release event
void keyReleased(QKeyEvent * e);

protected:
//! Overridden key press event
void keyPressEvent(QKeyEvent * e);
@@ -398,6 +400,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! previous tool if current is for zooming/panning
QgsMapTool* mLastNonZoomMapTool;

//! tool to restore when editing is toggled.
QgsMapTool* mNonEditMapTool;

//! recently used extent
QgsRect mLastExtent;

@@ -141,6 +141,11 @@ bool QgsMapTool::isZoomTool()
return false;
}

bool QgsMapTool::isEditTool()
{
return false;
}

QgsMapCanvas* QgsMapTool::canvas()
{
return mCanvas;
@@ -78,7 +78,13 @@ class GUI_EXPORT QgsMapTool : public QObject
* If it does, we will be able to perform the zoom and then
* resume operations with the original / previously used tool.*/
virtual bool isZoomTool();


/** Check whether this MapTool performs an edit operation.
* If it does, we will deactivate it when editing is turned off and
* reactivate it when editing is turned back on.
*/
virtual bool isEditTool();

//! called when set as currently active map tool
virtual void activate();

0 comments on commit 5130557

Please sign in to comment.
You can’t perform that action at this time.