| 161 | } |
| 162 | |
| 163 | PyObject* PropertyContainerPy::setEditorMode(PyObject* args) |
| 164 | { |
| 165 | char* name {}; |
| 166 | short type {}; |
| 167 | if (PyArg_ParseTuple(args, "sh", &name, &type)) { |
| 168 | App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name); |
| 169 | if (!prop) { |
| 170 | PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", name); |
| 171 | return nullptr; |
| 172 | } |
| 173 | |
| 174 | std::bitset<32> status(prop->getStatus()); |
| 175 | status.set(Property::ReadOnly, (type & 1) > 0); |
| 176 | status.set(Property::Hidden, (type & 2) > 0); |
| 177 | prop->setStatusValue(status.to_ulong()); |
| 178 | |
| 179 | Py_Return; |
| 180 | } |
| 181 | |
| 182 | PyErr_Clear(); |
| 183 | PyObject* iter {}; |
| 184 | if (PyArg_ParseTuple(args, "sO", &name, &iter)) { |
| 185 | if (PyTuple_Check(iter) || PyList_Check(iter)) { |
| 186 | Py::Sequence seq(iter); |
| 187 | App::Property* prop = getPropertyContainerPtr()->getPropertyByName(name); |
| 188 | if (!prop) { |
| 189 | PyErr_Format(PyExc_AttributeError, "Property container has no property '%s'", name); |
| 190 | return nullptr; |
| 191 | } |
| 192 | |
| 193 | // reset all bits first |
| 194 | std::bitset<32> status(prop->getStatus()); |
| 195 | status.reset(Property::ReadOnly); |
| 196 | status.reset(Property::Hidden); |
| 197 | for (Py::Sequence::iterator it = seq.begin(); it != seq.end(); ++it) { |
| 198 | std::string str = static_cast<std::string>(Py::String(*it)); |
| 199 | if (str == "ReadOnly") { |
| 200 | status.set(Property::ReadOnly); |
| 201 | } |
| 202 | else if (str == "Hidden") { |
| 203 | status.set(Property::Hidden); |
| 204 | } |
| 205 | } |
| 206 | prop->setStatusValue(status.to_ulong()); |
| 207 | |
| 208 | Py_Return; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | PyErr_SetString(PyExc_TypeError, |
| 213 | "First argument must be str, second can be int, list or tuple"); |
| 214 | return nullptr; |
| 215 | } |
| 216 | |
| 217 | static const std::map<std::string, int>& getStatusMap() |
| 218 | { |
nothing calls this directly
no test coverage detected