From a412d309c5985a1679ed62b287df97e0678b886b Mon Sep 17 00:00:00 2001 From: blobfish Date: Sun, 3 May 2015 12:11:21 -0400 Subject: [PATCH] App: Doc: affected labels list in delete command --- src/Gui/CommandDoc.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 423b389b1..329eef80e 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -28,6 +28,7 @@ # include # include # include +# include # include # include # include @@ -1067,15 +1068,20 @@ void StdCmdDelete::activated(int iMsg) } else { // check if we can delete the object + std::set affectedLabels; for (std::vector::iterator ft = sel.begin(); ft != sel.end(); ++ft) { App::DocumentObject* obj = ft->getObject(); std::vector links = obj->getInList(); if (!links.empty()) { // check if the referenced objects are groups or are selected too for (std::vector::iterator lt = links.begin(); lt != links.end(); ++lt) { - if (!(*lt)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId()) && !rSel.isSelected(*lt)) { + if ( + (!(*lt)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) && + (!rSel.isSelected(*lt)) && + (!(*lt)->getTypeId().isDerivedFrom(Base::Type::fromName("Part::BodyBase"))) + ){ autoDeletion = false; - break; + affectedLabels.insert(QString::fromUtf8((*lt)->Label.getValue())); } } @@ -1086,10 +1092,16 @@ void StdCmdDelete::activated(int iMsg) } if (!autoDeletion) { + QString bodyMessage; + QTextStream bodyMessageStream(&bodyMessage); + bodyMessageStream << qApp->translate("Std_Delete", + "The following, referencing objects might break.\n\n" + "Are you sure you want to continue?\n\n"); + for (const auto ¤tLabel : affectedLabels) + bodyMessageStream << currentLabel << '\n'; + int ret = QMessageBox::question(Gui::getMainWindow(), - qApp->translate("Std_Delete", "Object dependencies"), - qApp->translate("Std_Delete", "This object is referenced by other objects and thus these objects might get broken.\n" - "Are you sure to continue?"), + qApp->translate("Std_Delete", "Object dependencies"), bodyMessage, QMessageBox::Yes, QMessageBox::No); if (ret == QMessageBox::Yes) autoDeletion = true;