Support delete action if you select tool from label.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-24 21:17:23 +03:00
parent 939e849560
commit 5679158b56
4 changed files with 25 additions and 0 deletions

View File

@ -48,6 +48,7 @@ VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsIte
radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm);
namePoint = new VGraphicsSimpleTextItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolPoint::ShowContextMenu);
connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolPoint::DeleteFromLabel);
namePoint->setBrush(Qt::black);
lineName = new QGraphicsLineItem(this);
lineName->setPen(QPen(Qt::black));
@ -182,6 +183,12 @@ void VToolPoint::Disable(bool disable)
DisableItem(this, disable);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPoint::DeleteFromLabel()
{
DeleteTool(); //Leave this method immediately after call!!!
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.

View File

@ -56,6 +56,7 @@ public slots:
virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
void Disable(bool disable);
void DeleteFromLabel();
protected:
/** @brief radius radius circle. */
qreal radius;

View File

@ -46,6 +46,7 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent)
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
QFont font = this->font();
font.setPointSize(font.pointSize()+20);
@ -156,3 +157,17 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
QGraphicsSimpleTextItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Delete:
emit DeleteTool();
return; //Leave this method immediately after call!!!
default:
break;
}
QGraphicsSimpleTextItem::keyReleaseEvent ( event );
}

View File

@ -58,6 +58,7 @@ signals:
* @param event context menu event.
*/
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
void DeleteTool();
protected:
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent *event );
@ -65,6 +66,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent *event );
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void keyReleaseEvent ( QKeyEvent * event );
private:
/** @brief fontSize label font size. */
qint32 fontSize;