Disable also deletion tool from keyboard when tool cannot be deleted.

--HG--
branch : develop
This commit is contained in:
dismine 2014-09-26 20:09:20 +03:00
parent 0dc4a33432
commit d950acfc23
4 changed files with 23 additions and 15 deletions

View File

@ -33,6 +33,7 @@
#include "../options.h"
#include "vtranslation.h"
#include <QSettings>
#include "../widgets/vmaingraphicsview.h"
class VApplication;// used in define
class QUndoStack;

View File

@ -36,7 +36,6 @@
#include "../../dialogs/tools/dialogtool.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
#include "../../widgets/vmaingraphicsview.h"
/**
* @brief The VDrawTool abstract class for all draw tool.
@ -138,7 +137,6 @@ protected:
}
if (selectedAction == actionRemove)
{
qApp->getSceneView()->itemClicked(nullptr);
DeleteTool();
}
}

View File

@ -168,17 +168,21 @@ void VToolSinglePoint::decrementReferens()
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::DeleteTool(bool ask)
{
if (ask)
if (_referens <= 1)
{
if (ConfirmDeletion() == QMessageBox::Cancel)
qApp->getSceneView()->itemClicked(nullptr);
if (ask)
{
return;
if (ConfirmDeletion() == QMessageBox::Cancel)
{
return;
}
}
}
DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw);
connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VPattern::NeedFullParsing);
qApp->getUndoStack()->push(deletePP);
DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw);
connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VPattern::NeedFullParsing);
qApp->getUndoStack()->push(deletePP);
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -33,6 +33,7 @@
#include "../core/vapplication.h"
#include "../geometry/vpointf.h"
#include "../undocommands/savetooloptions.h"
#include "../widgets/vmaingraphicsview.h"
const QString VAbstractTool::AttrType = QStringLiteral("type");
const QString VAbstractTool::AttrMx = QStringLiteral("mx");
@ -249,16 +250,20 @@ QPointF VAbstractTool::addVector(const QPointF &p, const QPointF &p1, const QPoi
*/
void VAbstractTool::DeleteTool(bool ask)
{
if (ask)
if (_referens <= 1)
{
if (ConfirmDeletion() == QMessageBox::Cancel)
qApp->getSceneView()->itemClicked(nullptr);
if (ask)
{
return;
if (ConfirmDeletion() == QMessageBox::Cancel)
{
return;
}
}
DelTool *delTool = new DelTool(doc, id);
connect(delTool, &DelTool::NeedFullParsing, doc, &VPattern::NeedFullParsing);
qApp->getUndoStack()->push(delTool);
}
DelTool *delTool = new DelTool(doc, id);
connect(delTool, &DelTool::NeedFullParsing, doc, &VPattern::NeedFullParsing);
qApp->getUndoStack()->push(delTool);
}
//---------------------------------------------------------------------------------------------------------------------