ipsservices/nmipssettings/src/nmipssettingshelper.cpp
changeset 54 997a02608b3a
parent 53 bf7eb7911fc5
child 51 d845db10c0d4
child 59 16ed8d08d0b1
equal deleted inserted replaced
53:bf7eb7911fc5 54:997a02608b3a
   310 
   310 
   311                     // If changes are made to refreshMailItems, conversion table in
   311                     // If changes are made to refreshMailItems, conversion table in
   312                     // refreshPeriodModified method needs to be updated also.
   312                     // refreshPeriodModified method needs to be updated also.
   313                     QStringList refreshMailItems;
   313                     QStringList refreshMailItems;
   314                     refreshMailItems << hbTrId("txt_mailips_setlabel_val_keep_uptodate")
   314                     refreshMailItems << hbTrId("txt_mailips_setlabel_val_keep_uptodate")
   315                                      << hbTrId("txt_mailips_setlabel_val_every_15_minutes")
   315                                      << HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_15_minutes"))
   316                                      << hbTrId("txt_mailips_setlabel_val_every_1_hour")
   316                                      << HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_1_hour"))
   317                                      << hbTrId("txt_mailips_setlabel_val_every_4_hours");
   317                                      << HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_4_hours"));
   318                     formItemData->setContentWidgetData("items", refreshMailItems);
   318                     formItemData->setContentWidgetData("items", refreshMailItems);
   319                     mDataForm.addConnection(
   319                     mDataForm.addConnection(
   320                         formItemData, SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),
   320                         formItemData, SIGNAL(valueChanged(QPersistentModelIndex, QVariant)),
   321                         this, SLOT(refreshPeriodModified(QPersistentModelIndex, QVariant)));
   321                         this, SLOT(refreshPeriodModified(QPersistentModelIndex, QVariant)));
   322                 }
   322                 }
   814 {
   814 {
   815     Q_UNUSED(text);
   815     Q_UNUSED(text);
   816     mCurrentLineEditChanged = true;
   816     mCurrentLineEditChanged = true;
   817 }
   817 }
   818 
   818 
   819 void NmIpsSettingsHelper::handleModelDataChange(QModelIndex startIn, QModelIndex endIn)
       
   820 {
       
   821     Q_UNUSED(endIn);
       
   822     HbDataFormModelItem *item = mDataFormModel.itemFromIndex(startIn);
       
   823     
       
   824     if(item == mContentItems.value(IpsServices::IncomingSecureSockets)) {
       
   825         QVariant data = item->contentWidgetData("selected");
       
   826         incomingSecureConnectionItemChange(data.toInt());
       
   827     }
       
   828     else if(item == mContentItems.value(IpsServices::IncomingPort)) {
       
   829         QVariant data = item->contentWidgetData("selected");
       
   830         incomingPortChange(data.toInt());
       
   831     }
       
   832     else if(item == mContentItems.value(IpsServices::OutgoingSecureSockets)) {
       
   833         QVariant data = item->contentWidgetData("selected");
       
   834         outgoingSecureConnectionItemChange(data.toInt());
       
   835     }
       
   836     else if(item == mContentItems.value(IpsServices::OutgoingPort)) {
       
   837         QVariant data = item->contentWidgetData("selected");
       
   838         outgoingPortChange(data.toInt());
       
   839     }
       
   840     else if(item == mContentItems.value(IpsServices::SMTPAuthentication)) {
       
   841         QVariant data = item->contentWidgetData("selected");
       
   842         outgoingAuthenticationChange(data.toInt());
       
   843     }
       
   844     else if(item == mContentItems.value(IpsServices::FolderPath)) {
       
   845         QVariant data = item->contentWidgetData("selected");
       
   846         folderPathChange(data.toInt());
       
   847     }
       
   848 }
       
   849 
       
   850 /*!
   819 /*!
   851     Saves the incoming port value into database if user has changed the value. If the user wish to
   820     Saves the incoming port value into database if user has changed the value. If the user wish to
   852     define the port, a input dialog is shown.
   821     define the port, a input dialog is shown.
   853     \param index Used to determine if the default value or a user defined value should be written
   822     \param index Used to determine if the default value or a user defined value should be written
   854 */
   823 */
   855 void NmIpsSettingsHelper::incomingPortChange(int index)
   824 void NmIpsSettingsHelper::incomingPortChange(int index)
   856 {
   825 {
   857     int previousindex = getCorrectIncomingPortRadioButtonIndex();
   826     int previousindex = getCorrectIncomingPortRadioButtonIndex();
   858     
   827     
   859     if (previousindex != index ) {
   828     if (index == IpsServices::NmIpsSettingsDefault) {
   860         if (index == IpsServices::NmIpsSettingsDefault) {
   829         if (index != previousindex) {
   861             emit goOffline(mSettingsManager.mailboxId());
   830             emit goOffline(mSettingsManager.mailboxId());
   862             mEmitOnline = true;
   831             mEmitOnline = true;
   863             int port = mSettingsManager.determineDefaultIncomingPort();
   832             int port = mSettingsManager.determineDefaultIncomingPort();
   864             mSettingsManager.writeSetting(IpsServices::IncomingPort, port);
   833             mSettingsManager.writeSetting(IpsServices::IncomingPort, port);    
   865         } else if (index == IpsServices::NmIpsSettingsUserDefined) {
   834         }
   866             showIncomingPortInputDialog();
   835     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
   867         }  
   836         showIncomingPortInputDialog();
   868     }
   837     }
   869 }
   838 }
   870 
   839 
   871 /*!
   840 /*!
   872     Shows an input dialog for allowing the user to specify a incoming port.
   841     Shows an input dialog for allowing the user to specify a incoming port.
  1028     Saves the folderpath value into database if user has changed the value.
   997     Saves the folderpath value into database if user has changed the value.
  1029 */
   998 */
  1030 void NmIpsSettingsHelper::folderPathChange(int index)
   999 void NmIpsSettingsHelper::folderPathChange(int index)
  1031 {
  1000 {
  1032     int previousindex = getCorrectFolderPathRadioButtonIndex();
  1001     int previousindex = getCorrectFolderPathRadioButtonIndex();
  1033     
  1002         
  1034     if (previousindex != index ) {
  1003     if (index == IpsServices::NmIpsSettingsDefault) {
  1035         if (index == IpsServices::NmIpsSettingsDefault) {
  1004         if (index != previousindex ) {
  1036             // Empty string sets the folder path to default.
  1005             // Empty string sets the folder path to default.
  1037             mSettingsManager.writeSetting(IpsServices::FolderPath, "");
  1006             mSettingsManager.writeSetting(IpsServices::FolderPath, "");    
  1038         } else if (index == IpsServices::NmIpsSettingsUserDefined) {
  1007         }
  1039             showFolderPathInputDialog();       
  1008     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
  1040         }
  1009         showFolderPathInputDialog();       
  1041     }
  1010     }
  1042 }
  1011 }
  1043 
  1012 
  1044 /*!
  1013 /*!
  1045     Show a input dialog for allowing the user to specify a folder path.
  1014     Show a input dialog for allowing the user to specify a folder path.
  1134     \param value Selected value as a text.
  1103     \param value Selected value as a text.
  1135 */
  1104 */
  1136 void NmIpsSettingsHelper::refreshPeriodModified(QPersistentModelIndex, QVariant value)
  1105 void NmIpsSettingsHelper::refreshPeriodModified(QPersistentModelIndex, QVariant value)
  1137 {
  1106 {
  1138     QMap<QString, int> conversionTable;
  1107     QMap<QString, int> conversionTable;
  1139     conversionTable[hbTrId("txt_mailips_setlabel_val_keep_uptodate")] = 5;
  1108     conversionTable[HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_keep_uptodate"))] = 5;
  1140     conversionTable[hbTrId("txt_mailips_setlabel_val_every_15_minutes")] = 15;
  1109     conversionTable[HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_15_minutes"))] = 15;
  1141     conversionTable[hbTrId("txt_mailips_setlabel_val_every_1_hour")] = 60;
  1110     conversionTable[HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_1_hour"))] = 60;
  1142     conversionTable[hbTrId("txt_mailips_setlabel_val_every_4_hours")] = 240;
  1111     conversionTable[HbStringUtil::convertDigits(hbTrId("txt_mailips_setlabel_val_every_4_hours"))] = 240;
  1143 
  1112 
  1144     int selectedValue(conversionTable.value(value.toString()));
  1113     int selectedValue(conversionTable.value(value.toString()));
  1145     QVariant previouslySelectedValue;
  1114     QVariant previouslySelectedValue;
  1146     mSettingsManager.readSetting(IpsServices::ReceptionRefreshPeriodDayTime,
  1115     mSettingsManager.readSetting(IpsServices::ReceptionRefreshPeriodDayTime,
  1147         previouslySelectedValue);
  1116         previouslySelectedValue);
  1312 */
  1281 */
  1313 void NmIpsSettingsHelper::outgoingPortChange(int index)
  1282 void NmIpsSettingsHelper::outgoingPortChange(int index)
  1314 {
  1283 {
  1315     int previousindex = getCorrectOutgoingPortRadioButtonIndex();
  1284     int previousindex = getCorrectOutgoingPortRadioButtonIndex();
  1316     
  1285     
  1317     if (previousindex != index) {
  1286     if (index == IpsServices::NmIpsSettingsDefault) {
  1318         if (index == IpsServices::NmIpsSettingsDefault) {
  1287         if (index != previousindex) {
  1319             emit goOffline(mSettingsManager.mailboxId());
  1288             emit goOffline(mSettingsManager.mailboxId());
  1320             mEmitOnline = true;
  1289             mEmitOnline = true;
  1321             int port = mSettingsManager.determineDefaultOutgoingPort();
  1290             int port = mSettingsManager.determineDefaultOutgoingPort();
  1322             mSettingsManager.writeSetting(IpsServices::OutgoingPort, port);
  1291             mSettingsManager.writeSetting(IpsServices::OutgoingPort, port);    
  1323         } else if (index == IpsServices::NmIpsSettingsUserDefined) {
  1292         }
  1324             showOutgoingPortInputDialog();
  1293     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
  1325         }
  1294         showOutgoingPortInputDialog();
  1326     }
  1295     }
  1327 }
  1296 }
  1328 
  1297 
  1329 /*!
  1298 /*!
  1330     Shows an input dialog for allowing the user to specify a outgoing port.
  1299     Shows an input dialog for allowing the user to specify a outgoing port.