Improved loging. Base point's DeleteTool should ignore value "_referens".
--HG-- branch : develop
This commit is contained in:
parent
31ee872a1d
commit
a342948437
|
@ -166,25 +166,26 @@ void VToolBasePoint::decrementReferens()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolBasePoint::DeleteTool(bool ask)
|
||||
{
|
||||
if (_referens <= 1)
|
||||
qCDebug(vTool, "Deleting base point.");
|
||||
qApp->getSceneView()->itemClicked(nullptr);
|
||||
if (ask)
|
||||
{
|
||||
qApp->getSceneView()->itemClicked(nullptr);
|
||||
if (ask)
|
||||
qCDebug(vTool, "Asking.");
|
||||
if (ConfirmDeletion() == QMessageBox::No)
|
||||
{
|
||||
if (ConfirmDeletion() == QMessageBox::No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
qCDebug(vTool, "User said no.");
|
||||
return;
|
||||
}
|
||||
|
||||
DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw);
|
||||
connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
|
||||
qApp->getUndoStack()->push(deletePP);
|
||||
|
||||
// Throw exception, this will help prevent case when we forget to immediately quit function.
|
||||
VExceptionToolWasDeleted e("Tool was used after deleting.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
qCDebug(vTool, "Begin deleting.");
|
||||
DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw);
|
||||
connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
|
||||
qApp->getUndoStack()->push(deletePP);
|
||||
|
||||
// Throw exception, this will help prevent case when we forget to immediately quit function.
|
||||
VExceptionToolWasDeleted e("Tool was used after deleting.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -291,26 +292,32 @@ void VToolBasePoint::ReadToolAttributes(const QDomElement &domElement)
|
|||
*/
|
||||
void VToolBasePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event )
|
||||
{
|
||||
qCDebug(vTool, "Context menu base point");
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
qCDebug(vTool, "Restored overriden cursor");
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
if (doc->CountPP() > 1)
|
||||
{
|
||||
qCDebug(vTool, "PP count > 1");
|
||||
ContextMenu<DialogSinglePoint>(this, event, RemoveOption::Enable, Referens::Ignore);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "PP count = 1");
|
||||
ContextMenu<DialogSinglePoint>(this, event, RemoveOption::Disable);
|
||||
}
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
qCDebug(vTool, "Tool was deleted. Immediately leave method.");
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
qCDebug(vTool, "Context menu closed. Tool was not deleted.");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "vtoolsinglepoint.h"
|
||||
|
||||
/**
|
||||
* @brief The VToolBasePoint class tool for creation pattern base point. Obly base point can move. All object
|
||||
* @brief The VToolBasePoint class tool for creation pattern base point. Only base point can move. All object
|
||||
* pattern peace depend on base point.
|
||||
*/
|
||||
class VToolBasePoint : public VToolSinglePoint
|
||||
|
|
|
@ -133,6 +133,7 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, c
|
|||
SCASSERT(tool != nullptr);
|
||||
SCASSERT(event != nullptr);
|
||||
|
||||
qCDebug(vTool, "Creating tool context menu.");
|
||||
QMenu menu;
|
||||
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
||||
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
||||
|
@ -142,26 +143,31 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, c
|
|||
{
|
||||
if (_referens > 1)
|
||||
{
|
||||
qCDebug(vTool, "Remove disabled. Tool has childern.");
|
||||
actionRemove->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "Remove enabled. Tool has not childern.");
|
||||
actionRemove->setEnabled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "Remove enabled. Ignore referens value.");
|
||||
actionRemove->setEnabled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "Remove disabled.");
|
||||
actionRemove->setEnabled(false);
|
||||
}
|
||||
|
||||
QAction *selectedAction = menu.exec(event->screenPos());
|
||||
if (selectedAction == actionOption)
|
||||
{
|
||||
qCDebug(vTool, "Show options.");
|
||||
qApp->getSceneView()->itemClicked(nullptr);
|
||||
dialog = new Dialog(getData(), id, qApp->getMainWindow());
|
||||
dialog->setModal(true);
|
||||
|
@ -175,6 +181,7 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, c
|
|||
}
|
||||
if (selectedAction == actionRemove)
|
||||
{
|
||||
qCDebug(vTool, "Deleting tool.");
|
||||
DeleteTool(); // do not catch exception here
|
||||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
|
|
|
@ -67,16 +67,22 @@ VAbstractTool::~VAbstractTool()
|
|||
*/
|
||||
void VAbstractTool::DeleteTool(bool ask)
|
||||
{
|
||||
qCDebug(vTool, "Deleting abstract tool.");
|
||||
if (_referens <= 1)
|
||||
{
|
||||
qCDebug(vTool, "No children.");
|
||||
qApp->getSceneView()->itemClicked(nullptr);
|
||||
if (ask)
|
||||
{
|
||||
qCDebug(vTool, "Asking.");
|
||||
if (ConfirmDeletion() == QMessageBox::No)
|
||||
{
|
||||
qCDebug(vTool, "User said no.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qCDebug(vTool, "Begin deleting.");
|
||||
DelTool *delTool = new DelTool(doc, id);
|
||||
connect(delTool, &DelTool::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
|
||||
qApp->getUndoStack()->push(delTool);
|
||||
|
@ -85,6 +91,10 @@ void VAbstractTool::DeleteTool(bool ask)
|
|||
VExceptionToolWasDeleted e("Tool was used after deleting.");
|
||||
throw e;
|
||||
}
|
||||
else
|
||||
{
|
||||
qCDebug(vTool, "Can't delete, tool has children.");
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user