@ -486,8 +486,14 @@ void UBBoardView::handleItemsSelection(QGraphicsItem *item)
if ( item )
if ( item )
{
{
// item has group as first parent - it is any item or UBGraphicsStrokesGroup.
// item has group as first parent - it is any item or UBGraphicsStrokesGroup.
if ( item - > parentItem ( ) & & UBGraphicsGroupContainerItem : : Type = = getMovingItem ( ) - > parentItem ( ) - > type ( ) )
if ( getMovingItem ( ) )
return ;
{
if ( getMovingItem ( ) - > parentItem ( ) )
{
if ( item - > parentItem ( ) & & UBGraphicsGroupContainerItem : : Type = = getMovingItem ( ) - > parentItem ( ) - > type ( ) )
return ;
}
}
// delegate buttons shouldn't selected
// delegate buttons shouldn't selected
if ( DelegateButton : : Type = = item - > type ( ) )
if ( DelegateButton : : Type = = item - > type ( ) )
@ -653,11 +659,17 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
if ( ! ( mMouseButtonIsPressed | | mTabletStylusIsPressed ) )
if ( ! ( mMouseButtonIsPressed | | mTabletStylusIsPressed ) )
return false ;
return false ;
if ( getMovingItem ( ) - > data ( UBGraphicsItemData : : ItemLocked ) . toBool ( ) )
if ( getMovingItem ( ) )
return false ;
{
if ( getMovingItem ( ) - > data ( UBGraphicsItemData : : ItemLocked ) . toBool ( ) )
return false ;
if ( getMovingItem ( ) - > parentItem ( ) & & UBGraphicsGroupContainerItem : : Type = = getMovingItem ( ) - > parentItem ( ) - > type ( ) & & ! getMovingItem ( ) - > isSelected ( ) & & getMovingItem ( ) - > parentItem ( ) - > isSelected ( ) )
if ( getMovingItem ( ) - > parentItem ( ) )
return false ;
{
if ( UBGraphicsGroupContainerItem : : Type = = getMovingItem ( ) - > parentItem ( ) - > type ( ) & & ! getMovingItem ( ) - > isSelected ( ) & & getMovingItem ( ) - > parentItem ( ) - > isSelected ( ) )
return false ;
}
}
UBStylusTool : : Enum currentTool = ( UBStylusTool : : Enum ) UBDrawingController : : drawingController ( ) - > stylusTool ( ) ;
UBStylusTool : : Enum currentTool = ( UBStylusTool : : Enum ) UBDrawingController : : drawingController ( ) - > stylusTool ( ) ;
@ -831,20 +843,22 @@ void UBBoardView::handleItemMouseMove(QMouseEvent *event)
QPointF posAfterMove ;
QPointF posAfterMove ;
if ( getMovingItem ( ) )
if ( getMovingItem ( ) )
{
posBeforeMove = getMovingItem ( ) - > pos ( ) ;
posBeforeMove = getMovingItem ( ) - > pos ( ) ;
QGraphicsView : : mouseMoveEvent ( event ) ;
QGraphicsView : : mouseMoveEvent ( event ) ;
if ( getMovingItem ( ) )
posAfterMove = getMovingItem ( ) - > pos ( ) ;
posAfterMove = getMovingItem ( ) - > pos ( ) ;
}
mWidgetMoved = ( ( posAfterMove - posBeforeMove ) . manhattanLength ( ) ! = 0 ) ;
mWidgetMoved = ( ( posAfterMove - posBeforeMove ) . manhattanLength ( ) ! = 0 ) ;
// a cludge for terminate moving of w3c widgets.
// a cludge for terminate moving of w3c widgets.
// in some cases w3c widgets catches mouse move and doesn't sends that events to web page,
// in some cases w3c widgets catches mouse move and doesn't sends that events to web page,
// at simple - in google map widget - mouse move events doesn't comes to web page from rectangle of wearch bar on bottom right corner of widget.
// at simple - in google map widget - mouse move events doesn't comes to web page from rectangle of wearch bar on bottom right corner of widget.
if ( getMovingItem ( ) & & mWidgetMoved & & UBGraphicsW3CWidgetItem : : Type = = getMovingItem ( ) - > type ( ) )
if ( getMovingItem ( ) )
getMovingItem ( ) - > setPos ( posBeforeMove ) ;
{
if ( mWidgetMoved & & UBGraphicsW3CWidgetItem : : Type = = getMovingItem ( ) - > type ( ) )
getMovingItem ( ) - > setPos ( posBeforeMove ) ;
}
}
}
}
}
@ -1270,51 +1284,58 @@ void UBBoardView::mouseReleaseEvent (QMouseEvent *event)
setMovingItem ( nullptr ) ;
setMovingItem ( nullptr ) ;
}
}
else
else
if ( getMovingItem ( ) & & ( ! isCppTool ( getMovingItem ( ) ) | | UBGraphicsCurtainItem : : Type = = getMovingItem ( ) - > type ( ) ) )
{
if ( getMovingItem ( ) )
{
{
if ( suspendedMousePressEvent )
if ( ! isCppTool ( getMovingItem ( ) ) | | UBGraphicsCurtainItem : : Type = = getMovingItem ( ) - > type ( ) )
{
QGraphicsView : : mousePressEvent ( suspendedMousePressEvent ) ; // suspendedMousePressEvent is deleted by old Qt event loop
setMovingItem ( NULL ) ;
delete suspendedMousePressEvent ;
suspendedMousePressEvent = NULL ;
bReleaseIsNeed = true ;
}
else
{
{
if ( isUBItem ( getMovingItem ( ) ) & &
if ( suspendedMousePressEvent )
DelegateButton : : Type ! = getMovingItem ( ) - > type ( ) & &
UBGraphicsDelegateFrame : : Type ! = getMovingItem ( ) - > type ( ) & &
UBGraphicsCache : : Type ! = getMovingItem ( ) - > type ( ) & &
QGraphicsWebView : : Type ! = getMovingItem ( ) - > type ( ) & & // for W3C widgets as Tools.
! ( ! isMultipleSelectionEnabled ( ) & & getMovingItem ( ) - > parentItem ( ) & & UBGraphicsWidgetItem : : Type = = getMovingItem ( ) - > type ( ) & & UBGraphicsGroupContainerItem : : Type = = getMovingItem ( ) - > parentItem ( ) - > type ( ) ) )
{
{
bReleaseIsNeed = false ;
QGraphicsView : : mousePressEvent ( suspendedMousePressEvent ) ; // suspendedMousePressEvent is deleted by old Qt event loop
if ( getMovingItem ( ) - > isSelected ( ) & & isMultipleSelectionEnabled ( ) )
setMovingItem ( NULL ) ;
getMovingItem ( ) - > setSelected ( false ) ;
delete suspendedMousePressEvent ;
else
suspendedMousePressEvent = NULL ;
if ( getMovingItem ( ) - > parentItem ( ) & & getMovingItem ( ) - > parentItem ( ) - > isSelected ( ) & & isMultipleSelectionEnabled ( ) )
bReleaseIsNeed = true ;
getMovingItem ( ) - > parentItem ( ) - > setSelected ( false ) ;
}
else
{
if ( isUBItem ( getMovingItem ( ) ) & &
DelegateButton : : Type ! = getMovingItem ( ) - > type ( ) & &
UBGraphicsDelegateFrame : : Type ! = getMovingItem ( ) - > type ( ) & &
UBGraphicsCache : : Type ! = getMovingItem ( ) - > type ( ) & &
QGraphicsWebView : : Type ! = getMovingItem ( ) - > type ( ) & & // for W3C widgets as Tools.
! ( ! isMultipleSelectionEnabled ( ) & & getMovingItem ( ) - > parentItem ( ) & & UBGraphicsWidgetItem : : Type = = getMovingItem ( ) - > type ( ) & & UBGraphicsGroupContainerItem : : Type = = getMovingItem ( ) - > parentItem ( ) - > type ( ) ) )
{
bReleaseIsNeed = false ;
if ( getMovingItem ( ) - > isSelected ( ) & & isMultipleSelectionEnabled ( ) )
getMovingItem ( ) - > setSelected ( false ) ;
else
else
{
if ( getMovingItem ( ) - > parentItem ( ) & & getMovingItem ( ) - > parentItem ( ) - > isSelected ( ) & & isMultipleSelectionEnabled ( ) )
if ( getMovingItem ( ) - > isSelected ( ) )
getMovingItem ( ) - > parentItem ( ) - > setSelected ( false ) ;
bReleaseIsNeed = true ;
UBGraphicsTextItem * textItem = dynamic_cast < UBGraphicsTextItem * > ( getMovingItem ( ) ) ;
UBGraphicsMediaItem * movieItem = dynamic_cast < UBGraphicsMediaItem * > ( getMovingItem ( ) ) ;
if ( textItem )
textItem - > setSelected ( true ) ;
else if ( movieItem )
movieItem - > setSelected ( true ) ;
else
else
getMovingItem ( ) - > setSelected ( true ) ;
{
}
if ( getMovingItem ( ) - > isSelected ( ) )
bReleaseIsNeed = true ;
UBGraphicsTextItem * textItem = dynamic_cast < UBGraphicsTextItem * > ( getMovingItem ( ) ) ;
UBGraphicsMediaItem * movieItem = dynamic_cast < UBGraphicsMediaItem * > ( getMovingItem ( ) ) ;
if ( textItem )
textItem - > setSelected ( true ) ;
else if ( movieItem )
movieItem - > setSelected ( true ) ;
else
getMovingItem ( ) - > setSelected ( true ) ;
}
}
}
}
}
}
else
bReleaseIsNeed = true ;
}
}
else
else
bReleaseIsNeed = true ;
bReleaseIsNeed = true ;
}
if ( bReleaseIsNeed )
if ( bReleaseIsNeed )
{
{
@ -1402,9 +1423,13 @@ void UBBoardView::mouseReleaseEvent (QMouseEvent *event)
return ;
return ;
}
}
if ( mWidgetMoved ) {
if ( mWidgetMoved )
getMovingItem ( ) - > setSelected ( false ) ;
{
setMovingItem ( NULL ) ;
if ( getMovingItem ( ) )
{
getMovingItem ( ) - > setSelected ( false ) ;
setMovingItem ( NULL ) ;
}
mWidgetMoved = false ;
mWidgetMoved = false ;
}
}
else {
else {