BPS C++ API  2.24.4
BpsPropertyObject Class Reference

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. 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< QByteArrayattributeNames (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...
 
BpsPropertyObjectchildAt (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...
 
BpsPropertyObjectoperator= (const BpsPropertyObject &aOther)
 Assignment operator. More...
 
BpsPropertyObjectparent () const
 Get the parent of this object. More...
 
QString propertyAsString (const char *aName) const
 Gets a string representation of the value. More...
 
BpsPropertyObjectremoveChild (BpsPropertyObject *aChild)
 Remove a child. More...
 
BpsPropertyObjectremoveChild (int aIndex)
 Remove a child. More...
 
- Public Member Functions inherited from QObject
bool blockSignals (bool block)
 
const QObjectListchildren () 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< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, 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 QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () 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
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
 QObject (QObject *parent)
 
qobject_cast (const QObject *object)
 
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)
 
QThreadthread () const const
 

Protected Member Functions

virtual BpsPropertyObjectxmlCreateObject (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...
 
- Protected Member Functions inherited from QObject
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
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
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)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Properties inherited from QObject
 objectName
 

Detailed Description

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().

Constructor & Destructor Documentation

◆ BpsPropertyObject() [1/3]

BpsPropertyObject::BpsPropertyObject ( QObject aParent = nullptr)

Constructor for BpsPropertyObject.

Parameters
aParentThe parent widget.

◆ BpsPropertyObject() [2/3]

BpsPropertyObject::BpsPropertyObject ( const QString aName,
QObject aParent = nullptr 
)

Constructor for BpsPropertyObject.

Parameters
aNameThe object name to set.
aParentThe parent widget.

◆ BpsPropertyObject() [3/3]

BpsPropertyObject::BpsPropertyObject ( const BpsPropertyObject aOther)

Copy-constructor for BpsPropertyObject.

Parameters
aOtherThe source property to clone.

Member Function Documentation

◆ addAttribute()

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
Parameters
aPropertyName of the property.
aAttributeThe attribute name.
aValueThe attribute value.

◆ addProperty()

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.

Parameters
aNameName of the property.
aValueThe attribute value.

◆ appendChild()

void BpsPropertyObject::appendChild ( BpsPropertyObject aChild)

Appends a child to the end of the children list.

Parameters
aChildPointer to the child to be inserted.

◆ attribute()

QVariant BpsPropertyObject::attribute ( const char *  aProperty,
const char *  aAttribute 
) const

Get the attributes value.

In case there is no such attribute, QVariant() is returned.

Parameters
aPropertyName of the property.
aAttributeThe attribute name.
Returns
A QVariant is returned.

◆ attributeNames()

QList<QByteArray> BpsPropertyObject::attributeNames ( const char *  aProperty) const

Get a list of all attributes defined for a certain property.

Parameters
aPropertyName of the property.
Returns
A list of attribute names.

◆ childAt()

BpsPropertyObject* BpsPropertyObject::childAt ( int  aIndex) const

Get pointer to indexed child element.

Parameters
aIndexThe index of the requested child.
Returns
Pointer to child.

◆ childCount()

int BpsPropertyObject::childCount ( ) const
Returns
The number of children of this element.

◆ childIndex()

int BpsPropertyObject::childIndex ( BpsPropertyObject aChild) const

Get index of a child.

Parameters
aChildThis is a parameter.
Returns
Child index, or -1 if no such child found.

◆ childInserted

void BpsPropertyObject::childInserted ( int  aIndex,
BpsPropertyObject aChild 
)
signal

This signal is emitted when a new child is inserted.

Parameters
aIndexIndex of the new child.
aChildPointer to the new child.

◆ childMoved

void BpsPropertyObject::childMoved ( int  aOldIndex,
int  aNewIndex 
)
signal

This signal is emitted when a child is moved.

Parameters
aOldIndexThe former index of the child.
aNewIndexThe new index of the child.

◆ childRemoved

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!

Parameters
aIndexFormer index of the removed child.
aChildFormer pointer to the new child.

◆ children()

QList<BpsPropertyObject*> BpsPropertyObject::children ( ) const
Returns
The list of children.

◆ clear()

void BpsPropertyObject::clear ( )

Removes all dynamic properties and deletes all children.

The object name stays.

◆ hasProperty()

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).

Parameters
aNameName of the property.
Returns
True if the property is present.

◆ insertChild()

void BpsPropertyObject::insertChild ( int  aIndex,
BpsPropertyObject aChild 
)

Insert a child at the specified position in the children list.

Parameters
aIndexThe position to insert at.
aChildPointer to the child to be inserted.

◆ isModified()

bool BpsPropertyObject::isModified ( ) const
Returns
True if the item has been modified.

◆ isValid()

bool BpsPropertyObject::isValid ( BpsPropertyObject aObject) const
Parameters
aObjectObject to check.
Returns
True if the object belongs to this item (is this item itself or any descendant).

◆ loadXml()

void BpsPropertyObject::loadXml ( const QString aDocType,
const QString aXml 
)

Load the object from XML.

Parameters
aDocTypeDOCTYPE to check. No check when empty string.
aXmlString with the XML representation of the object to be loaded.

◆ makeXml()

QString BpsPropertyObject::makeXml ( const QString aDocType,
bool  aFormat = false 
) const

Creates XML to save the object and its children.

Parameters
aDocTypeDOCTYPE to use.
aFormatFormat the XML with newlines and indentions.
Returns
A QString with the XML representation of the object and it's children.

◆ modifiedChanged

void BpsPropertyObject::modifiedChanged ( bool  aModified)
signal

This signal is emitted when the modification status is changed.

Parameters
aModifiedThe new modification status.

◆ moveChild()

void BpsPropertyObject::moveChild ( int  aOldIndex,
int  aNewIndex 
)

Move a child in the list.

Parameters
aOldIndexIndex of the old position.
aNewIndexIndex of the new position.

◆ objectChanged

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().

◆ operator=()

BpsPropertyObject& BpsPropertyObject::operator= ( const BpsPropertyObject aOther)

Assignment operator.

Parameters
aOtherThe source property to clone.
Returns
Reference to the current object.

◆ parent()

BpsPropertyObject* BpsPropertyObject::parent ( ) const

Get the parent of this object.

Returns
The parent of this element, or 0 if this is a top level element.

◆ propertyAsString()

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().

Parameters
aNameName of the property.
Returns
The value of the named property represented as string.

◆ propertyChanged

void BpsPropertyObject::propertyChanged ( const QByteArray aName,
const QVariant aNewValue,
const QVariant aOldValue 
)
signal

This signal is emitted whenever a property changes, or after emitValues().

Parameters
aNameThe name of the property.
aNewValueThe new value.
aOldValueThe previous value. Note that this is equal to aNewValue when emit was done by emitValues().

◆ removeChild() [1/2]

BpsPropertyObject* BpsPropertyObject::removeChild ( BpsPropertyObject aChild)

Remove a child.

The child itself is not deleted, but it's parent is set to 0.

Parameters
aChildPointer to the child to be removed.
Returns
Pointer to removed child, or 0 if no such child found.

◆ removeChild() [2/2]

BpsPropertyObject* BpsPropertyObject::removeChild ( int  aIndex)

Remove a child.

The child itself is not deleted, but it's parent is set to 0.

Parameters
aIndexIndex of the child to be removed.
Returns
Pointer to removed child, or 0 if index out of bounds.

◆ setModified

void BpsPropertyObject::setModified ( bool  aModified = true)
slot

Set or clear the modification status.

Parameters
aModifiedThe new status to set.

◆ setProperty

virtual bool BpsPropertyObject::setProperty ( const char *  aName,
const QVariant aValue 
)
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.

Parameters
aNameName of the property.
aValueThe new value.
Returns
True if the value was modified.

◆ setPropertyAsString

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.

Parameters
aNameName of the property.
aValueThe new value.
Returns
True if the value was modified.

◆ xmlCreateObject()

virtual BpsPropertyObject* BpsPropertyObject::xmlCreateObject ( const QString aTagName,
int  aLevel 
) const
protectedvirtual

Create a new object while processing loadXml().

The default implementation returns a new BpsPropertyObject.

Parameters
aTagNameTag name of the element to be created.
aLevelElement level. The top level is 0, but this method will only be called for children of level 1 and up.
Returns
A BpsPropertyObject*, or a thereof derived object. Return 0 if no object can be created for the given name and level.

Reimplemented in BpsReportElement.

◆ xmlTagName()

virtual QString BpsPropertyObject::xmlTagName ( int  aLevel) const
protectedvirtual

Define a XML tag for the element of the level.

Parameters
aLevelElement level. The top level is 0.
Returns
Tag name. The default implementation returns object{level}.

Reimplemented in BpsReportElement.


The documentation for this class was generated from the following file: