fix api break for pointChanged. use pointChangedV2

This commit is contained in:
Loïc Bartoletti 2021-09-10 08:29:29 +02:00 committed by Nyall Dawson
parent 99af22b977
commit f4383aaa5b
4 changed files with 41 additions and 18 deletions

View File

@ -510,12 +510,25 @@ Push a warning
Remove any previously emitted warnings (if any) Remove any previously emitted warnings (if any)
%End %End
void pointChanged( const QgsPoint &point ); void pointChangedV2( const QgsPoint &point );
%Docstring %Docstring
Sometimes a constraint may change the current point out of a mouse event. This happens normally Sometimes a constraint may change the current point out of a mouse event. This happens normally
when a constraint is toggled. when a constraint is toggled.
:param point: The last known digitizing point. Can be used to emulate a mouse event. :param point: The last known digitizing point. Can be used to emulate a mouse event.
.. versionadded:: 3.22
%End
void pointChanged( const QgsPointXY &point ) /Deprecated/;
%Docstring
Sometimes a constraint may change the current point out of a mouse event. This happens normally
when a constraint is toggled.
:param point: The last known digitizing point. Can be used to emulate a mouse event.
.. deprecated:: QGIS 3.22
- No longer used, will be removed in QGIS 4.0. Use the variant which emits :py:class:`QgsPoint` object instead of :py:class:`QgsPointXY`.
%End %End

View File

@ -591,7 +591,7 @@ void QgsAdvancedDigitizingDockWidget::updateConstraintValue( CadConstraint *cons
constraint->setValue( value, convertExpression ); constraint->setValue( value, convertExpression );
// run a fake map mouse event to update the paint item // run a fake map mouse event to update the paint item
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
} }
void QgsAdvancedDigitizingDockWidget::lockConstraint( bool activate /* default true */ ) void QgsAdvancedDigitizingDockWidget::lockConstraint( bool activate /* default true */ )
@ -659,7 +659,7 @@ void QgsAdvancedDigitizingDockWidget::lockConstraint( bool activate /* default t
} }
// run a fake map mouse event to update the paint item // run a fake map mouse event to update the paint item
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
} }
} }
@ -1162,7 +1162,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mXConstraint->toggleLocked(); mXConstraint->toggleLocked();
emit lockXChanged( mXConstraint->isLocked() ); emit lockXChanged( mXConstraint->isLocked() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier ) else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier )
@ -1171,7 +1171,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mXConstraint->toggleRelative(); mXConstraint->toggleRelative();
emit relativeXChanged( mXConstraint->relative() ); emit relativeXChanged( mXConstraint->relative() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
} }
@ -1192,7 +1192,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mYConstraint->toggleLocked(); mYConstraint->toggleLocked();
emit lockYChanged( mYConstraint->isLocked() ); emit lockYChanged( mYConstraint->isLocked() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier ) else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier )
@ -1201,7 +1201,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mYConstraint->toggleRelative(); mYConstraint->toggleRelative();
emit relativeYChanged( mYConstraint->relative() ); emit relativeYChanged( mYConstraint->relative() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
} }
@ -1222,7 +1222,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mZConstraint->toggleLocked(); mZConstraint->toggleLocked();
emit lockZChanged( mZConstraint->isLocked() ); emit lockZChanged( mZConstraint->isLocked() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier ) else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier )
@ -1231,7 +1231,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mZConstraint->toggleRelative(); mZConstraint->toggleRelative();
emit relativeZChanged( mZConstraint->relative() ); emit relativeZChanged( mZConstraint->relative() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
} }
@ -1252,7 +1252,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mMConstraint->toggleLocked(); mMConstraint->toggleLocked();
emit lockMChanged( mMConstraint->isLocked() ); emit lockMChanged( mMConstraint->isLocked() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier ) else if ( type == QEvent::ShortcutOverride && e->modifiers() == Qt::ShiftModifier )
@ -1261,7 +1261,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mMConstraint->toggleRelative(); mMConstraint->toggleRelative();
emit relativeMChanged( mMConstraint->relative() ); emit relativeMChanged( mMConstraint->relative() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
} }
@ -1284,7 +1284,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mAngleConstraint->toggleLocked(); mAngleConstraint->toggleLocked();
emit lockAngleChanged( mAngleConstraint->isLocked() ); emit lockAngleChanged( mAngleConstraint->isLocked() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
} }
@ -1294,7 +1294,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mAngleConstraint->toggleRelative(); mAngleConstraint->toggleRelative();
emit relativeAngleChanged( mAngleConstraint->relative() ); emit relativeAngleChanged( mAngleConstraint->relative() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
} }
@ -1317,7 +1317,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
{ {
mDistanceConstraint->toggleLocked(); mDistanceConstraint->toggleLocked();
emit lockDistanceChanged( mDistanceConstraint->isLocked() ); emit lockDistanceChanged( mDistanceConstraint->isLocked() );
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
e->accept(); e->accept();
} }
} }
@ -1362,7 +1362,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
e->accept(); e->accept();
// run a fake map mouse event to update the paint item // run a fake map mouse event to update the paint item
emit pointChanged( mCadPointList.value( 0 ) ); emit pointChangedV2( mCadPointList.value( 0 ) );
} }
break; break;
} }

View File

@ -493,8 +493,18 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private
* when a constraint is toggled. * when a constraint is toggled.
* *
* \param point The last known digitizing point. Can be used to emulate a mouse event. * \param point The last known digitizing point. Can be used to emulate a mouse event.
* \since QGIS 3.22
*/ */
void pointChanged( const QgsPoint &point ); void pointChangedV2( const QgsPoint &point );
/**
* Sometimes a constraint may change the current point out of a mouse event. This happens normally
* when a constraint is toggled.
*
* \param point The last known digitizing point. Can be used to emulate a mouse event.
* \deprecated since QGIS 3.22 - No longer used, will be removed in QGIS 4.0. Use the variant which emits QgsPoint object instead of QgsPointXY.
*/
Q_DECL_DEPRECATED void pointChanged( const QgsPointXY &point ) SIP_DEPRECATED;
//! Signals for external widgets that need to update according to current values //! Signals for external widgets that need to update according to current values

View File

@ -121,7 +121,7 @@ void QgsMapToolAdvancedDigitizing::canvasMoveEvent( QgsMapMouseEvent *e )
void QgsMapToolAdvancedDigitizing::activate() void QgsMapToolAdvancedDigitizing::activate()
{ {
QgsMapToolEdit::activate(); QgsMapToolEdit::activate();
connect( mCadDockWidget, &QgsAdvancedDigitizingDockWidget::pointChanged, this, &QgsMapToolAdvancedDigitizing::cadPointChanged ); connect( mCadDockWidget, &QgsAdvancedDigitizingDockWidget::pointChangedV2, this, &QgsMapToolAdvancedDigitizing::cadPointChanged );
mCadDockWidget->enable(); mCadDockWidget->enable();
mSnapToGridCanvasItem = new QgsSnapToGridCanvasItem( mCanvas ); mSnapToGridCanvasItem = new QgsSnapToGridCanvasItem( mCanvas );
QgsVectorLayer *layer = currentVectorLayer(); QgsVectorLayer *layer = currentVectorLayer();
@ -136,7 +136,7 @@ void QgsMapToolAdvancedDigitizing::activate()
void QgsMapToolAdvancedDigitizing::deactivate() void QgsMapToolAdvancedDigitizing::deactivate()
{ {
QgsMapToolEdit::deactivate(); QgsMapToolEdit::deactivate();
disconnect( mCadDockWidget, &QgsAdvancedDigitizingDockWidget::pointChanged, this, &QgsMapToolAdvancedDigitizing::cadPointChanged ); disconnect( mCadDockWidget, &QgsAdvancedDigitizingDockWidget::pointChangedV2, this, &QgsMapToolAdvancedDigitizing::cadPointChanged );
mCadDockWidget->disable(); mCadDockWidget->disable();
delete mSnapToGridCanvasItem; delete mSnapToGridCanvasItem;
mSnapToGridCanvasItem = nullptr; mSnapToGridCanvasItem = nullptr;