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