TD: fix undo/redo for dimension objects
* do not emit dragFinished() signal inside mousePressEvent as nothing has been done. This avoids to create an empty transaction and doesn't touch the document * inside mouseReleaseEvent() check if the mouse has been moved and only if yes emit the signal * improve error handling in mouseDoubleClickEvent * in mouseDoubleClickEvent start to edit the view provider
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
# include <BRepAdaptor_Curve.hxx>
|
||||
# include <Precision.hxx>
|
||||
|
||||
# include <QApplication>
|
||||
# include <QDebug>
|
||||
# include <QGraphicsScene>
|
||||
# include <QGraphicsSceneMouseEvent>
|
||||
# include <QPainter>
|
||||
@@ -52,7 +54,6 @@
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
@@ -76,7 +77,6 @@
|
||||
#include "QGIViewDimension.h"
|
||||
#include "ViewProviderDimension.h"
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "TaskDimension.h"
|
||||
|
||||
#define NORMAL 0
|
||||
#define PRE 1
|
||||
@@ -149,10 +149,7 @@ void QGIDatumLabel::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
m_ctrl = true;
|
||||
}
|
||||
|
||||
if(scene() && this == scene()->mouseGrabberItem()) {
|
||||
Q_EMIT dragFinished();
|
||||
}
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void QGIDatumLabel::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
|
||||
@@ -164,8 +161,11 @@ void QGIDatumLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGIDL::mouseReleaseEvent()\n");
|
||||
m_ctrl = false;
|
||||
if(scene() && this == scene()->mouseGrabberItem()) {
|
||||
Q_EMIT dragFinished();
|
||||
if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton))
|
||||
.length() > 0) {
|
||||
if (scene() && this == scene()->mouseGrabberItem()) {
|
||||
Q_EMIT dragFinished();
|
||||
}
|
||||
}
|
||||
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
@@ -175,13 +175,17 @@ void QGIDatumLabel::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
QGIViewDimension* qgivDimension = dynamic_cast<QGIViewDimension*>(parentItem());
|
||||
if (qgivDimension == nullptr) {
|
||||
qWarning() << "QGIDatumLabel::mouseDoubleClickEvent: No parent item";
|
||||
return;
|
||||
}
|
||||
auto ViewProvider = static_cast<ViewProviderDimension*>(qgivDimension->getViewProvider(qgivDimension->getViewObject()));
|
||||
|
||||
auto ViewProvider = dynamic_cast<ViewProviderDimension*>(qgivDimension->getViewProvider(qgivDimension->getViewObject()));
|
||||
if (ViewProvider == nullptr) {
|
||||
qWarning() << "QGIDatumLabel::mouseDoubleClickEvent: No valid view provider";
|
||||
return;
|
||||
}
|
||||
Gui::Control().showDialog(new TaskDlgDimension(qgivDimension, ViewProvider));
|
||||
|
||||
ViewProvider->startDefaultEditMode();
|
||||
QGraphicsItem::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
virtual bool doubleClicked(void);
|
||||
void startDefaultEditMode();
|
||||
|
||||
virtual TechDraw::DrawViewDimension* getViewObject() const;
|
||||
|
||||
@@ -89,9 +90,6 @@ public:
|
||||
protected:
|
||||
virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop);
|
||||
|
||||
private:
|
||||
void startDefaultEditMode();
|
||||
|
||||
private:
|
||||
static const char *StandardAndStyleEnums[];
|
||||
static const char *RenderingExtentEnums[];
|
||||
|
||||
Reference in New Issue
Block a user