Skip to content

Commit

Permalink
update sip binding after r8656:
Browse files Browse the repository at this point in the history
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@8665 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jun 21, 2008
1 parent daf6308 commit 5e58eb5
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 37 deletions.
6 changes: 4 additions & 2 deletions python/gui/qgsmapcanvas.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions python/gui/qgsmaptool.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 16 additions & 2 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -4847,8 +4858,6 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
return;
}

mMapCanvas->restoreMapTool();

mActionToggleEditing->setEnabled(true);
mActionRemoveLayer->setEnabled(true);
mActionInOverview->setEnabled(true);
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -583,6 +586,8 @@ class Tools
QgsMapTool* mAddRing;
QgsMapTool* mAddIsland;
} mMapTools;

QgsMapTool *mNonEditMapTool;

//!The name of the active theme
QString mThemeName;
Expand Down
21 changes: 2 additions & 19 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class QgsMapCanvas::CanvasProperties
mMapOverview = NULL;
mMapTool = NULL;
mLastNonZoomMapTool = NULL;
mNonEditMapTool = NULL;

mDrawing = false;
mFrozen = false;
Expand Down Expand Up @@ -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);
}

Expand Down
21 changes: 9 additions & 12 deletions src/gui/qgsmapcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/gui/qgsmaptool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 5e58eb5

Please sign in to comment.