+ make isReadOnly & isHidden of PropertyContainer non-virtual

This commit is contained in:
wmayer
2015-11-14 02:07:57 +01:00
parent 081bc6b107
commit 53d323b5e0
8 changed files with 37 additions and 46 deletions

View File

@@ -93,7 +93,7 @@ public:
const char* getPropertyDocumentation(const char *name) const;
/// check if the property is read-only
bool isReadOnly(const Property* prop) const;
/// check if the nameed property is read-only
/// check if the named property is read-only
bool isReadOnly(const char *name) const;
/// check if the property is hidden
bool isHidden(const Property* prop) const;

View File

@@ -156,7 +156,7 @@ public:
const char* getPropertyGroup(const char *name) const {
return props->getPropertyGroup(name);
}
/// get the Group of a Property
/// get the Documentation of a Property
const char* getPropertyDocumentation(const Property* prop) const {
return props->getPropertyDocumentation(prop);
}
@@ -164,22 +164,6 @@ public:
const char* getPropertyDocumentation(const char *name) const {
return props->getPropertyDocumentation(name);
}
/// check if the property is read-only
bool isReadOnly(const Property* prop) const {
return props->isReadOnly(prop);
}
/// check if the nameed property is read-only
bool isReadOnly(const char *name) const {
return props->isReadOnly(name);
}
/// check if the property is hidden
bool isHidden(const Property* prop) const {
return props->isHidden(prop);
}
/// check if the named property is hidden
bool isHidden(const char *name) const {
return props->isHidden(name);
}
//@}
/** @name Property serialization */

View File

@@ -125,22 +125,22 @@ const char* PropertyContainer::getPropertyDocumentation(const char *name) const
bool PropertyContainer::isReadOnly(const Property* prop) const
{
return (getPropertyData().getType(this,prop) & Prop_ReadOnly) == Prop_ReadOnly;
return (getPropertyType(prop) & Prop_ReadOnly) == Prop_ReadOnly;
}
bool PropertyContainer::isReadOnly(const char *name) const
{
return (getPropertyData().getType(this,name) & Prop_ReadOnly) == Prop_ReadOnly;
return (getPropertyType(name) & Prop_ReadOnly) == Prop_ReadOnly;
}
bool PropertyContainer::isHidden(const Property* prop) const
{
return (getPropertyData().getType(this,prop) & Prop_Hidden) == Prop_Hidden;
return (getPropertyType(prop) & Prop_Hidden) == Prop_Hidden;
}
bool PropertyContainer::isHidden(const char *name) const
{
return (getPropertyData().getType(this,name) & Prop_Hidden) == Prop_Hidden;
return (getPropertyType(name) & Prop_Hidden) == Prop_Hidden;
}
const char* PropertyContainer::getPropertyName(const Property* prop)const

View File

@@ -125,13 +125,13 @@ public:
/// get the Group of a named Property
virtual const char* getPropertyDocumentation(const char *name) const;
/// check if the property is read-only
virtual bool isReadOnly(const Property* prop) const;
/// check if the nameed property is read-only
virtual bool isReadOnly(const char *name) const;
bool isReadOnly(const Property* prop) const;
/// check if the named property is read-only
bool isReadOnly(const char *name) const;
/// check if the property is hidden
virtual bool isHidden(const Property* prop) const;
bool isHidden(const Property* prop) const;
/// check if the named property is hidden
virtual bool isHidden(const char *name) const;
bool isHidden(const char *name) const;
virtual App::Property* addDynamicProperty(
const char* type, const char* name=0,
const char* group=0, const char* doc=0,

View File

@@ -171,7 +171,13 @@ PyObject* PropertyContainerPy::getGroupOfProperty(PyObject *args)
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
return NULL; // NULL triggers exception
const char* Group = getPropertyContainerPtr()->getPropertyGroup(pstr);
Property* prop = getPropertyContainerPtr()->getPropertyByName(pstr);
if (!prop) {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
return 0;
}
const char* Group = getPropertyContainerPtr()->getPropertyGroup(prop);
if (Group)
return Py::new_reference_to(Py::String(Group));
else
@@ -184,7 +190,13 @@ PyObject* PropertyContainerPy::getDocumentationOfProperty(PyObject *args)
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
return NULL; // NULL triggers exception
const char* Group = getPropertyContainerPtr()->getPropertyDocumentation(pstr);
Property* prop = getPropertyContainerPtr()->getPropertyByName(pstr);
if (!prop) {
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", pstr);
return 0;
}
const char* Group = getPropertyContainerPtr()->getPropertyDocumentation(prop);
if (Group)
return Py::new_reference_to(Py::String(Group));
else

View File

@@ -345,22 +345,6 @@ public:
const char* getPropertyDocumentation(const char *name) const {
return props->getPropertyDocumentation(name);
}
/// check if the property is read-only
bool isReadOnly(const App::Property* prop) const {
return props->isReadOnly(prop);
}
/// check if the nameed property is read-only
bool isReadOnly(const char *name) const {
return props->isReadOnly(name);
}
/// check if the property is hidden
bool isHidden(const App::Property* prop) const {
return props->isHidden(prop);
}
/// check if the named property is hidden
bool isHidden(const char *name) const {
return props->isHidden(name);
}
//@}
/** @name Property serialization */

View File

@@ -217,7 +217,8 @@ void PropertyModel::buildUp(const PropertyModel::PropertyList& props)
for (jt = props.begin(); jt != props.end(); ++jt) {
App::Property* prop = jt->second.front();
const char* group = prop->getGroup();
std::string grp = group ? group : "Base";
bool isEmpty = (group == 0 || group[0] == '\0');
std::string grp = isEmpty ? "Base" : group;
propGroup[grp].push_back(jt->second);
}

View File

@@ -210,6 +210,16 @@ public:
return props.getPropertyType(prop);
}
/// get the group of a property
const char* getPropertyGroup(const App::Property* prop) const {
return props.getPropertyGroup(prop);
}
/// get the documentation of a property
const char* getPropertyDocumentation(const App::Property* prop) const {
return props.getPropertyDocumentation(prop);
}
/// get the name of a property
virtual const char* getName(const App::Property* prop) const {
return props.getPropertyName(prop);