|
|
|
@ -100,7 +100,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int p |
|
|
|
|
mStartLayer = pStartLayer; |
|
|
|
|
mEndLayer = pEndLayer; |
|
|
|
|
|
|
|
|
|
mFilterZIndex = true;
|
|
|
|
|
mFilterZIndex = true; |
|
|
|
|
|
|
|
|
|
mLongPressTimer.setInterval(mLongPressInterval); |
|
|
|
|
mLongPressTimer.setSingleShot(true); |
|
|
|
@ -288,7 +288,7 @@ UBBoardView::keyPressEvent (QKeyEvent *event) |
|
|
|
|
void UBBoardView::keyReleaseEvent(QKeyEvent *event) |
|
|
|
|
{ |
|
|
|
|
// if (!event->isAccepted ())
|
|
|
|
|
{
|
|
|
|
|
{ |
|
|
|
|
if (Qt::Key_Shift == event->key() |
|
|
|
|
||Qt::Key_Control == event->key()) |
|
|
|
|
{ |
|
|
|
@ -430,7 +430,7 @@ bool UBBoardView::itemHaveParentWithType(QGraphicsItem *item, int type) |
|
|
|
|
|
|
|
|
|
if (type == item->type()) |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return itemHaveParentWithType(item->parentItem(), type); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -447,7 +447,7 @@ bool UBBoardView::isUBItem(QGraphicsItem *item) |
|
|
|
|
void UBBoardView::handleItemsSelection(QGraphicsItem *item) |
|
|
|
|
{ |
|
|
|
|
// we need to select new pressed itemOnBoard and deselect all other items.
|
|
|
|
|
// the trouble is in:
|
|
|
|
|
// the trouble is in:
|
|
|
|
|
// some items can has parents (groupped items or strokes, or strokes in groups).
|
|
|
|
|
// some items is already selected and we don't need to reselect them
|
|
|
|
|
//
|
|
|
|
@ -458,11 +458,11 @@ void UBBoardView::handleItemsSelection(QGraphicsItem *item) |
|
|
|
|
// item has group as first parent - it is any item or UBGraphicsStrokesGroup.
|
|
|
|
|
if(item->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type()) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// delegate buttons shouldn't selected
|
|
|
|
|
if (DelegateButton::Type == item->type()) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// click on svg items (images on Frame) shouldn't change selection.
|
|
|
|
|
if (QGraphicsSvgItem::Type == item->type()) |
|
|
|
|
return; |
|
|
|
@ -470,8 +470,8 @@ void UBBoardView::handleItemsSelection(QGraphicsItem *item) |
|
|
|
|
// Delegate frame shouldn't selected
|
|
|
|
|
if (UBGraphicsDelegateFrame::Type == item->type()) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if we need to uwe multiple selection - we shouldn't deselect other items.
|
|
|
|
|
if (!isMultipleSelectionEnabled()) |
|
|
|
|
{ |
|
|
|
@ -495,8 +495,8 @@ void UBBoardView::handleItemsSelection(QGraphicsItem *item) |
|
|
|
|
bool UBBoardView::itemShouldReceiveMousePressEvent(QGraphicsItem *item) |
|
|
|
|
{ |
|
|
|
|
/*
|
|
|
|
|
Some items should receive mouse press events averytime,
|
|
|
|
|
some items should receive that events when they are selected,
|
|
|
|
|
Some items should receive mouse press events averytime, |
|
|
|
|
some items should receive that events when they are selected, |
|
|
|
|
some items shouldn't receive mouse press events at mouse press, but should receive them at mouse release (suspended mouse press event) |
|
|
|
|
|
|
|
|
|
Here we determines cases when items should to get mouse press event at pressing on mouse. |
|
|
|
@ -559,9 +559,9 @@ Here we determines cases when items should to get mouse press event at pressing |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
case UBGraphicsWidgetItem::Type: |
|
|
|
|
if (currentTool == UBStylusTool::Selector && item->parentItem() && item->parentItem()->isSelected())
|
|
|
|
|
if (currentTool == UBStylusTool::Selector && item->parentItem() && item->parentItem()->isSelected()) |
|
|
|
|
return true; |
|
|
|
|
if (currentTool == UBStylusTool::Selector && item->isSelected())
|
|
|
|
|
if (currentTool == UBStylusTool::Selector && item->isSelected()) |
|
|
|
|
return true; |
|
|
|
|
if (currentTool == UBStylusTool::Play) |
|
|
|
|
return true; |
|
|
|
@ -574,7 +574,7 @@ Here we determines cases when items should to get mouse press event at pressing |
|
|
|
|
|
|
|
|
|
bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item) |
|
|
|
|
{ |
|
|
|
|
if (!item)
|
|
|
|
|
if (!item) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (item == scene()->backgroundObject()) |
|
|
|
@ -594,7 +594,7 @@ bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item) |
|
|
|
|
if (currentTool == UBStylusTool::Selector && item->isSelected()) |
|
|
|
|
return true; |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case DelegateButton::Type: |
|
|
|
|
case UBGraphicsMediaItem::Type: |
|
|
|
|
return true; |
|
|
|
@ -606,7 +606,7 @@ bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item) |
|
|
|
|
|
|
|
|
|
bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) |
|
|
|
|
{ |
|
|
|
|
if (!item)
|
|
|
|
|
if (!item) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (item == scene()->backgroundObject()) |
|
|
|
@ -614,15 +614,15 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) |
|
|
|
|
|
|
|
|
|
if (!(mMouseButtonIsPressed || mTabletStylusIsPressed)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (movingItem->data(UBGraphicsItemData::ItemLocked).toBool()) |
|
|
|
|
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(); |
|
|
|
|
|
|
|
|
|
switch(item->type()) |
|
|
|
|
{ |
|
|
|
|
case UBGraphicsCurtainItem::Type: |
|
|
|
@ -630,7 +630,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
case UBGraphicsWidgetItem::Type: |
|
|
|
|
if(currentTool == UBStylusTool::Selector && item->isSelected())
|
|
|
|
|
if(currentTool == UBStylusTool::Selector && item->isSelected()) |
|
|
|
|
return false; |
|
|
|
|
if(currentTool == UBStylusTool::Play) |
|
|
|
|
return false; |
|
|
|
@ -640,7 +640,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) |
|
|
|
|
if (item->isSelected()) |
|
|
|
|
return false; |
|
|
|
|
case UBGraphicsMediaItem::Type: |
|
|
|
|
case UBGraphicsStrokesGroup::Type:
|
|
|
|
|
case UBGraphicsStrokesGroup::Type: |
|
|
|
|
return true; |
|
|
|
|
case UBGraphicsTextItem::Type: |
|
|
|
|
return !item->isSelected(); |
|
|
|
@ -654,13 +654,13 @@ QGraphicsItem* UBBoardView::determineItemToPress(QGraphicsItem *item) |
|
|
|
|
{ |
|
|
|
|
if(item) |
|
|
|
|
{ |
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
|
|
|
|
|
|
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); |
|
|
|
|
|
|
|
|
|
// if item is on group and group is not selected - group should take press.
|
|
|
|
|
if (UBStylusTool::Selector == currentTool
|
|
|
|
|
&& item->parentItem()
|
|
|
|
|
&& UBGraphicsGroupContainerItem::Type == item->parentItem()->type()
|
|
|
|
|
&& !item->parentItem()->isSelected())
|
|
|
|
|
if (UBStylusTool::Selector == currentTool |
|
|
|
|
&& item->parentItem() |
|
|
|
|
&& UBGraphicsGroupContainerItem::Type == item->parentItem()->type() |
|
|
|
|
&& !item->parentItem()->isSelected()) |
|
|
|
|
return item->parentItem(); |
|
|
|
|
|
|
|
|
|
// items like polygons placed in two groups nested, so we need to recursive call.
|
|
|
|
@ -676,7 +676,7 @@ QGraphicsItem* UBBoardView::determineItemToMove(QGraphicsItem *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) && (UBGraphicsWidgetItem::Type == item->type())) |
|
|
|
@ -696,7 +696,7 @@ QGraphicsItem* UBBoardView::determineItemToMove(QGraphicsItem *item) |
|
|
|
|
// selected groups should be moved by moving any element
|
|
|
|
|
if (item->parentItem()->isSelected()) |
|
|
|
|
return item; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item->isSelected()) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
@ -704,7 +704,7 @@ QGraphicsItem* UBBoardView::determineItemToMove(QGraphicsItem *item) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 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()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -715,7 +715,7 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event) |
|
|
|
|
{ |
|
|
|
|
mLastPressedMousePos = mapToScene(event->pos()); |
|
|
|
|
|
|
|
|
|
// Determining item who will take mouse press event
|
|
|
|
|
// Determining item who will take mouse press event
|
|
|
|
|
//all other items will be deselected and if all item will be deselected, then
|
|
|
|
|
// wrong item can catch mouse press. because selected items placed on the top
|
|
|
|
|
movingItem = determineItemToPress(movingItem); |
|
|
|
@ -738,7 +738,7 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event) |
|
|
|
|
delete suspendedMousePressEvent; |
|
|
|
|
suspendedMousePressEvent = NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (itemShouldReceiveSuspendedMousePressEvent(movingItem)) |
|
|
|
|
{ |
|
|
|
|
suspendedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers()); |
|
|
|
@ -752,7 +752,7 @@ void UBBoardView::handleItemMouseMove(QMouseEvent *event) |
|
|
|
|
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 newPos = movingItem->pos() + scenePos - mLastPressedMousePos; |
|
|
|
@ -761,7 +761,7 @@ void UBBoardView::handleItemMouseMove(QMouseEvent *event) |
|
|
|
|
mWidgetMoved = true; |
|
|
|
|
event->accept(); |
|
|
|
|
} |
|
|
|
|
else
|
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
QPointF posBeforeMove; |
|
|
|
|
QPointF posAfterMove; |
|
|
|
@ -777,11 +777,10 @@ void UBBoardView::handleItemMouseMove(QMouseEvent *event) |
|
|
|
|
mWidgetMoved = ((posAfterMove-posBeforeMove).manhattanLength() != 0); |
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
if (mWidgetMoved && UBGraphicsW3CWidgetItem::Type == movingItem->type()) |
|
|
|
|
movingItem->setPos(posBeforeMove); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -801,7 +800,7 @@ void UBBoardView::moveRubberedItems(QPointF movingVector) |
|
|
|
|
{ |
|
|
|
|
QRectF invalidateRect = scene()->itemsBoundingRect(); |
|
|
|
|
|
|
|
|
|
foreach (QGraphicsItem *item, mRubberedItems)
|
|
|
|
|
foreach (QGraphicsItem *item, mRubberedItems) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (item->type() == UBGraphicsW3CWidgetItem::Type |
|
|
|
@ -810,10 +809,10 @@ void UBBoardView::moveRubberedItems(QPointF movingVector) |
|
|
|
|
|| item->type() == UBGraphicsSvgItem::Type |
|
|
|
|
|| item->type() == UBGraphicsTextItem::Type |
|
|
|
|
|| item->type() == UBGraphicsStrokesGroup::Type |
|
|
|
|
|| item->type() == UBGraphicsGroupContainerItem::Type)
|
|
|
|
|
|| item->type() == UBGraphicsGroupContainerItem::Type) |
|
|
|
|
{ |
|
|
|
|
item->setPos(item->pos()+movingVector);
|
|
|
|
|
}
|
|
|
|
|
item->setPos(item->pos()+movingVector); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
scene()->invalidate(invalidateRect); |
|
|
|
@ -829,7 +828,7 @@ void UBBoardView::longPressEvent() |
|
|
|
|
UBDrawingController *drawingController = UBDrawingController::drawingController(); |
|
|
|
|
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
disconnect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent())); |
|
|
|
|
|
|
|
|
|
if (UBStylusTool::Selector == currentTool) |
|
|
|
@ -899,7 +898,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) |
|
|
|
|
connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent())); |
|
|
|
|
if (!movingItem && !mController->cacheIsVisible()) |
|
|
|
|
mLongPressTimer.start(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!movingItem) { |
|
|
|
|
// Rubberband selection implementation
|
|
|
|
|
if (!mUBRubberBand) { |
|
|
|
@ -986,7 +985,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) |
|
|
|
|
void |
|
|
|
|
UBBoardView::mouseMoveEvent (QMouseEvent *event) |
|
|
|
|
{ |
|
|
|
|
if(!mIsDragInProgress && ((mapToScene(event->pos()) - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()))
|
|
|
|
|
if(!mIsDragInProgress && ((mapToScene(event->pos()) - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -1077,14 +1076,14 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (!mTabletStylusIsPressed && scene ()) |
|
|
|
|
{
|
|
|
|
|
{ |
|
|
|
|
scene ()->inputDeviceMove (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ())), mMouseButtonIsPressed); |
|
|
|
|
} |
|
|
|
|
event->accept (); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())
|
|
|
|
|
mWidgetMoved = true; |
|
|
|
|
if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) |
|
|
|
|
mWidgetMoved = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
@ -1105,9 +1104,9 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) |
|
|
|
|
mWidgetMoved = false; |
|
|
|
|
movingItem = NULL; |
|
|
|
|
} |
|
|
|
|
else
|
|
|
|
|
else |
|
|
|
|
if (movingItem) |
|
|
|
|
{
|
|
|
|
|
{ |
|
|
|
|
if (suspendedMousePressEvent) |
|
|
|
|
{ |
|
|
|
|
QGraphicsView::mousePressEvent(suspendedMousePressEvent); // suspendedMousePressEvent is deleted by old Qt event loop
|
|
|
|
@ -1140,7 +1139,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) |
|
|
|
|
|
|
|
|
|
movingItem->setSelected(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1163,7 +1162,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (suspendedMousePressEvent)
|
|
|
|
|
if (suspendedMousePressEvent) |
|
|
|
|
{ |
|
|
|
|
QGraphicsView::mousePressEvent(suspendedMousePressEvent); // suspendedMousePressEvent is deleted by old Qt event loop
|
|
|
|
|
movingItem = NULL; |
|
|
|
|