wlanutilities/wpswizard/src/wpswizardsteptwo.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  *   WPS Wizard Page: Step 2
       
    16  *
       
    17  */
       
    18 
       
    19 // System includes
       
    20 #include <HbWidget>
       
    21 #include <HbRadioButtonList>
       
    22 #include <HbLineEdit>
       
    23 #include <HbLabel>
       
    24 #include <HbMainWindow>
       
    25 
       
    26 // User includes
       
    27 #include "wpswizardsteptwo.h"
       
    28 #include "wpswizard_p.h"
       
    29 
       
    30 // Trace includes
       
    31 #include "OstTraceDefinitions.h"
       
    32 #ifdef OST_TRACE_COMPILER_IN_USE
       
    33 #include "wpswizardsteptwoTraces.h"
       
    34 #endif
       
    35 
       
    36 // External function prototypes
       
    37 
       
    38 // Local constants
       
    39 
       
    40 /*!
       
    41    \class WpsPageStepTwo
       
    42    \brief Implementation of wps wizard page for step two. 
       
    43  */
       
    44 
       
    45 // ======== LOCAL FUNCTIONS ========
       
    46 
       
    47 // ======== MEMBER FUNCTIONS ========
       
    48 
       
    49 /*!
       
    50    Constructor for WPS page two
       
    51    
       
    52    @param [in] parent Pointer to the WPS wizard private implementation 
       
    53  */
       
    54 WpsPageStepTwo::WpsPageStepTwo(WpsWizardPrivate* parent) :
       
    55     WpsWizardPage(parent), 
       
    56     mWidget(NULL), 
       
    57     mRadio(NULL), 
       
    58     mHeading(NULL),
       
    59     mValid(false), 
       
    60     mItemSelected(0),
       
    61     mLoader(NULL)
       
    62 {
       
    63     OstTraceFunctionEntry1(WPSPAGESTEPTWO_WPSPAGESTEPTWO_ENTRY, this); 
       
    64     OstTraceFunctionExit1(WPSPAGESTEPTWO_WPSPAGESTEPTWO_EXIT, this);
       
    65 
       
    66 }
       
    67 
       
    68 /*!
       
    69    Destructor
       
    70  */
       
    71 WpsPageStepTwo::~WpsPageStepTwo()
       
    72 {
       
    73     OstTraceFunctionEntry1(WPSPAGESTEPTWO_WPSPAGESTEPTWO_DESTRUCTOR_ENTRY, this);
       
    74     delete mLoader;
       
    75     OstTraceFunctionExit1(WPSPAGESTEPTWO_WPSPAGESTEPTWO_DESTRUCTOR_EXIT, this);
       
    76 }
       
    77 
       
    78 /*!
       
    79    Loads the page with all the widgets
       
    80    
       
    81    @return HbWidget* Returns the view widget
       
    82  */
       
    83 HbWidget* WpsPageStepTwo::initializePage()
       
    84 {
       
    85     OstTraceFunctionEntry1(WPSPAGESTEPTWO_INITIALIZEPAGE_ENTRY, this);
       
    86 
       
    87     if (!mWidget) {
       
    88         bool ok;
       
    89         mLoader = new HbDocumentLoader(mWizard->mainWindow());
       
    90         
       
    91         mLoader->load(":/docml/occ_wps_01_05.docml", &ok);
       
    92         Q_ASSERT(ok);
       
    93         
       
    94         // Initialize orientation
       
    95         loadDocmlSection(mWizard->mainWindow()->orientation());
       
    96 
       
    97         mWidget = qobject_cast<HbWidget*> (mLoader->findWidget("occ_wps_P1"));
       
    98         Q_ASSERT(mWidget);
       
    99 
       
   100         mHeading = qobject_cast<HbLabel*> (mLoader->findWidget("label"));
       
   101         Q_ASSERT(mHeading);
       
   102         mHeading->setPlainText(hbTrId("txt_occ_dialog_selected_network_supports_wifi_pro"));
       
   103 
       
   104         mRadio = qobject_cast<HbRadioButtonList*> (mLoader->findWidget("radioButtonList"));
       
   105         Q_ASSERT(mRadio); 
       
   106         
       
   107         //Set Options
       
   108         QStringList list;
       
   109         list << hbTrId("txt_occ_list_use_pushbutton")
       
   110              << hbTrId("txt_occ_list_use_pin_code")
       
   111              << hbTrId("txt_occ_list_configure_manually");
       
   112         mRadio->setItems(list);
       
   113 
       
   114         bool connectOk = connect(
       
   115             mRadio, 
       
   116             SIGNAL(itemSelected(int)), 
       
   117             this,
       
   118             SLOT(itemSelected(int)));
       
   119         Q_ASSERT(connectOk);
       
   120 
       
   121         connectOk = connect(
       
   122             mWizard->mainWindow(), 
       
   123             SIGNAL(orientationChanged(Qt::Orientation)),
       
   124             this, 
       
   125             SLOT(loadDocmlSection(Qt::Orientation)));
       
   126         Q_ASSERT(connectOk);
       
   127     }
       
   128     
       
   129     OstTraceFunctionExit1(WPSPAGESTEPTWO_INITIALIZEPAGE_EXIT, this);
       
   130     return mWidget;
       
   131 }
       
   132 
       
   133 /*!
       
   134    Funtion to determine the next page to be displayed in the wizard process
       
   135    
       
   136    @param [out] removeFromStack bool indicating whether the current page should be 
       
   137    removed from the stack
       
   138    
       
   139    @return int Page Id of the next page to be displayed.
       
   140  */
       
   141 int WpsPageStepTwo::nextId(bool &removeFromStack) const
       
   142 {
       
   143     OstTraceFunctionEntry1(WPSPAGESTEPTWO_NEXTID_ENTRY, this);
       
   144     int id = WpsWizardPage::PageWpsWizardStep3_Button;
       
   145     removeFromStack = false;
       
   146     
       
   147     if (mItemSelected == WpsPushButtonMode) {
       
   148         id = WpsWizardPage::PageWpsWizardStep3_Button;
       
   149         
       
   150     } else if (mItemSelected == WpsPinCodeMode) {
       
   151         id = WpsWizardPage::PageWpsWizardStep3_Number;
       
   152         
       
   153     } else {
       
   154         id = mWizard->nextPageId(false);
       
   155     }
       
   156     
       
   157     OstTraceFunctionExit1(WPSPAGESTEPTWO_NEXTID_EXIT, this);
       
   158     return id;
       
   159 }
       
   160 
       
   161 /*!
       
   162    Determines the Number of steps to move backwards when 'Prev' Button
       
   163    is clicked
       
   164    
       
   165    @return int Number of pages to move backwards
       
   166  */
       
   167 int WpsPageStepTwo::previousTriggered()
       
   168 {
       
   169     OstTraceFunctionEntry1(WPSPAGESTEPTWO_PREVIOUSTRIGGERED_ENTRY, this);
       
   170     OstTraceFunctionExit1(WPSPAGESTEPTWO_PREVIOUSTRIGGERED_EXIT, this);
       
   171     return 1;
       
   172 }
       
   173 
       
   174 /*!
       
   175    CallBack when the cancel button is clicked
       
   176  */
       
   177 void WpsPageStepTwo::cancelTriggered()
       
   178 {
       
   179     OstTraceFunctionEntry1(WPSPAGESTEPTWO_CANCELTRIGGERED_ENTRY, this); 
       
   180     OstTraceFunctionExit1(WPSPAGESTEPTWO_CANCELTRIGGERED_EXIT, this);
       
   181 }
       
   182 
       
   183 /*!
       
   184    Determines whether the Next action button should be enabled or not
       
   185    
       
   186    @return bool Indicating whether next button is enabled or not.
       
   187  */
       
   188 bool WpsPageStepTwo::showPage()
       
   189 {
       
   190     return mValid;
       
   191 }
       
   192 
       
   193 /*!
       
   194    Call back when an item is selected from the list on the UI
       
   195    
       
   196    @param [in] index Indcating the relative position in the list
       
   197  */
       
   198 void WpsPageStepTwo::itemSelected(int index)
       
   199 {
       
   200     OstTraceFunctionEntry1(WPSPAGESTEPTWO_ITEMSELECTED_ENTRY, this);
       
   201     mValid = true;
       
   202     mWizard->enableNextButton(mValid);
       
   203     mItemSelected = index;   
       
   204     OstTraceFunctionExit1(WPSPAGESTEPTWO_ITEMSELECTED_EXIT, this);
       
   205 }
       
   206 
       
   207 /*!
       
   208    Loads docml at initialization phase and when HbMainWindow sends 
       
   209    orientation() signal.
       
   210    
       
   211    @param [in] orientation orientation to be loaded.
       
   212  */
       
   213 void WpsPageStepTwo::loadDocmlSection(Qt::Orientation orientation)
       
   214 {
       
   215     bool ok = false;
       
   216     
       
   217     // Load the orientation specific section
       
   218     if (orientation == Qt::Horizontal) {
       
   219         mLoader->load(":/docml/occ_wps_01_05.docml", "landscape", &ok);
       
   220         Q_ASSERT(ok);
       
   221     }  else {
       
   222         Q_ASSERT(orientation == Qt::Vertical);
       
   223         mLoader->load(":/docml/occ_wps_01_05.docml", "portrait", &ok);
       
   224         Q_ASSERT(ok);
       
   225     }
       
   226 }
       
   227