wlanutilities/wlanwizard/src/wlanwizardpagessid.cpp
author hgs
Thu, 24 Jun 2010 10:49:51 +0300
changeset 39 7b3e49e4608a
parent 31 e8f4211554fb
child 43 72ebcbb64834
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
hgs
parents:
diff changeset
     1
/*
39
hgs
parents: 31
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents: 31
diff changeset
     3
* All rights reserved.
hgs
parents: 31
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents: 31
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents: 31
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents: 31
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents: 31
diff changeset
     8
*
hgs
parents: 31
diff changeset
     9
* Initial Contributors:
hgs
parents: 31
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents: 31
diff changeset
    11
*
hgs
parents: 31
diff changeset
    12
* Contributors:
hgs
parents: 31
diff changeset
    13
*
hgs
parents: 31
diff changeset
    14
* Description: 
hgs
parents: 31
diff changeset
    15
* WLAN Wizard Page: SSID Selection.
hgs
parents: 31
diff changeset
    16
*/
31
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
// System includes
hgs
parents:
diff changeset
    19
#include <HbDocumentLoader>
hgs
parents:
diff changeset
    20
#include <HbMainWindow>
hgs
parents:
diff changeset
    21
#include <HbWidget>
hgs
parents:
diff changeset
    22
#include <HbLineEdit>
hgs
parents:
diff changeset
    23
#include <HbEditorInterface>
hgs
parents:
diff changeset
    24
#include <HbLabel>
hgs
parents:
diff changeset
    25
#include <wlanqtutils.h>
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
// User includes
hgs
parents:
diff changeset
    28
#include "wlanwizardpagessid.h"
hgs
parents:
diff changeset
    29
#include "wlanwizard_p.h"
hgs
parents:
diff changeset
    30
#include "wlanwizardutils.h"
hgs
parents:
diff changeset
    31
#include "OstTraceDefinitions.h"
hgs
parents:
diff changeset
    32
#ifdef OST_TRACE_COMPILER_IN_USE
hgs
parents:
diff changeset
    33
#include "wlanwizardpagessidTraces.h"
hgs
parents:
diff changeset
    34
#endif
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
/*!
39
hgs
parents: 31
diff changeset
    37
 * Constructor method for the SSID query view object.
hgs
parents: 31
diff changeset
    38
 * @param [in] parent pointer to parent object.
31
hgs
parents:
diff changeset
    39
 */
hgs
parents:
diff changeset
    40
WlanWizardPageSsid::WlanWizardPageSsid(WlanWizardPrivate* parent) :
hgs
parents:
diff changeset
    41
    WlanWizardPageInternal(parent),
hgs
parents:
diff changeset
    42
    mWidget(NULL),
hgs
parents:
diff changeset
    43
    mLabel(NULL),
hgs
parents:
diff changeset
    44
    mSsid(NULL),
hgs
parents:
diff changeset
    45
    mLoader(NULL)
hgs
parents:
diff changeset
    46
{
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
}
hgs
parents:
diff changeset
    49
hgs
parents:
diff changeset
    50
/*!
hgs
parents:
diff changeset
    51
 * Destructor. Loader widget is deleted.
hgs
parents:
diff changeset
    52
 * All document widgets are deleted by wlanwizard_p destructor.
hgs
parents:
diff changeset
    53
 */
hgs
parents:
diff changeset
    54
WlanWizardPageSsid::~WlanWizardPageSsid()
hgs
parents:
diff changeset
    55
{
hgs
parents:
diff changeset
    56
    delete mLoader;
hgs
parents:
diff changeset
    57
}
hgs
parents:
diff changeset
    58
hgs
parents:
diff changeset
    59
/*!
hgs
parents:
diff changeset
    60
 * Page initialization. If view is already loaded, does nothing.
39
hgs
parents: 31
diff changeset
    61
 * @return pointer to widget "occ_add_wlan_01".
31
hgs
parents:
diff changeset
    62
 */
hgs
parents:
diff changeset
    63
HbWidget* WlanWizardPageSsid::initializePage()
hgs
parents:
diff changeset
    64
{
hgs
parents:
diff changeset
    65
    OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESSID_INITIALIZEPAGE,
hgs
parents:
diff changeset
    66
        "WlanWizardPageSsid::initializePage" );
hgs
parents:
diff changeset
    67
39
hgs
parents: 31
diff changeset
    68
    // It is not possible for this method to be called more than once during
hgs
parents: 31
diff changeset
    69
    // wizard lifetime.
hgs
parents: 31
diff changeset
    70
    Q_ASSERT(mWidget == NULL);
31
hgs
parents:
diff changeset
    71
39
hgs
parents: 31
diff changeset
    72
    bool ok;
31
hgs
parents:
diff changeset
    73
39
hgs
parents: 31
diff changeset
    74
    mLoader = new HbDocumentLoader(mWizard->mainWindow());
31
hgs
parents:
diff changeset
    75
39
hgs
parents: 31
diff changeset
    76
    mLoader->load(":/docml/occ_add_wlan_01_04.docml", &ok);
hgs
parents: 31
diff changeset
    77
    Q_ASSERT(ok);
hgs
parents: 31
diff changeset
    78
hgs
parents: 31
diff changeset
    79
    // Load orientation
hgs
parents: 31
diff changeset
    80
    loadDocmlSection(mWizard->mainWindow()->orientation());
31
hgs
parents:
diff changeset
    81
39
hgs
parents: 31
diff changeset
    82
    // Load widgets
hgs
parents: 31
diff changeset
    83
    mWidget = qobject_cast<HbWidget*> (mLoader->findWidget(
hgs
parents: 31
diff changeset
    84
        "occ_add_wlan_01"));
hgs
parents: 31
diff changeset
    85
    Q_ASSERT(mWidget != NULL);
31
hgs
parents:
diff changeset
    86
39
hgs
parents: 31
diff changeset
    87
    mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog"));
hgs
parents: 31
diff changeset
    88
    Q_ASSERT(mLabel != NULL);
31
hgs
parents:
diff changeset
    89
39
hgs
parents: 31
diff changeset
    90
    mSsid = qobject_cast<HbLineEdit*> (mLoader->findWidget("lineEditKey"));
hgs
parents: 31
diff changeset
    91
    Q_ASSERT(mSsid != NULL);
hgs
parents: 31
diff changeset
    92
hgs
parents: 31
diff changeset
    93
    mLabel->setPlainText(hbTrId(
hgs
parents: 31
diff changeset
    94
        "txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));
31
hgs
parents:
diff changeset
    95
39
hgs
parents: 31
diff changeset
    96
    // Connect orientation signal from the main window to orientation
hgs
parents: 31
diff changeset
    97
    // loader.
hgs
parents: 31
diff changeset
    98
    ok = connect(mWizard->mainWindow(),
hgs
parents: 31
diff changeset
    99
        SIGNAL(orientationChanged(Qt::Orientation)), this,
hgs
parents: 31
diff changeset
   100
        SLOT(loadDocmlSection(Qt::Orientation)));
hgs
parents: 31
diff changeset
   101
    Q_ASSERT(ok);
31
hgs
parents:
diff changeset
   102
39
hgs
parents: 31
diff changeset
   103
    // Connect text change-signal from input dialog to handler function
hgs
parents: 31
diff changeset
   104
    ok = connect(mSsid, SIGNAL(textChanged(const QString &)), this,
hgs
parents: 31
diff changeset
   105
        SLOT(textChanged(const QString &)));
hgs
parents: 31
diff changeset
   106
    Q_ASSERT(ok);
31
hgs
parents:
diff changeset
   107
39
hgs
parents: 31
diff changeset
   108
    HbEditorInterface editInterface(mSsid);
hgs
parents: 31
diff changeset
   109
    
hgs
parents: 31
diff changeset
   110
    // TODO: remove (HbEditorConstraints) type cast when 
hgs
parents: 31
diff changeset
   111
    // Q_DECLARE_OPERATORS_FOR_FLAGS(HbEditorConstraints) is defined (SDK xxx)
hgs
parents: 31
diff changeset
   112
    editInterface.setInputConstraints(
hgs
parents: 31
diff changeset
   113
        (HbEditorConstraints)(HbEditorConstraintAutoCompletingField |
hgs
parents: 31
diff changeset
   114
            HbEditorConstraintLatinAlphabetOnly));
hgs
parents: 31
diff changeset
   115
    
hgs
parents: 31
diff changeset
   116
    editInterface.setSmileyTheme(HbSmileyTheme());
hgs
parents: 31
diff changeset
   117
    editInterface.setEditorClass(HbInputEditorClassNetworkName);
hgs
parents: 31
diff changeset
   118
    mSsid->setInputMethodHints(
hgs
parents: 31
diff changeset
   119
        Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase);
hgs
parents: 31
diff changeset
   120
    mSsid->setMaxLength(WlanWizardUtils::SsidMaxLength);
31
hgs
parents:
diff changeset
   121
39
hgs
parents: 31
diff changeset
   122
	return mWidget;
31
hgs
parents:
diff changeset
   123
}
hgs
parents:
diff changeset
   124
hgs
parents:
diff changeset
   125
/*!
39
hgs
parents: 31
diff changeset
   126
 * This method is overrides the default implementation from WlanWizardPage.
hgs
parents: 31
diff changeset
   127
 * It indicates whether the Next-button should be enabled or not.
hgs
parents: 31
diff changeset
   128
 * @return true, if mSsid edit field is not empty.
hgs
parents: 31
diff changeset
   129
 */
hgs
parents: 31
diff changeset
   130
bool WlanWizardPageSsid::showPage()
hgs
parents: 31
diff changeset
   131
{
hgs
parents: 31
diff changeset
   132
    // Initiate the scanning of public APs here.
hgs
parents: 31
diff changeset
   133
    mWizard->wlanQtUtils()->scanWlanAps();
hgs
parents: 31
diff changeset
   134
    
hgs
parents: 31
diff changeset
   135
    // Open virtual keyboard by setting focus to line edit
hgs
parents: 31
diff changeset
   136
    mSsid->setFocus();
hgs
parents: 31
diff changeset
   137
hgs
parents: 31
diff changeset
   138
    return !(mSsid->text().isEmpty());
hgs
parents: 31
diff changeset
   139
}
hgs
parents: 31
diff changeset
   140
hgs
parents: 31
diff changeset
   141
/*!
hgs
parents: 31
diff changeset
   142
 * Stores the SSID selection in the configuration.
hgs
parents: 31
diff changeset
   143
 * @param [out] removeFromStack returns false.
hgs
parents: 31
diff changeset
   144
 * @return WlanWizardPageScanning page id.
31
hgs
parents:
diff changeset
   145
 */
hgs
parents:
diff changeset
   146
int WlanWizardPageSsid::nextId(bool &removeFromStack) const
hgs
parents:
diff changeset
   147
{
hgs
parents:
diff changeset
   148
    removeFromStack = false;
hgs
parents:
diff changeset
   149
39
hgs
parents: 31
diff changeset
   150
    // SSID is stored into configuration
hgs
parents: 31
diff changeset
   151
    mWizard->setConfiguration(WlanWizardPrivate::ConfSsid, mSsid->text());
hgs
parents: 31
diff changeset
   152
    
hgs
parents: 31
diff changeset
   153
    return WlanWizardPageInternal::PageScanning;
31
hgs
parents:
diff changeset
   154
}
hgs
parents:
diff changeset
   155
hgs
parents:
diff changeset
   156
/*!
39
hgs
parents: 31
diff changeset
   157
 * Loads the document orientation information from occ_add_wlan_01_04.docml
hgs
parents: 31
diff changeset
   158
 * This is called each time phone orientation changes.
hgs
parents: 31
diff changeset
   159
 * @param [in] orientation indicates whether the phone is in portrait or
hgs
parents: 31
diff changeset
   160
 * landscape mode.
31
hgs
parents:
diff changeset
   161
 */
39
hgs
parents: 31
diff changeset
   162
void WlanWizardPageSsid::loadDocmlSection(Qt::Orientation orientation)
31
hgs
parents:
diff changeset
   163
{
hgs
parents:
diff changeset
   164
    OstTrace1( TRACE_FLOW, WLANWIZARDPAGESSID_LOADDOCML,
hgs
parents:
diff changeset
   165
        "WlanWizardPageSsid::loadDocml - orientation ;orientation=%x",
hgs
parents:
diff changeset
   166
        ( TUint )( orientation ) );
hgs
parents:
diff changeset
   167
39
hgs
parents: 31
diff changeset
   168
    WlanWizardPageInternal::loadDocmlSection(
hgs
parents: 31
diff changeset
   169
        mLoader,
hgs
parents: 31
diff changeset
   170
        orientation,
hgs
parents: 31
diff changeset
   171
        ":/docml/occ_add_wlan_01_04.docml", 
hgs
parents: 31
diff changeset
   172
        "portrait_section",
hgs
parents: 31
diff changeset
   173
        "landscape_section");
31
hgs
parents:
diff changeset
   174
}
hgs
parents:
diff changeset
   175
hgs
parents:
diff changeset
   176
/*!
39
hgs
parents: 31
diff changeset
   177
 * Executed when changes have been made to the mSsid field (and the field is
hgs
parents: 31
diff changeset
   178
 * not empty).
hgs
parents: 31
diff changeset
   179
 * @param [in] text is not used at this point.
31
hgs
parents:
diff changeset
   180
 */
39
hgs
parents: 31
diff changeset
   181
void WlanWizardPageSsid::textChanged(const QString &text)
31
hgs
parents:
diff changeset
   182
{
39
hgs
parents: 31
diff changeset
   183
    Q_UNUSED(text);
hgs
parents: 31
diff changeset
   184
    OstTrace0( TRACE_FLOW, WLANWIZARDPAGESSID_TEXTCHANGED,
hgs
parents: 31
diff changeset
   185
        "WlanWizardPageSsid::textChanged in text edit widget" );
31
hgs
parents:
diff changeset
   186
39
hgs
parents: 31
diff changeset
   187
    mWizard->enableNextButton(!(mSsid->text().isEmpty()));
31
hgs
parents:
diff changeset
   188
}