ipsservices/nmipssettings/src/nmipssettingsplugin.cpp
changeset 62 a8c646b56683
parent 57 ae34e1715e21
child 68 83cc6bae1de8
equal deleted inserted replaced
57:ae34e1715e21 62:a8c646b56683
    24 #include <HbStringUtil>
    24 #include <HbStringUtil>
    25 #include <HbDataForm>
    25 #include <HbDataForm>
    26 #include <HbDataFormModel>
    26 #include <HbDataFormModel>
    27 #include <HbDataFormModelItem>
    27 #include <HbDataFormModelItem>
    28 #include <HbLineEdit>
    28 #include <HbLineEdit>
       
    29 #include <HbAction>
    29 
    30 
    30 #include <cpsettingformitemdata.h>
    31 #include <cpsettingformitemdata.h>
    31 
    32 
    32 #include "nmipssettingsplugin.h"
    33 #include "nmipssettingsplugin.h"
    33 #include "nmipssettingshelper.h"
    34 #include "nmipssettingshelper.h"
    58     Constructor of NmIpsSettingsPlugin.
    59     Constructor of NmIpsSettingsPlugin.
    59 */
    60 */
    60 NmIpsSettingsPlugin::NmIpsSettingsPlugin()
    61 NmIpsSettingsPlugin::NmIpsSettingsPlugin()
    61 : mSettingsHelper(0),
    62 : mSettingsHelper(0),
    62   mSettingsManager(0),
    63   mSettingsManager(0),
    63   mHiddenItem(false)
    64   mHiddenItem(false),
       
    65   mCurrentInboxIndex(-1)
    64 {
    66 {
    65     QString lang = QLocale::system().name();
    67     QString lang = QLocale::system().name();
    66     QString path = "Z:/resource/qt/translations/";
    68     QString path = "Z:/resource/qt/translations/";
    67     QString appName = "mailips_";
    69     QString appName = "mailips_";
    68     QString commonName = "common_";
    70     QString commonName = "common_";
   334     item.appendChild(showMailInInboxItem);
   336     item.appendChild(showMailInInboxItem);
   335 
   337 
   336     // Active sync profile connection
   338     // Active sync profile connection
   337     mForm->addConnection(infoItem, SIGNAL(currentIndexChanged(int)),
   339     mForm->addConnection(infoItem, SIGNAL(currentIndexChanged(int)),
   338         mSettingsHelper, SLOT(receivingScheduleChange(int)));
   340         mSettingsHelper, SLOT(receivingScheduleChange(int)));
   339 
   341     mForm->addConnection(showMailInInboxItem, SIGNAL(finished(HbAction *)),
   340     mForm->addConnection(showMailInInboxItem, SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),
   342            this, SLOT(showMailInInboxModified(HbAction *)));
   341         this, SLOT(showMailInInboxModified(QPersistentModelIndex, QVariant)));
   343     mForm->addConnection(showMailInInboxItem, SIGNAL(itemSelected(int)),
   342 
   344            this, SLOT(inboxSelectionModified(int)));
       
   345     
   343     // Must be called manually here, because the signal->slot connection set above using
   346     // Must be called manually here, because the signal->slot connection set above using
   344     // HbDataForm::addConnection() is actually established AFTER the properties have first been
   347     // HbDataForm::addConnection() is actually established AFTER the properties have first been
   345     // set to the widget, causing the first currentIndexChanged signal not to reach
   348     // set to the widget, causing the first currentIndexChanged signal not to reach
   346     // NmIpsSettingsHelper::receivingScheduleChange().
   349     // NmIpsSettingsHelper::receivingScheduleChange().
   347     mSettingsHelper->receivingScheduleChange(profileIndex.toInt());
   350     mSettingsHelper->receivingScheduleChange(profileIndex.toInt());
   632         mSettingsManager->writeSetting(IpsServices::ReceptionUserDefinedProfile, userDefineMode);
   635         mSettingsManager->writeSetting(IpsServices::ReceptionUserDefinedProfile, userDefineMode);
   633     }
   636     }
   634 }
   637 }
   635 
   638 
   636 /*!
   639 /*!
   637     Handles mail in inbox modifications.
   640 Handles mail in inbox modifications.
   638 
   641 
   639     \param value Selected value as a text.
   642 \param action Action that determines whether user clicked OK or cancel.
   640 */
   643 */
   641 void NmIpsSettingsPlugin::showMailInInboxModified(QPersistentModelIndex, QVariant value)
   644 void NmIpsSettingsPlugin::showMailInInboxModified(HbAction *action)
   642 {
   645 {
   643     QMap<QString, int> conversionTable;
   646     if ((action->text() == hbTrId("txt_common_button_ok"))
   644     conversionTable[HbStringUtil::convertDigits("50")] = 50;
   647             && (mCurrentInboxIndex >=0 && mCurrentInboxIndex <=3)) {
   645     conversionTable[HbStringUtil::convertDigits("100")] = 100;
   648         int conversionTable[] = { 50, 100, 500, 0 };
   646     conversionTable[HbStringUtil::convertDigits("500")] = 500;
   649         int selectedValue(conversionTable[mCurrentInboxIndex]);
   647     conversionTable[hbTrId("txt_mailips_setlabel_val_all")] = 0;
   650         
   648 
   651         QVariant previouslySelectedValue;
   649     int selectedValue(conversionTable.value(value.toString()));
   652         mSettingsManager->readSetting(IpsServices::ReceptionInboxSyncWindow, previouslySelectedValue);
   650     QVariant previouslySelectedValue;
   653         if (previouslySelectedValue.toInt() != selectedValue) {
   651     mSettingsManager->readSetting(IpsServices::ReceptionInboxSyncWindow, previouslySelectedValue);
   654             mSettingsHelper->handleReceivingScheduleSettingChange(
   652     if (previouslySelectedValue.toInt() != selectedValue) {
   655                 IpsServices::ReceptionInboxSyncWindow, selectedValue);
   653         mSettingsHelper->handleReceivingScheduleSettingChange(
   656         }
   654             IpsServices::ReceptionInboxSyncWindow, selectedValue);
   657     }
   655     }
   658     mCurrentInboxIndex = -1;
       
   659 }
       
   660 /*!
       
   661 Handles mail in inbox modifications.
       
   662 
       
   663 Index   Value
       
   664 0       50
       
   665 1       100
       
   666 2       500
       
   667 3       All
       
   668 
       
   669 \param index The index value of the selection.
       
   670 */
       
   671 void NmIpsSettingsPlugin::inboxSelectionModified(int index)
       
   672 {
       
   673     mCurrentInboxIndex = index;
   656 }
   674 }
   657 
   675 
   658 Q_EXPORT_PLUGIN2(nmipssettings, NmIpsSettingsPlugin);
   676 Q_EXPORT_PLUGIN2(nmipssettings, NmIpsSettingsPlugin);