Fixed issue #30.

--HG--
branch : develop
This commit is contained in:
dismine 2014-01-03 17:13:43 +02:00
parent 266c0f812f
commit 20e22439c9
29 changed files with 324 additions and 153 deletions

View File

@ -161,23 +161,7 @@ protected:
{
if (selectedAction == actionRemove)
{
//deincrement referens
RemoveReferens();
//remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
QDomElement element;
bool ok = doc->GetActivCalculationElement(element);
if (ok)
{
element.removeChild(domElement);
//update xml file
emit FullUpdateTree();
//remove form scene
emit RemoveTool(tool);
}
}
DeleteTool(tool);
}
}
}

View File

@ -193,7 +193,7 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
secondPointId, typeLine, typeCreation);
scene->addItem(point);
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolAlongLine::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);

View File

@ -43,6 +43,7 @@ VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::S
this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
if (typeCreation == Tool::FromGui)
@ -127,7 +128,7 @@ void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &rad
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
scene->addItem(toolArc);
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(toolArc, &VToolArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(toolArc, &VToolArc::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
doc->AddTool(id, toolArc);
doc->IncrementReferens(center);
}
@ -245,6 +246,37 @@ void VToolArc::RemoveReferens()
doc->DecrementReferens(arc->GetCenter().id());
}
QVariant VToolArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
}
return QGraphicsItem::itemChange(change, value);
}
void VToolArc::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
break;
default:
break;
}
QGraphicsItem::keyReleaseEvent ( event );
}
void VToolArc::RefreshGeometry()
{
this->setPen(QPen(currentColor, widthHairLine/factor));

View File

@ -148,6 +148,8 @@ protected:
* @brief RemoveReferens
*/
virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private:
/**
* @brief dialogArc

View File

@ -134,7 +134,7 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
thirdPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolBisector::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);

View File

@ -145,7 +145,7 @@ void VToolCutSpline::Create(const qint64 _id, const QString &pointName,
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation);
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point);
doc->AddTool(spl1id, point);

View File

@ -216,7 +216,7 @@ void VToolCutSplinePath::Create(const qint64 _id, const QString &pointName, cons
splPath2id, typeCreation);
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point);
doc->AddTool(splPath1id, point);

View File

@ -108,7 +108,7 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
basePointId, typeCreation);
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);

View File

@ -107,7 +107,7 @@ void VToolHeight::Create(const qint64 _id, const QString &pointName, const QStri
typeCreation);
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);

View File

@ -42,6 +42,7 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
this->setPen(QPen(Qt::black, widthHairLine/factor));
@ -98,7 +99,7 @@ void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64
Q_ASSERT(line != 0);
scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(line, &VToolLine::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor);
doc->AddTool(id, line);
doc->IncrementReferens(firstPoint);
@ -198,6 +199,37 @@ void VToolLine::RemoveReferens()
doc->DecrementReferens(secondPoint);
}
QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
}
return QGraphicsItem::itemChange(change, value);
}
void VToolLine::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
break;
default:
break;
}
QGraphicsItem::keyReleaseEvent ( event );
}
void VToolLine::RefreshGeometry()
{
QDomElement domElement = doc->elementById(QString().setNum(id));

View File

@ -138,6 +138,8 @@ protected:
* @brief RemoveReferens
*/
virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private:
/**
* @brief firstPoint

View File

@ -116,7 +116,7 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
p2Line2Id, typeCreation);
scene->addItem(point);
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolLineIntersect::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(p1Line1Id);

View File

@ -110,7 +110,7 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
firstPointId, secondPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolNormal::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);

View File

@ -39,6 +39,7 @@ VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphics
&VToolPoint::NameChangePosition);
this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
}
@ -159,3 +160,34 @@ void VToolPoint::RefreshLine()
lineName->setVisible(true);
}
}
QVariant VToolPoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
}
return QGraphicsItem::itemChange(change, value);
}
void VToolPoint::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
break;
default:
break;
}
QGraphicsItem::keyReleaseEvent ( event );
}

View File

@ -123,6 +123,8 @@ protected:
* @brief RefreshLine
*/
void RefreshLine();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private:
Q_DISABLE_COPY(VToolPoint)
};

View File

@ -140,7 +140,7 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
firstPointId, secondPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolPointOfContact::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(center);

View File

@ -94,7 +94,7 @@ void VToolPointOfIntersection::Create(const qint64 _id, const QString &pointName
secondPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPointOfIntersection::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolPointOfIntersection::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);

View File

@ -142,7 +142,7 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
typeCreation);
scene->addItem(point);
connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolShoulderPoint::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(p1Line);

View File

@ -37,6 +37,7 @@ VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64
ignoreFullUpdate = true;
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, false);
if (typeCreation == Tool::FromGui)
{
AddToFile();

View File

@ -107,6 +107,11 @@ protected:
* @brief decrementReferens
*/
virtual void decrementReferens();
/**
* @brief DeleteTool delete tool from file and scene. This tool can't be deleted by now.
* @param tool tool what me delete.
*/
virtual void DeleteTool(QGraphicsItem *tool){Q_UNUSED(tool)}
private:
/**
* @brief dialogSinglePoint

View File

@ -46,6 +46,7 @@ VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, const T
this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePoint::FirstPoint, spl->GetP2(),
@ -131,7 +132,7 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c
VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation);
scene->addItem(spl);
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(spl, &VToolSpline::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
doc->AddTool(id, spl);
doc->IncrementReferens(p1);
@ -274,6 +275,37 @@ void VToolSpline::RemoveReferens()
doc->DecrementReferens(spl->GetP4().id());
}
QVariant VToolSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
}
return QGraphicsItem::itemChange(change, value);
}
void VToolSpline::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
break;
default:
break;
}
QGraphicsItem::keyReleaseEvent ( event );
}
void VToolSpline::RefreshGeometry()
{
this->setPen(QPen(currentColor, widthHairLine/factor));

View File

@ -176,6 +176,8 @@ protected:
* @brief RemoveReferens
*/
virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private:
/**
* @brief dialogSpline

View File

@ -44,6 +44,7 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
for (qint32 i = 1; i<=splPath->Count(); ++i)
@ -118,7 +119,7 @@ void VToolSplinePath::Create(const qint64 _id, VSplinePath *path, VMainGraphicsS
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
scene->addItem(spl);
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(spl, &VToolSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(spl, &VToolSplinePath::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor);
doc->AddTool(id, spl);
}
@ -350,6 +351,37 @@ void VToolSplinePath::RemoveReferens()
}
}
QVariant VToolSplinePath::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
}
return QGraphicsItem::itemChange(change, value);
}
void VToolSplinePath::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
break;
default:
break;
}
QGraphicsItem::keyReleaseEvent ( event );
}
void VToolSplinePath::RefreshGeometry()
{
this->setPen(QPen(currentColor, widthHairLine/factor));

View File

@ -168,6 +168,8 @@ protected:
* @brief RemoveReferens
*/
virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private:
/**
* @brief dialogSplinePath

View File

@ -102,7 +102,7 @@ void VToolTriangle::Create(const qint64 _id, const QString &pointName, const qin
secondPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolTriangle::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(point, &VToolTriangle::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(axisP1Id);

View File

@ -178,6 +178,33 @@ void VAbstractTool::RemoveAllChild(QDomElement &domElement)
}
}
void VAbstractTool::DeleteTool(QGraphicsItem *tool)
{
if (_referens <= 1)
{
//remove from xml file
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
QDomNode element = domElement.parentNode();
if (element.isNull() == false)
{
RemoveReferens();//deincrement referens
element.removeChild(domElement);//remove form file
emit SceneRemoveTool(tool);//remove form scene
}
else
{
qWarning()<<"parent isNull"<<Q_FUNC_INFO;
}
}
else
{
qWarning()<<"Can't get element by id form file = "<<id<<Q_FUNC_INFO;
}
}
}
void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c)
{
//coefficient for equation of segment

View File

@ -270,7 +270,7 @@ signals:
* @brief RemoveTool
* @param tool
*/
void RemoveTool(QGraphicsItem *tool);
void SceneRemoveTool(QGraphicsItem *tool);
protected:
/**
* @brief doc dom document container
@ -310,6 +310,7 @@ protected:
* @param domElement
*/
void RemoveAllChild(QDomElement &domElement);
virtual void DeleteTool(QGraphicsItem *tool);
template <typename T>
/**
* @brief AddAttribute

View File

@ -72,6 +72,7 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
RefreshGeometry();
this->setPos(detail.getMx(), detail.getMy());
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
if (typeCreation == Tool::FromGui || typeCreation == Tool::FromTool)
{
AddToFile();
@ -152,7 +153,7 @@ void VToolDetail::Create(const qint64 &_id, const VDetail &newDetail, VMainGraph
VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene);
scene->addItem(detail);
connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(detail, &VToolDetail::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(detail, &VToolDetail::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QHash<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, detail);
}
@ -160,30 +161,7 @@ void VToolDetail::Create(const qint64 &_id, const VDetail &newDetail, VMainGraph
void VToolDetail::Remove()
{
//remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
QDomNode element = domElement.parentNode();
if (element.isNull() == false)
{
//deincrement referens
RemoveReferens();
element.removeChild(domElement);
//update xml file
//emit FullUpdateTree();
//remove form scene
emit RemoveTool(this);
}
else
{
qWarning()<<"parentNode isNull"<<Q_FUNC_INFO;
}
}
else
{
qWarning()<<"Can't get element by id = "<<id<<Q_FUNC_INFO;
}
}
void VToolDetail::FullUpdateFromFile()
@ -274,9 +252,36 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const
doc->FullUpdateTree();
}
}
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
}
return QGraphicsItem::itemChange(change, value);
}
void VToolDetail::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
break;
default:
break;
}
QGraphicsItem::keyReleaseEvent ( event );
}
void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
@ -311,30 +316,7 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
}
if (selectedAction == actionRemove)
{
//remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
QDomNode element = domElement.parentNode();
if (element.isNull() == false)
{
//deincrement referens
RemoveReferens();
element.removeChild(domElement);
//update xml file
emit FullUpdateTree();
//remove form scene
emit RemoveTool(this);
}
else
{
qWarning()<<"parentNode isNull"<<Q_FUNC_INFO;
}
}
else
{
qWarning()<<"Can't get element by id = "<<id<<Q_FUNC_INFO;
}
DeleteTool(this);
}
}
@ -397,6 +379,6 @@ void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
Q_ASSERT(tool != 0);
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &Tool::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(tool, &Tool::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this);
}

View File

@ -160,7 +160,7 @@ signals:
* @brief RemoveTool
* @param tool
*/
void RemoveTool(QGraphicsItem *tool);
void SceneRemoveTool(QGraphicsItem *tool);
protected:
/**
* @brief AddToFile
@ -176,7 +176,7 @@ protected:
* @param value
* @return
*/
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
/**
* @brief mouseReleaseEvent
* @param event
@ -191,6 +191,7 @@ protected:
* @brief RemoveReferens
*/
virtual void RemoveReferens();
virtual void keyReleaseEvent(QKeyEvent * event);
private:
Q_DISABLE_COPY(VToolDetail)
/**