Support QGraphicsView autoscroll of a draged object.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-11-25 19:26:37 +02:00
parent af1c40e027
commit 783e3d57c2
4 changed files with 25 additions and 2 deletions

View File

@ -153,6 +153,13 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co
MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), id, this->scene());
connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(moveSP);
if (scene())
{
if (QGraphicsView *view = scene()->views().at(0))
{
view->ensureVisible(this);
}
}
changeFinished = true;
}
}

View File

@ -29,6 +29,7 @@
#include "vcontrolpointspline.h"
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include <QPen>
#include <QStyleOptionGraphicsItem>
@ -129,6 +130,13 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang
// value - new position.
QPointF newPos = value.toPointF();
emit ControlPointChangePosition(indexSpline, position, newPos);
if (scene())
{
if (QGraphicsView *view = scene()->views().at(0))
{
view->ensureVisible(this);
}
}
changeFinished = false;
}
}

View File

@ -34,6 +34,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QKeyEvent>
#include <QGraphicsScene>
#include <QGraphicsView>
//---------------------------------------------------------------------------------------------------------------------
/**
@ -123,6 +124,13 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
changeFinished = false;
QPointF newPos = value.toPointF() + this->parentItem()->pos();
emit NameChangePosition(newPos);
if (scene())
{
if (QGraphicsView *view = scene()->views().at(0))
{
view->ensureVisible(this);
}
}
changeFinished = true;
}
}

View File

@ -125,8 +125,8 @@ public slots:
void ZoomOriginal();
void ZoomFitBest();
protected:
void mousePressEvent(QMouseEvent *mousePress);
void mouseReleaseEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *mousePress) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VMainGraphicsView)
GraphicsViewZoom* zoom;