DataObject Class Reference

base class for DataModels. More...

#include <dataobject.h>

Inheritance diagram for DataObject:

Inheritance graph
[legend]
List of all members.

Public Slots

virtual bool setProperty (const QString &propName, const QVariant &qv)
 overloaded for QString
virtual bool setProperty (const char *propName, const QVariant &qv)

Public Member Functions

 DataObject (QString name)
 This was recently marked explicit to avoid making implicit temporaries when passing a pointer to a method which expects an object.
virtual ~DataObject ()
 DataObject (QObject *parent=0)
 DataObject (const DataObject &other)
virtual bool readFrom (const QObject &source)
 Reads all the properties from the source object (using intraspection) and saves them to our object.
virtual bool writeTo (QObject &dest) const
 writes all our properties into a QObject
void adoptChildren (QObject *wayward)
 iterates through the wayward and steals all its children, reparenting them under "this"
virtual bool equals (const DataObject &other, bool compareChildren=true) const
 
Parameters:
compareChildren if true recursively checks children

virtual bool operator== (const DataObject &other) const
DataObjectoperator= (const DataObject &other)
virtual QString className () const
 We can't virtually override QObject::className(), but we override it anyway.
virtual QStringList propertyNames () const
 
Returns:
a list of propertyNames, so that the user of DataObject does not need to use a QMetaObject just to get a list of property names.

virtual QMetaProperty metaProperty (const QString &propname) const
virtual QMetaProperty metaProperty (int i) const
virtual uint numProperties () const
 
Returns:
number of properties.

virtual QString toString (int indentlevel=0) const
 
Returns:
human and machine readable representation of this object (XML format)

virtual QVariant property (QString name) const
 overloaded to support QString
virtual QVariant property (const char *name) const
virtual DataObjectclone (bool deep=false) const
 Polymorphic clone() method - its proper behavior is to copy all properties from *this into the new copy.

Detailed Description

base class for DataModels.

Provides support for dynamic properties and object creation, as well as constraints on property setting.

NOTE: As of Qt 4.2, most of the functionality of this class is superceded by QObject, which now supports dynamic properties.

Author:
Alan Ezust

Definition at line 20 of file dataobject.h.


Member Function Documentation

bool DataObject::writeTo ( QObject &  dest  )  const [virtual]

writes all our properties into a QObject

Returns:
true if successful in setting all properties.

Definition at line 222 of file dataobject.cpp.

References metaProperty(), property(), and propertyNames().

Referenced by clone().

Here is the call graph for this function:

void DataObject::adoptChildren ( QObject *  wayward  ) 

iterates through the wayward and steals all its children, reparenting them under "this"

Parameters:
wayward - another QObject which has children we wish to add to this. The wayward loses children.

Definition at line 81 of file dataobject.cpp.

bool DataObject::equals ( const DataObject other,
bool  compareChildren = true 
) const [virtual]

Parameters:
compareChildren if true recursively checks children

Returns:
true if other has the same property values as this.

Definition at line 88 of file dataobject.cpp.

References equals(), property(), propertyNames(), and toString().

Referenced by equals(), and operator==().

Here is the call graph for this function:

QString DataObject::className (  )  const [virtual]

We can't virtually override QObject::className(), but we override it anyway.

In DataObject, it is virtual, so it can return something else in derived classes.

Returns:
the name of this object's class

Reimplemented in PropsMap.

Definition at line 162 of file dataobject.cpp.

References property().

Referenced by ConstraintGroup::filter(), FormFactory::newForm(), StdinReader::readProperties(), ConstrainedDataObject::setProperty(), toString(), and ConstrainedDataObject::validInputs().

Here is the call graph for this function:

uint DataObject::numProperties (  )  const [virtual]

Returns:
number of properties.

Parameters:
superclass include superclass inherited properties in the count (currently ignored)

Definition at line 183 of file dataobject.cpp.

References propertyNames().

Here is the call graph for this function:

DataObject * DataObject::clone ( bool  deep = false  )  const [virtual]

Polymorphic clone() method - its proper behavior is to copy all properties from *this into the new copy.

Returns:
a newly allocated copy of *this
Should be overridden in derived classes.

Parameters:
deep if true, makes clones of all the children and reconstructs the tree.

Definition at line 204 of file dataobject.cpp.

References DataObject(), and writeTo().

Referenced by DataObjectTableModel::insertRows().

Here is the call graph for this function:

bool DataObject::setProperty ( const QString &  propName,
const QVariant &  qv 
) [virtual, slot]

overloaded for QString

Parameters:
propertyName name of property to set
value value to set property
Returns:
true if value satisfies the regexp constraint for this property.
NOTE: Qt3's QObject had these as virtual, but in Qt4, they are non-virtual. This means these methods will not be called if you use the QObject interface.

Reimplemented in ConstrainedDataObject.

Definition at line 72 of file dataobject.cpp.

Referenced by ObjectFactory::newAddress(), readFrom(), StdinReader::readProperties(), ConstrainedDataObject::setProperty(), and PropQuestion::setValue().


The documentation for this class was generated from the following files:
Generated on Wed Sep 30 01:15:44 2009 for oopapidocs by  doxygen 1.5.1