Call details context menu through label.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-06-17 16:13:49 +03:00
parent 2744f89ff3
commit 76d1c02423
4 changed files with 17 additions and 3 deletions

View File

@ -58,6 +58,9 @@ VNodePoint::VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quin
lineName = new QGraphicsLineItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VNodePoint::NameChangePosition);
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, [this](QGraphicsSceneContextMenuEvent *event) {
emit ShowContextMenu(event);
});
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);

View File

@ -53,6 +53,13 @@ public:
enum { Type = UserType + static_cast<int>(Tool::NodePoint)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
signals:
/**
* @brief ShowContextMenu emit when need show tool context menu.
* @param event context menu event.
*/
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
void NameChangePosition(const QPointF &pos);

View File

@ -84,8 +84,11 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
switch (detail.at(i).getTypeTool())
{
case (Tool::NodePoint):
InitTool<VNodePoint>(scene, detail.at(i));
{
VNodePoint *tool = InitTool<VNodePoint>(scene, detail.at(i));
connect(tool, &VNodePoint::ShowContextMenu, this, &VToolDetail::contextMenuEvent);
break;
}
case (Tool::NodeArc):
doc->IncrementReferens(detail.at(i).getId());
break;
@ -690,7 +693,7 @@ void VToolDetail::DeleteTool(bool ask)
//---------------------------------------------------------------------------------------------------------------------
template <typename Tool>
//cppcheck-suppress unusedFunction
void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
Tool* VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
{
QHash<quint32, VDataTool*>* tools = doc->getTools();
SCASSERT(tools != nullptr);
@ -700,6 +703,7 @@ void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
tool->setParentItem(this);
tool->SetParentType(ParentType::Item);
doc->IncrementReferens(node.getId());
return tool;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -122,7 +122,7 @@ private:
* @param scene pointer to scene.
* @param node node of detail.
*/
void InitTool(VMainGraphicsScene *scene, const VNodeDetail &node);
Tool* InitTool(VMainGraphicsScene *scene, const VNodeDetail &node);
virtual void DeleteTool(bool ask = true) Q_DECL_OVERRIDE;
};