homescreensrv_plat/hswidgetmodel_api/hswidget.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 16 Apr 2010 15:16:09 +0300
changeset 61 8e5041d13c84
parent 60 f62f87b200ec
permissions -rw-r--r--
Revision: 201011 Kit: 201015

/*
* 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:  Base class for all homescreen widgets.
*
*/


#ifndef HSWIDGET_H
#define HSWIDGET_H

#include <hswidgetmodel_global.h>
#include <hbwidget.h>


class HsWidgetPrivate;
class IHsWidgetPreferenceService;

class HSWIDGETMODEL_EXPORT HsWidget : public HbWidget
{
    Q_OBJECT

public:

    enum StartResult { StartResultRunning, StartResultFinished, StartResultFaulted };
    enum StopResult { StopResultFinished, StopResultFinishing, StopResultFaulted, StopResultFaulting };
    enum SuspendResult { SuspendResultSuspended, SuspendResultFaulted, SuspendResultFaulting };
    enum ResumeResult { ResumeResultRunning, ResumeResultFaulted, ResumeResultFaulting };


    HsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0);
    virtual ~HsWidget();

    IHsWidgetPreferenceService *widgetPreferenceService() const;

    void start();
    void stop();
    void suspend();
    void resume();

signals:

    void succeeded();
    void stopped();
    void faulted();

protected:

    
    virtual StartResult onStart() = 0;
    virtual StopResult onStop() = 0;
    virtual SuspendResult onSuspend();
    virtual ResumeResult onResume();

    void setFinished();
    void setFaulted();
    void setFaulting();

    /**
     * @copydoc QGraphicsWidget::mouseDoubleClickEvent()
     */
    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { Q_UNUSED(event) }

    /**
     * @copydoc QGraphicsWidget::mouseMoveEvent()
     */
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_UNUSED(event) }

    /**
     * @copydoc QGraphicsWidget::mousePressEvent()
     */
    void mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_UNUSED(event) }

    /**
     * @copydoc QGraphicsWidget::mouseReleaseEvent()
     */
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_UNUSED(event) }

private:

    Q_DISABLE_COPY(HsWidget)

private:

    HsWidgetPrivate *mD;
    friend class HsWidgetPrivate;

};




#endif