Skip to content

Commit

Permalink
[TD] handle deletions of hatches
Browse files Browse the repository at this point in the history
- also uniform line endings in ViewProviderLeader.cpp
  • Loading branch information
donovaly authored and WandererFan committed Mar 8, 2020
1 parent 3307e4b commit c390d64
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp
Expand Up @@ -181,7 +181,6 @@ void ViewProviderGeomHatch::updateGraphic(void)
}
}


void ViewProviderGeomHatch::getParameters(void)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
Expand All @@ -198,6 +197,14 @@ void ViewProviderGeomHatch::getParameters(void)
WeightPattern.setValue(weight);
}

bool ViewProviderGeomHatch::canDelete(App::DocumentObject *obj) const
{
// deletion of hatches don't destroy anything
// thus we can pass this action
Q_UNUSED(obj)
return true;
}

TechDraw::DrawGeomHatch* ViewProviderGeomHatch::getViewObject() const
{
return dynamic_cast<TechDraw::DrawGeomHatch*>(pcObject);
Expand Down
5 changes: 1 addition & 4 deletions src/Mod/TechDraw/Gui/ViewProviderGeomHatch.h
Expand Up @@ -28,7 +28,6 @@
#include <App/DocumentObject.h>
#include <App/FeaturePython.h>
#include <App/PropertyStandard.h>

#include <Gui/ViewProviderFeature.h>


Expand All @@ -52,19 +51,18 @@ class TechDrawGuiExport ViewProviderGeomHatch : public Gui::ViewProviderDocument
App::PropertyFloat WeightPattern;
App::PropertyColor ColorPattern;


virtual void attach(App::DocumentObject *) override;
virtual void updateData(const App::Property*) override;
virtual void onChanged(const App::Property *prop) override;
virtual bool setEdit(int ModNum) override;
virtual void unsetEdit(int ModNum) override;
virtual bool doubleClicked(void) override;

virtual bool useNewSelectionModel(void) const override {return false;}
virtual void setDisplayMode(const char* ModeName) override;
virtual std::vector<std::string> getDisplayModes(void) const override;
void updateGraphic(void);
void getParameters(void);
virtual bool canDelete(App::DocumentObject* obj) const;

TechDraw::DrawGeomHatch* getViewObject() const;

Expand All @@ -73,5 +71,4 @@ class TechDrawGuiExport ViewProviderGeomHatch : public Gui::ViewProviderDocument

} // namespace TechDrawGui


#endif // DRAWINGGUI_VIEWPROVIDERHATCH_H
10 changes: 9 additions & 1 deletion src/Mod/TechDraw/Gui/ViewProviderHatch.cpp
Expand Up @@ -113,6 +113,7 @@ void ViewProviderHatch::onChanged(const App::Property* prop)
}
}
}

void ViewProviderHatch::updateData(const App::Property* prop)
{
Gui::ViewProviderDocumentObject::updateData(prop);
Expand All @@ -123,6 +124,14 @@ TechDraw::DrawHatch* ViewProviderHatch::getViewObject() const
return dynamic_cast<TechDraw::DrawHatch*>(pcObject);
}

bool ViewProviderHatch::canDelete(App::DocumentObject *obj) const
{
// deletion of hatches don't destroy anything
// thus we can pass this action
Q_UNUSED(obj)
return true;
}

Gui::MDIView *ViewProviderHatch::getMDIView() const
{
auto obj = getViewObject();
Expand All @@ -131,4 +140,3 @@ Gui::MDIView *ViewProviderHatch::getMDIView() const
if(!vp) return 0;
return vp->getMDIView();
}

1 change: 1 addition & 0 deletions src/Mod/TechDraw/Gui/ViewProviderHatch.h
Expand Up @@ -54,6 +54,7 @@ class TechDrawGuiExport ViewProviderHatch : public Gui::ViewProviderDocumentObje
virtual std::vector<std::string> getDisplayModes(void) const override;
virtual void onChanged(const App::Property* prop) override;
virtual void updateData(const App::Property*) override;
virtual bool canDelete(App::DocumentObject* obj) const;

TechDraw::DrawHatch* getViewObject() const;

Expand Down
6 changes: 3 additions & 3 deletions src/Mod/TechDraw/Gui/ViewProviderLeader.cpp
Expand Up @@ -236,8 +236,8 @@ 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();
// get childs
auto childs = claimChildren();

if (!childs.empty()) {
QString bodyMessage;
Expand All @@ -258,7 +258,7 @@ 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
// that the parent view cannot be deleted is handled
// in its onDelete() function
Q_UNUSED(obj)
return true;
Expand Down

0 comments on commit c390d64

Please sign in to comment.