[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
Public Member Functions
KLFAbstractPropertizedObject Class Reference

An abstract object characterized by properties. More...

#include <klfpobj.h>

Inheritance diagram for KLFAbstractPropertizedObject:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 KLFAbstractPropertizedObject ()
virtual ~KLFAbstractPropertizedObject ()
virtual QString objectKind () const =0
 A string representing this object type.
virtual QVariant property (const QString &propName) const =0
 get a property's value
virtual QStringList propertyNameList () const =0
 Queries what property are (or can be) set.
virtual bool setProperty (const QString &pname, const QVariant &value)=0
 Assign a value to a property.
virtual QMap< QString, QVariantallProperties () const
 Convenience function to retrieve all properties.
virtual bool setAllProperties (const QMap< QString, QVariant > &data)
 Convenience function to load a set of property values.
virtual bool hasFixedTypes () const
virtual QByteArray typeNameFor (const QString &property) const
 Corresonding type for the given property.
virtual QByteArray typeSpecificationFor (const QString &property) const
 A type specification for the given property.

Detailed Description

An abstract object characterized by properties.

This class is an interface to get and set property values for objects like KLFPropertizedObject, QObject, QVariantMap-based, which store their information as logical properties.

Such objects should either inherit explicitely this class, or should provide an adapter class (eg. as for QObject).

This class was developed in the general idea of trying to avoid version issues in data formats, and storing everything as properties in a coherent form, eg. XML. See klfSave() and klfLoad().

QDataStream operators are implemented for this object.

Definition at line 58 of file klfpobj.h.


Constructor & Destructor Documentation

Definition at line 32 of file klfpobj.cpp.

Definition at line 35 of file klfpobj.cpp.


Member Function Documentation

Convenience function to retrieve all properties.

This function returns all the properties that have been set on this object with their corresponding values.

The default implementation uses propertyNameList() and property() to generate the required return value. It should be enough for most cases. If you really want to however, you can reimplement this function for your needs.

Reimplemented in KLFPropertizedObject.

Definition at line 51 of file klfpobj.cpp.

References property(), and propertyNameList().

Referenced by klfSaveVariantToText().

virtual bool KLFAbstractPropertizedObject::hasFixedTypes ( ) const [inline, virtual]
Returns:
TRUE if a all properties have fixed types, i.e. a given property can only contain a value of a certain type.

Definition at line 129 of file klfpobj.h.

Referenced by klfLoadVariantFromText(), and klfSaveVariantToText().

virtual QString KLFAbstractPropertizedObject::objectKind ( ) const [pure virtual]

A string representing this object type.

The string should be short, and contain only alphanumeric characters (a good idea is to give the class name here).

This is used for example as node name in XML exports.

Implemented in KLFPropertizedObject.

Referenced by klfLoadVariantFromText().

virtual QVariant KLFAbstractPropertizedObject::property ( const QString propName) const [pure virtual]

get a property's value

Returns:
the value of the given property, as a QVariant.

Implemented in KLFPropertizedObject.

Referenced by allProperties().

Queries what property are (or can be) set.

This function should return a list of property names that have been explicitely set on this object.

Implemented in KLFPropertizedObject.

Referenced by allProperties().

Convenience function to load a set of property values.

This function tries to set all the properties given in data. If one or more setProperty() call failed, then this function returns FALSE. TRUE is returned when all properties were set successfully.

The default implementation uses propertyNameList() and setProperty() to set all the given properties.

Subclasses may be interested in reimplementing this function in order to garantee the the properties are set in a correct order. This might be necessary in some cases where you are allowed to set a given property depending on the value of another, for example a "Locked" property.

Reimplemented in KLFPropertizedObject.

Definition at line 61 of file klfpobj.cpp.

References QMap::begin(), QMap::end(), KLF_DEBUG_BLOCK, KLF_FUNC_NAME, klfDbg, and setProperty().

Referenced by klfLoadVariantFromText().

virtual bool KLFAbstractPropertizedObject::setProperty ( const QString pname,
const QVariant value 
) [pure virtual]

Assign a value to a property.

It is up to the subclasse to implement this function.

This function checks that the given property pname is allowed to be modified to the new value value. If this is not the case, returns FALSE. Otherwise, this function tries to save the new value for the given property.

Returns:
TRUE if the property was successfully saved, FALSE if the property was not allowed to be modified or if the new value could not be set.

Implemented in KLFPropertizedObject.

Referenced by setAllProperties().

virtual QByteArray KLFAbstractPropertizedObject::typeNameFor ( const QString property) const [inline, virtual]

Corresonding type for the given property.

This function is only relevant if hasFixedTypes() returns TRUE.

Definition at line 135 of file klfpobj.h.

Referenced by klfLoadVariantFromText().

virtual QByteArray KLFAbstractPropertizedObject::typeSpecificationFor ( const QString property) const [inline, virtual]

A type specification for the given property.

A type specification is some additional data that specifies further the type. For example, a type KLFEnumType has to be specified to which enum values are allowed.

This is only used for types that derive KLFSpecifyableType.

Definition at line 144 of file klfpobj.h.

Referenced by klfLoadVariantFromText().


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

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net