+ Add method getEditorMode() to see if a property is hidden or read-only in the property editor
This commit is contained in:
parent
dc7ccc41af
commit
c54311123b
|
@ -37,6 +37,15 @@
|
||||||
</UserDocu>
|
</UserDocu>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
</Methode>
|
</Methode>
|
||||||
|
<Methode Name="getEditorMode">
|
||||||
|
<Documentation>
|
||||||
|
<UserDocu>Get the behaviour of the property in the property editor.
|
||||||
|
It returns a list of strings with the current mode. If the list is empty there are no special restrictions.
|
||||||
|
If the list contains 'ReadOnly' then the item appears in the property editor but is disabled.
|
||||||
|
If the list contains 'Hidden' then the item even doesn't appear in the property editor.
|
||||||
|
</UserDocu>
|
||||||
|
</Documentation>
|
||||||
|
</Methode>
|
||||||
<Methode Name="getGroupOfProperty">
|
<Methode Name="getGroupOfProperty">
|
||||||
<Documentation>
|
<Documentation>
|
||||||
<UserDocu>Return the name of the group which the property belongs to in this class. The properties sorted in differnt named groups for convenience.</UserDocu>
|
<UserDocu>Return the name of the group which the property belongs to in this class. The properties sorted in differnt named groups for convenience.</UserDocu>
|
||||||
|
|
|
@ -103,15 +103,66 @@ PyObject* PropertyContainerPy::setEditorMode(PyObject *args)
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
short type;
|
short type;
|
||||||
if (!PyArg_ParseTuple(args, "sh", &name, &type)) // convert args: Python->C
|
if (PyArg_ParseTuple(args, "sh", &name, &type)) {
|
||||||
|
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name);
|
||||||
|
if (!prop) {
|
||||||
|
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
prop->StatusBits.set(2,(type & 1) > 0);
|
||||||
|
prop->StatusBits.set(3,(type & 2) > 0);
|
||||||
|
|
||||||
|
Py_Return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyErr_Clear();
|
||||||
|
PyObject *iter;
|
||||||
|
if (PyArg_ParseTuple(args, "sO", &name, &iter)) {
|
||||||
|
if (PyTuple_Check(iter) || PyList_Check(iter)) {
|
||||||
|
Py::Sequence seq(iter);
|
||||||
|
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name);
|
||||||
|
if (!prop) {
|
||||||
|
PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset all bits first
|
||||||
|
prop->StatusBits.reset(2);
|
||||||
|
prop->StatusBits.reset(3);
|
||||||
|
|
||||||
|
for (Py::Sequence::iterator it = seq.begin();it!=seq.end();++it) {
|
||||||
|
std::string str = (std::string)Py::String(*it);
|
||||||
|
if (str == "ReadOnly")
|
||||||
|
prop->StatusBits.set(2);
|
||||||
|
else if (str == "Hidden")
|
||||||
|
prop->StatusBits.set(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_Return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PyErr_SetString(PyExc_TypeError, "First argument must be str, second can be int, list or tuple");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject* PropertyContainerPy::getEditorMode(PyObject *args)
|
||||||
|
{
|
||||||
|
char* name;
|
||||||
|
if (!PyArg_ParseTuple(args, "s", &name)) // convert args: Python->C
|
||||||
return NULL; // NULL triggers exception
|
return NULL; // NULL triggers exception
|
||||||
|
|
||||||
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name);
|
App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name);
|
||||||
|
Py::List ret;
|
||||||
if (prop) {
|
if (prop) {
|
||||||
prop->StatusBits.set(2,(type & 1) > 0);
|
short Type = prop->getType();
|
||||||
prop->StatusBits.set(3,(type & 2) > 0);
|
if ((prop->StatusBits.test(2)) || (Type & Prop_ReadOnly))
|
||||||
|
ret.append(Py::String("ReadOnly"));
|
||||||
|
if ((prop->StatusBits.test(3)) || (Type & Prop_Hidden))
|
||||||
|
ret.append(Py::String("Hidden"));
|
||||||
}
|
}
|
||||||
Py_Return;
|
return Py::new_reference_to(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* PropertyContainerPy::getGroupOfProperty(PyObject *args)
|
PyObject* PropertyContainerPy::getGroupOfProperty(PyObject *args)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user