Support QGraphicsView autoscroll of a draged object.
--HG-- branch : develop
This commit is contained in:
parent
af1c40e027
commit
783e3d57c2
|
@ -153,6 +153,13 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co
|
||||||
MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), id, this->scene());
|
MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), id, this->scene());
|
||||||
connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||||
qApp->getUndoStack()->push(moveSP);
|
qApp->getUndoStack()->push(moveSP);
|
||||||
|
if (scene())
|
||||||
|
{
|
||||||
|
if (QGraphicsView *view = scene()->views().at(0))
|
||||||
|
{
|
||||||
|
view->ensureVisible(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
changeFinished = true;
|
changeFinished = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "vcontrolpointspline.h"
|
#include "vcontrolpointspline.h"
|
||||||
|
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <QGraphicsView>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
|
@ -129,6 +130,13 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang
|
||||||
// value - new position.
|
// value - new position.
|
||||||
QPointF newPos = value.toPointF();
|
QPointF newPos = value.toPointF();
|
||||||
emit ControlPointChangePosition(indexSpline, position, newPos);
|
emit ControlPointChangePosition(indexSpline, position, newPos);
|
||||||
|
if (scene())
|
||||||
|
{
|
||||||
|
if (QGraphicsView *view = scene()->views().at(0))
|
||||||
|
{
|
||||||
|
view->ensureVisible(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
changeFinished = false;
|
changeFinished = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -123,6 +124,13 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
|
||||||
changeFinished = false;
|
changeFinished = false;
|
||||||
QPointF newPos = value.toPointF() + this->parentItem()->pos();
|
QPointF newPos = value.toPointF() + this->parentItem()->pos();
|
||||||
emit NameChangePosition(newPos);
|
emit NameChangePosition(newPos);
|
||||||
|
if (scene())
|
||||||
|
{
|
||||||
|
if (QGraphicsView *view = scene()->views().at(0))
|
||||||
|
{
|
||||||
|
view->ensureVisible(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
changeFinished = true;
|
changeFinished = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,8 @@ public slots:
|
||||||
void ZoomOriginal();
|
void ZoomOriginal();
|
||||||
void ZoomFitBest();
|
void ZoomFitBest();
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *mousePress);
|
virtual void mousePressEvent(QMouseEvent *mousePress) Q_DECL_OVERRIDE;
|
||||||
void mouseReleaseEvent(QMouseEvent *event);
|
virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VMainGraphicsView)
|
Q_DISABLE_COPY(VMainGraphicsView)
|
||||||
GraphicsViewZoom* zoom;
|
GraphicsViewZoom* zoom;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user