Remove the linked visibility group when deleting a group operation.

This commit is contained in:
Roman Telezhynskyi 2020-03-24 16:54:17 +02:00
parent 31f92c3610
commit 82570bf9db
4 changed files with 41 additions and 4 deletions

View File

@ -31,6 +31,7 @@
#include "../../../undocommands/label/operationshowlabel.h"
#include "../../../undocommands/savetooloptions.h"
#include "../../../undocommands/undogroup.h"
#include "../../../undocommands/deltool.h"
#include "../vgeometry/vpointf.h"
const QString VAbstractOperation::TagItem = QStringLiteral("item");
@ -619,6 +620,34 @@ void VAbstractOperation::ApplyToolOptions(const QList<quint32> &oldDependencies,
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::PerformDelete()
{
vidtype group = doc->GroupLinkedToTool(m_id);
bool deleteGroup = group != null_id;
qCDebug(vTool, "Begin deleting.");
if (deleteGroup)
{
qApp->getUndoStack()->beginMacro(tr("delete operation"));
qCDebug(vTool, "Deleting the linked group.");
DelGroup *delGroup = new DelGroup(doc, group);
connect(delGroup, &DelGroup::UpdateGroups, doc, &VAbstractPattern::UpdateVisiblityGroups);
qApp->getUndoStack()->push(delGroup);
}
qCDebug(vTool, "Deleting the tool.");
DelTool *delTool = new DelTool(doc, m_id);
connect(delTool, &DelTool::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
qApp->getUndoStack()->push(delTool);
if (deleteGroup)
{
qApp->getUndoStack()->endMacro();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::UpdateNamePosition(quint32 id, const QPointF &pos)
{

View File

@ -143,6 +143,7 @@ protected:
virtual void ChangeLabelVisibility(quint32 id, bool visible) override;
virtual void ApplyToolOptions(const QList<quint32> &oldDependencies, const QList<quint32> &newDependencies,
const QDomElement &oldDomElement, const QDomElement &newDomElement) override;
virtual void PerformDelete() override;
void UpdateNamePosition(quint32 id, const QPointF &pos);
void SaveSourceDestination(QDomElement &tag);

View File

@ -224,10 +224,7 @@ void VAbstractTool::DeleteToolWithConfirm(bool ask)
}
}
qCDebug(vTool, "Begin deleting.");
DelTool *delTool = new DelTool(doc, m_id);
connect(delTool, &DelTool::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
qApp->getUndoStack()->push(delTool);
PerformDelete();
// Throw exception, this will help prevent case when we forget to immediately quit function.
VExceptionToolWasDeleted e("Tool was used after deleting.");
@ -239,6 +236,15 @@ void VAbstractTool::DeleteToolWithConfirm(bool ask)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractTool::PerformDelete()
{
qCDebug(vTool, "Begin deleting.");
DelTool *delTool = new DelTool(doc, m_id);
connect(delTool, &DelTool::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
qApp->getUndoStack()->push(delTool);
}
//---------------------------------------------------------------------------------------------------------------------
int VAbstractTool::ConfirmDeletion()
{

View File

@ -159,6 +159,7 @@ protected:
*/
virtual void RemoveReferens() {}
virtual void DeleteToolWithConfirm(bool ask = true);
virtual void PerformDelete();
static int ConfirmDeletion();
template<typename T>