handle now also section view, detail view and view
This commit is contained in:
@@ -149,7 +149,10 @@ bool ViewProviderProjGroupItem::doubleClicked(void)
|
||||
bool ViewProviderProjGroupItem::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// we cannot delete the anchor view, thus check if the item is the front item
|
||||
// we also cannot delete if the item has a section or detail view
|
||||
|
||||
QString bodyMessage;
|
||||
QTextStream bodyMessageStream(&bodyMessage);
|
||||
bool isAnchor = false;
|
||||
|
||||
// get the item and group
|
||||
@@ -162,22 +165,40 @@ bool ViewProviderProjGroupItem::onDelete(const std::vector<std::string> &)
|
||||
&& (dpg->getAnchor() == dpgi))
|
||||
isAnchor = true;
|
||||
|
||||
// get child views
|
||||
auto viewSection = getObject()->getSectionRefs();
|
||||
auto viewDetail = getObject()->getDetailRefs();
|
||||
|
||||
if (isAnchor)
|
||||
{
|
||||
// generate dialog
|
||||
QString bodyMessage;
|
||||
QTextStream bodyMessageStream(&bodyMessage);
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"You cannot delete the anchor view of a projection group!");
|
||||
"You cannot delete the anchor view of a projection group.");
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
// don't allow to delete
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
}
|
||||
else if (!viewSection.empty()) {
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"You cannot delete this view because it has a section view that would become broken.");
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else if (!viewDetail.empty()) {
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"You cannot delete this view because it has a detail view that would become broken.");
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderProjGroupItem::canDelete(App::DocumentObject *obj) const
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <QMessageBox>
|
||||
#include <QTextStream>
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
@@ -35,6 +37,7 @@
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawViewDimension.h>
|
||||
#include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
@@ -246,3 +249,43 @@ void ViewProviderViewPart::handleChangedPropertyType(Base::XMLReader &reader, co
|
||||
ExtraWidth.setValue(ExtraWidthProperty.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderViewPart::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// we cannot delete if the view has a section or detail view
|
||||
|
||||
QString bodyMessage;
|
||||
QTextStream bodyMessageStream(&bodyMessage);
|
||||
|
||||
// get child views
|
||||
auto viewSection = getViewObject()->getSectionRefs();
|
||||
auto viewDetail = getViewObject()->getDetailRefs();
|
||||
|
||||
if (!viewSection.empty()) {
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"You cannot delete this view because it has a section view that would become broken.");
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else if (!viewDetail.empty()) {
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"You cannot delete this view because it has a detail view that would become broken.");
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderViewPart::canDelete(App::DocumentObject *obj) const
|
||||
{
|
||||
// deletions of part objects (detail view, View etc.) are valid
|
||||
// that it cannot be deleted if it has a child view is handled in the onDelete() function
|
||||
Q_UNUSED(obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
virtual bool useNewSelectionModel(void) const {return false;}
|
||||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
virtual bool canDelete(App::DocumentObject* obj) const;
|
||||
|
||||
public:
|
||||
virtual void onChanged(const App::Property *prop);
|
||||
|
||||
@@ -187,6 +187,14 @@ void ViewProviderViewSection::getParameters(void)
|
||||
WeightPattern.setValue(lineWeight);
|
||||
}
|
||||
|
||||
bool ViewProviderViewSection::canDelete(App::DocumentObject *obj) const
|
||||
{
|
||||
// a section view can be deleted
|
||||
// that its base view cannot be deleted is handled in its the onDelete() function
|
||||
Q_UNUSED(obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
TechDraw::DrawViewSection* ViewProviderViewSection::getViewObject() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawViewSection*>(pcObject);
|
||||
|
||||
@@ -65,8 +65,7 @@ public:
|
||||
|
||||
void updateGraphic(void);
|
||||
void getParameters(void);
|
||||
|
||||
|
||||
virtual bool canDelete(App::DocumentObject* obj) const;
|
||||
|
||||
virtual TechDraw::DrawViewSection* getViewObject() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user