Skip to content

Commit 4bdf54e

Browse files
author
jef
committedJun 21, 2008
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

File tree

7 files changed

+42
-37
lines changed

7 files changed

+42
-37
lines changed
 

‎python/gui/qgsmapcanvas.sip

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class QgsMapCanvas : QGraphicsView
211211
//! called to write map canvas settings to project
212212
void writeProject(QDomDocument &);
213213

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

245+
//! Emit map tool changed event
246+
void mapToolSet(QgsMapTool *tool);
245247

246-
protected:
248+
protected:
247249

248250
//! Overridden key press event
249251
void keyPressEvent(QKeyEvent * e);

‎python/gui/qgsmaptool.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ class QgsMapTool : QObject
5858
* If it does, we will be able to perform the zoom and then
5959
* resume operations with the original / previously used tool.*/
6060
virtual bool isZoomTool();
61+
62+
/** Check whether this MapTool performs an edit operation.
63+
* If it does, we will deactivate it when editing is turned off
64+
*/
65+
virtual bool isEditTool();
6166

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

‎src/app/qgisapp.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,9 @@ void QgisApp::setupConnections()
13561356
connect(mMapCanvas, SIGNAL(scaleChanged(double)), this, SLOT(showScale(double)));
13571357
connect(mMapCanvas, SIGNAL(scaleChanged(double)), this, SLOT(updateMouseCoordinatePrecision()));
13581358

1359+
mNonEditMapTool=NULL;
1360+
connect(mMapCanvas, SIGNAL(mapToolSet(QgsMapTool *)), this, SLOT(mapToolChanged(QgsMapTool *)));
1361+
13591362
connect(mRenderSuppressionCBox, SIGNAL(toggled(bool )), mMapCanvas, SLOT(setRenderFlag(bool)));
13601363
//
13611364
// Do we really need this ??? - its already connected to the esc key...TS
@@ -4677,6 +4680,14 @@ void QgisApp::showProgress(int theProgress, int theTotalSteps)
46774680

46784681
}
46794682

4683+
void QgisApp::mapToolChanged(QgsMapTool *tool)
4684+
{
4685+
if( tool && !tool->isEditTool() )
4686+
{
4687+
mNonEditMapTool = tool;
4688+
}
4689+
}
4690+
46804691
void QgisApp::showExtents()
46814692
{
46824693
// update the statusbar with the current extents.
@@ -4847,8 +4858,6 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
48474858
return;
48484859
}
48494860

4850-
mMapCanvas->restoreMapTool();
4851-
48524861
mActionToggleEditing->setEnabled(true);
48534862
mActionRemoveLayer->setEnabled(true);
48544863
mActionInOverview->setEnabled(true);
@@ -4864,6 +4873,11 @@ void QgisApp::activateDeactivateLayerRelatedActions(QgsMapLayer* layer)
48644873
const QgsVectorLayer* vlayer = dynamic_cast<const QgsVectorLayer*>(layer);
48654874
const QgsVectorDataProvider* dprovider = vlayer->getDataProvider();
48664875

4876+
if( !vlayer->isEditable() && mMapCanvas->mapTool() && mMapCanvas->mapTool()->isEditTool() )
4877+
{
4878+
mMapCanvas->setMapTool(mNonEditMapTool);
4879+
}
4880+
48674881
if (dprovider)
48684882
{
48694883
//start editing/stop editing

‎src/app/qgisapp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ public slots:
318318
//! starts/stops editing mode of the current layer
319319
void toggleEditing();
320320

321+
//! map tool changed
322+
void mapToolChanged(QgsMapTool *tool);
323+
321324
/** Activates or deactivates actions depending on the current maplayer type.
322325
Is called from the legend when the current legend item has changed*/
323326
void activateDeactivateLayerRelatedActions(QgsMapLayer* layer);
@@ -583,6 +586,8 @@ class Tools
583586
QgsMapTool* mAddRing;
584587
QgsMapTool* mAddIsland;
585588
} mMapTools;
589+
590+
QgsMapTool *mNonEditMapTool;
586591

587592
//!The name of the active theme
588593
QString mThemeName;

‎src/gui/qgsmapcanvas.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ class QgsMapCanvas::CanvasProperties
8787
mMapOverview = NULL;
8888
mMapTool = NULL;
8989
mLastNonZoomMapTool = NULL;
90-
mNonEditMapTool = NULL;
9190

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

968+
emit mapToolSet(mMapTool);
969969
} // setMapTool
970970

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-
989971
void QgsMapCanvas::unsetMapTool(QgsMapTool* tool)
990972
{
991973
if (mMapTool && mMapTool == tool)
992974
{
993975
mMapTool->deactivate();
994976
mMapTool = NULL;
977+
emit mapToolSet(NULL);
995978
setCursor(Qt::ArrowCursor);
996979
}
997980

‎src/gui/qgsmapcanvas.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ 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();
239-
240237
public slots:
241238

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

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

305-
protected:
302+
//! Emit map tool changed event
303+
void mapToolSet(QgsMapTool *tool);
304+
305+
protected:
306306
//! Overridden key press event
307307
void keyPressEvent(QKeyEvent * e);
308308

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

386-
/** debugging member
387-
invoked when a connect() is made to this object
388-
*/
389-
void connectNotify( const char * signal );
386+
/**debugging member
387+
invoked when a connect() is made to this object
388+
*/
389+
void connectNotify( const char * signal );
390390

391391
//! current layer in legend
392392
QgsMapLayer* mCurrentLayer;
@@ -400,9 +400,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
400400
//! previous tool if current is for zooming/panning
401401
QgsMapTool* mLastNonZoomMapTool;
402402

403-
//! tool to restore when editing is toggled.
404-
QgsMapTool* mNonEditMapTool;
405-
406403
//! recently used extent
407404
QgsRect mLastExtent;
408405

‎src/gui/qgsmaptool.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ class GUI_EXPORT QgsMapTool : public QObject
8080
virtual bool isZoomTool();
8181

8282
/** 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.
83+
* If it does, we will deactivate it when editing is turned off
8584
*/
8685
virtual bool isEditTool();
8786

0 commit comments

Comments
 (0)
Please sign in to comment.