From 8eecfe78a3c56398187450ed46353bcbb1deb754 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 19 Oct 2017 11:20:19 +0300 Subject: [PATCH] New feature multi deletion pieces. --HG-- branch : develop --- src/libs/vtools/tools/vtoolseamallowance.cpp | 56 +++++++++++++++++--- src/libs/vtools/tools/vtoolseamallowance.h | 2 + 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 1fb7e5916..58d5e9acc 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1146,14 +1146,32 @@ void VToolSeamAllowance::keyReleaseEvent(QKeyEvent *event) switch (event->key()) { case Qt::Key_Delete: - try + if (ConfirmDeletion() == QMessageBox::Yes) { - DeleteTool(); - } - catch(const VExceptionToolWasDeleted &e) - { - Q_UNUSED(e); - return;//Leave this method immediately!!! + const QList toolList = SelectedTools(); + + try + { + if (not toolList.isEmpty()) + { + qApp->getUndoStack()->beginMacro(tr("multi deletion")); + + for(int i=0; i < toolList.size(); ++i) + { + toolList.at(i)->Remove(false); + } + } + DeleteTool(false); + } + catch(const VExceptionToolWasDeleted &e) + { + Q_UNUSED(e); + if (not toolList.isEmpty()) + { + qApp->getUndoStack()->endMacro(); + } + return;//Leave this method immediately!!! + } } break; default: @@ -1648,3 +1666,27 @@ void VToolSeamAllowance::UpdateLabelItem(VTextGraphicsItem *labelItem, QPointF p labelItem->Update(); labelItem->GetTextLines() > 0 ? labelItem->show() : labelItem->hide(); } + +//--------------------------------------------------------------------------------------------------------------------- +QList VToolSeamAllowance::SelectedTools() const +{ + QList tools; + if(m_sceneDetails) + { + const QList list = m_sceneDetails->selectedItems(); + + if (not list.isEmpty()) + { + for(int i=0; i < list.size(); ++i) + { + VToolSeamAllowance *tool = qgraphicsitem_cast(list.at(i)); + if (tool->getId() != m_id) + { + tools.append(tool); + } + } + } + } + + return tools; +} diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 3a353d0b4..5453a6f9d 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -190,6 +190,8 @@ private: bool PrepareLabelData(const VPatternLabelData &labelData, VTextGraphicsItem *labelItem, QPointF &pos, qreal &labelAngle); void UpdateLabelItem(VTextGraphicsItem *labelItem, QPointF pos, qreal labelAngle); + + QList SelectedTools() const; }; #endif // VTOOLSEAMALLOWANCE_H