This class is a generic editable object. More...
#include <bpspropertyobject.h>
Public Slots | |
void | setModified (bool aModified=true) |
Set or clear the modification status. More... | |
virtual bool | setProperty (const char *aName, const QVariant &aValue) |
Set the value of a property. More... | |
bool | setPropertyAsString (const char *aName, const QString &aValue) |
Set the value of a property by converting from a string. More... | |
Signals | |
void | childInserted (int aIndex, BpsPropertyObject *aChild) |
This signal is emitted when a new child is inserted. More... | |
void | childMoved (int aOldIndex, int aNewIndex) |
This signal is emitted when a child is moved. More... | |
void | childRemoved (int aIndex, BpsPropertyObject *aChild) |
This signal is emitted when a child is removed. More... | |
void | modifiedChanged (bool aModified) |
This signal is emitted when the modification status is changed. More... | |
void | objectChanged () |
This signal is emitted whenever anything in the object or any of its descendants (children, grandchildren, ...) is changed. More... | |
void | propertyChanged (const QByteArray &aName, const QVariant &aNewValue, const QVariant &aOldValue) |
This signal is emitted whenever a property changes, or after emitValues(). More... | |
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. More... | |
void | addProperty (const char *aName, const QVariant &aValue) |
Add or remove a property. More... | |
void | appendChild (BpsPropertyObject *aChild) |
Appends a child to the end of the children list. More... | |
QVariant | attribute (const char *aProperty, const char *aAttribute) const |
Get the attributes value. More... | |
QList< QByteArray > | attributeNames (const char *aProperty) const |
Get a list of all attributes defined for a certain property. More... | |
BpsPropertyObject (const BpsPropertyObject &aOther) | |
Copy-constructor for BpsPropertyObject. More... | |
BpsPropertyObject (const QString &aName, QObject *aParent=nullptr) | |
Constructor for BpsPropertyObject. More... | |
BpsPropertyObject (QObject *aParent=nullptr) | |
Constructor for BpsPropertyObject. More... | |
BpsPropertyObject * | childAt (int aIndex) const |
Get pointer to indexed child element. More... | |
int | childCount () const |
int | childIndex (BpsPropertyObject *aChild) const |
Get index of a child. More... | |
QList< BpsPropertyObject * > | children () const |
void | clear () |
Removes all dynamic properties and deletes all children. More... | |
void | emitValues () |
Emits valueChanged() for all properties. | |
bool | hasProperty (const char *aName) const |
Check if a property with given name has been added by BpsPropertyObject::addProperty(). More... | |
void | insertChild (int aIndex, BpsPropertyObject *aChild) |
Insert a child at the specified position in the children list. More... | |
bool | isModified () const |
bool | isValid (BpsPropertyObject *aObject) const |
void | loadXml (const QString &aDocType, const QString &aXml) |
Load the object from XML. More... | |
QString | makeXml (const QString &aDocType, bool aFormat=false) const |
Creates XML to save the object and its children. More... | |
void | moveChild (int aOldIndex, int aNewIndex) |
Move a child in the list. More... | |
BpsPropertyObject & | operator= (const BpsPropertyObject &aOther) |
Assignment operator. More... | |
BpsPropertyObject * | parent () const |
Get the parent of this object. More... | |
QString | propertyAsString (const char *aName) const |
Gets a string representation of the value. More... | |
BpsPropertyObject * | removeChild (BpsPropertyObject *aChild) |
Remove a child. More... | |
BpsPropertyObject * | removeChild (int aIndex) |
Remove a child. More... | |
![]() | |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
QObject (QObject *parent) | |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
Protected Member Functions | |
virtual BpsPropertyObject * | xmlCreateObject (const QString &aTagName, int aLevel) const |
Create a new object while processing loadXml(). More... | |
virtual QString | xmlTagName (int aLevel) const |
Define a XML tag for the element of the level. More... | |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
![]() | |
typedef | QObjectList |
![]() | |
objectName | |
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 = nullptr | ) |
Constructor for BpsPropertyObject.
aParent | The parent widget. |
Constructor for BpsPropertyObject.
aName | The object name to set. |
aParent | The parent widget. |
BpsPropertyObject::BpsPropertyObject | ( | const BpsPropertyObject & | aOther | ) |
Copy-constructor for BpsPropertyObject.
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 |
aProperty | Name of the property. |
aAttribute | The attribute name. |
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.
aName | Name of the property. |
aValue | The attribute value. |
void BpsPropertyObject::appendChild | ( | BpsPropertyObject * | aChild | ) |
Appends a child to the end of the children list.
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.
aProperty | Name of the property. |
aAttribute | The attribute name. |
QList<QByteArray> BpsPropertyObject::attributeNames | ( | const char * | aProperty | ) | const |
Get a list of all attributes defined for a certain property.
aProperty | Name of the property. |
BpsPropertyObject* BpsPropertyObject::childAt | ( | int | aIndex | ) | const |
Get pointer to indexed child element.
aIndex | The index of the requested child. |
int BpsPropertyObject::childCount | ( | ) | const |
int BpsPropertyObject::childIndex | ( | BpsPropertyObject * | aChild | ) | const |
Get index of a child.
aChild | This is a parameter. |
|
signal |
This signal is emitted when a new child is inserted.
aIndex | Index of the new child. |
aChild | Pointer to the new child. |
|
signal |
This signal is emitted when a child is moved.
aOldIndex | The former index of the child. |
aNewIndex | The new index of the child. |
|
signal |
This signal is emitted when a child is removed.
ATTENTION! Both, index and child pointer are now invalid!
aIndex | Former index of the removed child. |
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.
bool BpsPropertyObject::hasProperty | ( | const char * | aName | ) | const |
Check if a property with given name has been added by BpsPropertyObject::addProperty().
This is a convenience function for QObject::dynamicPropertyNames().contains(aName).
aName | Name of the property. |
void BpsPropertyObject::insertChild | ( | int | aIndex, |
BpsPropertyObject * | aChild | ||
) |
Insert a child at the specified position in the children list.
aIndex | The position to insert at. |
aChild | Pointer to the child to be inserted. |
bool BpsPropertyObject::isModified | ( | ) | const |
bool BpsPropertyObject::isValid | ( | BpsPropertyObject * | aObject | ) | const |
aObject | Object to check. |
Load the object from XML.
aDocType | DOCTYPE to check. No check when empty string. |
aXml | String with the XML representation of the object to be loaded. |
Creates XML to save the object and its children.
aDocType | DOCTYPE to use. |
aFormat | Format the XML with newlines and indentions. |
|
signal |
This signal is emitted when the modification status is changed.
aModified | The new modification status. |
void BpsPropertyObject::moveChild | ( | int | aOldIndex, |
int | aNewIndex | ||
) |
Move a child in the list.
aOldIndex | Index of the old position. |
aNewIndex | Index of the new position. |
|
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.
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().
aName | Name of the property. |
|
signal |
This signal is emitted whenever a property changes, or after emitValues().
aName | The name of the property. |
aNewValue | The new value. |
aOldValue | The previous value. Note that this is equal to aNewValue when emit was done by emitValues(). |
BpsPropertyObject* BpsPropertyObject::removeChild | ( | BpsPropertyObject * | aChild | ) |
Remove a child.
The child itself is not deleted, but it's parent is set to 0.
aChild | Pointer to the child to be removed. |
BpsPropertyObject* BpsPropertyObject::removeChild | ( | int | aIndex | ) |
Remove a child.
The child itself is not deleted, but it's parent is set to 0.
aIndex | Index of the child to be removed. |
|
slot |
Set or clear the modification status.
aModified | The new status to set. |
|
virtualslot |
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.
aName | Name of the property. |
aValue | The new value. |
|
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.
aName | Name of the property. |
aValue | The new value. |
|
protectedvirtual |
Create a new object while processing loadXml().
The default implementation returns a new BpsPropertyObject.
aTagName | Tag name of the element to be created. |
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.
|
protectedvirtual |
Define a XML tag for the element of the level.
aLevel | Element level. The top level is 0. |
Reimplemented in BpsReportElement.