Skip to content
Permalink
Browse files
update sip binding after r8656:
replaces QgsMapCanvas::restoreMapTool(), which shouldn't be public, with a
signal and handles it in QgisApp.



git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8665 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 21, 2008
1 parent dbce3e2 commit 4bdf54e25a78fa761eb4f47ebaa9f47b07a2adbd
Showing with 42 additions and 37 deletions.
  1. +4 −2 python/gui/qgsmapcanvas.sip
  2. +5 −0 python/gui/qgsmaptool.sip
  3. +16 −2 src/app/qgisapp.cpp
  4. +5 −0 src/app/qgisapp.h
  5. +2 −19 src/gui/qgsmapcanvas.cpp
  6. +9 −12 src/gui/qgsmapcanvas.h
  7. +1 −2 src/gui/qgsmaptool.h
@@ -211,7 +211,7 @@ class QgsMapCanvas : QGraphicsView
//! called to write map canvas settings to project
void writeProject(QDomDocument &);

signals:
signals:
/** Let the owner know how far we are with render operations */
void setProgress(int,int);
/** emits current mouse position */
@@ -242,8 +242,10 @@ signals:
//! Emit key release event
void keyReleased(QKeyEvent * e);

//! Emit map tool changed event
void mapToolSet(QgsMapTool *tool);

protected:
protected:

//! Overridden key press event
void keyPressEvent(QKeyEvent * e);
@@ -58,6 +58,11 @@ class QgsMapTool : 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
*/
virtual bool isEditTool();

//! called when set as currently active map tool
virtual void activate();
@@ -1356,6 +1356,9 @@ void QgisApp::setupConnections()
connect(mMapCanvas, SIGNAL(scaleChanged(double)), this, SLOT(showScale(double)));
connect(mMapCanvas, SIGNAL(scaleChanged(double)), this, SLOT(updateMouseCoordinatePrecision()));

mNonEditMapTool=NULL;
connect(mMapCanvas, SIGNAL(mapToolSet(QgsMapTool *)), this, SLOT(mapToolChanged(QgsMapTool *)));

connect(mRenderSuppressionCBox, SIGNAL(toggled(bool )), mMapCanvas, SLOT(setRenderFlag(bool)));
//
// Do we really need this ??? - its already connected to the esc key...TS
@@ -4677,6 +4680,14 @@ void QgisApp::showProgress(int theProgress, int theTotalSteps)

}

void QgisApp::mapToolChanged(QgsMapTool *tool)
{
if( tool && !tool->isEditTool() )
{
mNonEditMapTool = tool;
}
}

void QgisApp::showExtents()
{
// update the statusbar with the current extents.
@@ -4847,8 +4858,6 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
return;
}

mMapCanvas->restoreMapTool();

mActionToggleEditing->setEnabled(true);
mActionRemoveLayer->setEnabled(true);
mActionInOverview->setEnabled(true);
@@ -4864,6 +4873,11 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
const QgsVectorLayer* vlayer = dynamic_cast<const QgsVectorLayer*>(layer);
const QgsVectorDataProvider* dprovider = vlayer->getDataProvider();

if( !vlayer->isEditable() && mMapCanvas->mapTool() && mMapCanvas->mapTool()->isEditTool() )
{
mMapCanvas->setMapTool(mNonEditMapTool);
}

if (dprovider)
{
//start editing/stop editing
@@ -318,6 +318,9 @@ public slots:
//! starts/stops editing mode of the current layer
void toggleEditing();

//! map tool changed
void mapToolChanged(QgsMapTool *tool);

/** Activates or deactivates actions depending on the current maplayer type.
Is called from the legend when the current legend item has changed*/
void activateDeactivateLayerRelatedActions(QgsMapLayer* layer);
@@ -583,6 +586,8 @@ class Tools
QgsMapTool* mAddRing;
QgsMapTool* mAddIsland;
} mMapTools;

QgsMapTool *mNonEditMapTool;

//!The name of the active theme
QString mThemeName;
@@ -87,7 +87,6 @@ class QgsMapCanvas::CanvasProperties
mMapOverview = NULL;
mMapTool = NULL;
mLastNonZoomMapTool = NULL;
mNonEditMapTool = NULL;

mDrawing = false;
mFrozen = false;
@@ -966,32 +965,16 @@ void QgsMapCanvas::setMapTool(QgsMapTool* tool)
if (mMapTool)
mMapTool->activate();

emit mapToolSet(mMapTool);
} // 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)
{
mMapTool->deactivate();
mMapTool = NULL;
emit mapToolSet(NULL);
setCursor(Qt::ArrowCursor);
}

@@ -234,9 +234,6 @@ 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:

/**Repaints the canvas map*/
@@ -271,7 +268,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! called to write map canvas settings to project
void writeProject(QDomDocument &);

signals:
signals:
/** Let the owner know how far we are with render operations */
void setProgress(int,int);
/** emits current mouse position */
@@ -302,7 +299,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! Emit key release event
void keyReleased(QKeyEvent * e);

protected:
//! Emit map tool changed event
void mapToolSet(QgsMapTool *tool);

protected:
//! Overridden key press event
void keyPressEvent(QKeyEvent * e);

@@ -383,10 +383,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
the last entry in case a lot of resize events arrive in short time*/
QList< QPair<int, int> > mResizeQueue;

/** debugging member
invoked when a connect() is made to this object
*/
void connectNotify( const char * signal );
/**debugging member
invoked when a connect() is made to this object
*/
void connectNotify( const char * signal );

//! current layer in legend
QgsMapLayer* mCurrentLayer;
@@ -400,9 +400,6 @@ 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;

@@ -80,8 +80,7 @@ class GUI_EXPORT QgsMapTool : public QObject
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.
* If it does, we will deactivate it when editing is turned off
*/
virtual bool isEditTool();

0 comments on commit 4bdf54e

Please sign in to comment.