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

This commit is contained in:
Nyall Dawson 2020-03-11 16:27:47 +10:00
parent 1e67ee42fa
commit fd65c2d05a
4 changed files with 30 additions and 0 deletions

View File

@ -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:

View File

@ -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();
}

View File

@ -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:
/**

View File

@ -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();
}