cmmanager/cppacketdataapplugin/src/cppacketdataapview.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 62 bb1f80fb7db2
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Control Panel packet data AP settings view header file.  
       
    16 *
       
    17 */
       
    18 
       
    19 // System includes
       
    20 #include <QString>
       
    21 #include <QStringList>
       
    22 #include <QVariant>
       
    23 #include <HbMainWindow>
       
    24 #include <HbMenu>
       
    25 #include <HbDataForm>
       
    26 #include <HbDataFormModel>
       
    27 #include <HbDataFormViewItem>
       
    28 #include <HbLineEdit>
       
    29 #include <HbEditorInterface>
       
    30 #include <HbUrlFilter>
       
    31 #include <HbPopup>
       
    32 #include <HbMessageBox>
       
    33 #include <HbAction>
       
    34 #include <cpsettingformitemdata.h>
       
    35 #include <cmconnectionmethod_shim.h>
       
    36 
       
    37 // User includes
       
    38 #include "cppacketdataapplugin.h"
       
    39 #include "cppacketdataapview.h"
       
    40 #include "cppacketdataapadvancedview.h"
       
    41 #include "OstTraceDefinitions.h"
       
    42 #ifdef OST_TRACE_COMPILER_IN_USE
       
    43 #include "cppacketdataapviewTraces.h"
       
    44 #endif
       
    45 
       
    46 /*!
       
    47     \class CpPacketDataApView
       
    48     \brief Implements the settings view for packet data bearer access points.
       
    49 */
       
    50 
       
    51 // External function prototypes
       
    52 
       
    53 // Local constants
       
    54 
       
    55 // ======== LOCAL FUNCTIONS ========
       
    56 
       
    57 // ======== MEMBER FUNCTIONS ========
       
    58 
       
    59 /*!
       
    60     Constructor.
       
    61 */
       
    62 CpPacketDataApView::CpPacketDataApView(
       
    63     CmConnectionMethodShim *cmConnectionMethod,
       
    64     QGraphicsItem *parent) :
       
    65         CpBaseSettingView(0, parent),
       
    66         mForm(0),
       
    67         mModel(0),
       
    68         mApSettingsGroupItem(0),
       
    69         mConnectionNameItem(0),
       
    70         mAccessPointNameItem(0),
       
    71         mUserNameItem(0),
       
    72         mPasswordItem(0),
       
    73         mAuthenticationItem(0),
       
    74         mHomepageItem(0),
       
    75         mAdvancedSettingsAction(0),
       
    76         mCmConnectionMethod(cmConnectionMethod),
       
    77         mMessageBox(0)
       
    78 {
       
    79     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_CPPACKETDATAAPVIEW_ENTRY);
       
    80     
       
    81     HbMenu *menu = this->menu();
       
    82     mAdvancedSettingsAction = menu->addAction(
       
    83         hbTrId("txt_occ_opt_advanced_settings"));
       
    84     bool status = connect(
       
    85         menu,
       
    86         SIGNAL(triggered(HbAction*)),
       
    87         this,
       
    88         SLOT(menuActionTriggered(HbAction*)));
       
    89     Q_ASSERT(status);
       
    90 
       
    91     // Construct packet data AP settings UI
       
    92     mForm = new HbDataForm();
       
    93     this->setWidget(mForm);
       
    94     mModel = new HbDataFormModel(mForm);
       
    95     mForm->setModel(mModel);
       
    96     
       
    97     // Add access point settings group
       
    98     createAccessPointSettingsGroup();
       
    99         
       
   100     status = connect(
       
   101         mForm,
       
   102         SIGNAL(itemShown(const QModelIndex)),
       
   103         this,
       
   104         SLOT(setEditorPreferences(const QModelIndex)));
       
   105     Q_ASSERT(status);
       
   106 
       
   107     // Expand Access point settings group
       
   108     mForm->setExpanded(mModel->indexFromItem(mApSettingsGroupItem), true);
       
   109     
       
   110     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_CPPACKETDATAAPVIEW_EXIT);
       
   111 }
       
   112 
       
   113 /*!
       
   114     Destructor.
       
   115 */
       
   116 CpPacketDataApView::~CpPacketDataApView()
       
   117 {
       
   118     OstTraceFunctionEntry0(DUP1_CPPACKETDATAAPVIEW_CPPACKETDATAAPVIEW_ENTRY);
       
   119     
       
   120     OstTraceFunctionExit0(DUP1_CPPACKETDATAAPVIEW_CPPACKETDATAAPVIEW_EXIT);
       
   121 }
       
   122 
       
   123 /*!
       
   124     Adds settings group with all settings items to the model.
       
   125 */
       
   126 void CpPacketDataApView::createAccessPointSettingsGroup()
       
   127 {
       
   128     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_CREATEACCESSPOINTSETTINGSGROUP_ENTRY);
       
   129     
       
   130     // Access point settings group
       
   131     mApSettingsGroupItem = new HbDataFormModelItem(
       
   132         HbDataFormModelItem::GroupItem, 
       
   133         hbTrId("txt_occ_subhead_access_point_settings"));
       
   134     mModel->appendDataFormItem(mApSettingsGroupItem);
       
   135     
       
   136     // Connection name
       
   137     mConnectionNameItem = new CpSettingFormItemData(
       
   138         HbDataFormModelItem::TextItem,
       
   139         hbTrId("txt_occ_setlabel_connection_name"));
       
   140     // Connect signal and add item to group
       
   141     mForm->addConnection(
       
   142         mConnectionNameItem,
       
   143         SIGNAL(editingFinished()),
       
   144         this,
       
   145         SLOT(connectionNameChanged()));
       
   146     mConnectionNameItem->setContentWidgetData("objectName", "connectionNameEdit");
       
   147     mApSettingsGroupItem->appendChild(mConnectionNameItem);
       
   148     
       
   149     // Access point name
       
   150     mAccessPointNameItem = new CpSettingFormItemData(
       
   151         HbDataFormModelItem::TextItem,
       
   152         hbTrId("txt_occ_setlabel_access_point_name"));
       
   153     // Connect signal and add item to group
       
   154     mForm->addConnection(
       
   155         mAccessPointNameItem,
       
   156         SIGNAL(editingFinished()),
       
   157         this,
       
   158         SLOT(accessPointNameChanged()));
       
   159     mAccessPointNameItem->setContentWidgetData("objectName", "accessPointNameEdit");
       
   160     mApSettingsGroupItem->appendChild(mAccessPointNameItem);
       
   161     
       
   162     // User name
       
   163     mUserNameItem = new CpSettingFormItemData(
       
   164         HbDataFormModelItem::TextItem,
       
   165         hbTrId("txt_occ_setlabel_user_name"));
       
   166     // Connect signal and add item to group
       
   167     mForm->addConnection(
       
   168         mUserNameItem,
       
   169         SIGNAL(editingFinished()),
       
   170         this,
       
   171         SLOT(userNameChanged()));
       
   172     mUserNameItem->setContentWidgetData("objectName", "userNameEdit");
       
   173     mApSettingsGroupItem->appendChild(mUserNameItem);
       
   174     
       
   175     // Password
       
   176     mPasswordItem = new CpSettingFormItemData(
       
   177         HbDataFormModelItem::TextItem,
       
   178         hbTrId("txt_occ_setlabel_password"));
       
   179     mPasswordItem->setContentWidgetData("echoMode", "PasswordEchoOnEdit");
       
   180     // Connect signal and add item to group
       
   181     mForm->addConnection(
       
   182         mPasswordItem,
       
   183         SIGNAL(editingFinished()),
       
   184         this,
       
   185         SLOT(passwordChanged()));
       
   186     mPasswordItem->setContentWidgetData("objectName", "passwordEdit");
       
   187     mApSettingsGroupItem->appendChild(mPasswordItem);
       
   188     
       
   189     // Authentication
       
   190     mAuthenticationItem = new CpSettingFormItemData(
       
   191         HbDataFormModelItem::ComboBoxItem,
       
   192         hbTrId("txt_occ_setlabel_authentication"));
       
   193     // Add items to combobox
       
   194     QStringList authenticationItems;
       
   195     authenticationItems
       
   196         << hbTrId("txt_occ_setlabel_authentication_val_normal")
       
   197         << hbTrId("txt_occ_setlabel_authentication_val_secure");
       
   198     mAuthenticationItem->setContentWidgetData("items", authenticationItems);
       
   199     // Construct map to link item indexes to setting values
       
   200     mAuthenticationMap.insert(0, false); // normal (plaintext allowed)
       
   201     mAuthenticationMap.insert(1, true); // secure (plaintext disabled)
       
   202     // Connect signal and add item to group
       
   203     mForm->addConnection(
       
   204         mAuthenticationItem,
       
   205         SIGNAL(currentIndexChanged(int)),
       
   206         this,
       
   207         SLOT(authenticationChanged(int)));
       
   208     mAuthenticationItem->setContentWidgetData("objectName", "authenticationCB");
       
   209     mApSettingsGroupItem->appendChild(mAuthenticationItem);
       
   210     
       
   211     // Homepage
       
   212     mHomepageItem = new CpSettingFormItemData(
       
   213         HbDataFormModelItem::TextItem,
       
   214         hbTrId("txt_occ_setlabel_homepage"));
       
   215     // Connect signal and add item to group
       
   216     mForm->addConnection(
       
   217         mHomepageItem,
       
   218         SIGNAL(editingFinished()),
       
   219         this,
       
   220         SLOT(homepageChanged()));
       
   221     mHomepageItem->setContentWidgetData("objectName", "homePageEdit");
       
   222     mApSettingsGroupItem->appendChild(mHomepageItem);
       
   223     
       
   224     // Read settings from CommsDat and update widgets
       
   225     updateAccessPointSettingsGroup();
       
   226     
       
   227     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_CREATEACCESSPOINTSETTINGSGROUP_EXIT);
       
   228 }
       
   229 
       
   230 /*!
       
   231     Reads attribute values and updates "Access point settings" group settings.
       
   232 */
       
   233 void CpPacketDataApView::updateAccessPointSettingsGroup()
       
   234 {
       
   235     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_UPDATEACCESSPOINTSETTINGSGROUP_ENTRY);
       
   236 
       
   237     // Get attributes from CommsDat and set values to UI widgets
       
   238     
       
   239     // Connection name
       
   240     QString connectionName = mCmConnectionMethod->getStringAttribute(
       
   241         CMManagerShim::CmName);
       
   242     mConnectionNameItem->setContentWidgetData("text", connectionName);
       
   243     
       
   244     // Access point name
       
   245     QString accessPointName = mCmConnectionMethod->getStringAttribute(
       
   246         CMManagerShim::PacketDataAPName);
       
   247     mAccessPointNameItem->setContentWidgetData("text", accessPointName);
       
   248     
       
   249     // User name
       
   250     QString userName = mCmConnectionMethod->getStringAttribute(
       
   251         CMManagerShim::PacketDataIFAuthName);
       
   252     mUserNameItem->setContentWidgetData("text", userName);
       
   253     
       
   254     // Password
       
   255     QString password = mCmConnectionMethod->getStringAttribute(
       
   256         CMManagerShim::PacketDataIFAuthPass);
       
   257     mPasswordItem->setContentWidgetData("text", password);
       
   258 
       
   259     // Authentication
       
   260     bool disablePlainText = mCmConnectionMethod->getBoolAttribute(
       
   261         CMManagerShim::PacketDataDisablePlainTextAuth);
       
   262     mAuthenticationItem->setContentWidgetData("currentIndex",
       
   263         mAuthenticationMap.key(disablePlainText));
       
   264     
       
   265     // Homepage
       
   266     QString homepage = mCmConnectionMethod->getStringAttribute(
       
   267         CMManagerShim::CmStartPage);
       
   268     mHomepageItem->setContentWidgetData("text", homepage);
       
   269     
       
   270     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_UPDATEACCESSPOINTSETTINGSGROUP_EXIT);
       
   271 }
       
   272 
       
   273 /*!
       
   274     Shows message box with "OK" button using given text.
       
   275 */
       
   276 void CpPacketDataApView::showMessageBox(
       
   277     HbMessageBox::MessageBoxType type,
       
   278     const QString &text)
       
   279 {
       
   280     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_SHOWMESSAGEBOX_ENTRY);
       
   281     
       
   282     // Create a message box
       
   283     mMessageBox = QSharedPointer<HbMessageBox>(new HbMessageBox(type));
       
   284     mMessageBox->setText(text);
       
   285     mMessageBox->setModal(true);
       
   286     mMessageBox->setTimeout(HbPopup::NoTimeout);
       
   287     mMessageBox->open();
       
   288     
       
   289     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_SHOWMESSAGEBOX_EXIT);
       
   290 }
       
   291 
       
   292 /*!
       
   293     Tries to update connection method changes to CommsDat.
       
   294     Returns "true" if success, "false" if some error happened. 
       
   295 */
       
   296 bool CpPacketDataApView::tryUpdate()
       
   297 {
       
   298     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_TRYUPDATE_ENTRY);
       
   299     
       
   300     // Try update
       
   301     try {
       
   302         mCmConnectionMethod->update();
       
   303     }
       
   304     catch (const std::exception&) {
       
   305         // Handle error
       
   306         handleUpdateError();
       
   307         
       
   308         OstTraceFunctionExit0(CPPACKETDATAAPVIEW_TRYUPDATE_EXIT);
       
   309         return false;
       
   310     }
       
   311 
       
   312     OstTraceFunctionExit0(DUP1_CPPACKETDATAAPVIEW_TRYUPDATE_EXIT);
       
   313     return true;
       
   314 }
       
   315 
       
   316 /*!
       
   317     Handles failed CommsDat update.
       
   318  */
       
   319 void CpPacketDataApView::handleUpdateError()
       
   320 {
       
   321     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_HANDLEUPDATEERROR_ENTRY);
       
   322     
       
   323     // Show error note to user
       
   324     showMessageBox(
       
   325         HbMessageBox::MessageTypeWarning,
       
   326         hbTrId("txt_occ_info_unable_to_save_setting"));
       
   327     // Reload settings from CommsDat and update UI
       
   328     try {
       
   329         mCmConnectionMethod->refresh();
       
   330     }
       
   331     catch (const std::exception&) {
       
   332         // Ignore error from refresh. Most likely this will not happen, but
       
   333         // if it does, there isn't very much we can do.
       
   334         OstTrace0(
       
   335             TRACE_ERROR,
       
   336             CPPACKETDATAAPVIEW_HANDLEUPDATEERROR,
       
   337             "Refresh failed");
       
   338     };
       
   339     updateAccessPointSettingsGroup();
       
   340     
       
   341     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_HANDLEUPDATEERROR_EXIT);
       
   342 }
       
   343 
       
   344 /*!
       
   345     Updates connection name to CommsDat.
       
   346 */
       
   347 void CpPacketDataApView::connectionNameChanged()
       
   348 {
       
   349     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_CONNECTIONNAMECHANGED_ENTRY);
       
   350     
       
   351     QString connectionName =
       
   352         mConnectionNameItem->contentWidgetData("text").toString();
       
   353     if (!connectionName.isEmpty()) {
       
   354         // Update to CommsDat
       
   355         mCmConnectionMethod->setStringAttribute(
       
   356             CMManagerShim::CmName,
       
   357             connectionName);
       
   358         if (tryUpdate()) {
       
   359             // Update successful
       
   360             // Read name because in case the name already exists it will
       
   361             // be made unique by CMManager
       
   362             connectionName = mCmConnectionMethod->getStringAttribute(
       
   363                 CMManagerShim::CmName);
       
   364             mConnectionNameItem->setContentWidgetData("text", connectionName);
       
   365         }
       
   366     } else {
       
   367         // Inform user of invalid name
       
   368         showMessageBox(
       
   369             HbMessageBox::MessageTypeInformation,
       
   370             hbTrId("txt_occ_info_invalid_name"));
       
   371 
       
   372         // Empty name not allowed, revert back to old value in CommsDat
       
   373         connectionName = mCmConnectionMethod->getStringAttribute(
       
   374             CMManagerShim::CmName);
       
   375         mConnectionNameItem->setContentWidgetData("text", connectionName);
       
   376      }
       
   377     
       
   378     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_CONNECTIONNAMECHANGED_EXIT);
       
   379 }
       
   380 
       
   381 /*!
       
   382     Updates access point name to CommsDat.
       
   383 */
       
   384 void CpPacketDataApView::accessPointNameChanged()
       
   385 {
       
   386     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_ACCESSPOINTNAMECHANGED_ENTRY);
       
   387     
       
   388     // Update to CommsDat
       
   389     QString accessPointName =
       
   390         mAccessPointNameItem->contentWidgetData("text").toString();
       
   391     if (!accessPointName.isEmpty()) {
       
   392         mCmConnectionMethod->setStringAttribute(
       
   393             CMManagerShim::PacketDataAPName,
       
   394             accessPointName);
       
   395         (void)tryUpdate();
       
   396     } else {
       
   397         // Inform user of invalid name
       
   398         showMessageBox(
       
   399             HbMessageBox::MessageTypeInformation,
       
   400             hbTrId("txt_occ_info_invalid_name"));
       
   401     
       
   402         // Empty name not allowed, revert back to old value in CommsDat
       
   403         accessPointName = mCmConnectionMethod->getStringAttribute(
       
   404             CMManagerShim::PacketDataAPName);
       
   405         mAccessPointNameItem->setContentWidgetData("text", accessPointName);
       
   406     }
       
   407     
       
   408     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_ACCESSPOINTNAMECHANGED_EXIT);
       
   409 }
       
   410 
       
   411 /*!
       
   412     Updates user name to CommsDat.
       
   413 */
       
   414 void CpPacketDataApView::userNameChanged()
       
   415 {
       
   416     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_USERNAMECHANGED_ENTRY);
       
   417     
       
   418     // Update to CommsDat
       
   419     QVariant userName = mUserNameItem->contentWidgetData("text");
       
   420     mCmConnectionMethod->setStringAttribute(
       
   421         CMManagerShim::PacketDataIFAuthName,
       
   422         userName.toString());
       
   423     (void)tryUpdate();
       
   424     
       
   425     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_USERNAMECHANGED_EXIT);
       
   426 }
       
   427 
       
   428 /*!
       
   429     Updates password to CommsDat.
       
   430 */
       
   431 void CpPacketDataApView::passwordChanged()
       
   432 {
       
   433     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_PASSWORDCHANGED_ENTRY);
       
   434     
       
   435     // Update to CommsDat
       
   436     QVariant password = mPasswordItem->contentWidgetData("text");
       
   437     mCmConnectionMethod->setStringAttribute(
       
   438         CMManagerShim::PacketDataIFAuthPass,
       
   439         password.toString());
       
   440     (void)tryUpdate();
       
   441     
       
   442     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_PASSWORDCHANGED_EXIT);
       
   443 }
       
   444 
       
   445 /*!
       
   446     Updates authentication setting to CommsDat.
       
   447 */
       
   448 void CpPacketDataApView::authenticationChanged(int index)
       
   449 {
       
   450     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_AUTHENTICATIONCHANGED_ENTRY);
       
   451     
       
   452     // Update to CommsDat
       
   453     mCmConnectionMethod->setBoolAttribute(
       
   454         CMManagerShim::PacketDataDisablePlainTextAuth,
       
   455         mAuthenticationMap.value(index));
       
   456     (void)tryUpdate();
       
   457     
       
   458     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_AUTHENTICATIONCHANGED_EXIT);
       
   459 }
       
   460 
       
   461 /*!
       
   462     Updates homepage to CommsDat.
       
   463 */
       
   464 void CpPacketDataApView::homepageChanged()
       
   465 {
       
   466     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_HOMEPAGECHANGED_ENTRY);
       
   467     
       
   468     // Update to CommsDat
       
   469     QString homepage = mHomepageItem->contentWidgetData("text").toString();
       
   470     mCmConnectionMethod->setStringAttribute(
       
   471         CMManagerShim::CmStartPage, homepage);
       
   472     (void)tryUpdate();
       
   473     
       
   474     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_HOMEPAGECHANGED_EXIT);
       
   475 }
       
   476 
       
   477 /*!
       
   478     Handles menu actions.
       
   479 */
       
   480 void CpPacketDataApView::menuActionTriggered(HbAction *action)
       
   481 {
       
   482     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_MENUACTIONTRIGGERED_ENTRY);
       
   483     
       
   484     if (action == mAdvancedSettingsAction) {
       
   485         // "Advanced settings" selected
       
   486         HbMainWindow *mainWindow = this->mainWindow();
       
   487 
       
   488         // Create the advanced settings view
       
   489         HbView *newView = new CpPacketDataApAdvancedView(mCmConnectionMethod);
       
   490         // Connect signal to return back to the previous view
       
   491         bool status = QObject::connect(
       
   492             newView,
       
   493             SIGNAL(aboutToClose()),
       
   494             this,
       
   495             SLOT(restoreCurrentView()));
       
   496         Q_ASSERT(status);
       
   497 
       
   498         // Show the advanced settings view
       
   499         mainWindow->addView(newView);
       
   500         mainWindow->setCurrentView(newView);
       
   501     }
       
   502     
       
   503     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_MENUACTIONTRIGGERED_EXIT);
       
   504 }
       
   505 
       
   506 /*!
       
   507     Deletes the current view and sets this view as the current one.
       
   508 */
       
   509 void CpPacketDataApView::restoreCurrentView()
       
   510 {
       
   511     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_RESTORECURRENTVIEW_ENTRY);
       
   512     
       
   513     HbMainWindow *mainWindow = this->mainWindow();
       
   514     
       
   515     // Remove the previous view and delete it
       
   516     HbView *prevView = mainWindow->currentView();
       
   517     mainWindow->removeView(prevView);
       
   518     prevView->deleteLater();
       
   519     
       
   520     // Set this view on top
       
   521     mainWindow->setCurrentView(this);
       
   522     
       
   523     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_RESTORECURRENTVIEW_EXIT);
       
   524 }
       
   525 
       
   526 /*!
       
   527     Sets editor preferences for all HbLineEdit items.
       
   528 */
       
   529 void CpPacketDataApView::setEditorPreferences(const QModelIndex modelIndex)
       
   530 {
       
   531     OstTraceFunctionEntry0(CPPACKETDATAAPVIEW_SETEDITORPREFERENCES_ENTRY);
       
   532     
       
   533     HbDataFormViewItem *viewItem = qobject_cast<HbDataFormViewItem *>
       
   534         (mForm->itemByIndex(modelIndex));
       
   535     HbDataFormModelItem *modelItem = mModel->itemFromIndex(modelIndex);
       
   536     
       
   537     if (modelItem == mConnectionNameItem
       
   538         || modelItem == mAccessPointNameItem
       
   539         || modelItem == mUserNameItem
       
   540         || modelItem == mPasswordItem
       
   541         || modelItem == mHomepageItem ) {
       
   542         // HbLineEdit items, get editor and editor interface
       
   543         HbLineEdit *edit = qobject_cast<HbLineEdit *>
       
   544             (viewItem->dataItemContentWidget());
       
   545         HbEditorInterface editInterface(edit);
       
   546         
       
   547         if (modelItem == mConnectionNameItem) {
       
   548             // Setup editor for connection name
       
   549             editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   550             edit->setInputMethodHints(Qt::ImhNoPredictiveText); 
       
   551             edit->setMaxLength(CMManagerShim::CmNameLength);
       
   552         } else if (modelItem == mAccessPointNameItem) {
       
   553             // Setup editor for packet data AP name
       
   554             editInterface.setMode(HbInputModeNone);
       
   555             editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   556             editInterface.setDigitType(HbDigitTypeNone);
       
   557             edit->setInputMethodHints(
       
   558                 Qt::ImhNoPredictiveText
       
   559                 | Qt::ImhPreferLowercase);
       
   560             edit->setMaxLength(CMManagerShim::PacketDataAPNameLength);
       
   561         } else if (modelItem == mUserNameItem) {
       
   562             // Setup editor for user name
       
   563             editInterface.setMode(HbInputModeNone);
       
   564             editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   565             editInterface.setEditorClass(HbInputEditorClassUsername);
       
   566             editInterface.setDigitType(HbDigitTypeNone);
       
   567             edit->setInputMethodHints(
       
   568                 Qt::ImhNoPredictiveText
       
   569                 | Qt::ImhPreferLowercase);
       
   570             edit->setMaxLength(CMManagerShim::PacketDataIFAuthNameLength);
       
   571         } else if (modelItem == mPasswordItem) {
       
   572             // Setup editor for password
       
   573             editInterface.setMode(HbInputModeNone);
       
   574             editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   575             editInterface.setEditorClass(HbInputEditorClassPassword);
       
   576             editInterface.setDigitType(HbDigitTypeNone);
       
   577             edit->setInputMethodHints(
       
   578                 Qt::ImhNoPredictiveText
       
   579                 | Qt::ImhPreferLowercase);
       
   580             edit->setMaxLength(CMManagerShim::PacketDataIFAuthPassLength);
       
   581         } else { /* mHomepageItem */
       
   582             // Setup editor for URL
       
   583             editInterface.setMode(HbInputModeNone);
       
   584             editInterface.setInputConstraints(HbEditorConstraintLatinAlphabetOnly);
       
   585             editInterface.setFilter(HbUrlFilter::instance());
       
   586             editInterface.setEditorClass(HbInputEditorClassUrl);
       
   587             editInterface.setDigitType(HbDigitTypeNone);
       
   588             edit->setInputMethodHints(
       
   589                 Qt::ImhNoPredictiveText
       
   590                 | Qt::ImhPreferLowercase);
       
   591             edit->setMaxLength(CMManagerShim::CmStartPageLength);
       
   592         }
       
   593     }
       
   594     
       
   595     OstTraceFunctionExit0(CPPACKETDATAAPVIEW_SETEDITORPREFERENCES_EXIT);
       
   596 }