80 For Example if below is the model hierarchy for profiles application |
85 For Example if below is the model hierarchy for profiles application |
81 - general |
86 - general |
82 - ringtone_general |
87 - ringtone_general |
83 - unknowncaller_ringtone_general, |
88 - unknowncaller_ringtone_general, |
84 |
89 |
85 Then sample code to create above model and data it to dataForm would be, |
90 Then sample code to create above model and data it to data form would be, |
86 |
91 |
87 \code |
92 \code |
88 HbDataForm* form = new HbDataForm(); |
93 HbDataForm* form = new HbDataForm(); |
89 form->setHeading(QString("Profiles")); |
94 form->setHeading(QString("Profiles")); |
90 form->setDescription(QString("With profiles you can define themes used in different profiles")); |
95 form->setDescription(QString("With profiles you can define themes used in different profiles")); |
102 */ |
107 */ |
103 |
108 |
104 /*! |
109 /*! |
105 \enum HbDataFormModelItem::Roles |
110 \enum HbDataFormModelItem::Roles |
106 |
111 |
107 This enum defines the Roles supported by dataForm.Any data from application |
112 This enum defines the Roles supported by dataForm. Any data from application |
108 can be added through these Roles. |
113 can be added through these Roles. |
109 */ |
114 */ |
110 |
115 |
111 /*! |
116 /*! |
112 \var HbDataFormModelItem::LabelRole |
117 \var HbDataFormModelItem::LabelRole |
113 LabelRole: This Role is used for data label of the DataFormViewItem |
118 LabelRole: This Role is used for data item label/heading of HbDataFormViewItem. |
114 |
119 |
115 */ |
120 */ |
116 |
121 |
117 |
122 |
118 /*! |
123 /*! |
119 \var HbDataFormModelItem::ItemTypeRole |
124 \var HbDataFormModelItem::ItemTypeRole |
120 ItemTypeRole: This Role is used for data itemType of the HbDataFormModelItem |
125 ItemTypeRole: This Role is used for data item type of the HbDataFormModelItem |
121 |
126 |
122 */ |
127 */ |
123 |
128 |
124 /*! |
129 /*! |
125 \var HbDataFormModelItem::PropertyRole |
130 \var HbDataFormModelItem::PropertyRole |
174 SliderItem: This itemType is for slider type of data item |
172 SliderItem: This itemType is for slider type of data item |
175 |
173 |
176 */ |
174 */ |
177 |
175 |
178 /*! |
176 /*! |
179 |
|
180 \var HbDataFormModelItem::VolumeSliderItem |
|
181 VolumeSliderItem: This itemType is for volume slider type of data item |
|
182 |
|
183 */ |
|
184 |
|
185 /*! |
|
186 \var HbDataFormModelItem::CheckBoxItem |
177 \var HbDataFormModelItem::CheckBoxItem |
187 CheckBoxItem: This itemType is for check box type of data item |
178 CheckBoxItem: This itemType is for check box type of data item |
188 |
179 |
189 */ |
180 */ |
190 |
181 |
191 /*! |
182 /*! |
192 \var HbDataFormModelItem::TextItem |
183 \var HbDataFormModelItem::TextItem |
193 TextItem: This itemType is for text type of data item |
184 TextItem: This itemType is for text type of data item |
194 The TextItem by default has maximum 4 rows. |
185 The TextItem by default has maximum 4 rows. |
195 Application can configure thisvalue using HbLineEdit Property maxRows. |
186 Application can configure this value using HbLineEdit Property maxRows. |
196 This Property Value has to be set using SetContentWidgetData API. |
187 This Property Value has to be set using setContentWidgetData() API. |
197 |
188 |
198 */ |
189 */ |
199 |
190 |
200 /*! |
191 /*! |
201 \var HbDataFormModelItem::ToggleValueItem |
192 \var HbDataFormModelItem::ToggleValueItem |
247 \var HbDataFormModelItem::RadioButtonListItem |
238 \var HbDataFormModelItem::RadioButtonListItem |
248 RadioButtonListItem: This itemType is for radio button list type of data item |
239 RadioButtonListItem: This itemType is for radio button list type of data item |
249 |
240 |
250 RadioButtonListItem will appear in three display modes |
241 RadioButtonListItem will appear in three display modes |
251 |
242 |
252 automatic : radioButtonList item appear as embedded( inline) if it contains less than four items and |
243 - Automatic : radioButtonList item appear as embedded( inline) if it contains less than four items and |
253 if more than three items then selected items are displayed as text on a PushButton and when pushbutton |
244 if more than three items then selected items are displayed as text on a PushButton and when pushbutton |
254 clicked it lunches popup. Automatic mode is set as the default mode. |
245 clicked it lunches popup. Automatic mode is set as the default mode. |
255 |
246 |
256 embedded : Application can set these items as always embedded(inline) by setting the property "displayMode" |
247 - Embedded : Application can set these items as always embedded(inline) by setting the property "displayMode" |
257 with value of property as "embedded" |
248 with value of property as "embedded" |
258 |
249 |
259 popup : Application can set these items as always popup by setting the property "displayMode" |
250 - Popup : Application can set these items as always popup by setting the property "displayMode" |
260 with value of property as "popup" |
251 with value of property as "popup" |
261 HbDataFormModelItem *radioItem = model->appendDataItem(HbDataFormModelItem::RadioButtonListItem, |
252 HbDataFormModelItem *radioItem = model->appendDataItem(HbDataFormModelItem::RadioButtonListItem, |
262 QString("Caller Tone")); |
253 QString("Caller Tone")); |
263 radioItem->setContentWidgetData(QString("displayMode"),QString("embedded")); |
254 radioItem->setContentWidgetData(QString("displayMode"),QString("embedded")); |
264 radioItem->setContentWidgetData(QString("displayMode"),QString("automatic")); |
255 radioItem->setContentWidgetData(QString("displayMode"),QString("automatic")); |
270 \var HbDataFormModelItem::MultiselectionItem |
261 \var HbDataFormModelItem::MultiselectionItem |
271 MultiselectionItem: This itemType is for multi selection type of data item. |
262 MultiselectionItem: This itemType is for multi selection type of data item. |
272 |
263 |
273 MultiSelectionListItem will appear in three display modes |
264 MultiSelectionListItem will appear in three display modes |
274 |
265 |
275 automatic : radioButtonList item appear as embedded( inline) if it contains less than four items and |
266 - Automatic : radioButtonList item appear as embedded( inline) if it contains less than four items and |
276 if more than three items then selected items are displayed as text on a PushButton and when pushbutton |
267 if more than three items then selected items are displayed as text on a PushButton and when pushbutton |
277 clicked it lunches popup. Automatic mode is set as the default mode. |
268 clicked it lunches popup. Automatic mode is set as the default mode. |
278 |
269 |
279 embedded : Application can set these items as always embedded(inline) by setting the property "displayMode" |
270 - Embedded : Application can set these items as always embedded(inline) by setting the property "displayMode" |
280 with value of property as "embedded" |
271 with value of property as "embedded" |
281 |
272 |
282 popup : Application can set these items as always popup by setting the property "displayMode" |
273 - Popup : Application can set these items as always popup by setting the property "displayMode" |
283 with value of property as "popup" |
274 with value of property as "popup" |
284 HbDataFormModelItem *radioItem = model->appendDataItem(HbDataFormModelItem::MultiSelectionListItem, |
275 HbDataFormModelItem *radioItem = model->appendDataItem(HbDataFormModelItem::MultiSelectionListItem, |
285 QString("Caller Tone")); |
276 QString("Caller Tone")); |
286 radioItem->setContentWidgetData(QString("displayMode"),QString("embedded")); |
277 radioItem->setContentWidgetData(QString("displayMode"),QString("embedded")); |
287 radioItem->setContentWidgetData(QString("displayMode"),QString("automatic")); |
278 radioItem->setContentWidgetData(QString("displayMode"),QString("automatic")); |
441 |
434 |
442 } |
435 } |
443 |
436 |
444 /*! |
437 /*! |
445 @beta |
438 @beta |
|
439 |
446 Removes the child item at the given \a index. The item at \a index is |
440 Removes the child item at the given \a index. The item at \a index is |
447 deleted. |
441 deleted. |
448 |
442 |
449 \sa removeChildren |
443 \sa removeChildren |
450 */ |
444 */ |
451 void HbDataFormModelItem::removeChild(int index) |
445 void HbDataFormModelItem::removeChild(int index) |
452 { |
446 { |
453 Q_D(HbDataFormModelItem); |
447 if( ( index < 0 ) || ( index >= childCount() ) ) { |
454 |
448 return; |
|
449 } |
|
450 Q_D(HbDataFormModelItem); |
455 HbDataFormModel* model = static_cast<HbDataFormModel*>(d->mModel); |
451 HbDataFormModel* model = static_cast<HbDataFormModel*>(d->mModel); |
456 if(model) { |
452 |
|
453 if(model) |
457 model->d_func()->rowsAboutToBeRemoved(this, index, index); |
454 model->d_func()->rowsAboutToBeRemoved(this, index, index); |
458 HbDataFormModelItem *item = d->mChildItems.takeAt(index); |
455 |
459 if ( item ) { |
456 HbDataFormModelItem *item = d->mChildItems.at(index); |
|
457 if( item ) { |
|
458 int childCount = item->childCount(); |
|
459 for ( int childIndex = 0; childIndex <= childCount ;childIndex++) { |
|
460 item->removeChild(0); |
|
461 } |
|
462 |
|
463 HbDataFormModelItem *item = d->mChildItems.takeAt(index); |
460 delete item; |
464 delete item; |
461 item = 0; |
465 item = 0; |
462 } |
466 } |
|
467 |
|
468 if(model) |
463 model->d_func()->rowsRemoved(); |
469 model->d_func()->rowsRemoved(); |
464 } |
470 |
465 else { |
471 } |
466 HbDataFormModelItem *item = d->mChildItems.takeAt(index); |
472 |
467 if ( item ) { |
473 /*! |
468 delete item; |
474 @beta |
469 item = 0; |
475 |
470 } |
|
471 } |
|
472 |
|
473 } |
|
474 |
|
475 /*! |
|
476 @beta |
|
477 Removes the given no of \a count of childitems from the given \a startindex. The |
476 Removes the given no of \a count of childitems from the given \a startindex. The |
478 items are deleted. |
477 items are deleted. |
479 |
478 |
480 \sa removeChild |
479 \sa removeChild |
481 */ |
480 */ |
482 void HbDataFormModelItem::removeChildren(int startIndex, int count) |
481 void HbDataFormModelItem::removeChildren(int startIndex, int count) |
483 { |
482 { |
484 Q_D(HbDataFormModelItem); |
483 if( ( startIndex < 0 ) || ( startIndex > childCount() ) || ( count <= 0 )) { |
485 |
484 return; |
486 HbDataFormModel* model = static_cast<HbDataFormModel*>(d->mModel); |
485 } |
487 model->d_func()->rowsAboutToBeRemoved(this, startIndex, startIndex + count -1); |
486 |
488 for(int index = 0; index < count ;index++) { |
487 if( startIndex + count > childCount() ) { |
|
488 return; |
|
489 } |
|
490 |
|
491 Q_D(HbDataFormModelItem); |
|
492 |
|
493 HbDataFormModel* model = static_cast<HbDataFormModel*>(d->mModel); |
|
494 if( model ) { |
|
495 model->d_func()->rowsAboutToBeRemoved(this, startIndex, startIndex + count -1); |
|
496 } |
|
497 |
|
498 for(int index = 0; index < count ;index++) { |
489 HbDataFormModelItem *item = d->mChildItems.takeAt(0); |
499 HbDataFormModelItem *item = d->mChildItems.takeAt(0); |
490 if ( item ) { |
500 if ( item ) { |
491 delete item; |
501 delete item; |
492 item = 0; |
502 item = 0; |
493 } |
503 } |
494 } |
504 } |
495 model->d_func()->rowsRemoved(); |
505 |
496 } |
506 if( model ) { |
497 |
507 model->d_func()->rowsRemoved(); |
498 /*! |
508 } |
499 @beta |
509 } |
|
510 |
|
511 /*! |
|
512 @beta |
|
513 |
500 Returns the child item at the given \a index. |
514 Returns the child item at the given \a index. |
501 Returns 0 if \a index passed in greater than count or less than 0. |
515 Returns 0 if \a index passed in greater than count or less than 0. |
502 |
516 |
503 \sa indexOf |
517 \sa indexOf |
504 */ |
518 */ |
618 */ |
635 */ |
619 void HbDataFormModelItem::setContentWidgetData( |
636 void HbDataFormModelItem::setContentWidgetData( |
620 const QString& propertyName ,const QVariant &value) |
637 const QString& propertyName ,const QVariant &value) |
621 { |
638 { |
622 Q_D(HbDataFormModelItem); |
639 Q_D(HbDataFormModelItem); |
623 d->mProperties.remove(propertyName); |
640 d->setContentWidgetData(propertyName, value); |
624 d->mProperties.insert(propertyName,value); |
641 |
625 d->mDirtyProperty = propertyName; |
642 d->mDirtyProperty = propertyName; |
626 |
|
627 HbDataFormModel *data_model = static_cast<HbDataFormModel*>(d->mModel); |
643 HbDataFormModel *data_model = static_cast<HbDataFormModel*>(d->mModel); |
628 if(data_model) { |
644 if(data_model) { |
629 QModelIndex index = data_model->indexFromItem(this); |
645 QModelIndex index = data_model->indexFromItem(this); |
630 emit data_model->dataChanged(index, index); |
646 emit data_model->dataChanged(index, index); |
631 } |
647 } |
632 } |
648 } |
633 |
649 |
634 /*! |
650 /*! |
635 @beta |
651 @beta |
|
652 |
636 Returns the property \a value for the given \a propertyName. |
653 Returns the property \a value for the given \a propertyName. |
637 */ |
654 */ |
638 QVariant HbDataFormModelItem::contentWidgetData(const QString& propertyName ) const |
655 QVariant HbDataFormModelItem::contentWidgetData(const QString& propertyName ) const |
639 { |
656 { |
640 Q_D(const HbDataFormModelItem); |
657 Q_D(const HbDataFormModelItem); |
641 return d->mProperties.value(propertyName); |
658 return d->mProperties.value(propertyName); |
642 } |
659 } |
|
660 |
643 /*! |
661 /*! |
644 @beta |
662 @beta |
|
663 |
645 Returns all properties with values which was set in HbDataFormModelItem. |
664 Returns all properties with values which was set in HbDataFormModelItem. |
646 */ |
665 */ |
647 QHash<QString, QVariant> HbDataFormModelItem::contentWidgetData() const |
666 QHash<QString, QVariant> HbDataFormModelItem::contentWidgetData() const |
648 { |
667 { |
649 Q_D(const HbDataFormModelItem); |
668 Q_D(const HbDataFormModelItem); |
650 return d->mProperties; |
669 return d->mProperties; |
651 } |
670 } |
|
671 |
652 /*! |
672 /*! |
653 @beta |
673 @beta |
|
674 |
654 Sets \a parent as a parent to this item. |
675 Sets \a parent as a parent to this item. |
655 It only sets the parent pointer. It doesnt put the item in the |
676 It only sets the parent pointer. It doesnt put the item in the |
656 hierarchy. |
677 hierarchy. |
657 */ |
678 */ |
658 void HbDataFormModelItem::setParent(HbDataFormModelItem* parent) |
679 void HbDataFormModelItem::setParent(HbDataFormModelItem* parent) |
661 d->mParentItem=parent; |
682 d->mParentItem=parent; |
662 } |
683 } |
663 |
684 |
664 /*! |
685 /*! |
665 @beta |
686 @beta |
|
687 |
666 Returns the parent of the this data item. |
688 Returns the parent of the this data item. |
667 */ |
689 */ |
668 HbDataFormModelItem* HbDataFormModelItem::parent() const |
690 HbDataFormModelItem* HbDataFormModelItem::parent() const |
669 { |
691 { |
670 Q_D(const HbDataFormModelItem); |
692 Q_D(const HbDataFormModelItem); |
671 return d->mParentItem; |
693 return d->mParentItem; |
672 } |
694 } |
673 |
695 |
674 /*! |
696 /*! |
675 @beta |
697 @beta |
|
698 |
676 Sets \a type as a DataItemType for this data item. |
699 Sets \a type as a DataItemType for this data item. |
677 */ |
700 */ |
678 void HbDataFormModelItem::setType(HbDataFormModelItem::DataItemType type) |
701 void HbDataFormModelItem::setType(HbDataFormModelItem::DataItemType type) |
679 { |
702 { |
680 setData(ItemTypeRole,type); |
703 setData(ItemTypeRole,type); |
681 } |
704 } |
682 |
705 |
683 /*! |
706 /*! |
684 @beta |
707 @beta |
|
708 |
685 Returns the DataItemType of the this item. |
709 Returns the DataItemType of the this item. |
686 */ |
710 */ |
687 HbDataFormModelItem::DataItemType HbDataFormModelItem::type() const |
711 HbDataFormModelItem::DataItemType HbDataFormModelItem::type() const |
688 { |
712 { |
689 return static_cast<HbDataFormModelItem::DataItemType>(data(ItemTypeRole).toInt()); |
713 return static_cast<HbDataFormModelItem::DataItemType>(data(ItemTypeRole).toInt()); |
690 } |
714 } |
691 |
715 |
692 /*! |
716 /*! |
693 @beta |
717 @beta |
|
718 |
694 Sets the \a label to the item. This is valid only if the type is other than FormPageItem, |
719 Sets the \a label to the item. This is valid only if the type is other than FormPageItem, |
695 GroupItem and GroupPageItem. |
720 GroupItem and GroupPageItem. |
696 */ |
721 */ |
697 void HbDataFormModelItem::setLabel(const QString& label) |
722 void HbDataFormModelItem::setLabel(const QString& label) |
698 { |
723 { |
699 setData(LabelRole,label); |
724 setData(LabelRole,label); |
700 } |
725 } |
701 |
726 |
702 /*! |
727 /*! |
703 @beta |
728 @beta |
|
729 |
704 Returns the label of the item. |
730 Returns the label of the item. |
705 */ |
731 */ |
706 QString HbDataFormModelItem::label() const |
732 QString HbDataFormModelItem::label() const |
707 { |
733 { |
708 return data(LabelRole).toString(); |
734 return data(LabelRole).toString(); |
709 } |
735 } |
710 |
736 |
711 /*! |
737 /*! |
712 @beta |
738 @beta |
|
739 |
713 Sets the \a icon to the item. This is valid only if the type is other than FormPageItem, |
740 Sets the \a icon to the item. This is valid only if the type is other than FormPageItem, |
714 GroupItem and GroupPageItem. |
741 GroupItem and GroupPageItem. |
715 */ |
742 */ |
716 void HbDataFormModelItem::setIcon(const QString& icon) |
743 void HbDataFormModelItem::setIcon(const QString& icon) |
717 { |
744 { |
718 setData(Qt::DecorationRole,icon); |
745 setData(Qt::DecorationRole,icon); |
719 } |
746 } |
720 |
747 |
721 /*! |
748 /*! |
722 @beta |
749 @beta |
|
750 |
723 Returns the icon of the item. |
751 Returns the icon of the item. |
724 */ |
752 */ |
725 QString HbDataFormModelItem::icon() const |
753 QString HbDataFormModelItem::icon() const |
726 { |
754 { |
727 return data(Qt::DecorationRole).toString(); |
755 return data(Qt::DecorationRole).toString(); |
728 } |
756 } |
729 |
757 |
730 /* |
758 /*! |
731 QHash<QString, QVariant> HbDataFormModelItem::getContentWidgetValues() |
759 @beta |
732 { |
760 |
733 Q_D(const HbDataFormModelItem); |
|
734 return d->mProperties; |
|
735 }*/ |
|
736 |
|
737 /*! |
|
738 Sets whether the item is enabled. |
761 Sets whether the item is enabled. |
739 |
762 |
740 If enabled is true, the item is \a enabled, meaning that the user can interact with the item |
763 If enabled is true, the item is \a enabled, meaning that the user can interact with the item |
741 if \a enabled is false, the user cannot interact with the item. |
764 if \a enabled is false, the user cannot interact with the item. |
742 */ |
765 */ |
757 } |
780 } |
758 } |
781 } |
759 } |
782 } |
760 |
783 |
761 /*! |
784 /*! |
762 Returns true if the item is enabled; otherwise returns false. |
785 @beta |
|
786 Returns true if the item is enabled otherwise returns false. |
763 */ |
787 */ |
764 bool HbDataFormModelItem::isEnabled() const |
788 bool HbDataFormModelItem::isEnabled() const |
765 { |
789 { |
766 Q_D(const HbDataFormModelItem); |
790 Q_D(const HbDataFormModelItem); |
767 return d->mFlags & Qt::ItemIsEnabled; |
791 return d->mFlags & Qt::ItemIsEnabled; |
768 } |
792 } |
769 |
793 |
770 /*! |
794 /*! |
|
795 @beta |
771 Returns item flags for this item. |
796 Returns item flags for this item. |
772 */ |
797 */ |
773 Qt::ItemFlags HbDataFormModelItem::flags() const |
798 Qt::ItemFlags HbDataFormModelItem::flags() const |
774 { |
799 { |
775 Q_D(const HbDataFormModelItem); |
800 Q_D(const HbDataFormModelItem); |
776 return d->mFlags; |
801 return d->mFlags; |
777 } |
802 } |
778 |
803 |
779 /*! |
804 /*! |
780 @proto |
805 @beta |
781 Sets the \a description to the item. This is valid only if the type is GroupItem or |
806 Sets the \a description to the item. This is valid only if the type is GroupItem or |
782 DataItem. Its not valid for GroupPageItem and FormPageItem. |
807 DataItem. Its not valid for GroupPageItem and FormPageItem. |
783 */ |
808 */ |
784 void HbDataFormModelItem::setDescription(const QString& description) |
809 void HbDataFormModelItem::setDescription(const QString& description) |
785 { |
810 { |
786 setData(DescriptionRole , description); |
811 setData(DescriptionRole , description); |
787 } |
812 } |
788 |
813 |
789 /*! |
814 /*! |
790 @proto |
815 @beta |
791 Returns the description of the item. |
816 Returns the description of the item. |
792 */ |
817 */ |
793 QString HbDataFormModelItem::description() const |
818 QString HbDataFormModelItem::description() const |
794 { |
819 { |
795 return data(DescriptionRole).toString(); |
820 return data(DescriptionRole).toString(); |