controlpanel/src/cpframework/src/cpdataformbuttonentryviewitem.cpp
changeset 23 7e4c5a2ff1a2
parent 21 851e19007849
child 52 58cebe0861a8
--- a/controlpanel/src/cpframework/src/cpdataformbuttonentryviewitem.cpp	Mon May 03 12:46:45 2010 +0300
+++ b/controlpanel/src/cpframework/src/cpdataformbuttonentryviewitem.cpp	Fri May 14 16:07:47 2010 +0300
@@ -121,13 +121,14 @@
 }
 
 /*!
+    Deprecated. Be instead of HbDataFormViewItem::restore()
 	Inherit from HbDataForm. This function is called by hbdataform's framework, 
 	for supporting to load entry item's text, icon and additional text dynamically.
-	It is not recommanded to call this function mannually.
+	It is not recommended to call this function manually.
  */
 void CpDataFormButtonEntryViewItem::load()
 {
-	HbDataFormViewItem::load();
+	//HbDataFormViewItem::load();
 
 	if (d_ptr->mWidget) {
 		HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
@@ -152,5 +153,37 @@
 		}
 	}
 }
+/*!
+    Inherit from HbDataForm. This function is called by hbdataform's framework, 
+    for supporting to load entry item's text, icon and additional text dynamically.
+    It is not recommended to call this function manually.
+ */
+void CpDataFormButtonEntryViewItem::restore()
+{
+    HbDataFormViewItem::restore();
+
+    if (d_ptr->mWidget) {
+        HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
+            modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
+
+        if(itemType == CpSettingFormEntryItemData::ButtonEntryItem) {
+
+            QModelIndex itemIndex = modelIndex();
+            HbDataFormModel *model = static_cast<HbDataFormModel*>(itemView()->model());;
+            HbDataFormModelItem *modelItem = static_cast<HbDataFormModelItem*>(
+                model->itemFromIndex(itemIndex));
+
+            const QMetaObject *metaObj = d_ptr->mWidget->metaObject();
+            int count = metaObj->propertyCount();
+            for (int i = 0; i < count; i++) {
+                QMetaProperty metaProperty = metaObj->property(i);
+                if (metaProperty.isValid() && metaProperty.isWritable()) {
+                    metaProperty.write(d_ptr->mWidget,modelItem->contentWidgetData(metaProperty.name()));
+                }
+
+            }
+        }
+    }
+}
 
 //End of File