2024-12-13 18:11:34 +08:00
|
|
|
#include "util/subMovingSelector.h"
|
2024-12-13 18:08:00 +08:00
|
|
|
#include <QGraphicsSceneMouseEvent>
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
|
#include "graphicsItem/graphicsBaseItem.h"
|
|
|
|
|
#include "graphicsItem/handleText.h"
|
|
|
|
|
|
2025-02-06 16:36:50 +08:00
|
|
|
SubMovingSelector::SubMovingSelector(FixedPortsModel* model,QObject *parent)
|
|
|
|
|
: BaseSelector(model,parent)
|
2024-12-13 18:08:00 +08:00
|
|
|
,m_pParentItem(nullptr)
|
|
|
|
|
{
|
|
|
|
|
m_type = ST_subMoving;
|
|
|
|
|
}
|
|
|
|
|
SubMovingSelector::~SubMovingSelector()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubMovingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
|
|
|
|
|
{
|
|
|
|
|
ms_ptMouseLast = event->scenePos();
|
|
|
|
|
|
|
|
|
|
QList<QGraphicsItem *> items = scene->selectedItems();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubMovingSelector::mouseMoveEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
|
|
|
|
|
{
|
|
|
|
|
ms_ptMouseLast = event->scenePos();
|
|
|
|
|
if(m_pParentItem == nullptr)
|
|
|
|
|
{
|
|
|
|
|
QList<QGraphicsItem *> items = scene->items(ms_ptMouseLast);
|
|
|
|
|
if (items.count() == 1)
|
|
|
|
|
{
|
|
|
|
|
ItemControlHandle* pHandle = qgraphicsitem_cast<ItemControlHandle*>(items.first());
|
|
|
|
|
if(pHandle)
|
|
|
|
|
{
|
|
|
|
|
GraphicsBaseItem* item = pHandle->getParentPtr();
|
|
|
|
|
if(item)
|
|
|
|
|
{
|
|
|
|
|
if(ms_nDragHandle >= H_textCaption && ms_nDragHandle < H_connect) //移动文本
|
|
|
|
|
{
|
|
|
|
|
pHandle->setPos(item->mapFromScene(ms_ptMouseLast));
|
|
|
|
|
m_pParentItem = item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(m_pParentItem)
|
|
|
|
|
{
|
|
|
|
|
if(ms_nDragHandle >= H_textCaption && ms_nDragHandle < H_connect) //文本
|
|
|
|
|
{
|
|
|
|
|
HandleText* pt = dynamic_cast<HandleText*>(m_pParentItem->getHandlePtr(ms_nDragHandle));
|
|
|
|
|
if(pt)
|
|
|
|
|
{
|
|
|
|
|
pt->setPos(m_pParentItem->mapFromScene(ms_ptMouseLast));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SubMovingSelector::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
|
|
|
|
|
{
|
|
|
|
|
m_pParentItem = nullptr;
|
|
|
|
|
ms_nDragHandle = H_none;
|
|
|
|
|
setCursor(scene, Qt::ArrowCursor);
|
|
|
|
|
scene->callParentEvent(event);
|
|
|
|
|
emit setWorkingSelector(ST_base);
|
|
|
|
|
}
|
|
|
|
|
|