controlpanelui/src/cpplugins/ringtoneplugin/src/cppersonalizationentryitemdata.cpp
changeset 40 593f946f4fec
parent 22 a5692c68d772
equal deleted inserted replaced
22:a5692c68d772 40:593f946f4fec
    45     CPFW_LOG("CpPersonalizationEntryItemData::CpPersonalizationEntryItemData(), START");
    45     CPFW_LOG("CpPersonalizationEntryItemData::CpPersonalizationEntryItemData(), START");
    46     mProfileModel = new CpProfileModel();
    46     mProfileModel = new CpProfileModel();
    47     if( mProfileModel )
    47     if( mProfileModel )
    48     {
    48     {
    49         QString strRing = loadStringValue();
    49         QString strRing = loadStringValue();
    50         if( strRing.contains( "No_Sound.wav", Qt::CaseInsensitive) )
    50         if( QFileInfo(strRing) == QFileInfo(g_strNoTone) )
    51         {
    51         {
    52             setDescription( hbTrId("txt_cp_list_no_tone" ) );   //sepcial handling about NoTone
    52             setDescription( hbTrId("txt_cp_list_no_tone" ) );   //sepcial handling about NoTone
    53         }
    53         }
    54         else
    54         else
    55         {
    55         {
    56             setDescription( strRing.section(QDir::separator (),-1) );
    56 		    setDescription( QFileInfo(strRing).baseName() );
    57         }
    57         }
    58     }
    58     }
    59     else
    59     else
    60     {
    60     {
    61         CPFW_LOG("CpPersonalizationEntryItemData::mProfileModel:NULL!");
    61         CPFW_LOG("CpPersonalizationEntryItemData::mProfileModel:NULL!");
    62     }
    62     }
    63     mSettingManager = new XQSettingsManager();
    63     mSettingManager = new XQSettingsManager();
    64     XQCentralRepositorySettingsKey key(KCRUidProfileEngine.iUid,KProEngSilenceMode);
    64     XQCentralRepositorySettingsKey key(KCRUidProfileEngine.iUid,KProEngSilenceMode);
    65 
    65     
       
    66     //Monitoring the active ring tone
       
    67     XQCentralRepositorySettingsKey keyForActiveRingTone(KCRUidProfileEngine.iUid,KProEngActiveRingTone);
       
    68     
    66     QVariant silenceMode = mSettingManager->readItemValue( key,XQSettingsManager::TypeInt );
    69     QVariant silenceMode = mSettingManager->readItemValue( key,XQSettingsManager::TypeInt );
    67     setEnabled( !silenceMode.toInt() );
    70     setEnabled( !silenceMode.toInt() );
    68     mSettingManager->startMonitoring( key,XQSettingsManager::TypeInt );
    71     mSettingManager->startMonitoring( key,XQSettingsManager::TypeInt );
       
    72     mSettingManager->startMonitoring(keyForActiveRingTone, XQSettingsManager::TypeString);
    69     connect(mSettingManager, SIGNAL(valueChanged (XQSettingsKey, QVariant)),
    73     connect(mSettingManager, SIGNAL(valueChanged (XQSettingsKey, QVariant)),
    70             this, SLOT(settingValueChanged(XQSettingsKey, QVariant)));
    74             this, SLOT(settingValueChanged(XQSettingsKey, QVariant)));
    71 
    75 
    72 }
    76 }
    73 void CpPersonalizationEntryItemData::settingValueChanged( const XQSettingsKey& key, const QVariant& value )
    77 void CpPersonalizationEntryItemData::settingValueChanged( const XQSettingsKey& key, const QVariant& value )
    74 {
    78 {
    75     Q_UNUSED(key);
    79     switch (key.key()) {
    76     setEnabled( !value.toInt() );
    80         case KProEngActiveRingTone:
       
    81         {
       
    82             QString strRing = loadStringValue();
       
    83             if( QFileInfo(strRing) == QFileInfo(g_strNoTone) )
       
    84             {
       
    85                 setDescription( hbTrId("txt_cp_list_no_tone" ) );   //sepcial handling about NoTone
       
    86             }
       
    87             else
       
    88             {
       
    89                 setDescription( QFileInfo(strRing).baseName() );
       
    90             }
       
    91             break;
       
    92         }
       
    93         case KProEngSilenceMode:
       
    94         {
       
    95             setEnabled( !value.toInt() );
       
    96             break;
       
    97             
       
    98         }
       
    99         default:
       
   100             break;
       
   101     }    
    77 }
   102 }
    78 
   103 
    79 CpPersonalizationEntryItemData::~CpPersonalizationEntryItemData()
   104 CpPersonalizationEntryItemData::~CpPersonalizationEntryItemData()
    80 {
   105 {
    81     if( mProfileModel )
   106     if( mProfileModel )
   114         break;
   139         break;
   115     case TONE_Ring:
   140     case TONE_Ring:
   116     default:
   141     default:
   117         if( m_profileID <0 )
   142         if( m_profileID <0 )
   118         {
   143         {
       
   144             
   119             strRing = mProfileModel->ringTone();
   145             strRing = mProfileModel->ringTone();
   120         }
   146         }
   121         else
   147         else
   122         {
   148         {
   123             strRing = mProfileModel->ringTone( m_profileID );
   149             strRing = mProfileModel->ringTone( m_profileID );
   169 }
   195 }
   170 
   196 
   171 void CpPersonalizationEntryItemData::handleOk(const QString &strFname)
   197 void CpPersonalizationEntryItemData::handleOk(const QString &strFname)
   172 {
   198 {
   173     if(strFname.length())
   199     if(strFname.length())
   174     {
   200     {   
   175         setDescription( strFname.section(QDir::separator (),-1) );
   201         //lower level services(tone fetcher or music fetcher)
       
   202         //will guarantee strFname is a valid absolute file path.
       
   203         setDescription(QFileInfo(strFname).baseName());
   176     }
   204     }
   177     else
   205     else
   178     {
   206     {
   179         setDescription( hbTrId("txt_cp_list_no_tone" ) );
   207         setDescription( hbTrId("txt_cp_list_no_tone" ) );
   180     }
   208     }