diff -r c743ef5928ba -r f9ce957a272c homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsmenubasestate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/homescreenapp/stateplugins/hsmenuworkerstateplugin/src/hsmenubasestate.cpp Fri Mar 19 09:27:44 2010 +0200 @@ -0,0 +1,104 @@ +/* + * 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 + +#include +#include +#include + +#include "hsmenubasestate.h" + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +HsMenuBaseState::HsMenuBaseState(const QString &objectName, QState *parent) : + QState(parent) +{ + construct(objectName); +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// + +HsMenuBaseState::~HsMenuBaseState() +{ +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +void HsMenuBaseState::construct(const QString &objectName) +{ + if (this->parent()) { + setObjectName(this->parent()->objectName() + "/" + objectName); + } else { + setObjectName(objectName); + } +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +void HsMenuBaseState::requestService(const QVariant &service) +{ + requestServices(QList () << service); +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +void HsMenuBaseState::requestServices(const QVariantList &services) +{ + // if value is not list, it returns empty list + QVariantList value = property(HS_SERVICES_REGISTRATION_KEY).toList(); + // apppend to list + value.append(services); + setProperty(HS_SERVICES_REGISTRATION_KEY, value); +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +HsShortcutService *HsMenuBaseState::shortcutService() const +{ + return propertyWithChecking(SHORTCUT_SERVICE_KEY).value< + HsShortcutService *> (); +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +HsContentService *HsMenuBaseState::contentService() const +{ + return propertyWithChecking(CONTENT_SERVICE_KEY).value< + HsContentService *> (); +} + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// +QVariant HsMenuBaseState::propertyWithChecking(const char *propertyName) const +{ + QVariant val = property(propertyName); + if (!val.isValid()) { + qWarning() << "Missing value for property: " << propertyName; + } + return val; +}