Skip to content
Permalink
Browse files

Fix mouse handles go out of sync after moving items with cursor keys

  • Loading branch information
nyalldawson committed Mar 11, 2020
1 parent 1e67ee4 commit fd65c2d05a64d2f4af4b520564b36b1fd31ea39e
@@ -237,6 +237,11 @@ Emitted when item requests that all connected arrows are repainted.
void updateArrowPaths();
%Docstring
Emitted when item requires that all connected arrow paths are recalculated.
%End

void sizePositionChanged();
%Docstring
Emitted when the item's size or position changes.
%End

protected slots:
@@ -118,6 +118,7 @@ void QgsModelComponentGraphicItem::moveComponentBy( qreal dx, qreal dy )
updateStoredComponentPosition( pos(), mComponent->size() );
emit changed();

emit sizePositionChanged();
emit updateArrowPaths();
}

@@ -141,6 +142,7 @@ void QgsModelComponentGraphicItem::setItemRect( QRectF )

emit changed();

emit sizePositionChanged();
emit updateArrowPaths();
}

@@ -275,6 +275,11 @@ class GUI_EXPORT QgsModelComponentGraphicItem : public QGraphicsObject
*/
void updateArrowPaths();

/**
* Emitted when the item's size or position changes.
*/
void sizePositionChanged();

protected slots:

/**
@@ -53,6 +53,24 @@ void QgsModelViewMouseHandles::paint( QPainter *painter, const QStyleOptionGraph

void QgsModelViewMouseHandles::selectionChanged()
{
//listen out for selected items' size and rotation changed signals
const QList<QGraphicsItem *> itemList = mView->items();
for ( QGraphicsItem *graphicsItem : itemList )
{
QgsModelComponentGraphicItem *item = dynamic_cast<QgsModelComponentGraphicItem *>( graphicsItem );
if ( !item )
continue;

if ( item->isSelected() )
{
connect( item, &QgsModelComponentGraphicItem::sizePositionChanged, this, &QgsModelViewMouseHandles::selectedItemSizeChanged );
}
else
{
disconnect( item, &QgsModelComponentGraphicItem::sizePositionChanged, this, &QgsModelViewMouseHandles::selectedItemSizeChanged );
}
}

resetStatusBar();
updateHandles();
}

0 comments on commit fd65c2d

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