1 /* |
|
2 * Copyright (c) 2006 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: Takes care of storing and serving the slides |
|
15 * to Slideshow plugin |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_SLIDESHOWMODEL_H |
|
22 #define C_SLIDESHOWMODEL_H |
|
23 |
|
24 #include <e32base.h> |
|
25 |
|
26 class CSlideshowSlide; |
|
27 |
|
28 // Slide Array's size. 5 seems like a reasonable granularity |
|
29 const TInt KSlideshowSlideArrayGranularity = 5; |
|
30 |
|
31 //Slide status |
|
32 //this is only called in startplugin, Dont call it anywhere |
|
33 //Get next slide status |
|
34 const TInt KStatusNoSlide = 0; //no side |
|
35 const TInt KStatusSlideDecoded = 1; //already decoded |
|
36 const TInt KStatusDecodingInProgress =2; //decoding in progress |
|
37 const TInt KStatusSlideNotDecoding = 3; //slide is there but not decoded |
|
38 const TInt KStatusSlideDecodeingFailed = 4; //could not decode the file |
|
39 |
|
40 // Slideshow model. |
|
41 // Contains slideshow slides, serves the slides to Slideshow plugin |
|
42 class CSlideshowModel : public CBase |
|
43 { |
|
44 |
|
45 public: |
|
46 /** |
|
47 * Return a new CSlideshowModel object |
|
48 */ |
|
49 static CSlideshowModel* NewL(); |
|
50 |
|
51 /** |
|
52 * Desconstructor |
|
53 */ |
|
54 virtual ~CSlideshowModel(); |
|
55 |
|
56 private: |
|
57 /** |
|
58 * Default constructor |
|
59 */ |
|
60 CSlideshowModel(); |
|
61 |
|
62 /* |
|
63 * Two-phase constructor, initialises member arrays and stuff |
|
64 */ |
|
65 virtual void ConstructL(); |
|
66 |
|
67 public: // Access functions |
|
68 /* |
|
69 * Number of slides query. |
|
70 */ |
|
71 TInt NumberOfSlides() const; |
|
72 |
|
73 /* |
|
74 * Add a slide to the end of the array. |
|
75 * |
|
76 * @param aSlide The new slide which will be added to the silde array. |
|
77 */ |
|
78 void AppendSlideL(CSlideshowSlide* aSlide); |
|
79 |
|
80 /* |
|
81 * Insert a slide at <aIndex>. Space must be reserved. |
|
82 * |
|
83 * @param aIndex The postion index which the new slide will be insert to. |
|
84 * @param aSilde The new slide which will be insert. |
|
85 */ |
|
86 void InsertSlideL(TInt aIndex, CSlideshowSlide* aSlide); |
|
87 |
|
88 /* |
|
89 * Delete slide at <aIndex>. |
|
90 * |
|
91 * @param aIndex The slide at <aIndex> will be delete. |
|
92 */ |
|
93 void DeleteSlide(TInt aIndex); |
|
94 |
|
95 /* |
|
96 * Delete all slides. |
|
97 */ |
|
98 void DeleteAll(); |
|
99 |
|
100 /* |
|
101 * Get slide at position <aIndex>. |
|
102 * |
|
103 * @return a slide at position <aIndex>. |
|
104 */ |
|
105 CSlideshowSlide* SlideAt(TInt aIndex) const; |
|
106 |
|
107 /* |
|
108 * Get current slide index. |
|
109 * |
|
110 * @return the current slide index. |
|
111 */ |
|
112 inline TInt CurrentSlideIndex() const; |
|
113 |
|
114 /* |
|
115 * Set current slide index. |
|
116 * |
|
117 * @param aIndex The slide index, which will be show. |
|
118 */ |
|
119 inline void SetCurrentSlideIndex(TInt aIndex); |
|
120 |
|
121 /* |
|
122 * Get next slide in sequence |
|
123 * |
|
124 * @param aRandom No used now. |
|
125 * @return the next slide. |
|
126 */ |
|
127 CSlideshowSlide* NextSlide(TBool aRandom); |
|
128 |
|
129 /* |
|
130 * Get slide status: decoded, decoding ,not started,decoding failed,no slide. |
|
131 * |
|
132 * @param aSlide the slide which status will be detected. |
|
133 * @return status of aSlide. |
|
134 */ |
|
135 TInt SlideStatus(CSlideshowSlide* aSlide); |
|
136 |
|
137 /* |
|
138 * Prepare next slide. |
|
139 * @param aRandom Whether select next slide random.( ETrue is random, EFalse is sequential) |
|
140 * @param aTargetSize The slide Size. |
|
141 */ |
|
142 void PrepareNextSlide(TBool aRandom, const TSize& aTargetSize); |
|
143 |
|
144 /* |
|
145 * Release next slide. |
|
146 */ |
|
147 void ReleaseNextSlide(); |
|
148 |
|
149 /* |
|
150 * Release Current slide. |
|
151 */ |
|
152 void ReleaseCurrentSlide(); |
|
153 |
|
154 /* |
|
155 * Get next slide index. |
|
156 * |
|
157 * @return the position index which slide will be on. |
|
158 */ |
|
159 inline TInt NextSlideIndex() const; |
|
160 |
|
161 /* |
|
162 * Reserve space for <aCount> slides. |
|
163 * |
|
164 * @param aCount The slide number. |
|
165 */ |
|
166 void SetReserveL(TInt aCount); |
|
167 |
|
168 /* |
|
169 * Query if model is busy (decoding a slide). |
|
170 * |
|
171 * @return status whether the model is ready.(ETrue is ready, EFalse is not) |
|
172 */ |
|
173 TBool Busy(); |
|
174 |
|
175 /* |
|
176 * Reset slide sequence, note that this will not release current image |
|
177 */ |
|
178 inline void ResetSlideSequence(); |
|
179 |
|
180 private: // Utility functions |
|
181 /* |
|
182 * Get a random number in the range aMin - aMax (inclusive) |
|
183 * |
|
184 * @param aMax The upper limited. |
|
185 * @param aMin The lower limited. |
|
186 * @return an random number which is between aMax and aMin. |
|
187 */ |
|
188 TInt Random(TInt aMax, TInt aMin = 0); |
|
189 |
|
190 private: |
|
191 /* |
|
192 * Slide array |
|
193 */ |
|
194 CArrayPtrFlat<CSlideshowSlide>* iSlides; |
|
195 |
|
196 /* |
|
197 * Current slide index |
|
198 */ |
|
199 TInt iCurrentSlide; |
|
200 |
|
201 /* |
|
202 * Next slide index |
|
203 */ |
|
204 TInt iNextSlide; |
|
205 |
|
206 /* |
|
207 * Random seed |
|
208 */ |
|
209 TInt64 iRandSeed; |
|
210 |
|
211 /* |
|
212 * Busy flag |
|
213 */ |
|
214 TBool iBusy; |
|
215 }; |
|
216 |
|
217 //------------------------------------------------------------------------------ |
|
218 // CSlideshowModel::CurrentSlideIndex |
|
219 //------------------------------------------------------------------------------ |
|
220 // |
|
221 TInt CSlideshowModel::CurrentSlideIndex() const |
|
222 { |
|
223 return iCurrentSlide; |
|
224 } |
|
225 |
|
226 |
|
227 //------------------------------------------------------------------------------ |
|
228 // CSlideshowModel::SetCurrentSlideIndex |
|
229 //------------------------------------------------------------------------------ |
|
230 // |
|
231 void CSlideshowModel::SetCurrentSlideIndex(TInt aIndex) |
|
232 { |
|
233 iCurrentSlide = aIndex; |
|
234 } |
|
235 |
|
236 |
|
237 //------------------------------------------------------------------------------ |
|
238 // CSlideshowModel::NextSlideIndex |
|
239 //------------------------------------------------------------------------------ |
|
240 // |
|
241 TInt CSlideshowModel::NextSlideIndex() const |
|
242 { |
|
243 return iNextSlide; |
|
244 } |
|
245 |
|
246 //------------------------------------------------------------------------------ |
|
247 // CSlideshowModel::ResetSlideSequence |
|
248 //------------------------------------------------------------------------------ |
|
249 // |
|
250 void CSlideshowModel::ResetSlideSequence() |
|
251 { |
|
252 iCurrentSlide = 0; |
|
253 iNextSlide = -1; |
|
254 } |
|
255 |
|
256 #endif // C_CSLIDESHOWMODEL_H |
|
257 |
|
258 // End of file |
|