wlanutilities/wpswizard/src/wpswizardsteptwo.cpp
branchGCC_SURGE
changeset 47 b3d8f88532b7
parent 19 10810c91db26
parent 46 2fbd1d709fe7
equal deleted inserted replaced
34:30a5f517c615 47:b3d8f88532b7
     1 /*
     1 /*
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of the License "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8  *
     8  *
     9  * Initial Contributors:
     9  * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    15  *   WPS Wizard Page: Step 2
    15  *   WPS Wizard Page: Step 2
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 // System includes
    19 // System includes
    20 #include <hbdocumentloader.h>
    20 #include <HbWidget>
    21 #include <hbwidget.h>
    21 #include <HbRadioButtonList>
    22 #include <hbradiobuttonlist.h>
    22 #include <HbLineEdit>
    23 #include <hblineedit.h>
    23 #include <HbLabel>
    24 #include <hblabel.h>
    24 #include <HbMainWindow>
    25 
    25 
    26 // User includes
    26 // User includes
    27 #include "wpswizardsteptwo.h"
    27 #include "wpswizardsteptwo.h"
    28 #include "wpswizard_p.h"
    28 #include "wpswizard_p.h"
    29 
    29 
    30 // Trace includes
    30 // Trace includes
    31 #include "OstTraceDefinitions.h"
    31 #include "OstTraceDefinitions.h"
    32 #ifdef OST_TRACE_COMPILER_IN_USE
    32 #ifdef OST_TRACE_COMPILER_IN_USE
    33 #include "wpspagesteptwoTraces.h"
    33 #include "wpswizardsteptwoTraces.h"
    34 #endif
    34 #endif
    35 
    35 
    36 
    36 // External function prototypes
    37 /*!
    37 
    38  * Constructor for WPS page two
    38 // Local constants
    39  * 
    39 
    40  * \param WpsWizardPrivate* Pointer to the WPS wizard private implementation 
    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 
    41  */
    53  */
    42 WpsPageStepTwo::WpsPageStepTwo(WpsWizardPrivate* parent) :
    54 WpsPageStepTwo::WpsPageStepTwo(WpsWizardPrivate* parent) :
    43     WpsWizardPage(parent), mWidget(NULL), mRadio(NULL), mValid(false)
    55     WpsWizardPage(parent), 
    44     {
    56     mWidget(NULL), 
    45     OstTraceFunctionEntry1(WPSPAGESTEPTWO_WPSPAGESTEPTWO_ENTRY, this)
    57     mRadio(NULL), 
    46     OstTraceFunctionExit1(WPSPAGESTEPTWO_WPSPAGESTEPTWO_EXIT, this)
    58     mHeading(NULL),
    47 
    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);
    48     }
   127     }
    49 
   128     
    50 /*!
   129     OstTraceFunctionExit1(WPSPAGESTEPTWO_INITIALIZEPAGE_EXIT, this);
    51  * Destructor
       
    52  */
       
    53 WpsPageStepTwo::~WpsPageStepTwo()
       
    54     {
       
    55     OstTraceFunctionEntry1(WPSPAGESTEPTWO_WPSPAGESTEPTWO_ENTRY, this)
       
    56 
       
    57     delete mWidget;
       
    58     OstTraceFunctionExit1(WPSPAGESTEPTWO_WPSPAGESTEPTWO_EXIT, this)
       
    59 
       
    60     }
       
    61 
       
    62 /*!
       
    63   * Loads the page with all the widgets
       
    64   * 
       
    65   * \return HbWidget* Returns the view widget
       
    66  */
       
    67 HbWidget* WpsPageStepTwo::initializePage()
       
    68     {
       
    69     OstTraceFunctionEntry1(WPSPAGESTEPTWO_INITIALIZEPAGE_ENTRY, this)
       
    70 
       
    71     if (!mWidget)
       
    72         {
       
    73         bool ok;
       
    74         HbDocumentLoader loader;
       
    75         loader.load(":/docml/occ_wps_P1.docml", &ok);
       
    76         Q_ASSERT_X(ok, "WPS Wizard", "Invalid docml file");
       
    77 
       
    78         mWidget = qobject_cast<HbWidget*> (loader.findWidget("occ_wps_P1"));
       
    79         Q_ASSERT_X(mWidget != 0, "WPS Wizard", "View not found");
       
    80 
       
    81         mHeading
       
    82                 = qobject_cast<HbLabel*> (loader.findWidget("label_heading"));
       
    83         Q_ASSERT_X(mTitle != 0, "WPS wizard", "Header not found");
       
    84 
       
    85         mRadio = qobject_cast<HbRadioButtonList*> (loader.findWidget(
       
    86                 "radioButtonList"));
       
    87         Q_ASSERT_X(mRadio != 0, "WPS Wizard", "List not found");
       
    88 
       
    89         connect(mRadio, SIGNAL(itemSelected(int)), this,
       
    90                 SLOT(itemSelected(int)));
       
    91 
       
    92         }
       
    93     OstTraceFunctionExit1(WPSPAGESTEPTWO_INITIALIZEPAGE_EXIT, this)
       
    94 
       
    95     return mWidget;
   130     return mWidget;
    96     }
   131 }
    97 
   132 
    98 
   133 /*!
    99 /*!
   134    Funtion to determine the next page to be displayed in the wizard process
   100   * Funtion to determine the next page to be displayed in the wizard process
   135    
   101   * 
   136    @param [out] removeFromStack bool indicating whether the current page should be 
   102   * \param bool& RemoveFromStack indicating whether the current page should be 
   137    removed from the stack
   103   * removed from the stack
   138    
   104   * 
   139    @return int Page Id of the next page to be displayed.
   105   * \return int Page Id of the next page to be displayed.
       
   106  */
   140  */
   107 int WpsPageStepTwo::nextId(bool &removeFromStack) const
   141 int WpsPageStepTwo::nextId(bool &removeFromStack) const
   108     {
   142 {
   109     OstTraceFunctionEntry1(WPSPAGESTEPTWO_NEXTID_ENTRY, this)
   143     OstTraceFunctionEntry1(WPSPAGESTEPTWO_NEXTID_ENTRY, this);
   110     int id = WpsWizardPage::PageWpsWizardStep3_Button;
   144     int id = WpsWizardPage::PageWpsWizardStep3_Button;
   111     removeFromStack = false;
   145     removeFromStack = false;
   112     if (mItemSelected == 0)
   146     
       
   147     if (mItemSelected == WpsPushButtonMode) {
   113         id = WpsWizardPage::PageWpsWizardStep3_Button;
   148         id = WpsWizardPage::PageWpsWizardStep3_Button;
   114     else
   149         
       
   150     } else if (mItemSelected == WpsPinCodeMode) {
   115         id = WpsWizardPage::PageWpsWizardStep3_Number;
   151         id = WpsWizardPage::PageWpsWizardStep3_Number;
   116     OstTraceFunctionExit1(WPSPAGESTEPTWO_NEXTID_EXIT, this)
   152         
   117 
   153     } else {
   118 
   154         id = mWizard->nextPageId(false);
       
   155     }
       
   156     
       
   157     OstTraceFunctionExit1(WPSPAGESTEPTWO_NEXTID_EXIT, this);
   119     return id;
   158     return id;
   120     }
   159 }
   121 
   160 
   122 /*!
   161 /*!
   123   * Determines the Number of steps to move backwards when 'Prev' Button
   162    Determines the Number of steps to move backwards when 'Prev' Button
   124   * is clicked
   163    is clicked
   125   * 
   164    
   126   * \return int Number of pages to move backwards
   165    @return int Number of pages to move backwards
   127  */
   166  */
   128 int WpsPageStepTwo::stepsBackwards()
   167 int WpsPageStepTwo::previousTriggered()
   129     {
   168 {
   130     OstTraceFunctionEntry1(WPSPAGESTEPTWO_STEPSBACKWARDS_ENTRY, this)
   169     OstTraceFunctionEntry1(WPSPAGESTEPTWO_PREVIOUSTRIGGERED_ENTRY, this);
   131     OstTraceFunctionExit1(WPSPAGESTEPTWO_STEPBACKWARDS_EXIT, this)
   170     OstTraceFunctionExit1(WPSPAGESTEPTWO_PREVIOUSTRIGGERED_EXIT, this);
   132 
       
   133     return 1;
   171     return 1;
   134     }
   172 }
   135 
   173 
   136 /*!
   174 /*!
   137  * Callback when the previous button is clicked
   175    CallBack when the cancel button is clicked
   138 */
       
   139 void WpsPageStepTwo::previousTriggered()
       
   140     {
       
   141     OstTraceFunctionEntry1(WPSPAGESTEPTWO_PREVIOUSTRIGGERED_ENTRY, this)
       
   142     OstTraceFunctionExit1(WPSPAGESTEPTWO_PREVIOUSTRIGGERED_EXIT, this)
       
   143 
       
   144     }
       
   145 
       
   146 /*!
       
   147   * CallBack when the cancel button is clicked
       
   148  */
   176  */
   149 void WpsPageStepTwo::cancelTriggered()
   177 void WpsPageStepTwo::cancelTriggered()
   150     {
   178 {
   151     OstTraceFunctionEntry1(WPSPAGESTEPTWO_CANCELTRIGGERED_ENTRY, this)
   179     OstTraceFunctionEntry1(WPSPAGESTEPTWO_CANCELTRIGGERED_ENTRY, this); 
   152     OstTraceFunctionExit1(WPSPAGESTEPTWO_CANCELTRIGGERED_EXIT, this)
   180     OstTraceFunctionExit1(WPSPAGESTEPTWO_CANCELTRIGGERED_EXIT, this);
   153 
   181 }
   154     }
   182 
   155 
   183 /*!
   156 /*!
   184    Determines whether the Next action button should be enabled or not
   157   * Validates the content of the pages
   185    
   158   * 
   186    @return bool Indicating whether next button is enabled or not.
   159   * \return bool Indicating the result of the operation
   187  */
   160  */
   188 bool WpsPageStepTwo::showPage()
   161 bool WpsPageStepTwo::validate() const
   189 {
   162     {
       
   163     OstTraceFunctionEntry1(WPSPAGESTEPTWO_VALIDATE_ENTRY, this)
       
   164     OstTraceFunctionExit1(WPSPAGESTEPTWO_VALIDATE_EXIT, this)
       
   165 
       
   166     return mValid;
   190     return mValid;
   167     }
   191 }
   168 
   192 
   169 /*!
   193 /*!
   170   * Call back when an item is selected from the list on the UI
   194    Call back when an item is selected from the list on the UI
   171   * 
   195    
   172   * \param int index Indcating the relative position in the list
   196    @param [in] index Indcating the relative position in the list
   173  */
   197  */
   174 void WpsPageStepTwo::itemSelected(int index)
   198 void WpsPageStepTwo::itemSelected(int index)
   175     {
   199 {
   176     OstTraceFunctionEntry1(WPSPAGESTEPTWO_ITEMSELECTED_ENTRY, this)
   200     OstTraceFunctionEntry1(WPSPAGESTEPTWO_ITEMSELECTED_ENTRY, this);
   177 
       
   178     mValid = true;
   201     mValid = true;
   179     mWizard->enableNextButton(mValid);
   202     mWizard->enableNextButton(mValid);
   180     mItemSelected = index;
   203     mItemSelected = index;   
   181     OstTraceFunctionExit1(WPSPAGESTEPTWO_ITEMSELECTED_EXIT, this)
   204     OstTraceFunctionExit1(WPSPAGESTEPTWO_ITEMSELECTED_EXIT, this);
   182 
   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);
   183     }
   225     }
   184 
   226 }
       
   227