53 VProperty* tmpParent = parentid.isEmpty() ? nullptr : getProperty(parentid);
54 return addProperty(property,
id, tmpParent);
65 QString tmpOldID = getPropertyID(property);
66 if (!tmpOldID.isEmpty())
68 d_ptr->Properties.remove(tmpOldID);
77 d_ptr->RootProperties.append(property);
80 property->getParent()->removeChild(property);
86 d_ptr->Properties.insert(
id, property);
99 return hasProperty(property,
nullptr);
104 return d_ptr->Properties.value(
id,
nullptr);
110 removeProperty(tmpProp,
false);
125 removePropertyFromSet(prop);
138 return d_ptr->Properties.count();
143 d_ptr->Properties.clear();
144 while (!d_ptr->RootProperties.isEmpty())
146 VProperty* tmpProp = d_ptr->RootProperties.takeLast();
147 if (tmpProp !=
nullptr && delete_properties)
159 while (tmpCurrentProp && (look_for_parent_id || prop == tmpCurrentProp) )
167 i != d_ptr->Properties.constEnd(); ++i)
169 if (tmpCurrentProp == (*i))
175 tmpCurrentProp = tmpCurrentProp->
getParent();
185 return d_ptr->Properties;
190 return d_ptr->RootProperties;
195 return d_ptr->RootProperties.value(row,
nullptr);
200 return d_ptr->RootProperties.count();
207 foreach(
VProperty* tmpProperty, d_ptr->RootProperties)
208 cloneProperty(tmpProperty,
nullptr, tmpResult);
222 foreach(
VProperty* tmpProp, tmpChildrenList)
228 else if (tmpProp == property || hasProperty(property, tmpProp))
240 if (!output_set || !property_to_clone || !hasProperty(property_to_clone))
245 QString tmpID = getPropertyID(property_to_clone,
false);
250 output_set->
addProperty(tmpNewProperty, tmpID, parent_property);
251 for (
int i = 0; i < property_to_clone->
getRowCount(); ++i)
253 cloneProperty(property_to_clone->
getChild(i), tmpNewProperty, output_set);
261 removeProperty(tmpChild);
265 foreach(
const QString& tmpID, tmpKeys)
266 d_ptr->Properties.remove(tmpID);
269 d_ptr->RootProperties.removeAll(prop);
VPropertySet is a simple class for managing a set of properties. If you don't need all the Model-func...
virtual void removeProperty(const QString &id)
Removes a property from the set and deletes it.
Q_REQUIRED_RESULT VPropertySet * clone() const
Clones the property set.
virtual void clear(bool delete_properties=true)
Clears the set and (optionally) deletes all properties.
virtual ~VPropertySet()
Destructor.
VProperty * getRootProperty(int row) const
Returns the root property in a certain row.
virtual bool addProperty(VProperty *property, const QString &id, const QString &parentid)
Adds the property to the model and attaches it to the parentid. Note that if the property has a paren...
virtual int count() const
Returns the number of properties with in ID that are directly accessable by getProperty()
VPropertySet()
Default constructor, creating an empty property set.
virtual QString getPropertyID(const VProperty *prop, bool look_for_parent_id=true) const
Returns the ID of the property within the set The concept of property IDs is, that the object that ma...
virtual void removePropertyFromSet(VProperty *prop)
Recursivly removes a property's child properties from the set, but not from the parent.
virtual bool hasProperty(VProperty *property) const
Checks whether a property belongs to this set and returns the result.
virtual VProperty * getProperty(const QString &id) const
Gets a property by it's ID.
void cloneProperty(VProperty *property_to_clone, VProperty *parent_property, VPropertySet *output_set) const
Clones a property into another property set.
int getRootPropertyCount() const
Returns the number of independent properties.
const QMap< QString, VProperty * > & getPropertiesMap() const
Returns a const reference to the map of properties.
const QList< VProperty * > & getRootProperties() const
Returns a const reference to the list of root properties.
virtual VProperty * takeProperty(const QString &id)
Removes a property from the set and returns it.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const
Clones this property.
virtual int getRowCount() const
Gets the number of children.
virtual VProperty * getParent() const
Gets the parent of this property.
virtual int addChild(VProperty *child)
Adds a child to this property.
virtual VProperty * getChild(int row) const
Returns the child at a certain row.
virtual void setParent(VProperty *parent)
Sets the parent of this property.
virtual QList< VProperty * > & getChildren()
Returns a reference to the list of children.