diff -r c743ef5928ba -r f9ce957a272c homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsmenuworkerstate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsmenuworkerstate.cpp Fri Mar 19 09:27:44 2010 +0200 @@ -0,0 +1,124 @@ +/* + * 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: + * + */ + +#include + +#include "hsaddtohomescreenstate.h" +#include "hsaddappstocollectionstate.h" +#include "hsdeletecollectionstate.h" +#include "hsdeletecollectionitemstate.h" +#include "hsmenuworkerstate.h" +#include "hscollectionnamestate.h" +#include "hsarrangestate.h" +#include "hspreviewhswidgetstate.h" +/*! + \class HsMenuWorkerState + \ingroup group_hsmenustateplugin + \brief Menu Worker State. + */ + +/*! + Constructor. + \param parent Owner. + */ +HsMenuWorkerState::HsMenuWorkerState(QState *parent) : + QState(parent), mInitialState(0) +{ + construct(); +} + +/*! + Destructor. + */ +HsMenuWorkerState::~HsMenuWorkerState() +{ + +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +void HsMenuWorkerState::construct() +{ + HSMENUTEST_FUNC_ENTRY("HsMenuWorkerState::construct"); + setObjectName("homescreen.nokia.com/state/MenuWorkerState"); + + mInitialState = new QState(this); + setInitialState(mInitialState); + + // use templated creation method - less boilerplate code + createChildState (HsMenuEvent::AddToHomeScreen); + createChildState ( + HsMenuEvent::DeleteCollection); + createChildState ( + HsMenuEvent::RemoveAppFromCollection); + createChildState (HsMenuEvent::ArrangeCollection); + + // create a new child state based on the template + HsCollectionNameState *newChildState = new HsCollectionNameState(this); + // create a transition to the new child state which will be triggered by + // an event with specified operation type + HsMenuEventTransition *renameCollectionTransition = + new HsMenuEventTransition(HsMenuEvent::RenameCollection, + mInitialState, newChildState); + mInitialState->addTransition(renameCollectionTransition); + + HsMenuEventTransition *createCollectionTransition = + new HsMenuEventTransition(HsMenuEvent::CreateCollection, + mInitialState, newChildState); + mInitialState->addTransition(createCollectionTransition); + // set a transition to the initial state after child processing finished + newChildState->addTransition(mInitialState); + + HsAddAppsToCollectionState *addAppsToCollectionState = + new HsAddAppsToCollectionState(this); + // create a transition to the new child state which will be triggered by + // an event with specified operation type + HsMenuEventTransition *addAppsToCollectionTransition = + new HsMenuEventTransition(HsMenuEvent::AddAppsToCollection, + mInitialState, addAppsToCollectionState); + mInitialState->addTransition(addAppsToCollectionTransition); + // set a transition to the initial state after child processing finished + addAppsToCollectionState->addTransition(addAppsToCollectionState, + SIGNAL(finished()), mInitialState); + + createChildState (HsMenuEvent::PreviewHSWidget); + + HSMENUTEST_FUNC_EXIT("HsMenuWorkerState::construct"); +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +template +T *HsMenuWorkerState::createChildState( + HsMenuEvent::OperationType operation) +{ + HSMENUTEST_FUNC_ENTRY("HsMenuWorkerState::createChildState"); + // create a new child state based on the template + T *newChildState = new T(this); + // create a transition to the new child state which will be triggered by + // an event with specified operation type + HsMenuEventTransition *newChildStateTransition = + new HsMenuEventTransition(operation, mInitialState, newChildState); + mInitialState->addTransition(newChildStateTransition); + // set a transition to the initial state after child processing finished + newChildState->addTransition(mInitialState); + HSMENUTEST_FUNC_EXIT("HsMenuWorkerState::createChildState"); + + return newChildState; +}