controlpanel/src/cpframework/src/cpdataformbuttonentryviewitem.cpp
changeset 55 4c15d9aa2384
parent 37 940f6b67827d
equal deleted inserted replaced
47:dbe66a66f6a9 55:4c15d9aa2384
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  
    14 * Description:  View item implementation for button entry item.
    15 *
    15 *
    16 */
    16 */
    17 #include "cpdataformbuttonentryviewitem.h"
    17 #include "cpdataformbuttonentryviewitem.h"
    18 #include <hbdataformmodelitem.h>
    18 #include <hbdataformmodelitem.h>
    19 #include <hbpushbutton.h>
    19 #include <hbpushbutton.h>
   119     
   119     
   120     return 0;
   120     return 0;
   121 }
   121 }
   122 
   122 
   123 /*!
   123 /*!
   124     Deprecated. Be instead of HbDataFormViewItem::restore()
       
   125 	Inherit from HbDataForm. This function is called by hbdataform's framework, 
       
   126 	for supporting to load entry item's text, icon and additional text dynamically.
       
   127 	It is not recommended to call this function manually.
       
   128  */
       
   129 void CpDataFormButtonEntryViewItem::load()
       
   130 {
       
   131 	//HbDataFormViewItem::load();
       
   132 
       
   133 	if (d_ptr->mWidget) {
       
   134 		HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
       
   135 			modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
       
   136 
       
   137 		if(itemType == CpSettingFormEntryItemData::ButtonEntryItem) {
       
   138 
       
   139 			QModelIndex itemIndex = modelIndex();
       
   140 			HbDataFormModel *model = static_cast<HbDataFormModel*>(itemView()->model());;
       
   141 			HbDataFormModelItem *modelItem = static_cast<HbDataFormModelItem*>(
       
   142 				model->itemFromIndex(itemIndex));
       
   143 
       
   144 			const QMetaObject *metaObj = d_ptr->mWidget->metaObject();
       
   145 			int count = metaObj->propertyCount();
       
   146 			for (int i = 0; i < count; i++) {
       
   147 				QMetaProperty metaProperty = metaObj->property(i);
       
   148 				if (metaProperty.isValid() && metaProperty.isWritable()) {
       
   149 					metaProperty.write(d_ptr->mWidget,modelItem->contentWidgetData(metaProperty.name()));
       
   150 				}
       
   151 
       
   152 			}
       
   153 		}
       
   154 	}
       
   155 }
       
   156 /*!
       
   157     Inherit from HbDataForm. This function is called by hbdataform's framework, 
   124     Inherit from HbDataForm. This function is called by hbdataform's framework, 
   158     for supporting to load entry item's text, icon and additional text dynamically.
   125     for supporting to load entry item's text, icon and additional text dynamically.
   159     It is not recommended to call this function manually.
   126     It is not recommended to call this function manually.
   160  */
   127  */
   161 void CpDataFormButtonEntryViewItem::restore()
   128 void CpDataFormButtonEntryViewItem::restore()
   162 {
   129 {
   163     HbDataFormViewItem::restore();
   130     HbDataFormViewItem::restore();
   164 
   131 
       
   132     // Set widget's properties according to model item's content widget data
       
   133     // so that the widget can be refreshed
   165     if (d_ptr->mWidget) {
   134     if (d_ptr->mWidget) {
   166         HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
   135         HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
   167             modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
   136             modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
   168 
   137 
   169         if(itemType == CpSettingFormEntryItemData::ButtonEntryItem) {
   138         if(itemType == CpSettingFormEntryItemData::ButtonEntryItem) {