Skip to content

Commit

Permalink
Remove older item move code
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 12, 2020
1 parent 9044acd commit d6df6f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
32 changes: 7 additions & 25 deletions src/gui/processing/models/qgsmodelcomponentgraphicitem.cpp
Expand Up @@ -42,7 +42,6 @@ QgsModelComponentGraphicItem::QgsModelComponentGraphicItem( QgsProcessingModelCo
, mModel( model )
{
setAcceptHoverEvents( true );
setFlag( QGraphicsItem::ItemIsMovable, true );
setFlag( QGraphicsItem::ItemIsSelectable, true );
setFlag( QGraphicsItem::ItemSendsGeometryChanges, true );
setZValue( QgsModelGraphicsScene::ZValues::ModelComponent );
Expand Down Expand Up @@ -113,9 +112,14 @@ void QgsModelComponentGraphicItem::setFont( const QFont &font )

void QgsModelComponentGraphicItem::moveComponentBy( qreal dx, qreal dy )
{
mIsMoving = true;
moveBy( dx, dy );
mIsMoving = false;
mComponent->setPosition( pos() );

emit aboutToChange( tr( "Move %1" ).arg( mComponent->description() ) );
updateStoredComponentPosition( pos() );
emit changed();

emit updateArrowPaths();
}

void QgsModelComponentGraphicItem::mouseDoubleClickEvent( QGraphicsSceneMouseEvent * )
Expand Down Expand Up @@ -164,28 +168,6 @@ QVariant QgsModelComponentGraphicItem::itemChange( QGraphicsItem::GraphicsItemCh
{
switch ( change )
{
case QGraphicsItem::ItemPositionHasChanged:
{
emit updateArrowPaths();

if ( !mInitialized || pos() == mComponent->position() )
break;

mComponent->setPosition( pos() );

// also need to update the model's stored component's position
if ( !mIsMoving )
{
// we are just starting a move operation - so create the undo command using the existing state
emit aboutToChange( tr( "Move %1" ).arg( mComponent->description() ) );
}
updateStoredComponentPosition( pos() );

// we don't emit the changed signal to trigger the end of the undo command until the whole move operation finishes
// (i.e. we do that in mouseReleaseEvent)
mIsMoving = true;
break;
}
case QGraphicsItem::ItemSelectedChange:
{
emit repaintArrows();
Expand Down
1 change: 0 additions & 1 deletion src/gui/processing/models/qgsmodelcomponentgraphicitem.h
Expand Up @@ -121,7 +121,6 @@ class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
void moveComponentBy( qreal dx, qreal dy );

void mouseDoubleClickEvent( QGraphicsSceneMouseEvent *event ) override;
void mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) override;
void hoverEnterEvent( QGraphicsSceneHoverEvent *event ) override;
void hoverMoveEvent( QGraphicsSceneHoverEvent *event ) override;
void hoverLeaveEvent( QGraphicsSceneHoverEvent *event ) override;
Expand Down

0 comments on commit d6df6f7

Please sign in to comment.