App: Doc: affected labels list in delete command
This commit is contained in:
parent
4a1978aae9
commit
a412d309c5
|
@ -28,6 +28,7 @@
|
|||
# include <QEventLoop>
|
||||
# include <QFileDialog>
|
||||
# include <QLabel>
|
||||
# include <QTextStream>
|
||||
# include <QStatusBar>
|
||||
# include <QPointer>
|
||||
# include <QProcess>
|
||||
|
@ -1067,15 +1068,20 @@ void StdCmdDelete::activated(int iMsg)
|
|||
}
|
||||
else {
|
||||
// check if we can delete the object
|
||||
std::set<QString> affectedLabels;
|
||||
for (std::vector<Gui::SelectionObject>::iterator ft = sel.begin(); ft != sel.end(); ++ft) {
|
||||
App::DocumentObject* obj = ft->getObject();
|
||||
std::vector<App::DocumentObject*> links = obj->getInList();
|
||||
if (!links.empty()) {
|
||||
// check if the referenced objects are groups or are selected too
|
||||
for (std::vector<App::DocumentObject*>::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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user