This class is a generic editable object. More...
#include <bpspropertyobject.h>
Inheritance diagram for BpsPropertyObject:Public Slots | |
| void | setModified (bool aModified=true) |
| Set or clear the modification status. | |
| virtual bool | setProperty (const char *aName, const QVariant &aValue) |
| Set the value of a property. | |
| bool | setPropertyAsString (const char *aName, const QString &aValue) |
| Set the value of a property by converting from a string. | |
Signals | |
| void | childInserted (int aIndex, BpsPropertyObject *aChild) |
| This signal is emitted when a new child is inserted. | |
| void | childMoved (int aOldIndex, int aNewIndex) |
| This signal is emitted when a child is moved. | |
| void | childRemoved (int aIndex, BpsPropertyObject *aChild) |
| This signal is emitted when a child is removed. | |
| void | modifiedChanged (bool aModified) |
| This signal is emitted when the modification status is changed. | |
| void | objectChanged () |
| This signal is emitted whenever anything in the object or any of its descendants (children, grandchildren, ...) is changed. | |
| void | propertyChanged (const QByteArray &aName, const QVariant &aNewValue, const QVariant &aOldValue) |
| This signal is emitted whenever a property changes, or after emitValues(). | |
Public Member Functions | |
| void | addAttribute (const char *aProperty, const char *aAttribute, const QVariant &aValue=true) |
| Adds or remove an attribute to/from an existing property. | |
| void | addProperty (const char *aName, const QVariant &aValue) |
| Add or remove a property. | |
| void | appendChild (BpsPropertyObject *aChild) |
| Appends a child to the end of the children list. | |
| QVariant | attribute (const char *aProperty, const char *aAttribute) const |
| Get the attributes value. | |
| QList< QByteArray > | attributeNames (const char *aProperty) const |
| Get a list of all attributes defined for a certain property. | |
| BpsPropertyObject (QObject *aParent=0) | |
| Constructor for BpsPropertyObject. | |
| BpsPropertyObject (const QString &aName, QObject *aParent=0) | |
| Constructor for BpsPropertyObject. | |
| BpsPropertyObject (const BpsPropertyObject &aOther) | |
| Copy-constructor for BpsPropertyObject. | |
| BpsPropertyObject * | childAt (int aIndex) const |
| Get pointer to indexed child element. | |
| int | childCount () const |
| int | childIndex (BpsPropertyObject *aChild) const |
| Get index of a child. | |
| QList< BpsPropertyObject * > | children () const |
| void | clear () |
| Removes all dynamic properties and deletes all children. | |
| void | emitValues () |
| Emits valueChanged() for all properties. | |
| void | insertChild (int aIndex, BpsPropertyObject *aChild) |
| Insert a child at the specified position in the children list. | |
| bool | isModified () const |
| bool | isValid (BpsPropertyObject *aObject) const |
| void | loadXml (const QString &aDocType, const QString &aXml) |
| Load the object from XML. | |
| QString | makeXml (const QString &aDocType, bool aFormat=false) const |
| Creates XML to save the object and its children. | |
| void | moveChild (int aOldIndex, int aNewIndex) |
| Move a child in the list. | |
| BpsPropertyObject & | operator= (const BpsPropertyObject &aOther) |
| Assignment operator. | |
| BpsPropertyObject * | parent () const |
| Get the parent of this object. | |
| QString | propertyAsString (const char *aName) const |
| Gets a string representation of the value. | |
| BpsPropertyObject * | removeChild (int aIndex) |
| Remove a child. | |
Protected Member Functions | |
| virtual BpsPropertyObject * | xmlCreateObject (const QString &aTagName, int aLevel) const |
| Create a new object while processing loadXml(). | |
| virtual QString | xmlTagName (int aLevel) const |
| Define a XML tag for the element of the level. | |
This class is a generic editable object.
Query the property value with QObject::property(const char* name). If the property does not exist, an invalid value will be returned.
A list of all existing properties can be fetched with QObject::dynamicPropertyNames().
| BpsPropertyObject::BpsPropertyObject | ( | QObject * | aParent = 0 | ) |
Constructor for BpsPropertyObject.
| [in] | aParent | The parent widget. |
| BpsPropertyObject::BpsPropertyObject | ( | const QString & | aName, |
| QObject * | aParent = 0 |
||
| ) |
Constructor for BpsPropertyObject.
| [in] | aName | The object name to set. |
| [in] | aParent | The parent widget. |
| BpsPropertyObject::BpsPropertyObject | ( | const BpsPropertyObject & | aOther | ) |
Copy-constructor for BpsPropertyObject.
| [in] | aOther | The source property to clone. |
| void BpsPropertyObject::addAttribute | ( | const char * | aProperty, |
| const char * | aAttribute, | ||
| const QVariant & | aValue = true |
||
| ) |
Adds or remove an attribute to/from an existing property.
In case the attribute for this property did already exist, it's value is overwritten. Passing an invalid value will remove the attribute.
The currently supported attributes are:
| Attribute Name | Remark | Attribute Type | Property Types |
| readOnly | setValue() does not change the value | QVariant::Bool | any |
| noExport | Do not export this property to XML | QVariant::Bool | any |
| noImport | Do not import this property from XML | QVariant::Bool | any |
| xmlElement | Save as separate XML element instead of as attibute. | QVariant::Bool | any |
| [in] | aProperty | Name of the property. |
| [in] | aAttribute | The attribute name. |
| [in] | aValue | The attribute value. |
| void BpsPropertyObject::addProperty | ( | const char * | aName, |
| const QVariant & | aValue | ||
| ) |
Add or remove a property.
Make sure to pass an initial value of the desired type. Remove a property by passing an invalid value.
| [in] | aName | Name of the property. |
| [in] | aValue | The attribute value. |
| void BpsPropertyObject::appendChild | ( | BpsPropertyObject * | aChild | ) |
Appends a child to the end of the children list.
| [in] | aChild | Pointer to the child to be inserted. |
| QVariant BpsPropertyObject::attribute | ( | const char * | aProperty, |
| const char * | aAttribute | ||
| ) | const |
Get the attributes value.
In case there is no such attribute, QVariant() is returned.
| [in] | aProperty | Name of the property. |
| [in] | aAttribute | The attribute name. |
| QList<QByteArray> BpsPropertyObject::attributeNames | ( | const char * | aProperty | ) | const |
Get a list of all attributes defined for a certain property.
| [in] | aProperty | Name of the property. |
| BpsPropertyObject* BpsPropertyObject::childAt | ( | int | aIndex | ) | const |
Get pointer to indexed child element.
| [in] | aIndex | The index of the requested child. |
| int BpsPropertyObject::childCount | ( | ) | const |
| int BpsPropertyObject::childIndex | ( | BpsPropertyObject * | aChild | ) | const |
Get index of a child.
| [in] | aChild | This is a parameter. |
| void BpsPropertyObject::childInserted | ( | int | aIndex, |
| BpsPropertyObject * | aChild | ||
| ) | [signal] |
This signal is emitted when a new child is inserted.
| [in] | aIndex | Index of the new child. |
| [in] | aChild | Pointer to the new child. |
| void BpsPropertyObject::childMoved | ( | int | aOldIndex, |
| int | aNewIndex | ||
| ) | [signal] |
This signal is emitted when a child is moved.
| [in] | aOldIndex | The former index of the child. |
| [in] | aNewIndex | The new index of the child. |
| void BpsPropertyObject::childRemoved | ( | int | aIndex, |
| BpsPropertyObject * | aChild | ||
| ) | [signal] |
This signal is emitted when a child is removed.
ATTENTION! Both, index and child pointer are now invalid!
| [in] | aIndex | Former index of the removed child. |
| [in] | aChild | Former pointer to the new child. |
| QList<BpsPropertyObject*> BpsPropertyObject::children | ( | ) | const |
| void BpsPropertyObject::clear | ( | ) |
Removes all dynamic properties and deletes all children.
The object name stays.
| void BpsPropertyObject::insertChild | ( | int | aIndex, |
| BpsPropertyObject * | aChild | ||
| ) |
Insert a child at the specified position in the children list.
| [in] | aIndex | The position to insert at. |
| [in] | aChild | Pointer to the child to be inserted. |
| bool BpsPropertyObject::isModified | ( | ) | const |
| bool BpsPropertyObject::isValid | ( | BpsPropertyObject * | aObject | ) | const |
| [in] | aObject | Object to check. |
| void BpsPropertyObject::loadXml | ( | const QString & | aDocType, |
| const QString & | aXml | ||
| ) |
Load the object from XML.
| [in] | aDocType | DOCTYPE to check. No check when empty string. |
| [in] | aXml | String with the XML representation of the object to be loaded. |
| QString BpsPropertyObject::makeXml | ( | const QString & | aDocType, |
| bool | aFormat = false |
||
| ) | const |
Creates XML to save the object and its children.
| [in] | aDocType | DOCTYPE to use. |
| [in] | aFormat | Format the XML with newlines and indentions. |
| void BpsPropertyObject::modifiedChanged | ( | bool | aModified | ) | [signal] |
This signal is emitted when the modification status is changed.
| [in] | aModified | The new modification status. |
| void BpsPropertyObject::moveChild | ( | int | aOldIndex, |
| int | aNewIndex | ||
| ) |
Move a child in the list.
| [in] | aOldIndex | Index of the old position. |
| [in] | aNewIndex | Index of the new position. |
| void BpsPropertyObject::objectChanged | ( | ) | [signal] |
This signal is emitted whenever anything in the object or any of its descendants (children, grandchildren, ...) is changed.
It may be any property add/remove/change, attribute add/remove/change, child add/remove/move. This signal is not be emitted by emitValues() or setModified().
| BpsPropertyObject& BpsPropertyObject::operator= | ( | const BpsPropertyObject & | aOther | ) |
Assignment operator.
| [in] | aOther | The source property to clone. |
| BpsPropertyObject* BpsPropertyObject::parent | ( | ) | const |
Get the parent of this object.
| QString BpsPropertyObject::propertyAsString | ( | const char * | aName | ) | const |
Gets a string representation of the value.
This representation is also used for XML file generation.
Special conversions are made for types listed in the table below:
| Type | Representation |
| QVariant::PointF | x,y |
| QVariant::SizeF | width,height |
| QVariant::Color | #AARRGGBB where RR,GG,BB are the red green and blue values in hex, and AA is the alpha-channel (transparency) in hex |
Any other types are returned as by QVariant::toString().
| [in] | aName | Name of the property. |
| void BpsPropertyObject::propertyChanged | ( | const QByteArray & | aName, |
| const QVariant & | aNewValue, | ||
| const QVariant & | aOldValue | ||
| ) | [signal] |
This signal is emitted whenever a property changes, or after emitValues().
| [in] | aName | The name of the property. |
| [in] | aNewValue | The new value. |
| [in] | aOldValue | The previous value. Note that this is equal to aNewValue when emit was done by emitValues(). |
| BpsPropertyObject* BpsPropertyObject::removeChild | ( | int | aIndex | ) |
Remove a child.
The child itself is not deleted, but it's parent is set to 0.
| [in] | aIndex | Index of the child to be removed. |
| void BpsPropertyObject::setModified | ( | bool | aModified = true | ) | [slot] |
Set or clear the modification status.
| [in] | aModified | The new status to set. |
| virtual bool BpsPropertyObject::setProperty | ( | const char * | aName, |
| const QVariant & | aValue | ||
| ) | [virtual, slot] |
Set the value of a property.
Attempts to set the value of a not existing property, or a property with the attribute readOnly are ignored.
| [in] | aName | Name of the property. |
| [in] | aValue | The new value. |
Reimplemented in BpsReportElement.
| bool BpsPropertyObject::setPropertyAsString | ( | const char * | aName, |
| const QString & | aValue | ||
| ) | [slot] |
Set the value of a property by converting from a string.
See propertyAsString(const char* aName) for string format information.
After string conversion, setValue(const QString& aName, const QVariant& aValue) is called to effectively save the value.
| [in] | aName | Name of the property. |
| [in] | aValue | The new value. |
| virtual BpsPropertyObject* BpsPropertyObject::xmlCreateObject | ( | const QString & | aTagName, |
| int | aLevel | ||
| ) | const [protected, virtual] |
Create a new object while processing loadXml().
The default implementation returns a new BpsPropertyObject.
| [in] | aTagName | Tag name of the element to be created. |
| [in] | aLevel | Element level. The top level is 0, but this method will only be called for children of level 1 and up. |
Reimplemented in BpsReportElement.
| virtual QString BpsPropertyObject::xmlTagName | ( | int | aLevel | ) | const [protected, virtual] |
Define a XML tag for the element of the level.
| [in] | aLevel | Element level. The top level is 0. |
Reimplemented in BpsReportElement.