diff --git a/src/App/DynamicProperty.h b/src/App/DynamicProperty.h index afff5016e7..8423e1b2ca 100644 --- a/src/App/DynamicProperty.h +++ b/src/App/DynamicProperty.h @@ -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; diff --git a/src/App/FeaturePython.h b/src/App/FeaturePython.h index d0bc3fc473..1c706848c1 100644 --- a/src/App/FeaturePython.h +++ b/src/App/FeaturePython.h @@ -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 */ diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index 1450d79315..5dea4b36bb 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -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 diff --git a/src/App/PropertyContainer.h b/src/App/PropertyContainer.h index 7bb54dfb10..8b134c3de5 100644 --- a/src/App/PropertyContainer.h +++ b/src/App/PropertyContainer.h @@ -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, diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index 478c087201..8798739708 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -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 diff --git a/src/Gui/ViewProviderPythonFeature.h b/src/Gui/ViewProviderPythonFeature.h index 1e0eb82e06..4ee3b9580d 100644 --- a/src/Gui/ViewProviderPythonFeature.h +++ b/src/Gui/ViewProviderPythonFeature.h @@ -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 */ diff --git a/src/Gui/propertyeditor/PropertyModel.cpp b/src/Gui/propertyeditor/PropertyModel.cpp index 04a89ba549..6b83f67997 100644 --- a/src/Gui/propertyeditor/PropertyModel.cpp +++ b/src/Gui/propertyeditor/PropertyModel.cpp @@ -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); } diff --git a/src/Mod/Spreadsheet/App/Sheet.h b/src/Mod/Spreadsheet/App/Sheet.h index 6f70c1edb4..b84393f1fe 100644 --- a/src/Mod/Spreadsheet/App/Sheet.h +++ b/src/Mod/Spreadsheet/App/Sheet.h @@ -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);