controlpanelui/src/cpplugins/personalizationplugin/src/cpprofilesettingform.cpp
changeset 22 a5692c68d772
parent 21 2883a5458389
child 26 808caa51b78b
child 40 593f946f4fec
equal deleted inserted replaced
21:2883a5458389 22:a5692c68d772
   100     QHash<int,HbDataFormModelItem*> modelItems;
   100     QHash<int,HbDataFormModelItem*> modelItems;
   101     
   101     
   102     //ring tone item
   102     //ring tone item
   103     QFileInfo ringToneFileInfo( profileSettings.mRingTone );
   103     QFileInfo ringToneFileInfo( profileSettings.mRingTone );
   104     HbDataFormModelItem *modelItem = new CpPersonalizationEntryItemData( *mItemDataHelper,
   104     HbDataFormModelItem *modelItem = new CpPersonalizationEntryItemData( *mItemDataHelper,
   105             hbTrId("txt_cp_dblist_ringtone"), ringToneFileInfo.fileName(), mFileIconProvider->icon( ringToneFileInfo ),
   105             hbTrId("txt_cp_dblist_ringtone"), ringToneFileInfo.fileName(), "qtg_large_ring_tone",
   106             CpPersonalizationEntryItemData::TONE_Ring, profileId );
   106             CpPersonalizationEntryItemData::TONE_Ring, profileId );
   107     mModel->appendDataFormItem(modelItem, parent);
   107     mModel->appendDataFormItem(modelItem, parent);
   108     modelItems.insert(ProfileItemRingTone,modelItem);
   108     modelItems.insert(ProfileItemRingTone,modelItem);
   109     
   109     
   110     //message tone item
   110     //message tone item
   111     QFileInfo messageToneFileInfo( profileSettings.mMessageTone );
   111     QFileInfo messageToneFileInfo( profileSettings.mMessageTone );
   112     modelItem = new CpPersonalizationEntryItemData( *mItemDataHelper,
   112     modelItem = new CpPersonalizationEntryItemData( *mItemDataHelper,
   113             hbTrId("txt_cp_dblist_message_tone"), messageToneFileInfo.fileName(), mFileIconProvider->icon( messageToneFileInfo ),
   113             hbTrId("txt_cp_dblist_message_tone"), messageToneFileInfo.fileName(), "qtg_large_message",
   114             CpPersonalizationEntryItemData::TONE_Message,
   114             CpPersonalizationEntryItemData::TONE_Message,
   115             profileId );
   115             profileId );
   116     mModel->appendDataFormItem(modelItem , parent);
   116     mModel->appendDataFormItem(modelItem , parent);
   117     modelItems.insert(ProfileItemMessageTone,modelItem);
   117     modelItems.insert(ProfileItemMessageTone,modelItem);
   118     
   118     
   119     //email tone item
   119     //email tone item
   120     QFileInfo emailToneFileInfo( profileSettings.mEmailTone );
   120     QFileInfo emailToneFileInfo( profileSettings.mEmailTone );
   121     modelItem = new CpPersonalizationEntryItemData( *mItemDataHelper,
   121     modelItem = new CpPersonalizationEntryItemData( *mItemDataHelper,
   122             hbTrId("txt_cp_dblist_email_tone"),  emailToneFileInfo.fileName(), mFileIconProvider->icon( emailToneFileInfo ),
   122             hbTrId("txt_cp_dblist_email_tone"),  emailToneFileInfo.fileName(), "qtg_large_email",
   123             CpPersonalizationEntryItemData::TONE_Email,
   123             CpPersonalizationEntryItemData::TONE_Email,
   124             profileId );
   124             profileId );
   125     mModel->appendDataFormItem(modelItem , parent);
   125     mModel->appendDataFormItem(modelItem , parent);
   126     modelItems.insert(ProfileItemEmailTone,modelItem);
   126     modelItems.insert(ProfileItemEmailTone,modelItem);
   127     
   127     
   128     //reminder tone item
   128     //reminder tone item
   129     QFileInfo reminderToneFileInfo( profileSettings.mReminderTone );
   129     QFileInfo reminderToneFileInfo( profileSettings.mReminderTone );
   130     modelItem = new CpPersonalizationEntryItemData( *mItemDataHelper,
   130     modelItem = new CpPersonalizationEntryItemData( *mItemDataHelper,
   131             hbTrId("txt_cp_dblist_reminder_tone"), reminderToneFileInfo.fileName(), mFileIconProvider->icon( reminderToneFileInfo ),
   131             hbTrId("txt_cp_dblist_reminder_tone"), reminderToneFileInfo.fileName(), "qtg_large_calendar",
   132             CpPersonalizationEntryItemData::TONE_Reminder,
   132             CpPersonalizationEntryItemData::TONE_Reminder,
   133             profileId );
   133             profileId );
   134     mModel->appendDataFormItem(modelItem , parent);
   134     mModel->appendDataFormItem(modelItem , parent);
   135     modelItems.insert(ProfileItemReminderTone,modelItem);
   135     modelItems.insert(ProfileItemReminderTone,modelItem);
   136     
   136     
   417 {
   417 {
   418     mProfileModel->setKeyTouchScreenTone( EProfileWrapperGeneralId, value );
   418     mProfileModel->setKeyTouchScreenTone( EProfileWrapperGeneralId, value );
   419     HbDataFormModelItem *modelItem = profileItem(EProfileWrapperGeneralId,ProfileItemKeyandTouchScreenTones);
   419     HbDataFormModelItem *modelItem = profileItem(EProfileWrapperGeneralId,ProfileItemKeyandTouchScreenTones);
   420     if (modelItem) {
   420     if (modelItem) {
   421         modelItem->setContentWidgetData( QString("value"), value );
   421         modelItem->setContentWidgetData( QString("value"), value );
   422         QMap< QString, QVariant > elements;
   422         setMuteIcon(modelItem, (value == 0) );            
   423         if (value != 0) {      
       
   424             elements.insert(QString("DecreaseElement"), QVariant(":/icon/hb_vol_slider_decrement.svg"));
       
   425             elements.insert(QString("IncreaseElement"), QVariant(":/icon/hb_vol_slider_increment.svg"));
       
   426             elements.insert(QString("IconElement"), QVariant(":/icon/hb_vol_slider_unmuted.svg") );            
       
   427         }
       
   428         else {
       
   429             elements.insert(QString("DecreaseElement"), QVariant(":/icon/hb_vol_slider_decrement.svg"));
       
   430             elements.insert(QString("IncreaseElement"), QVariant(":/icon/hb_vol_slider_increment.svg"));
       
   431             elements.insert(QString("IconElement"), QVariant(":/icon/hb_vol_slider_muted.svg") );  
       
   432         }
       
   433         modelItem->setContentWidgetData( QString( "elementIcons" ), elements );            
       
   434     }
   423     }
   435 }
   424 }
   436 
   425 
   437 
   426 
   438 //general vibra
   427 //general vibra
   479     mProfileModel->setKeyTouchScreenTone( EProfileWrapperMeetingId, value );
   468     mProfileModel->setKeyTouchScreenTone( EProfileWrapperMeetingId, value );
   480     
   469     
   481     HbDataFormModelItem *modelItem = profileItem(EProfileWrapperMeetingId,ProfileItemKeyandTouchScreenTones);
   470     HbDataFormModelItem *modelItem = profileItem(EProfileWrapperMeetingId,ProfileItemKeyandTouchScreenTones);
   482     if (modelItem) {
   471     if (modelItem) {
   483         modelItem->setContentWidgetData( QString("value"), value );
   472         modelItem->setContentWidgetData( QString("value"), value );
   484         QMap< QString, QVariant > elements;
   473         setMuteIcon(modelItem, (value == 0) );            
   485         if (value != 0) {
       
   486             elements.insert(QString("DecreaseElement"), QVariant(":/icon/hb_vol_slider_decrement.svg"));
       
   487             elements.insert(QString("IncreaseElement"), QVariant(":/icon/hb_vol_slider_increment.svg"));
       
   488             elements.insert(QString("IconElement"), QVariant(":/icon/hb_vol_slider_unmuted.svg") );            
       
   489         }
       
   490         else {
       
   491             elements.insert(QString("DecreaseElement"), QVariant(":/icon/hb_vol_slider_decrement.svg"));
       
   492             elements.insert(QString("IncreaseElement"), QVariant(":/icon/hb_vol_slider_increment.svg"));
       
   493             elements.insert(QString("IconElement"), QVariant(":/icon/hb_vol_slider_muted.svg") );  
       
   494         }
       
   495         modelItem->setContentWidgetData( QString( "elementIcons" ), elements );            
       
   496     }
   474     }
   497 }
   475 }
   498 
   476 
   499 
   477 
   500 //meeting vibra
   478 //meeting vibra
   555         QHash< int,QHash<int,HbDataFormModelItem*>  >::const_iterator it (mProfileModelItems.begin());
   533         QHash< int,QHash<int,HbDataFormModelItem*>  >::const_iterator it (mProfileModelItems.begin());
   556         for(; it != mProfileModelItems.end(); ++it ) {          
   534         for(; it != mProfileModelItems.end(); ++it ) {          
   557             for (int i = 0; i < sizeof(silenceSensitiveModelItemIds)/sizeof(silenceSensitiveModelItemIds[0]);++i) {           
   535             for (int i = 0; i < sizeof(silenceSensitiveModelItemIds)/sizeof(silenceSensitiveModelItemIds[0]);++i) {           
   558                 QHash<int,HbDataFormModelItem*>::const_iterator found = it.value().find(silenceSensitiveModelItemIds[i]);
   536                 QHash<int,HbDataFormModelItem*>::const_iterator found = it.value().find(silenceSensitiveModelItemIds[i]);
   559                 if (found != it.value().end()) {
   537                 if (found != it.value().end()) {
   560                     found.value()->setEnabled(!value.toBool());
   538                     if (found.key() == CpProfileSettingForm::ProfileItemKeyandTouchScreenTones) {
       
   539                         int currentValue = found.value()->contentWidgetData("value").toInt();
       
   540                         // change the mute icon when the silence mode is changed
       
   541                         bool isMute = value.toBool() || (currentValue == 0);
       
   542                         setMuteIcon(found.value(), isMute); 
       
   543                     } 
       
   544                     found.value()->setEnabled(!value.toBool());                             
   561                 }
   545                 }
   562             }   
   546             }   
   563         }
   547         }
   564     }
   548     }
   565 }
   549 }
   567 HbDataFormModelItem *CpProfileSettingForm::profileItem(int profileId,int profileItemId)
   551 HbDataFormModelItem *CpProfileSettingForm::profileItem(int profileId,int profileItemId)
   568 {
   552 {
   569     return mProfileModelItems.value(profileId).value(profileItemId);
   553     return mProfileModelItems.value(profileId).value(profileItemId);
   570 }
   554 }
   571 
   555 
       
   556 /*!
       
   557  *  Set the slider icon to mute or unmute
       
   558  *  @param isMute: identified the icon of slider, mute or unmute
       
   559  *  @param profileId: identified which slider should be changed
       
   560  */
       
   561 
       
   562 void CpProfileSettingForm::setMuteIcon(HbDataFormModelItem *sliderItem, bool isMute)
       
   563 {
       
   564     if (sliderItem == 0) {
       
   565         return;
       
   566     }
       
   567     //VolumeSliderItem will be depreacted, so ignore the assert about it
       
   568     if (sliderItem->type() != HbDataFormModelItem::SliderItem) {
       
   569         return;
       
   570     }
       
   571     
       
   572     QMap<QString, QVariant> elements = sliderItem->contentWidgetData("elementIcons").toMap();
       
   573     
       
   574     if (isMute) {        
       
   575         elements.insert(QString("IconElement"), QVariant(":/icon/hb_vol_slider_muted.svg"));
       
   576     }
       
   577     else {
       
   578         elements.insert(QString("IconElement"), QVariant(":/icon/hb_vol_slider_unmuted.svg"));
       
   579     }
       
   580     sliderItem->setContentWidgetData( QString( "elementIcons" ), elements ); 
       
   581 }
   572 //End of File
   582 //End of File