do not use an int but an enum to handle different modes

This commit is contained in:
wmayer
2019-09-27 22:00:25 +02:00
parent b450f5a5c8
commit 1a2370cd91
2 changed files with 76 additions and 42 deletions

View File

@@ -42,6 +42,12 @@ class Property;
class AppExport FeaturePythonImp
{
public:
enum ValueT {
NotImplemented = 0, // not handled
Accepted = 1, // handled and accepted
Rejected = 2 // handled and rejected
};
FeaturePythonImp(App::DocumentObject*);
~FeaturePythonImp();
@@ -61,19 +67,20 @@ public:
bool getSubObjects(std::vector<std::string> &ret, int reason) const;
bool getLinkedObject(App::DocumentObject *&ret, bool recurse,
Base::Matrix4D *mat, bool transform, int depth) const;
Base::Matrix4D *mat, bool transform, int depth) const;
int canLinkProperties() const;
ValueT canLinkProperties() const;
int allowDuplicateLabel() const;
ValueT allowDuplicateLabel() const;
int redirectSubName(std::ostringstream &ss,
App::DocumentObject *topParent, App::DocumentObject *child) const;
ValueT redirectSubName(std::ostringstream &ss,
App::DocumentObject *topParent,
App::DocumentObject *child) const;
int canLoadPartial() const;
/// return true to activate tree view group object handling
int hasChildElement() const;
ValueT hasChildElement() const;
/// Get sub-element visibility
int isElementVisible(const char *) const;
/// Set sub-element visibility
@@ -235,10 +242,14 @@ public:
/// return true to activate tree view group object handling
virtual bool hasChildElement() const override {
int ret = imp->hasChildElement();
if(ret<0)
switch (imp->hasChildElement()) {
case FeaturePythonImp::Accepted:
return true;
case FeaturePythonImp::Rejected:
return false;
default:
return FeatureT::hasChildElement();
return ret?true:false;
}
}
/// Get sub-element visibility
virtual int isElementVisible(const char *element) const override {
@@ -256,26 +267,38 @@ public:
}
virtual bool canLinkProperties() const override {
int ret = imp->canLinkProperties();
if(ret < 0)
switch (imp->canLinkProperties()) {
case FeaturePythonImp::Accepted:
return true;
case FeaturePythonImp::Rejected:
return false;
default:
return FeatureT::canLinkProperties();
return ret?true:false;
}
}
virtual bool allowDuplicateLabel() const override {
int ret = imp->allowDuplicateLabel();
if(ret < 0)
switch (imp->allowDuplicateLabel()) {
case FeaturePythonImp::Accepted:
return true;
case FeaturePythonImp::Rejected:
return false;
default:
return FeatureT::allowDuplicateLabel();
return ret?true:false;
}
}
virtual bool redirectSubName(std::ostringstream &ss,
App::DocumentObject *topParent, App::DocumentObject *child) const override
{
int ret = imp->redirectSubName(ss,topParent,child);
if(ret < 0)
return FeatureT::redirectSubName(ss,topParent,child);
return ret?true:false;
switch (imp->redirectSubName(ss,topParent,child)) {
case FeaturePythonImp::Accepted:
return true;
case FeaturePythonImp::Rejected:
return false;
default:
return FeatureT::redirectSubName(ss, topParent, child);
}
}
virtual int canLoadPartial() const override {