|
|
@ -443,23 +443,23 @@ void UBBoardView::handleItemsSelection(QGraphicsItem *item) |
|
|
|
//
|
|
|
|
//
|
|
|
|
// item selection managed by QGraphicsView::mousePressEvent(). It should be called later.
|
|
|
|
// item selection managed by QGraphicsView::mousePressEvent(). It should be called later.
|
|
|
|
|
|
|
|
|
|
|
|
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 == movingItem->parentItem()->type()) |
|
|
|
if(item->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// delegate buttons shouldn't selected
|
|
|
|
// delegate buttons shouldn't selected
|
|
|
|
if (DelegateButton::Type == item->type()) |
|
|
|
if (DelegateButton::Type == item->type()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// click on svg items (images on Frame) shouldn't change selection.
|
|
|
|
// click on svg items (images on Frame) shouldn't change selection.
|
|
|
|
if (QGraphicsSvgItem::Type == item->type()) |
|
|
|
if (QGraphicsSvgItem::Type == item->type()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// Delegate frame shouldn't selected
|
|
|
|
// Delegate frame shouldn't selected
|
|
|
|
if (UBGraphicsDelegateFrame::Type == item->type()) |
|
|
|
if (UBGraphicsDelegateFrame::Type == item->type()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if we need to uwe multiple selection - we shouldn't deselect other items.
|
|
|
|
// if we need to uwe multiple selection - we shouldn't deselect other items.
|
|
|
@ -591,9 +591,9 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) |
|
|
|
if (movingItem->data(UBGraphicsItemData::ItemLocked).toBool()) |
|
|
|
if (movingItem->data(UBGraphicsItemData::ItemLocked).toBool()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (movingItem->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type() && !movingItem->isSelected() && movingItem->parentItem()->isSelected()) |
|
|
|
if (movingItem->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type() && !movingItem->isSelected() && movingItem->parentItem()->isSelected()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
|
|
|
|
|
|
|
|
|
|
|
|
switch(item->type()) |
|
|
|
switch(item->type()) |
|
|
@ -617,7 +617,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) |
|
|
|
case UBGraphicsTextItem::Type: |
|
|
|
case UBGraphicsTextItem::Type: |
|
|
|
return !item->isSelected(); |
|
|
|
return !item->isSelected(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -625,9 +625,9 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) |
|
|
|
QGraphicsItem* UBBoardView::determineItemToPress(QGraphicsItem *item) |
|
|
|
QGraphicsItem* UBBoardView::determineItemToPress(QGraphicsItem *item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(item) |
|
|
|
if(item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
|
|
|
|
|
|
|
|
|
|
|
|
// groups should should be moved instead of strokes groups
|
|
|
|
// groups should should be moved instead of strokes groups
|
|
|
|
if (item->parentItem() && UBGraphicsStrokesGroup::Type == item->type()) |
|
|
|
if (item->parentItem() && UBGraphicsStrokesGroup::Type == item->type()) |
|
|
|
return item->parentItem(); |
|
|
|
return item->parentItem(); |
|
|
@ -639,7 +639,7 @@ QGraphicsItem* UBBoardView::determineItemToPress(QGraphicsItem *item) |
|
|
|
&& !item->parentItem()->isSelected())
|
|
|
|
&& !item->parentItem()->isSelected())
|
|
|
|
return item->parentItem(); |
|
|
|
return item->parentItem(); |
|
|
|
|
|
|
|
|
|
|
|
// items like polygons placed in two groups nested, so we need to recursive call.
|
|
|
|
// items like polygons placed in two groups nested, so we need to recursive call.
|
|
|
|
if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type()) |
|
|
|
if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type()) |
|
|
|
return determineItemToPress(item->parentItem()); |
|
|
|
return determineItemToPress(item->parentItem()); |
|
|
|
} |
|
|
|
} |
|
|
@ -653,33 +653,33 @@ QGraphicsItem* UBBoardView::determineItemToMove(QGraphicsItem *item) |
|
|
|
if(item) |
|
|
|
if(item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
|
|
|
|
|
|
|
|
|
|
|
|
//W3C widgets should take mouse move events from play tool.
|
|
|
|
//W3C widgets should take mouse move events from play tool.
|
|
|
|
if ((UBStylusTool::Play == currentTool) && (UBGraphicsW3CWidgetItem::Type == item->type())) |
|
|
|
if ((UBStylusTool::Play == currentTool) && (UBGraphicsW3CWidgetItem::Type == item->type())) |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
|
|
|
|
|
|
|
|
// if item is in group
|
|
|
|
// if item is in group
|
|
|
|
if(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()) |
|
|
|
if(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// play tool should move groups by any element
|
|
|
|
// play tool should move groups by any element
|
|
|
|
if (UBStylusTool::Play == currentTool && item->parentItem()->isSelected()) |
|
|
|
if (UBStylusTool::Play == currentTool && item->parentItem()->isSelected()) |
|
|
|
return item->parentItem(); |
|
|
|
return item->parentItem(); |
|
|
|
|
|
|
|
|
|
|
|
// groups should should be moved instead of strokes groups
|
|
|
|
// groups should should be moved instead of strokes groups
|
|
|
|
if (UBGraphicsStrokesGroup::Type == item->type()) |
|
|
|
if (UBGraphicsStrokesGroup::Type == item->type()) |
|
|
|
return item->parentItem(); |
|
|
|
return item->parentItem(); |
|
|
|
|
|
|
|
|
|
|
|
// selected groups should be moved by moving any element
|
|
|
|
// selected groups should be moved by moving any element
|
|
|
|
if (item->parentItem()->isSelected()) |
|
|
|
if (item->parentItem()->isSelected()) |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
|
|
|
|
|
|
|
|
if (item->isSelected()) |
|
|
|
if (item->isSelected()) |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
return item->parentItem(); |
|
|
|
return item->parentItem(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// items like polygons placed in two groups nested, so we need to recursive call.
|
|
|
|
// items like polygons placed in two groups nested, so we need to recursive call.
|
|
|
|
if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type())
|
|
|
|
if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type())
|
|
|
|
return determineItemToMove(item->parentItem()); |
|
|
|
return determineItemToMove(item->parentItem()); |
|
|
|
} |
|
|
|
} |
|
|
@ -724,10 +724,10 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event) |
|
|
|
|
|
|
|
|
|
|
|
void UBBoardView::handleItemMouseMove(QMouseEvent *event) |
|
|
|
void UBBoardView::handleItemMouseMove(QMouseEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// determine item to move (maybee we need to move group of item or his parent.
|
|
|
|
// determine item to move (maybee we need to move group of item or his parent.
|
|
|
|
movingItem = determineItemToMove(movingItem); |
|
|
|
movingItem = determineItemToMove(movingItem); |
|
|
|
|
|
|
|
|
|
|
|
// items should be moved not every mouse move.
|
|
|
|
// items should be moved not every mouse move.
|
|
|
|
if (movingItem && itemShouldBeMoved(movingItem) && (mMouseButtonIsPressed || mTabletStylusIsPressed))
|
|
|
|
if (movingItem && itemShouldBeMoved(movingItem) && (mMouseButtonIsPressed || mTabletStylusIsPressed))
|
|
|
|
{ |
|
|
|
{ |
|
|
|
QPointF scenePos = mapToScene(event->pos()); |
|
|
|
QPointF scenePos = mapToScene(event->pos()); |
|
|
@ -753,8 +753,8 @@ void UBBoardView::handleItemMouseMove(QMouseEvent *event) |
|
|
|
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 (mWidgetMoved && UBGraphicsW3CWidgetItem::Type == movingItem->type()) |
|
|
|
if (mWidgetMoved && UBGraphicsW3CWidgetItem::Type == movingItem->type()) |
|
|
|
movingItem->setPos(posBeforeMove); |
|
|
|
movingItem->setPos(posBeforeMove); |
|
|
|
|
|
|
|
|
|
|
@ -1093,9 +1093,9 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (QGraphicsSvgItem::Type != movingItem->type() && |
|
|
|
if (QGraphicsSvgItem::Type != movingItem->type() && |
|
|
|
UBGraphicsDelegateFrame::Type != movingItem->type() && |
|
|
|
UBGraphicsDelegateFrame::Type != movingItem->type() && |
|
|
|
UBToolWidget::Type != movingItem->type() && |
|
|
|
UBToolWidget::Type != movingItem->type() && |
|
|
|
QGraphicsWebView::Type != movingItem->type() && // for W3C widgets as Tools.
|
|
|
|
QGraphicsWebView::Type != movingItem->type() && // for W3C widgets as Tools.
|
|
|
|
!(!isMultipleSelectionEnabled() && movingItem->parentItem() && UBGraphicsWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type())) |
|
|
|
!(!isMultipleSelectionEnabled() && movingItem->parentItem() && UBGraphicsWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type())) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bReleaseIsNeed = false; |
|
|
|
bReleaseIsNeed = false; |
|
|
|
if (movingItem->isSelected() && isMultipleSelectionEnabled()) |
|
|
|
if (movingItem->isSelected() && isMultipleSelectionEnabled()) |
|
|
@ -1319,14 +1319,20 @@ void UBBoardView::dragMoveEvent(QDragMoveEvent *event) |
|
|
|
|
|
|
|
|
|
|
|
void UBBoardView::dropEvent (QDropEvent *event) |
|
|
|
void UBBoardView::dropEvent (QDropEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!itemAt(event->pos().x(),event->pos().y())) { |
|
|
|
QGraphicsItem *onItem = itemAt(event->pos().x(),event->pos().y()); |
|
|
|
if (!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source()) || dynamic_cast<UBTGMediaWidget*>(event->source()) || dynamic_cast<QListView *>(event->source()) || dynamic_cast<UBTGDraggableTreeItem*>(event->source())) { |
|
|
|
if (onItem && onItem->type() == UBGraphicsWidgetItem::Type) { |
|
|
|
mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); |
|
|
|
QGraphicsView::dropEvent(event); |
|
|
|
event->acceptProposedAction(); |
|
|
|
} else { |
|
|
|
|
|
|
|
if (!event->source() |
|
|
|
|
|
|
|
|| qobject_cast<UBThumbnailWidget *>(event->source()) |
|
|
|
|
|
|
|
|| qobject_cast<QWebView*>(event->source()) |
|
|
|
|
|
|
|
|| qobject_cast<UBTGMediaWidget*>(event->source()) |
|
|
|
|
|
|
|
|| qobject_cast<QListView *>(event->source()) |
|
|
|
|
|
|
|
|| qobject_cast<UBTGDraggableTreeItem*>(event->source())) { |
|
|
|
|
|
|
|
mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); |
|
|
|
|
|
|
|
event->acceptProposedAction(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
QGraphicsView::dropEvent(event); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
@ -1515,11 +1521,11 @@ UBBoardView::setToolCursor (int tool) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool UBBoardView::hasSelectedParents(QGraphicsItem * item) |
|
|
|
bool UBBoardView::hasSelectedParents(QGraphicsItem * item) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (item->isSelected()) |
|
|
|
if (item->isSelected()) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
if (item->parentItem()==NULL) |
|
|
|
if (item->parentItem()==NULL) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
return hasSelectedParents(item->parentItem()); |
|
|
|
return hasSelectedParents(item->parentItem()); |
|
|
|
} |
|
|
|
} |
|
|
|