[TD] handle object deletions better

see https://forum.freecadweb.org/viewtopic.php?p=366902#p366902
This commit is contained in:
donovaly
2020-03-03 03:54:08 +01:00
committed by WandererFan
parent b25ca7194c
commit def5159c38
10 changed files with 175 additions and 7 deletions

View File

@@ -24,6 +24,8 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QMessageBox>
# include <QTextStream>
# ifdef FC_OS_WIN32
# include <windows.h>
# endif
@@ -47,6 +49,7 @@
#include <Mod/TechDraw/App/DrawSVGTemplate.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include "DrawGuiUtil.h"
#include "QGITemplate.h"
#include "QGISVGTemplate.h"
#include "QGVPage.h"
@@ -182,6 +185,31 @@ void ViewProviderTemplate::setMarkers(bool state)
}
}
bool ViewProviderTemplate::onDelete(const std::vector<std::string> &)
{
// deleting the template will break the page view, thus warn the user
// get the page
auto page = getTemplate()->getParentPage();
// generate dialog
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");
bodyMessageStream << '\n' << QString::fromUtf8(page->Label.getValue());
// show and evaluate dialog
int DialogResult = QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
QMessageBox::Yes, QMessageBox::No);
if (DialogResult == QMessageBox::Yes)
return true;
else
return false;
}
MDIViewPage* ViewProviderTemplate::getMDIViewPage(void) const
{
MDIViewPage* myMdi = nullptr;