wlanutilities/wlanwizard/src/wlanwizardpagessid.cpp
branchRCL_3
changeset 24 63be7eb3fc78
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
       
     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 * WLAN Wizard Page: SSID Selection.
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <HbDocumentLoader>
       
    20 #include <HbMainWindow>
       
    21 #include <HbWidget>
       
    22 #include <HbLineEdit>
       
    23 #include <HbEditorInterface>
       
    24 #include <HbLabel>
       
    25 #include <wlanqtutils.h>
       
    26 
       
    27 // User includes
       
    28 #include "wlanwizardpagessid.h"
       
    29 #include "wlanwizard_p.h"
       
    30 #include "wlanwizardutils.h"
       
    31 #include "OstTraceDefinitions.h"
       
    32 #ifdef OST_TRACE_COMPILER_IN_USE
       
    33 #include "wlanwizardpagessidTraces.h"
       
    34 #endif
       
    35 
       
    36 /*!
       
    37  * Constructor method for the SSID query view object.
       
    38  * @param [in] parent pointer to parent object.
       
    39  */
       
    40 WlanWizardPageSsid::WlanWizardPageSsid(WlanWizardPrivate* parent) :
       
    41     WlanWizardPageInternal(parent),
       
    42     mWidget(NULL),
       
    43     mLabel(NULL),
       
    44     mSsid(NULL),
       
    45     mLoader(NULL)
       
    46 {
       
    47     OstTraceFunctionEntry0( WLANWIZARDPAGESSID_WLANWIZARDPAGESSID_ENTRY );
       
    48 
       
    49     OstTraceFunctionExit0( WLANWIZARDPAGESSID_WLANWIZARDPAGESSID_EXIT );
       
    50 }
       
    51 
       
    52 /*!
       
    53  * Destructor. Loader widget is deleted.
       
    54  * All document widgets are deleted by wlanwizard_p destructor.
       
    55  */
       
    56 WlanWizardPageSsid::~WlanWizardPageSsid()
       
    57 {
       
    58     OstTraceFunctionEntry0( DUP1_WLANWIZARDPAGESSID_WLANWIZARDPAGESSID_ENTRY );
       
    59     delete mLoader;
       
    60     OstTraceFunctionExit0( DUP1_WLANWIZARDPAGESSID_WLANWIZARDPAGESSID_EXIT );
       
    61 }
       
    62 
       
    63 /*!
       
    64  * Page initialization. If view is already loaded, does nothing.
       
    65  * @return pointer to widget "occ_add_wlan_01".
       
    66  */
       
    67 HbWidget* WlanWizardPageSsid::initializePage()
       
    68 {
       
    69     OstTraceFunctionEntry0( WLANWIZARDPAGESSID_INITIALIZEPAGE_ENTRY );
       
    70     OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESSID_INITIALIZEPAGE,
       
    71         "WlanWizardPageSsid::initializePage" );
       
    72 
       
    73     // It is not possible for this method to be called more than once during
       
    74     // wizard lifetime.
       
    75     Q_ASSERT(mWidget == NULL);
       
    76 
       
    77     bool ok;
       
    78 
       
    79     mLoader = new HbDocumentLoader(mWizard->mainWindow());
       
    80 
       
    81     mLoader->load(":/docml/occ_add_wlan_01_04.docml", &ok);
       
    82     Q_ASSERT(ok);
       
    83 
       
    84     // Load orientation
       
    85     loadDocmlSection(mWizard->mainWindow()->orientation());
       
    86 
       
    87     // Load widgets
       
    88     mWidget = qobject_cast<HbWidget*> (mLoader->findWidget(
       
    89         "occ_add_wlan_01"));
       
    90     Q_ASSERT(mWidget != NULL);
       
    91 
       
    92     mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog"));
       
    93     Q_ASSERT(mLabel != NULL);
       
    94 
       
    95     mSsid = qobject_cast<HbLineEdit*> (mLoader->findWidget("lineEditKey"));
       
    96     Q_ASSERT(mSsid != NULL);
       
    97 
       
    98     mLabel->setPlainText(hbTrId(
       
    99         "txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));
       
   100 
       
   101     // Connect orientation signal from the main window to orientation
       
   102     // loader.
       
   103     ok = connect(mWizard->mainWindow(),
       
   104         SIGNAL(orientationChanged(Qt::Orientation)), this,
       
   105         SLOT(loadDocmlSection(Qt::Orientation)));
       
   106     Q_ASSERT(ok);
       
   107 
       
   108     // Connect text change-signal from input dialog to handler function
       
   109     ok = connect(mSsid, SIGNAL(textChanged(const QString &)), this,
       
   110         SLOT(textChanged(const QString &)));
       
   111     Q_ASSERT(ok);
       
   112 
       
   113     HbEditorInterface editInterface(mSsid);
       
   114     
       
   115     // TODO: remove (HbEditorConstraints) type cast when 
       
   116     // Q_DECLARE_OPERATORS_FOR_FLAGS(HbEditorConstraints) is defined (SDK xxx)
       
   117     editInterface.setInputConstraints(
       
   118         (HbEditorConstraints)(HbEditorConstraintAutoCompletingField |
       
   119             HbEditorConstraintLatinAlphabetOnly));
       
   120     
       
   121     editInterface.setSmileyTheme(HbSmileyTheme());
       
   122     editInterface.setEditorClass(HbInputEditorClassNetworkName);
       
   123     mSsid->setInputMethodHints(
       
   124         Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase);
       
   125     mSsid->setMaxLength(WlanWizardUtils::SsidMaxLength);
       
   126 
       
   127 	OstTraceFunctionExit0( WLANWIZARDPAGESSID_INITIALIZEPAGE_EXIT );
       
   128 	return mWidget;
       
   129 }
       
   130 
       
   131 /*!
       
   132  * This method is overrides the default implementation from WlanWizardPage.
       
   133  * It indicates whether the Next-button should be enabled or not.
       
   134  * @return true, if mSsid edit field is not empty.
       
   135  */
       
   136 bool WlanWizardPageSsid::showPage()
       
   137 {
       
   138     OstTraceFunctionEntry0( WLANWIZARDPAGESSID_SHOWPAGE_ENTRY );
       
   139     // Initiate the scanning of public APs here.
       
   140     mWizard->wlanQtUtils()->scanWlanAps();
       
   141     
       
   142     // Open virtual keyboard by setting focus to line edit
       
   143     mSsid->setFocus();
       
   144     OstTraceFunctionExit0( WLANWIZARDPAGESSID_SHOWPAGE_EXIT );
       
   145     return !(mSsid->text().isEmpty());
       
   146 }
       
   147 
       
   148 /*!
       
   149  * Stores the SSID selection in the configuration.
       
   150  * @param [out] removeFromStack returns false.
       
   151  * @return WlanWizardPageScanning page id.
       
   152  */
       
   153 int WlanWizardPageSsid::nextId(bool &removeFromStack) const
       
   154 {
       
   155     OstTraceFunctionEntry0( WLANWIZARDPAGESSID_NEXTID_ENTRY );
       
   156     removeFromStack = false;
       
   157 
       
   158     // SSID is stored into configuration
       
   159     mWizard->setConfiguration(WlanWizardPrivate::ConfSsid, mSsid->text());
       
   160     
       
   161     OstTraceFunctionExit0( WLANWIZARDPAGESSID_NEXTID_EXIT );
       
   162     return WlanWizardPageInternal::PageScanning;
       
   163 }
       
   164 
       
   165 /*!
       
   166  * Loads the document orientation information from occ_add_wlan_01_04.docml
       
   167  * This is called each time phone orientation changes.
       
   168  * @param [in] orientation indicates whether the phone is in portrait or
       
   169  * landscape mode.
       
   170  */
       
   171 void WlanWizardPageSsid::loadDocmlSection(Qt::Orientation orientation)
       
   172 {
       
   173     OstTraceFunctionEntry0( WLANWIZARDPAGESSID_LOADDOCMLSECTION_ENTRY );
       
   174     OstTrace1( TRACE_FLOW, WLANWIZARDPAGESSID_LOADDOCML,
       
   175         "WlanWizardPageSsid::loadDocml - orientation ;orientation=%x",
       
   176         ( TUint )( orientation ) );
       
   177 
       
   178     WlanWizardPageInternal::loadDocmlSection(
       
   179         mLoader,
       
   180         orientation,
       
   181         ":/docml/occ_add_wlan_01_04.docml", 
       
   182         "portrait_section",
       
   183         "landscape_section");
       
   184     OstTraceFunctionExit0( WLANWIZARDPAGESSID_LOADDOCMLSECTION_EXIT );
       
   185 }
       
   186 
       
   187 /*!
       
   188  * Executed when changes have been made to the mSsid field (and the field is
       
   189  * not empty).
       
   190  * @param [in] text is not used at this point.
       
   191  */
       
   192 void WlanWizardPageSsid::textChanged(const QString &text)
       
   193 {
       
   194     OstTraceFunctionEntry0( WLANWIZARDPAGESSID_TEXTCHANGED_ENTRY );
       
   195     Q_UNUSED(text);
       
   196     OstTrace0( TRACE_FLOW, WLANWIZARDPAGESSID_TEXTCHANGED,
       
   197         "WlanWizardPageSsid::textChanged in text edit widget" );
       
   198 
       
   199     mWizard->enableNextButton(!(mSsid->text().isEmpty()));
       
   200     OstTraceFunctionExit0( WLANWIZARDPAGESSID_TEXTCHANGED_EXIT );
       
   201 }