Skip to content
Permalink
Browse files

Fix error when the tools was changed. setParentTool is not needed.

  • Loading branch information
lbartoletti committed Aug 22, 2017
1 parent 5808cc1 commit 508aef055b371602b6dacb0c637d298a62976e8b
@@ -30,10 +30,6 @@ QgsMapToolAddCircle::QgsMapToolAddCircle( QgsMapToolCapture *parentTool, QgsMapC
, mCircle( QgsCircle() )
{
clean();
if ( mCanvas )
{
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddCircle::setParentTool );
}
}

QgsMapToolAddCircle::QgsMapToolAddCircle( QgsMapCanvas *canvas )
@@ -43,31 +39,13 @@ QgsMapToolAddCircle::QgsMapToolAddCircle( QgsMapCanvas *canvas )
, mCircle( QgsCircle() )
{
clean();
if ( mCanvas )
{
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddCircle::setParentTool );
}
}

QgsMapToolAddCircle::~QgsMapToolAddCircle()
{
clean();
}

void QgsMapToolAddCircle::setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool )
{
QgsMapToolCapture *tool = dynamic_cast<QgsMapToolCapture *>( oldTool );
QgsMapToolAddCircle *csTool = dynamic_cast<QgsMapToolAddCircle *>( oldTool );
if ( csTool && newTool == this )
{
mParentTool = csTool->mParentTool;
}
else if ( tool && newTool == this )
{
mParentTool = tool;
}
}

void QgsMapToolAddCircle::keyPressEvent( QKeyEvent *e )
{
if ( e && e->isAutoRepeat() )
@@ -35,9 +35,6 @@ class QgsMapToolAddCircle: public QgsMapToolCapture

void activate() override;

private slots:
void setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool );

protected:
explicit QgsMapToolAddCircle( QgsMapCanvas *canvas ); //forbidden

@@ -30,10 +30,6 @@ QgsMapToolAddEllipse::QgsMapToolAddEllipse( QgsMapToolCapture *parentTool, QgsMa
, mEllipse( QgsEllipse() )
{
clean();
if ( mCanvas )
{
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddEllipse::setParentTool );
}
}

QgsMapToolAddEllipse::QgsMapToolAddEllipse( QgsMapCanvas *canvas )
@@ -43,31 +39,13 @@ QgsMapToolAddEllipse::QgsMapToolAddEllipse( QgsMapCanvas *canvas )
, mEllipse( QgsEllipse() )
{
clean();
if ( mCanvas )
{
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddEllipse::setParentTool );
}
}

QgsMapToolAddEllipse::~QgsMapToolAddEllipse()
{
clean();
}

void QgsMapToolAddEllipse::setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool )
{
QgsMapToolCapture *tool = dynamic_cast<QgsMapToolCapture *>( oldTool );
QgsMapToolAddEllipse *csTool = dynamic_cast<QgsMapToolAddEllipse *>( oldTool );
if ( csTool && newTool == this )
{
mParentTool = csTool->mParentTool;
}
else if ( tool && newTool == this )
{
mParentTool = tool;
}
}

void QgsMapToolAddEllipse::keyPressEvent( QKeyEvent *e )
{
if ( e && e->isAutoRepeat() )
@@ -35,9 +35,6 @@ class QgsMapToolAddEllipse: public QgsMapToolCapture

void activate() override;

private slots:
void setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool );

protected:
explicit QgsMapToolAddEllipse( QgsMapCanvas *canvas ); //forbidden

@@ -31,10 +31,6 @@ QgsMapToolAddRectangle::QgsMapToolAddRectangle( QgsMapToolCapture *parentTool, Q
, mRectangle( QgsRectangle() )
{
clean();
if ( mCanvas )
{
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddRectangle::setParentTool );
}
}

QgsMapToolAddRectangle::QgsMapToolAddRectangle( QgsMapCanvas *canvas )
@@ -44,32 +40,13 @@ QgsMapToolAddRectangle::QgsMapToolAddRectangle( QgsMapCanvas *canvas )
, mRectangle( QgsRectangle() )
{
clean();
if ( mCanvas )
{
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddRectangle::setParentTool );
}
}

QgsMapToolAddRectangle::~QgsMapToolAddRectangle()
{
clean();
}

void QgsMapToolAddRectangle::setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool )
{

QgsMapToolCapture *tool = dynamic_cast<QgsMapToolCapture *>( oldTool );
QgsMapToolAddRectangle *csTool = dynamic_cast<QgsMapToolAddRectangle *>( oldTool );
if ( csTool && newTool == this )
{
mParentTool = csTool->mParentTool;
}
else if ( tool && newTool == this )
{
mParentTool = tool;
}
}

void QgsMapToolAddRectangle::keyPressEvent( QKeyEvent *e )
{
if ( e && e->isAutoRepeat() )
@@ -37,9 +37,6 @@ class QgsMapToolAddRectangle: public QgsMapToolCapture

void activate() override;

private slots:
void setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool );

protected:
explicit QgsMapToolAddRectangle( QgsMapCanvas *canvas ); //forbidden

@@ -30,10 +30,6 @@ QgsMapToolAddRegularPolygon::QgsMapToolAddRegularPolygon( QgsMapToolCapture *par
, mRegularPolygon( QgsRegularPolygon() )
{
clean();
if ( mCanvas )
{
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddRegularPolygon::setParentTool );
}
}

QgsMapToolAddRegularPolygon::QgsMapToolAddRegularPolygon( QgsMapCanvas *canvas )
@@ -43,32 +39,13 @@ QgsMapToolAddRegularPolygon::QgsMapToolAddRegularPolygon( QgsMapCanvas *canvas )
, mRegularPolygon( QgsRegularPolygon() )
{
clean();
if ( mCanvas )
{
connect( mCanvas, &QgsMapCanvas::mapToolSet, this, &QgsMapToolAddRegularPolygon::setParentTool );
}
}

QgsMapToolAddRegularPolygon::~QgsMapToolAddRegularPolygon()
{
clean();
}

void QgsMapToolAddRegularPolygon::setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool )
{
clean();
QgsMapToolCapture *tool = dynamic_cast<QgsMapToolCapture *>( oldTool );
QgsMapToolAddRegularPolygon *csTool = dynamic_cast<QgsMapToolAddRegularPolygon *>( oldTool );
if ( csTool && newTool == this )
{
mParentTool = csTool->mParentTool;
}
else if ( tool && newTool == this )
{
mParentTool = tool;
}
}

void QgsMapToolAddRegularPolygon::createNumberSidesSpinBox()
{
deleteNumberSidesSpinBox();
@@ -22,9 +22,6 @@ class QgsMapToolAddRegularPolygon: public QgsMapToolCapture

void activate() override;

private slots:
void setParentTool( QgsMapTool *newTool, QgsMapTool *oldTool );

protected:
explicit QgsMapToolAddRegularPolygon( QgsMapCanvas *canvas ); //forbidden

0 comments on commit 508aef0

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