|
|
@ -62,7 +62,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "core/memcheck.h" |
|
|
|
#include "core/memcheck.h" |
|
|
|
|
|
|
|
|
|
|
|
UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent) |
|
|
|
UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent, bool pIsControl) |
|
|
|
: QGraphicsView (pParent) |
|
|
|
: QGraphicsView (pParent) |
|
|
|
, mController (pController) |
|
|
|
, mController (pController) |
|
|
|
, mIsCreatingTextZone (false) |
|
|
|
, mIsCreatingTextZone (false) |
|
|
@ -72,6 +72,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent) |
|
|
|
, mLongPressInterval(1000) |
|
|
|
, mLongPressInterval(1000) |
|
|
|
, mIsDragInProgress(false) |
|
|
|
, mIsDragInProgress(false) |
|
|
|
, mMultipleSelectionIsEnabled(false) |
|
|
|
, mMultipleSelectionIsEnabled(false) |
|
|
|
|
|
|
|
, isControl(pIsControl) |
|
|
|
{ |
|
|
|
{ |
|
|
|
init (); |
|
|
|
init (); |
|
|
|
|
|
|
|
|
|
|
@ -81,13 +82,14 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent) |
|
|
|
mLongPressTimer.setSingleShot(true); |
|
|
|
mLongPressTimer.setSingleShot(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent) |
|
|
|
UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int pEndLayer, QWidget* pParent, bool pIscontrol) |
|
|
|
: QGraphicsView (pParent) |
|
|
|
: QGraphicsView (pParent) |
|
|
|
, mController (pController) |
|
|
|
, mController (pController) |
|
|
|
, suspendedMousePressEvent(NULL) |
|
|
|
, suspendedMousePressEvent(NULL) |
|
|
|
, mLongPressInterval(1000) |
|
|
|
, mLongPressInterval(1000) |
|
|
|
, mIsDragInProgress(false) |
|
|
|
, mIsDragInProgress(false) |
|
|
|
, mMultipleSelectionIsEnabled(false) |
|
|
|
, mMultipleSelectionIsEnabled(false) |
|
|
|
|
|
|
|
, isControl(pIscontrol) |
|
|
|
{ |
|
|
|
{ |
|
|
|
init (); |
|
|
|
init (); |
|
|
|
|
|
|
|
|
|
|
@ -124,6 +126,8 @@ void UBBoardView::init () |
|
|
|
setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); |
|
|
|
setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff); |
|
|
|
setAcceptDrops (true); |
|
|
|
setAcceptDrops (true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setOptimizationFlag (QGraphicsView::IndirectPainting); // enable UBBoardView::drawItems filter
|
|
|
|
|
|
|
|
|
|
|
|
mTabletStylusIsPressed = false; |
|
|
|
mTabletStylusIsPressed = false; |
|
|
|
mMouseButtonIsPressed = false; |
|
|
|
mMouseButtonIsPressed = false; |
|
|
|
mPendingStylusReleaseEvent = false; |
|
|
|
mPendingStylusReleaseEvent = false; |
|
|
@ -532,11 +536,11 @@ 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()) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
|
|
|
|
|
|
|
|
|
|
|
|
if (movingItem->parentItem() && !movingItem->isSelected() && movingItem->parentItem()->isSelected()) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(item->type()) |
|
|
|
switch(item->type()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case UBGraphicsGroupContainerItem::Type: |
|
|
|
case UBGraphicsGroupContainerItem::Type: |
|
|
@ -557,6 +561,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) |
|
|
|
case UBGraphicsTextItem::Type: |
|
|
|
case UBGraphicsTextItem::Type: |
|
|
|
return !item->isSelected(); |
|
|
|
return !item->isSelected(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -566,24 +571,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.
|
|
|
|
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->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()) |
|
|
|
if(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
if (UBGraphicsStrokesGroup::Type == item->type()) |
|
|
|
|
|
|
|
return item->parentItem(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type())
|
|
|
|
if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type())
|
|
|
|
return determineItemToMove(item->parentItem());
|
|
|
|
return determineItemToMove(item->parentItem());
|
|
|
|
} |
|
|
|
} |
|
|
@ -595,14 +609,20 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mLastPressedMousePos = mapToScene(event->pos()); |
|
|
|
mLastPressedMousePos = mapToScene(event->pos()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Determining item who will take mouse press event
|
|
|
|
if (movingItem && QGraphicsSvgItem::Type != movingItem->type() |
|
|
|
//all other items will be deselected and if all item will be deselected, then
|
|
|
|
&& UBGraphicsDelegateFrame::Type != movingItem->type() |
|
|
|
// wrong item can catch mouse press. because selected items placed on the top
|
|
|
|
|
|
|
|
QGraphicsItem *pressedItem = determineItemToMove(movingItem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (movingItem
|
|
|
|
|
|
|
|
&& !(movingItem->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type()) |
|
|
|
|
|
|
|
&& QGraphicsSvgItem::Type != movingItem->type() |
|
|
|
|
|
|
|
&& UBGraphicsDelegateFrame::Type != movingItem->type() |
|
|
|
&& !mMultipleSelectionIsEnabled) |
|
|
|
&& !mMultipleSelectionIsEnabled) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach(QGraphicsItem *item, scene()->selectedItems()) |
|
|
|
foreach(QGraphicsItem *item, scene()->selectedItems()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (item != movingItem) |
|
|
|
if (item != pressedItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
item->setSelected(false); |
|
|
|
item->setSelected(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -634,9 +654,10 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event) |
|
|
|
|
|
|
|
|
|
|
|
void UBBoardView::handleItemMouseMove(QMouseEvent *event) |
|
|
|
void UBBoardView::handleItemMouseMove(QMouseEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (movingItem) |
|
|
|
// 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.
|
|
|
|
if (movingItem && itemShouldBeMoved(movingItem) && (mMouseButtonIsPressed || mTabletStylusIsPressed))
|
|
|
|
if (movingItem && itemShouldBeMoved(movingItem) && (mMouseButtonIsPressed || mTabletStylusIsPressed))
|
|
|
|
{ |
|
|
|
{ |
|
|
|
QPointF scenePos = mapToScene(event->pos()); |
|
|
|
QPointF scenePos = mapToScene(event->pos()); |
|
|
@ -662,6 +683,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,
|
|
|
|
|
|
|
|
// 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); |
|
|
|
|
|
|
|
|
|
|
@ -729,6 +752,11 @@ void UBBoardView::longPressEvent() |
|
|
|
|
|
|
|
|
|
|
|
void UBBoardView::mousePressEvent (QMouseEvent *event) |
|
|
|
void UBBoardView::mousePressEvent (QMouseEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!isControl) { |
|
|
|
|
|
|
|
event->ignore(); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mIsDragInProgress = false; |
|
|
|
mIsDragInProgress = false; |
|
|
|
|
|
|
|
|
|
|
|
if (isAbsurdPoint (event->pos ())) |
|
|
|
if (isAbsurdPoint (event->pos ())) |
|
|
@ -990,7 +1018,8 @@ 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() && |
|
|
|
QGraphicsWidget::Type != movingItem->type()) |
|
|
|
QGraphicsWidget::Type != movingItem->type() && |
|
|
|
|
|
|
|
!(movingItem->parentItem() && UBGraphicsW3CWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type())) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bReleaseIsNeed = false; |
|
|
|
bReleaseIsNeed = false; |
|
|
|
if (movingItem->isSelected() && mMultipleSelectionIsEnabled) |
|
|
|
if (movingItem->isSelected() && mMultipleSelectionIsEnabled) |
|
|
@ -1405,3 +1434,13 @@ UBBoardView::setToolCursor (int tool) |
|
|
|
controlViewport->setCursor (UBResources::resources ()->penCursor); |
|
|
|
controlViewport->setCursor (UBResources::resources ()->penCursor); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool UBBoardView::hasSelectedParents(QGraphicsItem * item) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (item->isSelected()) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
if (item->parentItem()==NULL) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
return hasSelectedParents(item->parentItem()); |
|
|
|
|
|
|
|
} |
|
|
|