libqutim
0.3.2.0
|
#include <dataforms.h>
Public Member Functions | |
DataItem () | |
DataItem (const QString &name, const LocalizedString &title, const QVariant &data) | |
DataItem (const LocalizedString &title, const QVariant &data=QVariant()) | |
DataItem (const DataItem &other) | |
~DataItem () | |
void | addSubitem (const DataItem &subitem) |
void | allowModifySubitems (const DataItem &defaultSubitem, int maxSubitemsCount=-1) |
QVariant | data () const |
template<typename T > | |
T | data (const T &def=T()) const |
const char * | dataChangedMethod () const |
QObject * | dataChangedReceiver () const |
DataItem | defaultSubitem () const |
QList< QByteArray > | dynamicPropertyNames () const |
bool | hasSubitems () const |
bool | isAllowedModifySubitems () const |
bool | isNull () const |
bool | isReadOnly () const |
int | maxSubitemsCount () const |
QString | name () const |
DataItem & | operator<< (const DataItem &subitem) |
DataItem & | operator= (const DataItem &other) |
QVariant | property (const char *name, const QVariant &def=QVariant()) const |
template<typename T > | |
T | property (const char *name, const T &def=T()) const |
bool | removeSubitem (const QString &name, bool recursive=false) |
int | removeSubitems (const QString &name, bool recursive=false) |
void | setData (const QVariant &itemData) |
void | setDataChangedHandler (QObject *receiver, const char *method) |
void | setName (const QString &itemName) |
void | setProperty (const char *name, const QVariant &value) |
void | setReadOnly (bool readOnly=true) |
void | setSubitems (const QList< DataItem > &newSubitems) |
void | setTitle (const LocalizedString &itemTitle) |
DataItem | subitem (const QString &name, bool recursive=false) const |
QList< DataItem > | subitems () const |
DataItem | takeSubitem (const QString &name, bool recursive=false) |
LocalizedString | title () const |
The DataItem class specifies one field or a group of fields in a data form.
The DataItem class is part qutIM's DataForms API and describes appearance and behaviour of a group of fields in a data form if it has subitems or if allowed to modify its subitems. Otherwise, DataItem describes appearance and behaviour of one field in a data form.
A DataItem object can have name() attribute by which you can access this object later using subitem(). Use setName() to set this property.
Specifying various attributes and properties, you able to change appearance and behaviour of fields in a data form. data() is the primary attribute, defines the default field value and can be specified using setData() or in the constructors. The title() attribute specifes the field title; you can set it using setTitle(). A DataItem object also may contain dynamic properties which are manipulated using property() to read them and setProperty() to write them.
The following types of data() and the dynamic properties are supported by DataForms API:
The items that have subitems may have the following properties:
Example of using data attribute and dynamic properties:
If you want to unite several fields in a group you create a parent DataItem object and add subitems to the object using addSubitem() or setSubitems(). Example of using subitems:
It is possible to allow user to modify subitems using allowModifySubitems(). Here is an example:
qutim_sdk_0_3::DataItem::DataItem | ( | const QString & | name, |
const LocalizedString & | title, | ||
const QVariant & | data | ||
) |
Constructs a new DataItem with the given name, title and data attributes.
qutim_sdk_0_3::DataItem::DataItem | ( | const LocalizedString & | title, |
const QVariant & | data = QVariant() |
||
) |
Constructs a new DataItem with the given title and data attributes.
qutim_sdk_0_3::DataItem::DataItem | ( | const DataItem & | other | ) |
Constructs a copy of other.
This operation occurs in constant time, because DataItem is implicitly shared. This makes returning a DataItem from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and this takes linear time.
qutim_sdk_0_3::DataItem::~DataItem | ( | ) |
Destroys the DataItem.
void qutim_sdk_0_3::DataItem::addSubitem | ( | const DataItem & | subitem | ) |
Adds new subitem to the list of subitems of this data item.
void qutim_sdk_0_3::DataItem::allowModifySubitems | ( | const DataItem & | defaultSubitem, |
int | maxSubitemsCount = -1 |
||
) |
Allows to modify the list of subitems by user.
defaultSubitem | The data item that will be used for creating a new field. |
maxSubitemsCount | Maximum count of the subitems that user cannot exceed. -1 if there is no limits. |
QVariant qutim_sdk_0_3::DataItem::data | ( | ) | const |
Returns the data of this data item.
T qutim_sdk_0_3::DataItem::data | ( | const T & | def = T() | ) | const |
Returns the data of this data item converted to template type T.
If the data cannot be converted, def will be returned.
const char* qutim_sdk_0_3::DataItem::dataChangedMethod | ( | ) | const |
Returns the method the data signal is connected to.
QObject* qutim_sdk_0_3::DataItem::dataChangedReceiver | ( | ) | const |
Returns the receiver of the data changed signal of the field.
DataItem qutim_sdk_0_3::DataItem::defaultSubitem | ( | ) | const |
Returns the data item that will be used for creating a new field.
QList<QByteArray> qutim_sdk_0_3::DataItem::dynamicPropertyNames | ( | ) | const |
bool qutim_sdk_0_3::DataItem::hasSubitems | ( | ) | const |
Returns true if this data item contains at least one subitem; otherwise returns false.
bool qutim_sdk_0_3::DataItem::isAllowedModifySubitems | ( | ) | const |
Returns true if modifying of the list of subitems by user is allowed; otherwise returns false.
bool qutim_sdk_0_3::DataItem::isNull | ( | ) | const |
Returns true if this data item is null; otherwise return false.
bool qutim_sdk_0_3::DataItem::isReadOnly | ( | ) | const |
Returns the readOnly property.
int qutim_sdk_0_3::DataItem::maxSubitemsCount | ( | ) | const |
Returns maximum count of the subitems that user cannot exceed.
Returns -1 if there is no limits.
QString qutim_sdk_0_3::DataItem::name | ( | ) | const |
Returns the name of this data item.
Adds new subitem to the list of subitems of this data item.
Assigns other to this data item and returns a reference to this data item.
QVariant qutim_sdk_0_3::DataItem::property | ( | const char * | name, |
const QVariant & | def = QVariant() |
||
) | const |
Returns the property named name.
If no such property exists, def will be returned.
T qutim_sdk_0_3::DataItem::property | ( | const char * | name, |
const T & | def = T() |
||
) | const |
Returns the name property converted to the template type T.
If the value cannot be converted, def will be returned.
bool qutim_sdk_0_3::DataItem::removeSubitem | ( | const QString & | name, |
bool | recursive = false |
||
) |
int qutim_sdk_0_3::DataItem::removeSubitems | ( | const QString & | name, |
bool | recursive = false |
||
) |
void qutim_sdk_0_3::DataItem::setData | ( | const QVariant & | itemData | ) |
Sets the data of this data item to be itemData.
void qutim_sdk_0_3::DataItem::setDataChangedHandler | ( | QObject * | receiver, |
const char * | method | ||
) |
Connects the data changed signal of the field to the method in the receiver.
The data changed signal has three paramenters:
void qutim_sdk_0_3::DataItem::setName | ( | const QString & | itemName | ) |
Sets the name of this data item to be itemName.
void qutim_sdk_0_3::DataItem::setProperty | ( | const char * | name, |
const QVariant & | value | ||
) |
Sets name property to be value.
void qutim_sdk_0_3::DataItem::setReadOnly | ( | bool | readOnly = true | ) |
Sets the readOnly property to be readOnly.
void qutim_sdk_0_3::DataItem::setSubitems | ( | const QList< DataItem > & | newSubitems | ) |
Sets the list of subitems to be newSubitems.
void qutim_sdk_0_3::DataItem::setTitle | ( | const LocalizedString & | itemTitle | ) |
Sets the title of this data item to be itemTitle.
DataItem qutim_sdk_0_3::DataItem::subitem | ( | const QString & | name, |
bool | recursive = false |
||
) | const |
Returns the subitem by its name.
QList<DataItem> qutim_sdk_0_3::DataItem::subitems | ( | ) | const |
Returns the list of subitems of this data item.
DataItem qutim_sdk_0_3::DataItem::takeSubitem | ( | const QString & | name, |
bool | recursive = false |
||
) |
LocalizedString qutim_sdk_0_3::DataItem::title | ( | ) | const |
Returns the title of this data item.