Commit 30b4a3f2 authored by Aleksei Kanash's avatar Aleksei Kanash

Improved behavior of interacts with items on board.

parent 3a296792
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "tools/UBGraphicsRuler.h"
#include "tools/UBGraphicsCurtainItem.h"
#include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h" #include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h" #include "tools/UBGraphicsTriangle.h"
...@@ -433,6 +435,15 @@ bool UBBoardView::itemHaveParentWithType(QGraphicsItem *item, int type) ...@@ -433,6 +435,15 @@ bool UBBoardView::itemHaveParentWithType(QGraphicsItem *item, int type)
return itemHaveParentWithType(item->parentItem(), type); return itemHaveParentWithType(item->parentItem(), type);
} }
bool UBBoardView::isUBItem(QGraphicsItem *item)
{
if ((UBGraphicsItemType::UserTypesCount > item->type()) && (item->type() > QGraphicsItem::UserType))
return true;
else
{
return false;
}
}
void UBBoardView::handleItemsSelection(QGraphicsItem *item) void UBBoardView::handleItemsSelection(QGraphicsItem *item)
{ {
...@@ -504,6 +515,13 @@ Here we determines cases when items should to get mouse press event at pressing ...@@ -504,6 +515,13 @@ Here we determines cases when items should to get mouse press event at pressing
switch(item->type()) switch(item->type())
{ {
case UBGraphicsProtractor::Type:
case UBGraphicsRuler::Type:
case UBGraphicsTriangle::Type:
case UBGraphicsCompass::Type:
case UBGraphicsCache::Type:
return true;
case UBGraphicsDelegateFrame::Type: case UBGraphicsDelegateFrame::Type:
case QGraphicsSvgItem::Type: case QGraphicsSvgItem::Type:
return true; return true;
...@@ -550,10 +568,7 @@ Here we determines cases when items should to get mouse press event at pressing ...@@ -550,10 +568,7 @@ Here we determines cases when items should to get mouse press event at pressing
break; break;
} }
if ((UBGraphicsItemType::UserTypesCount > item->type()) && (item->type() > QGraphicsItem::UserType)) return !isUBItem(item); // standard behavior of QGraphicsScene for not UB items. UB items should be managed upper.
return true;
else
return false;
} }
bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item) bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item)
...@@ -609,6 +624,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) ...@@ -609,6 +624,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
switch(item->type()) switch(item->type())
{ {
case UBGraphicsCurtainItem::Type:
case UBGraphicsGroupContainerItem::Type: case UBGraphicsGroupContainerItem::Type:
return true; return true;
...@@ -1102,7 +1118,8 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) ...@@ -1102,7 +1118,8 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
} }
else else
{ {
if (QGraphicsSvgItem::Type != movingItem->type() && if (isUBItem(movingItem) &&
QGraphicsSvgItem::Type != movingItem->type() &&
UBGraphicsDelegateFrame::Type != movingItem->type() && UBGraphicsDelegateFrame::Type != movingItem->type() &&
UBToolWidget::Type != movingItem->type() && UBToolWidget::Type != movingItem->type() &&
UBGraphicsCache::Type != movingItem->type() && UBGraphicsCache::Type != movingItem->type() &&
......
...@@ -57,6 +57,7 @@ class UBBoardView : public QGraphicsView ...@@ -57,6 +57,7 @@ class UBBoardView : public QGraphicsView
protected: protected:
bool itemIsLocked(QGraphicsItem *item); bool itemIsLocked(QGraphicsItem *item);
bool isUBItem(QGraphicsItem *item); // we should to determine items who is not UB and use general scene behavior for them.
void handleItemsSelection(QGraphicsItem *item); void handleItemsSelection(QGraphicsItem *item);
bool itemShouldReceiveMousePressEvent(QGraphicsItem *item); bool itemShouldReceiveMousePressEvent(QGraphicsItem *item);
bool itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item); bool itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment