[TD]fix multiple dimension drag

This commit is contained in:
Wanderer Fan
2022-08-10 10:03:37 -04:00
committed by WandererFan
parent 730b14353c
commit cb96332a64
2 changed files with 20 additions and 7 deletions

View File

@@ -95,7 +95,14 @@ enum SnapMode{
HorizontalSnap
};
QGIDatumLabel::QGIDatumLabel()
enum DragState {
NoDrag,
DragStarted,
Dragging };
QGIDatumLabel::QGIDatumLabel() :
m_dragState(NoDrag)
{
verticalSep = false;
posX = 0;
@@ -136,10 +143,16 @@ QVariant QGIDatumLabel::itemChange(GraphicsItemChange change, const QVariant &va
setPrettySel();
} else {
setPrettyNormal();
if (m_dragState == Dragging) {
//stop the drag if we are no longer selected.
m_dragState = NoDrag;
Q_EMIT dragFinished();
}
}
update();
} else if(change == ItemPositionHasChanged && scene()) {
setLabelCenter();
m_dragState = Dragging;
Q_EMIT dragging(m_ctrl);
}
@@ -164,11 +177,9 @@ void QGIDatumLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
{
// Base::Console().Message("QGIDL::mouseReleaseEvent()\n");
m_ctrl = false;
if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton))
.length() > 0) {
if (scene() && this == scene()->mouseGrabberItem()) {
Q_EMIT dragFinished();
}
if (m_dragState == Dragging) {
m_dragState = NoDrag;
Q_EMIT dragFinished();
}
QGraphicsItem::mouseReleaseEvent(event);

View File

@@ -136,6 +136,8 @@ protected:
bool m_isFramed;
double m_lineWidth;
int m_dragState;
private:
};