wlanutilities/wpswizard/src/wpswizardstepthreebutton.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 3 Push button number
    15  *   WPS Wizard Page: Step 3 Push button number
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 // System includes
    19 // System includes
    20 #include <hbdocumentloader.h>
    20 #include <HbDocumentLoader>
    21 #include <hbwidget.h>
    21 #include <HbWidget>
    22 #include <hbradiobuttonlist.h>
    22 #include <HbRadioButtonList>
    23 #include <hblineedit.h>
    23 #include <HbLineEdit>
    24 #include <hblabel.h>
    24 #include <HbLabel>
       
    25 #include <HbMainwindow>
    25 
    26 
    26 // User includes
    27 // User includes
    27 #include "wpswizardstepthreebutton.h"
    28 #include "wpswizardstepthreebutton.h"
    28 #include "wpswizard_p.h"
    29 #include "wpswizard_p.h"
    29 
    30 
    30 // Trace includes
    31 // Trace includes
    31 #include "OstTraceDefinitions.h"
    32 #include "OstTraceDefinitions.h"
    32 #ifdef OST_TRACE_COMPILER_IN_USE
    33 #ifdef OST_TRACE_COMPILER_IN_USE
    33 #include "wpspagestepthreebuttonTraces.h"
    34 #include "wpswizardstepthreebuttonTraces.h"
    34 #endif
    35 #endif
    35 
    36 
       
    37 // External function prototypes
       
    38 
       
    39 // Local constants
    36 
    40 
    37 /*!
    41 /*!
    38  * Constructor for WPS page three button
    42    \class WpsPageStepThreeButton
    39  * 
    43    \brief Implementation of wps wizard page for step three button press mode.
    40  * \param WpsWizardPrivate* Pointer to the WPS wizard private implementation 
    44  */
       
    45 
       
    46 // ======== LOCAL FUNCTIONS ========
       
    47 
       
    48 // ======== MEMBER FUNCTIONS ========
       
    49 
       
    50 /*!
       
    51    Constructor for WPS page three button
       
    52    
       
    53    @param [in] parent Pointer to the WPS wizard private implementation 
    41  */
    54  */
    42 WpsPageStepThreeButton::WpsPageStepThreeButton(WpsWizardPrivate* parent) :
    55 WpsPageStepThreeButton::WpsPageStepThreeButton(WpsWizardPrivate* parent) :
    43     WpsWizardPage(parent), mWidget(NULL), mRadio(NULL), mValid(true)
    56     WpsWizardPage(parent), 
       
    57     mWidget(NULL), 
       
    58     mHeading(NULL),
       
    59     mLoader(NULL)
    44 {
    60 {
    45 OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_WPSPAGESTEPTHREEBUTTON_ENTRY, this)
    61     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_WPSPAGESTEPTHREEBUTTON_ENTRY, this); 
    46 OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_WPSPAGESTEPTHREEBUTTON_EXIT, this)
    62     OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_WPSPAGESTEPTHREEBUTTON_EXIT, this);
    47 
    63 
    48 }
    64 }
    49 
    65 
    50 /*!
    66 /*!
    51  * Destructor
    67    Destructor
    52  */
    68  */
    53 WpsPageStepThreeButton::~WpsPageStepThreeButton()
    69 WpsPageStepThreeButton::~WpsPageStepThreeButton()
    54 {
    70 {
    55     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_WPSPAGESTEPTHREEBUTTON_ENTRY, this)
    71     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_WPSPAGESTEPTHREEBUTTON_DESTRUCTOR_ENTRY, this);
    56 
    72     delete mLoader;
    57     delete mWidget;
    73     OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_WPSPAGESTEPTHREEBUTTON_DESTRUCTOR_EXIT, this);
    58 
       
    59 OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_WPSPAGESTEPTHREEBUTTON_EXIT, this)
       
    60 }
    74 }
    61 
    75 
    62 /*!
    76 /*!
    63   * Loads the page with all the widgets
    77    Loads the page with all the widgets
    64   * 
    78    
    65   * \return HbWidget* Returns the view widget
    79    @return HbWidget* Returns the view widget
    66  */
    80  */
    67 HbWidget* WpsPageStepThreeButton::initializePage()
    81 HbWidget* WpsPageStepThreeButton::initializePage()
    68 {
    82 {
    69     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_INITIALIZEPAGE_ENTRY, this)
    83     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_INITIALIZEPAGE_ENTRY, this);
    70 
    84 
    71     if (!mWidget) {
    85     if (!mWidget) {
    72         bool ok;
    86         bool ok;
    73         HbDocumentLoader loader;
    87         mLoader = new HbDocumentLoader(mWizard->mainWindow());
    74         loader.load(":/docml/occ_wps_P2.docml", &ok);
    88         
    75         Q_ASSERT_X(ok, "WPS Wizard", "Invalid docml file");
    89         mLoader->load(":/docml/occ_wps_02_03.docml", &ok);
       
    90         Q_ASSERT(ok);
       
    91         
       
    92         // Initialize orientation
       
    93         loadDocmlSection(mWizard->mainWindow()->orientation());
    76 
    94 
    77         mWidget = qobject_cast<HbWidget*> (loader.findWidget("occ_wps_P2"));
    95         mWidget = qobject_cast<HbWidget*> (mLoader->findWidget("occ_wps_P2"));
    78         Q_ASSERT_X(mWidget != 0, "WPS Wizard", "View not found");
    96         Q_ASSERT(mWidget);
    79 
    97 
    80         //mTitle = qobject_cast<HbLabel*> (loader.findWidget("label_title"));
    98         mHeading = qobject_cast<HbLabel*> (mLoader->findWidget("label_heading"));
    81         //Q_ASSERT_X(mTitle != 0, "WPS wizard", "title not found");
    99         Q_ASSERT(mHeading);
    82 
   100         
    83         mHeading = qobject_cast<HbLabel*> (loader.findWidget("label_heading"));
   101         mHeading->setPlainText(hbTrId("txt_occ_dialog_first_press_button_on_the_wireless"));
    84         Q_ASSERT_X(mHeading != 0, "WPS wizard", "Header not found");
   102         
    85 
   103         bool connectOk = connect(
    86         mWizard->enableNextButton(true);
   104             mWizard->mainWindow(), 
    87     }
   105             SIGNAL(orientationChanged(Qt::Orientation)),
    88     OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_INITIALIZEPAGE_EXIT, this)
   106             this, 
    89 
   107             SLOT(loadDocmlSection(Qt::Orientation)));
       
   108        Q_ASSERT(connectOk);
       
   109     } 
       
   110     
       
   111     OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_INITIALIZEPAGE_EXIT, this);
    90     return mWidget;
   112     return mWidget;
    91 }
   113 }
    92 
   114 
    93 /*!
   115 /*!
    94   * Funtion to determine the next page to be displayed in the wizard process
   116    Funtion to determine the next page to be displayed in the wizard process
    95   * 
   117    
    96   * \param bool& RemoveFromStack indicating whether the current page should be 
   118    @param [out] removeFromStack bool indicating whether the current page should be 
    97   * removed from the stack
   119    removed from the stack
    98   * 
   120    
    99   * \return int Page Id of the next page to be displayed.
   121    @return int Page Id of the next page to be displayed.
   100  */
   122  */
   101 int WpsPageStepThreeButton::nextId(bool &removeFromStack) const
   123 int WpsPageStepThreeButton::nextId(bool &removeFromStack) const
   102 {
   124 {
   103     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_NEXTID_ENTRY, this)
   125     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_NEXTID_ENTRY, this);
   104     int id = WlanWizardPage::PageNone;
       
   105     removeFromStack = false;
   126     removeFromStack = false;
   106     id = WpsWizardPage::PageWpsWizardStep4;
   127     OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_NEXTID_EXIT, this);
   107     OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_NEXTID_EXIT, this)
       
   108 
   128 
   109     return id;
   129     return WpsWizardPage::PageWpsWizardStep4;
   110 }
   130 }
   111 
   131 
   112 /*!
   132 /*!
   113  * Determines the Number of steps to move backwards when 'Prev' Button
   133    Determines the Number of steps to move backwards when 'Prev' Button
   114  * is clicked
   134    is clicked
   115  * 
   135    
   116  * \return int Number of pages to move backwards
   136    @return int Number of pages to move backwards
   117 */
   137  */
   118 int WpsPageStepThreeButton::stepsBackwards()
   138 int WpsPageStepThreeButton::previousTriggered()
   119 {
   139 {
   120     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_STEPSBACKWARDS_ENTRY, this)
   140     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_PREVIOUSTRIGGERED_ENTRY, this); 
   121     OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_STEPBACKWARDS_EXIT, this)
   141     OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_PREVIOUSTRIGGERED_EXIT, this);
   122 
       
   123     return (PageWpsWizardStep3_Button - PageWpsWizardStep2);
   142     return (PageWpsWizardStep3_Button - PageWpsWizardStep2);
   124 }
   143 }
   125 
   144 
   126 /*!
   145 /*!
   127   * Callback when the previous button is clicked
   146    Loads docml at initialization phase and when HbMainWindow sends 
       
   147    orientation() signal.
       
   148    
       
   149    @param [in] orientation orientation to be loaded.
   128  */
   150  */
   129 void WpsPageStepThreeButton::previousTriggered()
   151 void WpsPageStepThreeButton::loadDocmlSection(Qt::Orientation orientation)
   130 {
   152 {
   131 OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_PREVIOUSTRIGGERED_ENTRY, this)
   153     bool ok = false;
   132 OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_PREVIOUSTRIGGERED_EXIT, this)
   154     
   133 
   155     // Load the orientation specific section
       
   156     if (orientation == Qt::Horizontal) {
       
   157         mLoader->load(":/docml/occ_wps_02_03.docml", "landscape", &ok);
       
   158         Q_ASSERT(ok);
       
   159     } else {
       
   160         Q_ASSERT(orientation == Qt::Vertical);
       
   161         mLoader->load(":/docml/occ_wps_02_03.docml", "portrait", &ok);
       
   162         Q_ASSERT(ok);
       
   163     }
   134 }
   164 }
   135 
   165 
   136 /*!
       
   137   * CallBack when the cancel button is clicked
       
   138  */
       
   139 void WpsPageStepThreeButton::cancelTriggered()
       
   140 {
       
   141 OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_CANCELTRIGGERED_ENTRY, this)
       
   142 OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_CANCELTRIGGERED_EXIT, this)
       
   143 
       
   144 }
       
   145 
       
   146 /*!
       
   147  * Validates the content of the pages
       
   148  * 
       
   149  * \return bool Indicating the result of the operation
       
   150 */
       
   151 bool WpsPageStepThreeButton::validate() const
       
   152 {
       
   153     OstTraceFunctionEntry1(WPSPAGESTEPTHREEBUTTON_VALIDATE_ENTRY, this)
       
   154     OstTraceFunctionExit1(WPSPAGESTEPTHREEBUTTON_VALIDATE_EXIT, this)
       
   155 
       
   156     return mValid;
       
   157 }
       
   158