coreapplicationuis/Rfs/Plugins/cprfsplugin/src/cprfssettingsform.cpp
changeset 56 11a052f4b02e
parent 21 c4cbaa4fb734
equal deleted inserted replaced
49:76883296a0d5 56:11a052f4b02e
    23 #include <hbdataformmodel.h>
    23 #include <hbdataformmodel.h>
    24 #include <hbpushbutton.h>
    24 #include <hbpushbutton.h>
    25 #include <rfsHandler.h>
    25 #include <rfsHandler.h>
    26 
    26 
    27 CpRfsSettingsForm::CpRfsSettingsForm(QGraphicsItem *parent) :
    27 CpRfsSettingsForm::CpRfsSettingsForm(QGraphicsItem *parent) :
    28     HbDataForm(parent)
    28     HbDataForm(parent),mTrans("control_panel")
    29     {
    29     {
    30     this->setHeading(tr("Restore Factory Settings"));
    30     this->setHeading(hbTrId("txt_cp_subhead_reset"));
    31 
    31 
    32     //initialize the form model
    32     //initialize the form model
    33     initRfsSettingModel();
    33     initRfsSettingModel();
    34 
    34 
    35     connect(this, SIGNAL(activated(QModelIndex)),this, SLOT(onItemActivated(QModelIndex)));
    35     connect(this, SIGNAL(itemShown(QModelIndex)),this, SLOT(onItemActivated(QModelIndex)));
    36     }
    36     }
    37 
    37 
    38 CpRfsSettingsForm::~CpRfsSettingsForm()
    38 CpRfsSettingsForm::~CpRfsSettingsForm()
    39     {
    39     {
       
    40     
    40     }
    41     }
    41 
    42 
    42 void CpRfsSettingsForm::initRfsSettingModel()
    43 void CpRfsSettingsForm::initRfsSettingModel()
    43     {
    44     {
    44     HbDataFormModel *model = new HbDataFormModel(0);
    45     HbDataFormModel *model = new HbDataFormModel(0);
    45 
    46 
    46 		// Create the custom items because HbPushButton cannot be added to the HbDataFormModelItem
    47 		// Create the custom items because HbPushButton cannot be added to the HbDataFormModelItem
    47     HbDataFormModelItem::DataItemType customItem = static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase + 1);
       
    48                     
       
    49     mNormalRfs = model->appendDataFormItem(customItem, QString(), model->invisibleRootItem());
       
    50     mNormalRfs->setData(HbDataFormModelItem::KeyRole, tr("Restore"));
       
    51 
       
    52     HbDataFormModelItem::DataItemType customItem1 = static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase + 1);
    48     HbDataFormModelItem::DataItemType customItem1 = static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase + 1);
    53                     
    49     
    54     mDeepRfs = model->appendDataFormItem(customItem1, QString(), model->invisibleRootItem());
    50     mNormalRfs = model->appendDataFormItem(customItem1, QString(), model->invisibleRootItem());
    55     mDeepRfs->setData(HbDataFormModelItem::KeyRole,tr("Delete Data and Restore"));
    51     mNormalRfs->setLabel(hbTrId("txt_cp_setlabel_settings_reset"));
    56 
    52     mNormalRfs->setDescription(hbTrId("txt_cp_info_original_settings_will_be_restored_no"));
       
    53     HbDataFormModelItem::DataItemType customItem2 = static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase + 2);
       
    54                
       
    55     mDeepRfs = model->appendDataFormItem(customItem2, QString(), model->invisibleRootItem());
       
    56     mDeepRfs->setLabel(hbTrId("txt_cp_setlabel_device_reset"));
       
    57     mDeepRfs->setDescription(hbTrId("txt_cp_info_all_data_will_be_deleted_and_factory_s")); 
    57     this->setModel(model);
    58     this->setModel(model);
    58     }
    59     }
    59 
    60 
    60 // On Item activated
    61 // On Item activated
    61 void CpRfsSettingsForm::onItemActivated(const QModelIndex &index)
    62 void CpRfsSettingsForm::onItemActivated(const QModelIndex &index)
    63     HbDataFormModelItem *itemData = static_cast<HbDataFormModelItem *> (index.internalPointer());
    64     HbDataFormModelItem *itemData = static_cast<HbDataFormModelItem *> (index.internalPointer());
    64     // to deal with orbit change temparialy
    65     // to deal with orbit change temparialy
    65     if (itemData->type() > HbDataFormModelItem::GroupPageItem)
    66     if (itemData->type() > HbDataFormModelItem::GroupPageItem)
    66         {
    67         {
    67         //get the widget of setting item
    68         //get the widget of setting item
    68         HbWidget* widget = this->dataFormViewItem(index)->dataItemContentWidget();
    69         HbAbstractViewItem* viewitem  = static_cast<HbAbstractItemView*>(this)->itemByIndex(index);
    69 
    70         HbWidget* widget =static_cast<HbDataFormViewItem*>(viewitem)->dataItemContentWidget(); 
    70 		if (itemData == mNormalRfs)
    71 		if (itemData == mNormalRfs)
    71             {
    72             {
    72             activateNormalRfs(widget);
    73             activateNormalRfs(widget);
    73             }
    74             }
    74 		if (itemData == mDeepRfs)
    75 		if (itemData == mDeepRfs)