--- a/src/hbwidgets/dataform/hbdataformmodelitem.cpp Fri May 14 16:09:54 2010 +0300
+++ b/src/hbwidgets/dataform/hbdataformmodelitem.cpp Thu May 27 13:10:59 2010 +0300
@@ -63,7 +63,12 @@
}
}
-
+void HbDataFormModelItemPrivate::setContentWidgetData(
+ const QString& propertyName ,const QVariant &value)
+{
+ mProperties.remove(propertyName);
+ mProperties.insert(propertyName,value);
+}
QAbstractItemModel* HbDataFormModelItemPrivate::model() const
{
return mModel;
@@ -82,7 +87,7 @@
- ringtone_general
- unknowncaller_ringtone_general,
- Then sample code to create above model and data it to dataForm would be,
+ Then sample code to create above model and data it to data form would be,
\code
HbDataForm* form = new HbDataForm();
@@ -104,20 +109,20 @@
/*!
\enum HbDataFormModelItem::Roles
- This enum defines the Roles supported by dataForm.Any data from application
+ This enum defines the Roles supported by dataForm. Any data from application
can be added through these Roles.
*/
/*!
\var HbDataFormModelItem::LabelRole
- LabelRole: This Role is used for data label of the DataFormViewItem
+ LabelRole: This Role is used for data item label/heading of HbDataFormViewItem.
*/
/*!
\var HbDataFormModelItem::ItemTypeRole
- ItemTypeRole: This Role is used for data itemType of the HbDataFormModelItem
+ ItemTypeRole: This Role is used for data item type of the HbDataFormModelItem
*/
@@ -135,13 +140,6 @@
*/
/*!
- \var HbDataFormModelItem::DescriptionRole
- DescriptionRole: This Role will add a description text in model item visualization. This role
- is valid only for GroupItem and data items ( > GroupPageItem ).
-
- */
-
-/*!
\enum HbDataFormModelItem::DataItemType
This enum defines itemtypes supported in dataform.
@@ -157,7 +155,7 @@
/*!
\var HbDataFormModelItem::GroupItem
- GroupItem is used for grouping diffrent group pages or grouping data items under one group
+ GroupItem is used for grouping different group pages or grouping data items under one group
heading.
*/
@@ -176,13 +174,6 @@
*/
/*!
-
- \var HbDataFormModelItem::VolumeSliderItem
- VolumeSliderItem: This itemType is for volume slider type of data item
-
- */
-
-/*!
\var HbDataFormModelItem::CheckBoxItem
CheckBoxItem: This itemType is for check box type of data item
@@ -192,8 +183,8 @@
\var HbDataFormModelItem::TextItem
TextItem: This itemType is for text type of data item
The TextItem by default has maximum 4 rows.
- Application can configure thisvalue using HbLineEdit Property maxRows.
- This Property Value has to be set using SetContentWidgetData API.
+ Application can configure this value using HbLineEdit Property maxRows.
+ This Property Value has to be set using setContentWidgetData() API.
*/
@@ -249,14 +240,14 @@
RadioButtonListItem will appear in three display modes
- automatic : radioButtonList item appear as embedded( inline) if it contains less than four items and
+ - Automatic : radioButtonList item appear as embedded( inline) if it contains less than four items and
if more than three items then selected items are displayed as text on a PushButton and when pushbutton
clicked it lunches popup. Automatic mode is set as the default mode.
- embedded : Application can set these items as always embedded(inline) by setting the property "displayMode"
+ - Embedded : Application can set these items as always embedded(inline) by setting the property "displayMode"
with value of property as "embedded"
- popup : Application can set these items as always popup by setting the property "displayMode"
+ - Popup : Application can set these items as always popup by setting the property "displayMode"
with value of property as "popup"
HbDataFormModelItem *radioItem = model->appendDataItem(HbDataFormModelItem::RadioButtonListItem,
QString("Caller Tone"));
@@ -272,14 +263,14 @@
MultiSelectionListItem will appear in three display modes
- automatic : radioButtonList item appear as embedded( inline) if it contains less than four items and
+ - Automatic : radioButtonList item appear as embedded( inline) if it contains less than four items and
if more than three items then selected items are displayed as text on a PushButton and when pushbutton
clicked it lunches popup. Automatic mode is set as the default mode.
- embedded : Application can set these items as always embedded(inline) by setting the property "displayMode"
+ - Embedded : Application can set these items as always embedded(inline) by setting the property "displayMode"
with value of property as "embedded"
- popup : Application can set these items as always popup by setting the property "displayMode"
+ - Popup : Application can set these items as always popup by setting the property "displayMode"
with value of property as "popup"
HbDataFormModelItem *radioItem = model->appendDataItem(HbDataFormModelItem::MultiSelectionListItem,
QString("Caller Tone"));
@@ -367,6 +358,7 @@
/*!
@beta
+
Adds the given \a child to the children list of current item.
\sa insertChild, insertChildren
@@ -416,6 +408,7 @@
/*!
@beta
+
Inserts the given list of \a items starting from the given \a row.
\sa insertChild, appendChild
@@ -443,6 +436,7 @@
/*!
@beta
+
Removes the child item at the given \a index. The item at \a index is
deleted.
@@ -450,30 +444,35 @@
*/
void HbDataFormModelItem::removeChild(int index)
{
+ if( ( index < 0 ) || ( index >= childCount() ) ) {
+ return;
+ }
Q_D(HbDataFormModelItem);
-
HbDataFormModel* model = static_cast<HbDataFormModel*>(d->mModel);
- if(model) {
+
+ if(model)
model->d_func()->rowsAboutToBeRemoved(this, index, index);
- HbDataFormModelItem *item = d->mChildItems.takeAt(index);
- if ( item ) {
+
+ HbDataFormModelItem *item = d->mChildItems.at(index);
+ if( item ) {
+ int childCount = item->childCount();
+ for ( int childIndex = 0; childIndex <= childCount ;childIndex++) {
+ item->removeChild(0);
+ }
+
+ HbDataFormModelItem *item = d->mChildItems.takeAt(index);
delete item;
item = 0;
- }
+ }
+
+ if(model)
model->d_func()->rowsRemoved();
- }
- else {
- HbDataFormModelItem *item = d->mChildItems.takeAt(index);
- if ( item ) {
- delete item;
- item = 0;
- }
- }
-
+
}
/*!
@beta
+
Removes the given no of \a count of childitems from the given \a startindex. The
items are deleted.
@@ -481,22 +480,37 @@
*/
void HbDataFormModelItem::removeChildren(int startIndex, int count)
{
- Q_D(HbDataFormModelItem);
+ if( ( startIndex < 0 ) || ( startIndex > childCount() ) || ( count <= 0 )) {
+ return;
+ }
+
+ if( startIndex + count > childCount() ) {
+ return;
+ }
- HbDataFormModel* model = static_cast<HbDataFormModel*>(d->mModel);
- model->d_func()->rowsAboutToBeRemoved(this, startIndex, startIndex + count -1);
- for(int index = 0; index < count ;index++) {
+ Q_D(HbDataFormModelItem);
+
+ HbDataFormModel* model = static_cast<HbDataFormModel*>(d->mModel);
+ if( model ) {
+ model->d_func()->rowsAboutToBeRemoved(this, startIndex, startIndex + count -1);
+ }
+
+ for(int index = 0; index < count ;index++) {
HbDataFormModelItem *item = d->mChildItems.takeAt(0);
if ( item ) {
delete item;
item = 0;
}
- }
- model->d_func()->rowsRemoved();
+ }
+
+ if( model ) {
+ model->d_func()->rowsRemoved();
+ }
}
/*!
@beta
+
Returns the child item at the given \a index.
Returns 0 if \a index passed in greater than count or less than 0.
@@ -513,6 +527,7 @@
/*!
@beta
+
Returns index of the given \a child.
\sa childAt
@@ -536,6 +551,7 @@
/*!
@beta
+
Returns the data for the given \a role. Returns empty string if DescriptionRole is queried for
items other then GroupItem and data item.
*/
@@ -565,6 +581,7 @@
/*!
@beta
+
Sets the given \a value of variant to the given \a role.
*/
void HbDataFormModelItem::setData(int role ,const QVariant &value)
@@ -620,10 +637,9 @@
const QString& propertyName ,const QVariant &value)
{
Q_D(HbDataFormModelItem);
- d->mProperties.remove(propertyName);
- d->mProperties.insert(propertyName,value);
+ d->setContentWidgetData(propertyName, value);
+
d->mDirtyProperty = propertyName;
-
HbDataFormModel *data_model = static_cast<HbDataFormModel*>(d->mModel);
if(data_model) {
QModelIndex index = data_model->indexFromItem(this);
@@ -633,6 +649,7 @@
/*!
@beta
+
Returns the property \a value for the given \a propertyName.
*/
QVariant HbDataFormModelItem::contentWidgetData(const QString& propertyName ) const
@@ -640,8 +657,10 @@
Q_D(const HbDataFormModelItem);
return d->mProperties.value(propertyName);
}
+
/*!
@beta
+
Returns all properties with values which was set in HbDataFormModelItem.
*/
QHash<QString, QVariant> HbDataFormModelItem::contentWidgetData() const
@@ -649,8 +668,10 @@
Q_D(const HbDataFormModelItem);
return d->mProperties;
}
+
/*!
@beta
+
Sets \a parent as a parent to this item.
It only sets the parent pointer. It doesnt put the item in the
hierarchy.
@@ -663,6 +684,7 @@
/*!
@beta
+
Returns the parent of the this data item.
*/
HbDataFormModelItem* HbDataFormModelItem::parent() const
@@ -673,6 +695,7 @@
/*!
@beta
+
Sets \a type as a DataItemType for this data item.
*/
void HbDataFormModelItem::setType(HbDataFormModelItem::DataItemType type)
@@ -682,6 +705,7 @@
/*!
@beta
+
Returns the DataItemType of the this item.
*/
HbDataFormModelItem::DataItemType HbDataFormModelItem::type() const
@@ -691,6 +715,7 @@
/*!
@beta
+
Sets the \a label to the item. This is valid only if the type is other than FormPageItem,
GroupItem and GroupPageItem.
*/
@@ -701,6 +726,7 @@
/*!
@beta
+
Returns the label of the item.
*/
QString HbDataFormModelItem::label() const
@@ -710,6 +736,7 @@
/*!
@beta
+
Sets the \a icon to the item. This is valid only if the type is other than FormPageItem,
GroupItem and GroupPageItem.
*/
@@ -720,6 +747,7 @@
/*!
@beta
+
Returns the icon of the item.
*/
QString HbDataFormModelItem::icon() const
@@ -727,14 +755,9 @@
return data(Qt::DecorationRole).toString();
}
-/*
-QHash<QString, QVariant> HbDataFormModelItem::getContentWidgetValues()
-{
- Q_D(const HbDataFormModelItem);
- return d->mProperties;
-}*/
+/*!
+ @beta
-/*!
Sets whether the item is enabled.
If enabled is true, the item is \a enabled, meaning that the user can interact with the item
@@ -759,7 +782,8 @@
}
/*!
- Returns true if the item is enabled; otherwise returns false.
+ @beta
+ Returns true if the item is enabled otherwise returns false.
*/
bool HbDataFormModelItem::isEnabled() const
{
@@ -768,6 +792,7 @@
}
/*!
+ @beta
Returns item flags for this item.
*/
Qt::ItemFlags HbDataFormModelItem::flags() const
@@ -777,7 +802,7 @@
}
/*!
- @proto
+ @beta
Sets the \a description to the item. This is valid only if the type is GroupItem or
DataItem. Its not valid for GroupPageItem and FormPageItem.
*/
@@ -787,7 +812,7 @@
}
/*!
- @proto
+ @beta
Returns the description of the item.
*/
QString HbDataFormModelItem::description() const