diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp index 63679534ca..41fbdeecc2 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp @@ -259,26 +259,6 @@ Qt::PenCapStyle QGIPrimPath::prefCapStyle() return result; } -void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent * event) -{ - //wf: this seems a bit of a hack. does it mess up selection of QGIPP?? - QGIView *parent; - QGraphicsItem* qparent = parentItem(); - if (qparent) { - parent = dynamic_cast (qparent); - if (parent) { -// Base::Console().Message("QGIPP::mousePressEvent - passing event to QGIV parent\n"); - parent->mousePressEvent(event); - } else { -// qparent->mousePressEvent(event); //protected! - QGraphicsPathItem::mousePressEvent(event); - } - } else { -// Base::Console().Message("QGIPP::mousePressEvent - passing event to ancestor\n"); - QGraphicsPathItem::mousePressEvent(event); - } -} - void QGIPrimPath::setFill(QColor c, Qt::BrushStyle s) { setFillColor(c); m_fillNormal = s; diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.h b/src/Mod/TechDraw/Gui/QGIPrimPath.h index fad67c44a5..18bb711549 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.h +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.h @@ -78,7 +78,6 @@ protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; - void mousePressEvent(QGraphicsSceneMouseEvent *event) override; virtual QColor getNormalColor(); virtual QColor getPreColor(); diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp index 13f3ff8a03..5da523acd4 100644 --- a/src/Mod/TechDraw/Gui/QGIView.cpp +++ b/src/Mod/TechDraw/Gui/QGIView.cpp @@ -159,10 +159,12 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value) return newPos; } + TechDraw::DrawView *viewObj = getViewObject(); + // TODO find a better data structure for this // this is just a pair isn't it? - if (getViewObject()->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { - TechDraw::DrawProjGroupItem* dpgi = static_cast(getViewObject()); + if (viewObj->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { + TechDraw::DrawProjGroupItem* dpgi = static_cast(viewObj); TechDraw::DrawProjGroup* dpg = dpgi->getPGroup(); if (dpg) { if(alignHash.size() == 1) { //if aligned. @@ -176,9 +178,13 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value) } } } else { - //not a dpgi, not locked, but moved. - //feat->setPosition(Rez::appX(newPos.x()), -Rez::appX(newPos.y()); + Gui::ViewProvider *vp = getViewProvider(viewObj); + if (vp && !vp->isRestoring()) { + viewObj->setPosition(Rez::appX(newPos.x()), + Rez::appX(isInnerView() ? getYInClip(newPos.y()) : -newPos.y())); + } } + return newPos; } @@ -203,7 +209,7 @@ void QGIView::mousePressEvent(QGraphicsSceneMouseEvent * event) m_dragState = DRAGSTARTED; } - QGraphicsItem::mousePressEvent(event); + QGraphicsItemGroup::mousePressEvent(event); } void QGIView::mouseMoveEvent(QGraphicsSceneMouseEvent * event) @@ -211,26 +217,16 @@ void QGIView::mouseMoveEvent(QGraphicsSceneMouseEvent * event) if (m_dragState == DRAGSTARTED) { m_dragState = DRAGGING; } - QGraphicsItem::mouseMoveEvent(event); + + QGraphicsItemGroup::mouseMoveEvent(event); } void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { - //TODO: this should be done in itemChange - item position has changed // Base::Console().Message("QGIV::mouseReleaseEvent() - %s\n", getViewName()); -// if(scene() && this == scene()->mouseGrabberItem()) { - if (m_dragState == DRAGGING && !m_locked) { - if (!isInnerView()) { - double tempX = x(), - tempY = getY(); - getViewObject()->setPosition(Rez::appX(tempX), Rez::appX(tempY)); - } else { - getViewObject()->setPosition(Rez::appX(x()), Rez::appX(getYInClip(y()))); - } - } m_dragState = NODRAG; - QGraphicsItem::mouseReleaseEvent(event); + QGraphicsItemGroup::mouseReleaseEvent(event); } void QGIView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)