handle Leaders, Welds, Tiles and RichAnnos
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
# include <QTextStream>
|
||||
#endif
|
||||
|
||||
#include <QMessageBox>
|
||||
@@ -230,3 +232,34 @@ void ViewProviderLeader::handleChangedPropertyType(Base::XMLReader &reader, cons
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderLeader::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// a leader line cannot be deleted if it has a child weld symbol
|
||||
|
||||
// get childs
|
||||
auto childs = claimChildren();
|
||||
|
||||
if (!childs.empty()) {
|
||||
QString bodyMessage;
|
||||
QTextStream bodyMessageStream(&bodyMessage);
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"You cannot delete this leader line because\n it has a weld symbol that would become broken.");
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderLeader::canDelete(App::DocumentObject *obj) const
|
||||
{
|
||||
// deletions of Leader line objects don't destroy anything
|
||||
// thus we can pass this action
|
||||
// that the parent view cannot be deleted is handled
|
||||
// in its onDelete() function
|
||||
Q_UNUSED(obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ public:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
virtual bool doubleClicked(void);
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
virtual bool canDelete(App::DocumentObject* obj) const;
|
||||
|
||||
std::vector<App::DocumentObject*> claimChildren(void) const;
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ bool ViewProviderProjGroupItem::onDelete(const std::vector<std::string> &)
|
||||
// get child views
|
||||
auto viewSection = getObject()->getSectionRefs();
|
||||
auto viewDetail = getObject()->getDetailRefs();
|
||||
auto viewLeader = getObject()->getLeaders();
|
||||
|
||||
if (isAnchor)
|
||||
{
|
||||
@@ -196,6 +197,14 @@ bool ViewProviderProjGroupItem::onDelete(const std::vector<std::string> &)
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else if (!viewLeader.empty()) {
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"You cannot delete this view because it has a leader line that would become broken.");
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -221,3 +221,12 @@ void ViewProviderRichAnno::handleChangedPropertyType(Base::XMLReader &reader, co
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderRichAnno::canDelete(App::DocumentObject *obj) const
|
||||
{
|
||||
// deletions of RichAnno objects don't destroy anything
|
||||
// thus we can pass this action
|
||||
// only for information: RichAnnos that have a parent
|
||||
// view will get the page as new parent if the view is deleted
|
||||
Q_UNUSED(obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
virtual bool doubleClicked(void);
|
||||
virtual bool canDelete(App::DocumentObject* obj) const;
|
||||
|
||||
virtual TechDraw::DrawRichAnno* getViewObject() const;
|
||||
TechDraw::DrawRichAnno* getFeature() const;
|
||||
@@ -72,7 +73,6 @@ protected:
|
||||
private:
|
||||
static App::PropertyIntegerConstraint::Constraints LineStyleRange;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace TechDrawGui
|
||||
|
||||
@@ -84,6 +84,16 @@ void ViewProviderTile::updateData(const App::Property* prop)
|
||||
// return dynamic_cast<TechDraw::DrawTile*>(pcObject);
|
||||
//}
|
||||
|
||||
bool ViewProviderTile::canDelete(App::DocumentObject *obj) const
|
||||
{
|
||||
// deletions of Tile objects don't destroy anything
|
||||
// thus we can pass this action
|
||||
// that the deletion of its parent weld symbol is not possible
|
||||
// is done in its onDelete() function
|
||||
Q_UNUSED(obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
TechDraw::DrawTile* ViewProviderTile::getFeature() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawTile*>(pcObject);
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
virtual void updateData(const App::Property*);
|
||||
virtual bool canDelete(App::DocumentObject *obj) const;
|
||||
|
||||
/* virtual TechDraw::DrawTile* getViewObject() const;*/
|
||||
virtual TechDraw::DrawTile* getFeature() const;
|
||||
|
||||
@@ -260,6 +260,7 @@ bool ViewProviderViewPart::onDelete(const std::vector<std::string> &)
|
||||
// get child views
|
||||
auto viewSection = getViewObject()->getSectionRefs();
|
||||
auto viewDetail = getViewObject()->getDetailRefs();
|
||||
auto viewLeader = getViewObject()->getLeaders();
|
||||
|
||||
if (!viewSection.empty()) {
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
@@ -277,6 +278,14 @@ bool ViewProviderViewPart::onDelete(const std::vector<std::string> &)
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else if (!viewLeader.empty()) {
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"You cannot delete this view because it has a leader line that would become broken.");
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
# include <QTextStream>
|
||||
#endif
|
||||
|
||||
/// Here the FreeCAD includes sorted by Base,App,Gui......
|
||||
@@ -94,14 +96,14 @@ void ViewProviderWeld::updateData(const App::Property* prop)
|
||||
ViewProviderDrawingView::updateData(prop);
|
||||
}
|
||||
|
||||
void ViewProviderWeld::onChanged(const App::Property* p)
|
||||
{
|
||||
QGIView* qgiv = getQView();
|
||||
if (qgiv) {
|
||||
qgiv->updateView(true);
|
||||
}
|
||||
|
||||
ViewProviderDrawingView::onChanged(p);
|
||||
void ViewProviderWeld::onChanged(const App::Property* p)
|
||||
{
|
||||
QGIView* qgiv = getQView();
|
||||
if (qgiv) {
|
||||
qgiv->updateView(true);
|
||||
}
|
||||
|
||||
ViewProviderDrawingView::onChanged(p);
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderWeld::claimChildren(void) const
|
||||
@@ -186,7 +188,37 @@ double ViewProviderWeld::prefTileTextAdjust(void)
|
||||
return adjust;
|
||||
}
|
||||
|
||||
bool ViewProviderWeld::onDelete(const std::vector<std::string> &)
|
||||
{
|
||||
// a weld cannot be deleted if it has a tile
|
||||
|
||||
// get childs
|
||||
auto childs = claimChildren();
|
||||
|
||||
if (!childs.empty()) {
|
||||
QString bodyMessage;
|
||||
QTextStream bodyMessageStream(&bodyMessage);
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"You cannot delete this weld symbol because\n it has a tile weld that would become broken.");
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderWeld::canDelete(App::DocumentObject *obj) const
|
||||
{
|
||||
// deletions of Weld objects don't destroy anything
|
||||
// thus we can pass this action
|
||||
// that the parent LeaderLine cannot be deleted is handled
|
||||
// in its onDelete() function
|
||||
Q_UNUSED(obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
TechDraw::DrawWeldSymbol* ViewProviderWeld::getViewObject() const
|
||||
{
|
||||
|
||||
@@ -67,7 +67,8 @@ public:
|
||||
std::string prefFontName(void);
|
||||
double prefFontSize(void);
|
||||
double prefTileTextAdjust(void);
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
virtual bool canDelete(App::DocumentObject* obj) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user