Allow to remove user-defined properties
This commit is contained in:
parent
482a73b302
commit
77144681ef
|
@ -245,6 +245,18 @@ Property* DynamicProperty::addDynamicProperty(const char* type, const char* name
|
|||
return pcProperty;
|
||||
}
|
||||
|
||||
bool DynamicProperty::removeDynamicProperty(const char* name)
|
||||
{
|
||||
std::map<std::string,PropData>::iterator it = props.find(name);
|
||||
if (it != props.end()) {
|
||||
delete it->second.property;
|
||||
props.erase(it);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string DynamicProperty::getUniquePropertyName(const char *Name) const
|
||||
{
|
||||
std::string CleanName = Base::Tools::getIdentifier(Name);
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
Property *getDynamicPropertyByName(const char* name) const;
|
||||
Property* addDynamicProperty(const char* type, const char* name=0, const char* group=0,
|
||||
const char* doc=0, short attr=0, bool ro=false, bool hidden=false);
|
||||
bool removeDynamicProperty(const char* name);
|
||||
std::vector<std::string> getDynamicPropertyNames() const;
|
||||
void addDynamicProperties(const PropertyContainer*);
|
||||
/// get the name of a property
|
||||
|
|
|
@ -100,6 +100,9 @@ public:
|
|||
short attr=0, bool ro=false, bool hidden=false) {
|
||||
return props->addDynamicProperty(type, name, group, doc, attr, ro, hidden);
|
||||
}
|
||||
virtual bool removeDynamicProperty(const char* name) {
|
||||
return props->removeDynamicProperty(name);
|
||||
}
|
||||
std::vector<std::string> getDynamicPropertyNames() const {
|
||||
return props->getDynamicPropertyNames();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,13 @@ The first argument specifies the type, the second the
|
|||
name of the property.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeProperty">
|
||||
<Documentation>
|
||||
<UserDocu>removeProperty(string) -- Remove a generic property.
|
||||
Note, you can only remove user-defined properties but not built-in ones.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="supportedProperties">
|
||||
<Documentation>
|
||||
|
|
|
@ -62,6 +62,16 @@ PyObject* FeaturePythonPy::addProperty(PyObject *args)
|
|||
return Py::new_reference_to(this);
|
||||
}
|
||||
|
||||
PyObject* FeaturePythonPy::removeProperty(PyObject *args)
|
||||
{
|
||||
char *sName;
|
||||
if (!PyArg_ParseTuple(args, "s", &sName))
|
||||
return NULL;
|
||||
|
||||
bool ok = getFeaturePythonPtr()->removeDynamicProperty(sName);
|
||||
return Py_BuildValue("O", (ok ? Py_True : Py_False));
|
||||
}
|
||||
|
||||
PyObject* FeaturePythonPy::supportedProperties(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
||||
|
|
|
@ -138,6 +138,9 @@ public:
|
|||
short attr=0, bool ro=false, bool hidden=false){
|
||||
return 0;
|
||||
}
|
||||
virtual bool removeDynamicProperty(const char* name) {
|
||||
return false;
|
||||
}
|
||||
virtual std::vector<std::string> getDynamicPropertyNames() const {
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
|
|
@ -188,6 +188,9 @@ public:
|
|||
short attr=0, bool ro=false, bool hidden=false) {
|
||||
return props->addDynamicProperty(type, name, group, doc, attr, ro, hidden);
|
||||
}
|
||||
virtual bool removeDynamicProperty(const char* name) {
|
||||
return props->removeDynamicProperty(name);
|
||||
}
|
||||
std::vector<std::string> getDynamicPropertyNames() const {
|
||||
return props->getDynamicPropertyNames();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,14 @@
|
|||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="removeProperty">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
removeProperty(string) -- Remove a generic property.
|
||||
Note, you can only remove user-defined properties but not built-in ones.
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="supportedProperties">
|
||||
<Documentation>
|
||||
<UserDocu>A list of supported property types</UserDocu>
|
||||
|
|
|
@ -84,6 +84,16 @@ PyObject* ViewProviderPythonFeaturePy::addProperty(PyObject *args)
|
|||
return Py::new_reference_to(this);
|
||||
}
|
||||
|
||||
PyObject* ViewProviderPythonFeaturePy::removeProperty(PyObject *args)
|
||||
{
|
||||
char *sName;
|
||||
if (!PyArg_ParseTuple(args, "s", &sName))
|
||||
return NULL;
|
||||
|
||||
bool ok = getViewProviderPythonFeaturePtr()->removeDynamicProperty(sName);
|
||||
return Py_BuildValue("O", (ok ? Py_True : Py_False));
|
||||
}
|
||||
|
||||
PyObject* ViewProviderPythonFeaturePy::supportedProperties(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) // convert args: Python->C
|
||||
|
|
Loading…
Reference in New Issue
Block a user