bagetmodel/src/baget.cpp
author hgs
Wed, 24 Mar 2010 03:15:43 +0200
changeset 89 1e87eb3b400f
parent 85 7feec50967db
permissions -rw-r--r--
201011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
85
7feec50967db 201003_02
hgs
parents:
diff changeset
     1
/*
7feec50967db 201003_02
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
7feec50967db 201003_02
hgs
parents:
diff changeset
     3
* All rights reserved.
7feec50967db 201003_02
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
7feec50967db 201003_02
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
7feec50967db 201003_02
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
7feec50967db 201003_02
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
7feec50967db 201003_02
hgs
parents:
diff changeset
     8
*
7feec50967db 201003_02
hgs
parents:
diff changeset
     9
* Initial Contributors:
7feec50967db 201003_02
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
7feec50967db 201003_02
hgs
parents:
diff changeset
    11
*
7feec50967db 201003_02
hgs
parents:
diff changeset
    12
* Contributors:
7feec50967db 201003_02
hgs
parents:
diff changeset
    13
* 
7feec50967db 201003_02
hgs
parents:
diff changeset
    14
* Description:  Base class for all bagets.
7feec50967db 201003_02
hgs
parents:
diff changeset
    15
*
7feec50967db 201003_02
hgs
parents:
diff changeset
    16
*/
7feec50967db 201003_02
hgs
parents:
diff changeset
    17
7feec50967db 201003_02
hgs
parents:
diff changeset
    18
#include "baget.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    19
#include "baget_p.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    20
7feec50967db 201003_02
hgs
parents:
diff changeset
    21
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
    22
    \enum BagetState
7feec50967db 201003_02
hgs
parents:
diff changeset
    23
    Lists states that the baget can be in.
7feec50967db 201003_02
hgs
parents:
diff changeset
    24
*/
7feec50967db 201003_02
hgs
parents:
diff changeset
    25
7feec50967db 201003_02
hgs
parents:
diff changeset
    26
/*
7feec50967db 201003_02
hgs
parents:
diff changeset
    27
    \var BagetState BagetStateConstructed
7feec50967db 201003_02
hgs
parents:
diff changeset
    28
    Baget is in this state right after construction.
7feec50967db 201003_02
hgs
parents:
diff changeset
    29
*/
7feec50967db 201003_02
hgs
parents:
diff changeset
    30
7feec50967db 201003_02
hgs
parents:
diff changeset
    31
/*
7feec50967db 201003_02
hgs
parents:
diff changeset
    32
    \var BagetState BagetStateRunning
7feec50967db 201003_02
hgs
parents:
diff changeset
    33
    Baget is performing regular operations (animations, etc.).
7feec50967db 201003_02
hgs
parents:
diff changeset
    34
    Baget is set to Running state after a call to start (if previously Constructed or Stopped) 
7feec50967db 201003_02
hgs
parents:
diff changeset
    35
    or resume (if previously Suspended) methods.
7feec50967db 201003_02
hgs
parents:
diff changeset
    36
    \sa Baget::start()
7feec50967db 201003_02
hgs
parents:
diff changeset
    37
    \sa Baget::resume()
7feec50967db 201003_02
hgs
parents:
diff changeset
    38
*/
7feec50967db 201003_02
hgs
parents:
diff changeset
    39
7feec50967db 201003_02
hgs
parents:
diff changeset
    40
/*
7feec50967db 201003_02
hgs
parents:
diff changeset
    41
    \var BagetState BagetStateSuspended
7feec50967db 201003_02
hgs
parents:
diff changeset
    42
    Baget operations are suspended (e.g. animation timers stopped).
7feec50967db 201003_02
hgs
parents:
diff changeset
    43
    Baget is set to Suspended after a call to suspend (if previously Running) method.
7feec50967db 201003_02
hgs
parents:
diff changeset
    44
    \sa Baget::suspend()
7feec50967db 201003_02
hgs
parents:
diff changeset
    45
*/
7feec50967db 201003_02
hgs
parents:
diff changeset
    46
7feec50967db 201003_02
hgs
parents:
diff changeset
    47
/*
7feec50967db 201003_02
hgs
parents:
diff changeset
    48
    \var BagetState BagetStateStopped 
7feec50967db 201003_02
hgs
parents:
diff changeset
    49
    Baget finished all processing and released all resources.
7feec50967db 201003_02
hgs
parents:
diff changeset
    50
    Baget is set to Stopped after a call to stop (if previously Running or Suspended) method.
7feec50967db 201003_02
hgs
parents:
diff changeset
    51
    \sa Baget::stop()
7feec50967db 201003_02
hgs
parents:
diff changeset
    52
*/
7feec50967db 201003_02
hgs
parents:
diff changeset
    53
7feec50967db 201003_02
hgs
parents:
diff changeset
    54
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
    55
    \class Baget
7feec50967db 201003_02
hgs
parents:
diff changeset
    56
    \brief Base class for all Bagets.
7feec50967db 201003_02
hgs
parents:
diff changeset
    57
7feec50967db 201003_02
hgs
parents:
diff changeset
    58
    Baget (BAckGround widgET) is a widget intended to be displayed in the background 
7feec50967db 201003_02
hgs
parents:
diff changeset
    59
    of an application view. It does not respond to user input. It usually performs some 
7feec50967db 201003_02
hgs
parents:
diff changeset
    60
    animations to make the view more appealing.
7feec50967db 201003_02
hgs
parents:
diff changeset
    61
    Bagets are intended for use with HbStackedLayout as the bottom most QGraphicsWidget.
7feec50967db 201003_02
hgs
parents:
diff changeset
    62
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    63
7feec50967db 201003_02
hgs
parents:
diff changeset
    64
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
    65
    Constructs a new Baget with \a parent and \a flags.
7feec50967db 201003_02
hgs
parents:
diff changeset
    66
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    67
Baget::Baget(QGraphicsItem *parent, Qt::WindowFlags flags) :
7feec50967db 201003_02
hgs
parents:
diff changeset
    68
    QGraphicsWidget(parent, flags), m_d(new BagetPrivate(this))
7feec50967db 201003_02
hgs
parents:
diff changeset
    69
{
7feec50967db 201003_02
hgs
parents:
diff changeset
    70
}
7feec50967db 201003_02
hgs
parents:
diff changeset
    71
7feec50967db 201003_02
hgs
parents:
diff changeset
    72
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
    73
    Destructs the class.
7feec50967db 201003_02
hgs
parents:
diff changeset
    74
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    75
Baget::~Baget()
7feec50967db 201003_02
hgs
parents:
diff changeset
    76
{
7feec50967db 201003_02
hgs
parents:
diff changeset
    77
    delete m_d;
7feec50967db 201003_02
hgs
parents:
diff changeset
    78
}
7feec50967db 201003_02
hgs
parents:
diff changeset
    79
7feec50967db 201003_02
hgs
parents:
diff changeset
    80
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
    81
    \fn void Baget::faulted()
7feec50967db 201003_02
hgs
parents:
diff changeset
    82
7feec50967db 201003_02
hgs
parents:
diff changeset
    83
    This signal is emitted if a fault occurs when changing Baget's state.
7feec50967db 201003_02
hgs
parents:
diff changeset
    84
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    85
7feec50967db 201003_02
hgs
parents:
diff changeset
    86
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
    87
    Returns the state that the Baget is currently in.
7feec50967db 201003_02
hgs
parents:
diff changeset
    88
    \return The current state.
7feec50967db 201003_02
hgs
parents:
diff changeset
    89
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    90
BagetState Baget::currentState()
7feec50967db 201003_02
hgs
parents:
diff changeset
    91
{
7feec50967db 201003_02
hgs
parents:
diff changeset
    92
    return m_d->currentState();
7feec50967db 201003_02
hgs
parents:
diff changeset
    93
}
7feec50967db 201003_02
hgs
parents:
diff changeset
    94
7feec50967db 201003_02
hgs
parents:
diff changeset
    95
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
    96
    Initiates Baget's processing.
7feec50967db 201003_02
hgs
parents:
diff changeset
    97
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    98
void Baget::start()
7feec50967db 201003_02
hgs
parents:
diff changeset
    99
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   100
    m_d->start();
7feec50967db 201003_02
hgs
parents:
diff changeset
   101
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   102
7feec50967db 201003_02
hgs
parents:
diff changeset
   103
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   104
    Stops Baget's processing.
7feec50967db 201003_02
hgs
parents:
diff changeset
   105
    After this call Baget should also free all resources.
7feec50967db 201003_02
hgs
parents:
diff changeset
   106
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   107
void Baget::stop()
7feec50967db 201003_02
hgs
parents:
diff changeset
   108
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   109
    m_d->stop();
7feec50967db 201003_02
hgs
parents:
diff changeset
   110
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   111
7feec50967db 201003_02
hgs
parents:
diff changeset
   112
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   113
    Resumes Baget's processing.
7feec50967db 201003_02
hgs
parents:
diff changeset
   114
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   115
void Baget::resume()
7feec50967db 201003_02
hgs
parents:
diff changeset
   116
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   117
    m_d->resume();
7feec50967db 201003_02
hgs
parents:
diff changeset
   118
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   119
7feec50967db 201003_02
hgs
parents:
diff changeset
   120
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   121
    Suspends Baget's processing.
7feec50967db 201003_02
hgs
parents:
diff changeset
   122
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   123
void Baget::suspend()
7feec50967db 201003_02
hgs
parents:
diff changeset
   124
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   125
    m_d->suspend();
7feec50967db 201003_02
hgs
parents:
diff changeset
   126
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   127
7feec50967db 201003_02
hgs
parents:
diff changeset
   128
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   129
    \fn virtual bool Baget::onStart() = 0
7feec50967db 201003_02
hgs
parents:
diff changeset
   130
7feec50967db 201003_02
hgs
parents:
diff changeset
   131
    After a call it should start Baget's processing.
7feec50967db 201003_02
hgs
parents:
diff changeset
   132
    Returns true if the operation secceeded, otherwise false - in this case 
7feec50967db 201003_02
hgs
parents:
diff changeset
   133
    the faulted() signal will be emitted by the base class.
7feec50967db 201003_02
hgs
parents:
diff changeset
   134
    \return Indicates if the operation succeeded.
7feec50967db 201003_02
hgs
parents:
diff changeset
   135
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   136
7feec50967db 201003_02
hgs
parents:
diff changeset
   137
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   138
    \fn virtual bool Baget::onStop() = 0
7feec50967db 201003_02
hgs
parents:
diff changeset
   139
7feec50967db 201003_02
hgs
parents:
diff changeset
   140
    After a call it should stop Baget's processing and 
7feec50967db 201003_02
hgs
parents:
diff changeset
   141
    free all resources.
7feec50967db 201003_02
hgs
parents:
diff changeset
   142
    Returns true if the operation secceeded, otherwise false - in this case 
7feec50967db 201003_02
hgs
parents:
diff changeset
   143
    the faulted() signal will be emitted by the base class.
7feec50967db 201003_02
hgs
parents:
diff changeset
   144
    \return Indicates if the operation succeeded.
7feec50967db 201003_02
hgs
parents:
diff changeset
   145
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   146
7feec50967db 201003_02
hgs
parents:
diff changeset
   147
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   148
    After a call it should resume Baget's processing.
7feec50967db 201003_02
hgs
parents:
diff changeset
   149
    Returns true if the operation secceeded, otherwise false - in this case 
7feec50967db 201003_02
hgs
parents:
diff changeset
   150
    the faulted() signal will be emitted by the base class.
7feec50967db 201003_02
hgs
parents:
diff changeset
   151
    The default implementation does nothing and always returns true.
7feec50967db 201003_02
hgs
parents:
diff changeset
   152
    \return Indicates if the operation succeeded.
7feec50967db 201003_02
hgs
parents:
diff changeset
   153
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   154
bool Baget::onResume()
7feec50967db 201003_02
hgs
parents:
diff changeset
   155
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   156
    return true;
7feec50967db 201003_02
hgs
parents:
diff changeset
   157
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   158
7feec50967db 201003_02
hgs
parents:
diff changeset
   159
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   160
    After a call it should suspend Baget's processing.
7feec50967db 201003_02
hgs
parents:
diff changeset
   161
    Returns true if the operation secceeded, otherwise false - in this case 
7feec50967db 201003_02
hgs
parents:
diff changeset
   162
    the faulted() signal will be emitted by the base class.
7feec50967db 201003_02
hgs
parents:
diff changeset
   163
    The default implementation does nothing and always returns true.
7feec50967db 201003_02
hgs
parents:
diff changeset
   164
    \return Indicates if the operation succeeded.
7feec50967db 201003_02
hgs
parents:
diff changeset
   165
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   166
bool Baget::onSuspend()
7feec50967db 201003_02
hgs
parents:
diff changeset
   167
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   168
    return true;
7feec50967db 201003_02
hgs
parents:
diff changeset
   169
}