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) if (selectedAction == actionRemove)
{ {
//deincrement referens DeleteTool(tool);
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);
}
}
} }
} }
} }

View file

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

View file

@ -43,6 +43,7 @@ VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, const Tool::S
this->setPath(path); this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine/factor)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
if (typeCreation == Tool::FromGui) 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); VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
scene->addItem(toolArc); scene->addItem(toolArc);
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); 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->AddTool(id, toolArc);
doc->IncrementReferens(center); doc->IncrementReferens(center);
} }
@ -245,6 +246,37 @@ void VToolArc::RemoveReferens()
doc->DecrementReferens(arc->GetCenter().id()); 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() void VToolArc::RefreshGeometry()
{ {
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor));

View file

@ -92,62 +92,64 @@ public slots:
/** /**
* @brief FullUpdateFromFile * @brief FullUpdateFromFile
*/ */
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
/** /**
* @brief FullUpdateFromGui * @brief FullUpdateFromGui
* @param result * @param result
*/ */
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
/** /**
* @brief ChangedActivDraw * @brief ChangedActivDraw
* @param newName * @param newName
*/ */
virtual void ChangedActivDraw(const QString &newName); virtual void ChangedActivDraw(const QString &newName);
/** /**
* @brief ShowTool * @brief ShowTool
* @param id * @param id
* @param color * @param color
* @param enable * @param enable
*/ */
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
/** /**
* @brief SetFactor * @brief SetFactor
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent
* @param event * @param event
*/ */
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/** /**
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/** /**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/ */
virtual void RefreshDataInFile(); virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event
*/ */
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/** /**
* @brief hoverMoveEvent * @brief hoverMoveEvent
* @param event * @param event
*/ */
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/** /**
* @brief hoverLeaveEvent * @brief hoverLeaveEvent
* @param event * @param event
*/ */
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private: private:
/** /**
* @brief dialogArc * @brief dialogArc
@ -156,7 +158,7 @@ private:
/** /**
* @brief RefreshGeometry * @brief RefreshGeometry
*/ */
void RefreshGeometry(); void RefreshGeometry();
}; };
#endif // VTOOLARC_H #endif // VTOOLARC_H

View file

@ -134,7 +134,7 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
thirdPointId, typeCreation); thirdPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); 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); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstPointId); 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); VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); 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); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->AddTool(spl1id, point); doc->AddTool(spl1id, point);

View file

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

View file

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

View file

@ -107,7 +107,7 @@ void VToolHeight::Create(const qint64 _id, const QString &pointName, const QStri
typeCreation); typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); 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); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePointId); 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->setLine(QLineF(first->toQPointF(), second->toQPointF()));
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
this->setPen(QPen(Qt::black, widthHairLine/factor)); 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); Q_ASSERT(line != 0);
scene->addItem(line); scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); 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); connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor);
doc->AddTool(id, line); doc->AddTool(id, line);
doc->IncrementReferens(firstPoint); doc->IncrementReferens(firstPoint);
@ -198,6 +199,37 @@ void VToolLine::RemoveReferens()
doc->DecrementReferens(secondPoint); 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() void VToolLine::RefreshGeometry()
{ {
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));

View file

@ -87,66 +87,68 @@ public slots:
/** /**
* @brief FullUpdateFromFile * @brief FullUpdateFromFile
*/ */
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
/** /**
* @brief ChangedActivDraw * @brief ChangedActivDraw
* @param newName * @param newName
*/ */
virtual void ChangedActivDraw(const QString &newName); virtual void ChangedActivDraw(const QString &newName);
/** /**
* @brief FullUpdateFromGui * @brief FullUpdateFromGui
* @param result * @param result
*/ */
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
/** /**
* @brief ShowTool * @brief ShowTool
* @param id * @param id
* @param color * @param color
* @param enable * @param enable
*/ */
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
/** /**
* @brief SetFactor * @brief SetFactor
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent
* @param event * @param event
*/ */
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/** /**
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/** /**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/ */
virtual void RefreshDataInFile(); virtual void RefreshDataInFile();
/** /**
* @brief hoverMoveEvent * @brief hoverMoveEvent
* @param event * @param event
*/ */
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/** /**
* @brief hoverLeaveEvent * @brief hoverLeaveEvent
* @param event * @param event
*/ */
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private: private:
/** /**
* @brief firstPoint * @brief firstPoint
*/ */
qint64 firstPoint; qint64 firstPoint;
/** /**
* @brief secondPoint * @brief secondPoint
*/ */
qint64 secondPoint; qint64 secondPoint;
/** /**
* @brief dialogLine * @brief dialogLine
*/ */
@ -154,7 +156,7 @@ private:
/** /**
* @brief RefreshGeometry * @brief RefreshGeometry
*/ */
void RefreshGeometry(); void RefreshGeometry();
}; };
#endif // VTOOLLINE_H #endif // VTOOLLINE_H

View file

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

View file

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

View file

@ -39,6 +39,7 @@ VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphics
&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->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id)); RefreshPointGeometry(*VAbstractTool::data.GeometricObject<const VPointF *>(id));
} }
@ -159,3 +160,34 @@ void VToolPoint::RefreshLine()
lineName->setVisible(true); 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 * @brief RefreshLine
*/ */
void RefreshLine(); void RefreshLine();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private: private:
Q_DISABLE_COPY(VToolPoint) Q_DISABLE_COPY(VToolPoint)
}; };

View file

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

View file

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

View file

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

View file

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

View file

@ -107,6 +107,11 @@ protected:
* @brief decrementReferens * @brief decrementReferens
*/ */
virtual void 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: private:
/** /**
* @brief dialogSinglePoint * @brief dialogSinglePoint

View file

@ -46,6 +46,7 @@ VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, const T
this->setPath(path); this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine/factor)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePoint::FirstPoint, spl->GetP2(), 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); VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation);
scene->addItem(spl); scene->addItem(spl);
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); 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); connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
doc->AddTool(id, spl); doc->AddTool(id, spl);
doc->IncrementReferens(p1); doc->IncrementReferens(p1);
@ -274,6 +275,37 @@ void VToolSpline::RemoveReferens()
doc->DecrementReferens(spl->GetP4().id()); 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() void VToolSpline::RefreshGeometry()
{ {
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor));

View file

@ -101,81 +101,83 @@ signals:
* @param controlPoint * @param controlPoint
* @param splinePoint * @param splinePoint
*/ */
void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position, const QPointF &controlPoint, void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position, const QPointF &controlPoint,
const QPointF &splinePoint ); const QPointF &splinePoint );
/** /**
* @brief setEnabledPoint * @brief setEnabledPoint
* @param enable * @param enable
*/ */
void setEnabledPoint ( bool enable ); void setEnabledPoint ( bool enable );
public slots: public slots:
/** /**
* @brief FullUpdateFromFile * @brief FullUpdateFromFile
*/ */
virtual void FullUpdateFromFile (); virtual void FullUpdateFromFile ();
/** /**
* @brief FullUpdateFromGui * @brief FullUpdateFromGui
* @param result * @param result
*/ */
virtual void FullUpdateFromGui ( int result ); virtual void FullUpdateFromGui ( int result );
/** /**
* @brief ControlPointChangePosition * @brief ControlPointChangePosition
* @param indexSpline * @param indexSpline
* @param position * @param position
* @param pos * @param pos
*/ */
void ControlPointChangePosition (const qint32 &indexSpline, const SplinePoint::Position &position, void ControlPointChangePosition (const qint32 &indexSpline, const SplinePoint::Position &position,
const QPointF &pos); const QPointF &pos);
/** /**
* @brief ChangedActivDraw * @brief ChangedActivDraw
* @param newName * @param newName
*/ */
virtual void ChangedActivDraw ( const QString &newName ); virtual void ChangedActivDraw ( const QString &newName );
/** /**
* @brief ShowTool * @brief ShowTool
* @param id * @param id
* @param color * @param color
* @param enable * @param enable
*/ */
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
/** /**
* @brief SetFactor * @brief SetFactor
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent
* @param event * @param event
*/ */
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/** /**
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile (); virtual void AddToFile ();
/** /**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/ */
virtual void RefreshDataInFile(); virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event
*/ */
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/** /**
* @brief hoverMoveEvent * @brief hoverMoveEvent
* @param event * @param event
*/ */
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/** /**
* @brief hoverLeaveEvent * @brief hoverLeaveEvent
* @param event * @param event
*/ */
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private: private:
/** /**
* @brief dialogSpline * @brief dialogSpline
@ -188,7 +190,7 @@ private:
/** /**
* @brief RefreshGeometry * @brief RefreshGeometry
*/ */
void RefreshGeometry (); void RefreshGeometry ();
}; };
#endif // VTOOLSPLINE_H #endif // VTOOLSPLINE_H

View file

@ -44,6 +44,7 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
this->setPath(path); this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine/factor)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
for (qint32 i = 1; i<=splPath->Count(); ++i) 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); VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
scene->addItem(spl); scene->addItem(spl);
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); 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); connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor);
doc->AddTool(id, spl); 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() void VToolSplinePath::RefreshGeometry()
{ {
this->setPen(QPen(currentColor, widthHairLine/factor)); this->setPen(QPen(currentColor, widthHairLine/factor));

View file

@ -54,7 +54,7 @@ public:
/** /**
* @brief setDialog * @brief setDialog
*/ */
virtual void setDialog(); virtual void setDialog();
/** /**
* @brief Create * @brief Create
* @param dialog * @param dialog
@ -93,81 +93,83 @@ signals:
* @param controlPoint * @param controlPoint
* @param splinePoint * @param splinePoint
*/ */
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
const QPointF &controlPoint, const QPointF &splinePoint); const QPointF &controlPoint, const QPointF &splinePoint);
/** /**
* @brief setEnabledPoint * @brief setEnabledPoint
* @param enable * @param enable
*/ */
void setEnabledPoint(bool enable); void setEnabledPoint(bool enable);
public slots: public slots:
/** /**
* @brief FullUpdateFromFile * @brief FullUpdateFromFile
*/ */
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
/** /**
* @brief FullUpdateFromGui * @brief FullUpdateFromGui
* @param result * @param result
*/ */
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
/** /**
* @brief ControlPointChangePosition * @brief ControlPointChangePosition
* @param indexSpline * @param indexSpline
* @param position * @param position
* @param pos * @param pos
*/ */
void ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position, void ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position,
const QPointF &pos); const QPointF &pos);
/** /**
* @brief ChangedActivDraw * @brief ChangedActivDraw
* @param newName * @param newName
*/ */
virtual void ChangedActivDraw(const QString &newName); virtual void ChangedActivDraw(const QString &newName);
/** /**
* @brief ShowTool * @brief ShowTool
* @param id * @param id
* @param color * @param color
* @param enable * @param enable
*/ */
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
/** /**
* @brief SetFactor * @brief SetFactor
* @param factor * @param factor
*/ */
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
protected: protected:
/** /**
* @brief contextMenuEvent * @brief contextMenuEvent
* @param event * @param event
*/ */
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/** /**
* @brief AddToFile * @brief AddToFile
*/ */
virtual void AddToFile(); virtual void AddToFile();
/** /**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/ */
virtual void RefreshDataInFile(); virtual void RefreshDataInFile();
/** /**
* @brief mouseReleaseEvent * @brief mouseReleaseEvent
* @param event * @param event
*/ */
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/** /**
* @brief hoverMoveEvent * @brief hoverMoveEvent
* @param event * @param event
*/ */
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/** /**
* @brief hoverLeaveEvent * @brief hoverLeaveEvent
* @param event * @param event
*/ */
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
/** /**
* @brief RemoveReferens * @brief RemoveReferens
*/ */
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
private: private:
/** /**
* @brief dialogSplinePath * @brief dialogSplinePath
@ -180,26 +182,26 @@ private:
/** /**
* @brief RefreshGeometry * @brief RefreshGeometry
*/ */
void RefreshGeometry(); void RefreshGeometry();
/** /**
* @brief AddPathPoint * @brief AddPathPoint
* @param domElement * @param domElement
* @param splPoint * @param splPoint
*/ */
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);
/** /**
* @brief UpdatePathPoint * @brief UpdatePathPoint
* @param node * @param node
* @param path * @param path
*/ */
void UpdatePathPoint(QDomNode& node, VSplinePath &path); void UpdatePathPoint(QDomNode& node, VSplinePath &path);
/** /**
* @brief CorectControlPoints * @brief CorectControlPoints
* @param spl * @param spl
* @param splPath * @param splPath
* @param indexSpline * @param indexSpline
*/ */
void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline); void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline);
}; };
#endif // VTOOLSPLINEPATH_H #endif // VTOOLSPLINEPATH_H

View file

@ -102,7 +102,7 @@ void VToolTriangle::Create(const qint64 _id, const QString &pointName, const qin
secondPointId, typeCreation); secondPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); 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); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(axisP1Id); 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) void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c)
{ {
//coefficient for equation of segment //coefficient for equation of segment

View file

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

View file

@ -72,6 +72,7 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
RefreshGeometry(); RefreshGeometry();
this->setPos(detail.getMx(), detail.getMy()); this->setPos(detail.getMx(), detail.getMy());
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
if (typeCreation == Tool::FromGui || typeCreation == Tool::FromTool) if (typeCreation == Tool::FromGui || typeCreation == Tool::FromTool)
{ {
AddToFile(); AddToFile();
@ -152,7 +153,7 @@ void VToolDetail::Create(const qint64 &_id, const VDetail &newDetail, VMainGraph
VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene); VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene);
scene->addItem(detail); scene->addItem(detail);
connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); 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(); QHash<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, detail); tools->insert(id, detail);
} }
@ -160,30 +161,7 @@ void VToolDetail::Create(const qint64 &_id, const VDetail &newDetail, VMainGraph
void VToolDetail::Remove() 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() void VToolDetail::FullUpdateFromFile()
@ -274,9 +252,36 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const
doc->FullUpdateTree(); 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); 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) void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
@ -311,30 +316,7 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
} }
if (selectedAction == actionRemove) if (selectedAction == actionRemove)
{ {
//remove form xml file DeleteTool(this);
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;
}
} }
} }
@ -397,6 +379,6 @@ void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId())); Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
Q_ASSERT(tool != 0); Q_ASSERT(tool != 0);
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(tool, &Tool::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(tool, &Tool::SceneRemoveTool, scene, &VMainGraphicsScene::RemoveTool);
tool->setParentItem(this); tool->setParentItem(this);
} }

View file

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