searchui/stateproviders/searchstateprovider/src/searchsettingsstate.cpp
author hgs
Mon, 06 Sep 2010 09:21:19 +0530
changeset 21 708468d5143e
parent 9 4a2987baf8f7
child 26 367228f82b66
permissions -rw-r--r--
201035

/*
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description:  Search Setting state.
 *
 */

#include "searchsettingsstate.h"
#include "settingswidget.h"
#include <hbdocumentloader.h>
#include <hbview.h>
#include <hblabel.h>
#include <hbstackedwidget.h>
#include <hbicon.h>
#include <hbinstance.h>
#include <hbaction.h>
#include <hbgridview.h>
#include <qstandarditemmodel.h>
#include <qdebug.h>
#include <qgraphicswidget.h>
#include <qdir.h>
// ---------------------------------------------------------------------------
// SearchSettingsState::SearchSettingsState
// ---------------------------------------------------------------------------
//
SearchSettingsState::SearchSettingsState(QState *parent) :
    QState(parent), mDocumentLoader(NULL)
    {
    minitialCount = true;
    mWidget = new SettingsWidget();

    connect(mWidget, SIGNAL(settingsEvent(bool)), this,
            SLOT(handleBackEvent(bool)));

    connect(mWidget, SIGNAL(selectedItemCategory(int, bool)), this,
            SLOT(getItemCategory(int, bool)));

    connect(mWidget, SIGNAL(ISProvidersIcon(HbIcon, int)), this,
            SLOT(slotISProvidersIcon(HbIcon, int)));
    }
// ---------------------------------------------------------------------------
// SearchSettingsState::~SearchSettingsState
// ---------------------------------------------------------------------------
//
SearchSettingsState::~SearchSettingsState()
    {
    delete mDocumentLoader;
    delete mWidget;
    }
// ---------------------------------------------------------------------------
// SearchSettingsState::slotISProvidersIcon
// ---------------------------------------------------------------------------
//
void SearchSettingsState::slotISProvidersIcon(HbIcon icon, int id)
    {
    emit publishISProviderIcon(id, icon);
    }
// ---------------------------------------------------------------------------
// SearchSettingsState::getItemCategory
// ---------------------------------------------------------------------------
//
void SearchSettingsState::getItemCategory(int str, bool avalue)
    {
    emit publishSelectedCategory(str, avalue);
    }
// ---------------------------------------------------------------------------
// SearchSettingsState::onEntry
// ---------------------------------------------------------------------------
//
void SearchSettingsState::onEntry(QEvent *event)
    {
    QState::onEntry(event);
    emit settingslaunched();
    if (minitialCount)
        {
        mWidget->loadBaseSettings();
        mWidget->loadDeviceSettings();
        mWidget->loadIS();
        isInternetOn();
        minitialCount = false;
       // isInternetOn();
        //emit backEventTriggered();
        }
    else
        {
        mWidget->launchSettingWidget();
        }    
    }
// ---------------------------------------------------------------------------
// SearchSettingsState::onExit
// ---------------------------------------------------------------------------
//
void SearchSettingsState::onExit(QEvent *event)
    {
    QState::onExit(event);
    }
// ---------------------------------------------------------------------------
// SearchSettingsState::handleBackEvent
// ---------------------------------------------------------------------------
//
void SearchSettingsState::handleBackEvent(bool aStatus)
    {
    if (mWidget)
        {
        isInternetOn();
        emit clickstatus(aStatus);
        }
    }
// ---------------------------------------------------------------------------
// SearchSettingsState::isInternetOn
// ---------------------------------------------------------------------------
//
void SearchSettingsState::isInternetOn()
    {
    if (mWidget->isInternetSearchOptionSelected())
        {
        emit switchToOnlineState();
        }
    else
        {
        emit switchToProState();
        }
    }