Commit 7c1057bf authored by Jochen Becher's avatar Jochen Becher

ModelEditor: Remove unfinished relation when focus is lost

Change-Id: Iee1031095845512bc69a31cbde7585e2f74ef805
Task-number: QTCREATORBUG-15799
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent ea014b84
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QPainter> #include <QPainter>
#include <QDebug>
namespace qmt { namespace qmt {
RelationStarter::RelationStarter(IRelationable *owner, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent) RelationStarter::RelationStarter(IRelationable *owner, DiagramSceneModel *diagramSceneModel, QGraphicsItem *parent)
...@@ -93,7 +91,8 @@ void RelationStarter::addArrow(const QString &id, ArrowItem::Shaft shaft, ...@@ -93,7 +91,8 @@ void RelationStarter::addArrow(const QString &id, ArrowItem::Shaft shaft,
void RelationStarter::mousePressEvent(QGraphicsSceneMouseEvent *event) void RelationStarter::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
m_currentPreviewArrow = 0; if (m_currentPreviewArrow)
return;
foreach (ArrowItem *item, m_arrows) { foreach (ArrowItem *item, m_arrows) {
if (item->boundingRect().contains(mapToItem(item, event->pos()))) { if (item->boundingRect().contains(mapToItem(item, event->pos()))) {
prepareGeometryChange(); prepareGeometryChange();
...@@ -148,6 +147,17 @@ void RelationStarter::keyPressEvent(QKeyEvent *event) ...@@ -148,6 +147,17 @@ void RelationStarter::keyPressEvent(QKeyEvent *event)
} }
} }
void RelationStarter::focusOutEvent(QFocusEvent *event)
{
Q_UNUSED(event);
if (m_currentPreviewArrow) {
m_currentPreviewArrow->scene()->removeItem(m_currentPreviewArrow);
delete m_currentPreviewArrow;
m_currentPreviewArrow = 0;
m_currentPreviewArrowIntermediatePoints.clear();
}
}
void RelationStarter::updateCurrentPreviewArrow(const QPointF &headPoint) void RelationStarter::updateCurrentPreviewArrow(const QPointF &headPoint)
{ {
prepareGeometryChange(); prepareGeometryChange();
......
...@@ -56,6 +56,7 @@ protected: ...@@ -56,6 +56,7 @@ protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override; void keyPressEvent(QKeyEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
private: private:
void updateCurrentPreviewArrow(const QPointF &headPoint); void updateCurrentPreviewArrow(const QPointF &headPoint);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment