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); lineName = new QGraphicsLineItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VNodePoint::NameChangePosition); &VNodePoint::NameChangePosition);
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, [this](QGraphicsSceneContextMenuEvent *event) {
emit ShowContextMenu(event);
});
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit())))); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
this->setBrush(QBrush(Qt::NoBrush)); this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);

View File

@ -53,6 +53,13 @@ public:
enum { Type = UserType + static_cast<int>(Tool::NodePoint)}; enum { Type = UserType + static_cast<int>(Tool::NodePoint)};
virtual QString getTagName() const Q_DECL_OVERRIDE; 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: public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
void NameChangePosition(const QPointF &pos); void NameChangePosition(const QPointF &pos);

View File

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

View File

@ -122,7 +122,7 @@ private:
* @param scene pointer to scene. * @param scene pointer to scene.
* @param node node of detail. * @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; virtual void DeleteTool(bool ask = true) Q_DECL_OVERRIDE;
}; };