controlpanelui/src/cpplugins/communicationplugin/src/cpcommunicationgroupitemdata.cpp
changeset 40 593f946f4fec
parent 22 a5692c68d772
equal deleted inserted replaced
22:a5692c68d772 40:593f946f4fec
    46     delete mSettingManager;
    46     delete mSettingManager;
    47 }
    47 }
    48 
    48 
    49 void CpCommunicationGroupItemData::beforeLoadingConfigPlugins(CpItemDataHelper &itemDataHelper)
    49 void CpCommunicationGroupItemData::beforeLoadingConfigPlugins(CpItemDataHelper &itemDataHelper)
    50 {
    50 {
    51     mAirplaneModeItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem);
    51     mAirplaneModeItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem);    
       
    52     mAirplaneModeItem->setContentWidgetData("text", hbTrId("txt_cp_button_offline"));
       
    53 	mAirplaneModeItem->setContentWidgetData("additionalText", hbTrId("txt_cp_button_offline"));
    52     mAirplaneModeItem->setDescription(hbTrId("txt_cp_info_in_offline_mode_all_wireless_communica"));
    54     mAirplaneModeItem->setDescription(hbTrId("txt_cp_info_in_offline_mode_all_wireless_communica"));
    53     
    55     mAirplaneModeItem->setContentWidgetData("objectName", "airplaneModeToggle");
       
    56     mAirplaneModeItem->setContentWidgetData("checkable", true);
    54     itemDataHelper.addConnection(mAirplaneModeItem,
    57     itemDataHelper.addConnection(mAirplaneModeItem,
    55             SIGNAL(clicked()),
    58             SIGNAL(toggled(bool)),
    56             this,
    59             this,
    57             SLOT(toggleAirplaneMode()));
    60             SLOT(toggleAirplaneMode(bool)));
    58     
    61     
    59     XQCentralRepositorySettingsKey key(KCRUidCoreApplicationUIs.iUid,KCoreAppUIsNetworkConnectionAllowed);
    62     XQCentralRepositorySettingsKey key(KCRUidCoreApplicationUIs.iUid,KCoreAppUIsNetworkConnectionAllowed);
    60     QVariant airplaneMode = mSettingManager->readItemValue(key,XQSettingsManager::TypeInt);
    63     QVariant airplaneMode = mSettingManager->readItemValue(key,XQSettingsManager::TypeInt);
    61     settingValueChanged(key,airplaneMode);
    64     settingValueChanged(key,airplaneMode);
    62     
    65     
    66     
    69     
    67     this->appendChild(mAirplaneModeItem);
    70     this->appendChild(mAirplaneModeItem);
    68     
    71     
    69 }
    72 }
    70 
    73 
    71 void CpCommunicationGroupItemData::toggleAirplaneMode()
    74 void CpCommunicationGroupItemData::toggleAirplaneMode(bool toggled)
    72 {
    75 {    
    73     XQCentralRepositorySettingsKey key(KCRUidCoreApplicationUIs.iUid,KCoreAppUIsNetworkConnectionAllowed);
    76     XQCentralRepositorySettingsKey key(KCRUidCoreApplicationUIs.iUid,KCoreAppUIsNetworkConnectionAllowed);
    74     QVariant airplaneMode = mSettingManager->readItemValue(key,XQSettingsManager::TypeInt);
    77     //toggled = true means ECoreAppUIsNetworkConnectionNotAllowed
    75         
    78     //toggled = false means ECoreAppUIsNetworkConnectionAllowed
    76     airplaneMode.setValue( static_cast<int> (!airplaneMode.toBool()) );
    79     QVariant airplaneMode(static_cast<int>(!toggled));
    77 
    80     mSettingManager->writeItemValue(key, airplaneMode);
    78     mSettingManager->writeItemValue(key,airplaneMode);
       
    79 }
    81 }
    80 
    82 
    81 void CpCommunicationGroupItemData::settingValueChanged(const XQSettingsKey &key, const QVariant &value)
    83 void CpCommunicationGroupItemData::settingValueChanged(const XQSettingsKey &key, const QVariant &value)
    82 {
    84 {
    83     if (mAirplaneModeItem 
    85     if (mAirplaneModeItem 
    84         && key.uid() == KCRUidCoreApplicationUIs.iUid 
    86         && key.uid() == KCRUidCoreApplicationUIs.iUid 
    85         && key.key() == KCoreAppUIsNetworkConnectionAllowed 
    87         && key.key() == KCoreAppUIsNetworkConnectionAllowed 
    86         && value.isValid()) {
    88         && value.isValid()) {          
    87         QString text = hbTrId("txt_cp_setlabel_offline_mode_val_on");
    89         //value.toBool() returns 
    88         QString additionalText = hbTrId("txt_cp_setlabel_offline_mode_val_off");
    90         //true(1) if value equals ECoreAppUIsNetworkConnectionAllowed, that means offline mode off.
    89         if (ECoreAppUIsNetworkConnectionAllowed == value.toInt()) {
    91         //false(0) if value equals ECoreAppUIsNetworkConnectionNotAllowed, that means offline mode on.
    90             ::qSwap (text, additionalText);
    92         mAirplaneModeItem->setContentWidgetData("checked", !value.toBool());
    91         }
       
    92         mAirplaneModeItem->setContentWidgetData("text",text);
       
    93         mAirplaneModeItem->setContentWidgetData("additionalText",additionalText);
       
    94     }
    93     }
    95 }
    94 }
    96 
    95 
    97 //End of File
    96 //End of File