Show context menu of tool on label.

--HG--
branch : develop
This commit is contained in:
dismine 2014-01-09 14:51:09 +02:00
parent d9a5296b34
commit 7b850afaea
26 changed files with 84 additions and 3 deletions

View File

@ -91,6 +91,11 @@ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu(dialogAlongLine, this, event); ContextMenu(dialogAlongLine, this, event);
} }
void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogAlongLine, this, event);
}
void VToolAlongLine::AddToFile() void VToolAlongLine::AddToFile()
{ {
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id); const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);

View File

@ -106,6 +106,7 @@ public slots:
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent

View File

@ -182,6 +182,11 @@ void VToolBisector::SetFactor(qreal factor)
RefreshGeometry(); RefreshGeometry();
} }
void VToolBisector::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogBisector, this, event);
}
void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
ContextMenu(dialogBisector, this, event); ContextMenu(dialogBisector, this, event);

View File

@ -119,6 +119,7 @@ public slots:
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent

View File

@ -151,6 +151,11 @@ void VToolEndLine::FullUpdateFromGui(int result)
dialogEndLine.clear(); dialogEndLine.clear();
} }
void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogEndLine, this, event);
}
void VToolEndLine::AddToFile() void VToolEndLine::AddToFile()
{ {
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id); const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);

View File

@ -101,6 +101,7 @@ public slots:
* @param result * @param result
*/ */
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent

View File

@ -166,6 +166,11 @@ void VToolHeight::FullUpdateFromGui(int result)
dialogHeight.clear(); dialogHeight.clear();
} }
void VToolHeight::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogHeight, this, event);
}
void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
ContextMenu(dialogHeight, this, event); ContextMenu(dialogHeight, this, event);

View File

@ -108,6 +108,7 @@ public slots:
* @param result * @param result
*/ */
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent

View File

@ -163,6 +163,11 @@ void VToolLineIntersect::SetFactor(qreal factor)
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id)); RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
} }
void VToolLineIntersect::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogLineIntersect, this, event);
}
void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
ContextMenu(dialogLineIntersect, this, event); ContextMenu(dialogLineIntersect, this, event);

View File

@ -106,6 +106,7 @@ public slots:
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent

View File

@ -167,6 +167,11 @@ void VToolNormal::SetFactor(qreal factor)
RefreshGeometry(); RefreshGeometry();
} }
void VToolNormal::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogNormal, this, event);
}
void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
ContextMenu(dialogNormal, this, event); ContextMenu(dialogNormal, this, event);

View File

@ -120,6 +120,7 @@ public slots:
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent

View File

@ -34,11 +34,13 @@ VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphics
QGraphicsEllipseItem(parent), radius(toPixel(2)), namePoint(0), lineName(0) QGraphicsEllipseItem(parent), radius(toPixel(2)), namePoint(0), lineName(0)
{ {
namePoint = new VGraphicsSimpleTextItem(this); namePoint = new VGraphicsSimpleTextItem(this);
Q_ASSERT(namePoint != 0);
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolPoint::ShowContextMenu);
namePoint->setBrush(Qt::black); namePoint->setBrush(Qt::black);
lineName = new QGraphicsLineItem(this); lineName = new QGraphicsLineItem(this);
Q_ASSERT(lineName != 0);
lineName->setPen(QPen(Qt::black)); lineName->setPen(QPen(Qt::black));
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition);
&VToolPoint::NameChangePosition);
this->setBrush(QBrush(Qt::NoBrush)); this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true);
@ -105,6 +107,11 @@ void VToolPoint::SetFactor(qreal factor)
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id)); RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
} }
void VToolPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
Q_UNUSED(event);
}
void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)

View File

@ -80,6 +80,7 @@ public slots:
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief radius * @brief radius

View File

@ -186,6 +186,11 @@ void VToolPointOfContact::SetFactor(qreal factor)
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id)); RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
} }
void VToolPointOfContact::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogPointOfContact, this, event);
}
void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
ContextMenu(dialogPointOfContact, this, event); ContextMenu(dialogPointOfContact, this, event);

View File

@ -116,6 +116,7 @@ public slots:
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent

View File

@ -128,6 +128,11 @@ void VToolPointOfIntersection::FullUpdateFromGui(int result)
dialogPointOfIntersection.clear(); dialogPointOfIntersection.clear();
} }
void VToolPointOfIntersection::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogPointOfIntersection, this, event);
}
void VToolPointOfIntersection::RemoveReferens() void VToolPointOfIntersection::RemoveReferens()
{ {
doc->DecrementReferens(firstPointId); doc->DecrementReferens(firstPointId);

View File

@ -97,6 +97,7 @@ public slots:
* @param result * @param result
*/ */
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief RemoveReferens * @brief RemoveReferens

View File

@ -190,6 +190,11 @@ void VToolShoulderPoint::SetFactor(qreal factor)
RefreshGeometry(); RefreshGeometry();
} }
void VToolShoulderPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogShoulderPoint, this, event);
}
void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{ {
ContextMenu(dialogShoulderPoint, this, event); ContextMenu(dialogShoulderPoint, this, event);

View File

@ -118,6 +118,7 @@ public slots:
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent

View File

@ -184,3 +184,8 @@ void VToolSinglePoint::SetFactor(qreal factor)
VDrawTool::SetFactor(factor); VDrawTool::SetFactor(factor);
RefreshPointGeometry(*(VAbstractTool::data.GeometricObject<const VPointF *>(id))); RefreshPointGeometry(*(VAbstractTool::data.GeometricObject<const VPointF *>(id)));
} }
void VToolSinglePoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogSinglePoint, this, event, false);
}

View File

@ -77,6 +77,7 @@ public slots:
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
signals: signals:
/** /**
* @brief FullUpdateTree * @brief FullUpdateTree

View File

@ -184,6 +184,11 @@ void VToolTriangle::FullUpdateFromGui(int result)
dialogTriangle.clear(); dialogTriangle.clear();
} }
void VToolTriangle::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogTriangle, this, event);
}
void VToolTriangle::RemoveReferens() void VToolTriangle::RemoveReferens()
{ {
doc->DecrementReferens(axisP1Id); doc->DecrementReferens(axisP1Id);

View File

@ -111,6 +111,7 @@ public slots:
* @param result * @param result
*/ */
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief RemoveReferens * @brief RemoveReferens

View File

@ -73,3 +73,8 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event); Q_UNUSED(event);
this->setBrush(Qt::black); this->setBrush(Qt::black);
} }
void VGraphicsSimpleTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
emit ShowContextMenu(event);
}

View File

@ -60,6 +60,7 @@ signals:
* @param pos * @param pos
*/ */
void NameChangePosition(const QPointF pos); void NameChangePosition(const QPointF pos);
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected: protected:
/** /**
* @brief itemChange * @brief itemChange
@ -78,6 +79,7 @@ protected:
* @param event * @param event
*/ */
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
private: private:
/** /**
* @brief fontSize * @brief fontSize