1 /* |
|
2 * Copyright (c) 2007-2008 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: suite presentation model |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_HNSUITEMODEL_H |
|
20 #define C_HNSUITEMODEL_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32hashtab.h> |
|
24 #include "hnsuiteobserver.h" |
|
25 #include "hnglobals.h" |
|
26 #include "hnitemmodel.h" |
|
27 |
|
28 class CHnSuiteModelContainer; |
|
29 class CHnItemModel; |
|
30 class MHnMenuItemModelIterator; |
|
31 class CHnActionModel; |
|
32 class CHnEventHandler; |
|
33 class MHnSuiteObserver; |
|
34 class CHnItemsOrder; |
|
35 class CHnItemFocusHandler; |
|
36 |
|
37 /** |
|
38 * Suite model class. |
|
39 * |
|
40 * Represents suite. Evaluated from CHnMdSuite class, contains |
|
41 * all data from services and xml configuration. It is used to fill data |
|
42 * displayed on the screen. |
|
43 * |
|
44 * @lib hnpresentationmodel |
|
45 * @since S60 5.0 |
|
46 * @ingroup group_hnpresentationmodel |
|
47 */ |
|
48 NONSHARABLE_CLASS( CHnSuiteModel ) : public CBase |
|
49 { |
|
50 |
|
51 public: |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 * |
|
56 * @since S60 5.0 |
|
57 * @param aEventHandler Event handler. |
|
58 * @param aGenreName Suite genre identifier. |
|
59 */ |
|
60 IMPORT_C static CHnSuiteModel* NewL( CHnEventHandler& aEventHandler, |
|
61 const TDesC& aGenreName ); |
|
62 |
|
63 /** |
|
64 * Virtual Destructor. |
|
65 * |
|
66 * @since S60 5.0 |
|
67 */ |
|
68 IMPORT_C ~CHnSuiteModel(); |
|
69 |
|
70 /** |
|
71 * Return Suite's genre name. |
|
72 * Used for identifying the Suite. |
|
73 * |
|
74 * @since S60 v5.0 |
|
75 * @return The genre name. |
|
76 */ |
|
77 IMPORT_C const TDesC& SuiteName() const; |
|
78 |
|
79 /** |
|
80 * Return Suite's name |
|
81 * This should be displayed in Status Pane |
|
82 * |
|
83 * @since S60 v5.0 |
|
84 * @return the name |
|
85 */ |
|
86 IMPORT_C const TDesC& Title() const; |
|
87 |
|
88 /** |
|
89 * Sets the Suite's name |
|
90 * |
|
91 * @since S60 v5.0 |
|
92 * @param aName the name |
|
93 */ |
|
94 IMPORT_C void SetTitleL( const TDesC& aName ); |
|
95 |
|
96 /** |
|
97 * Return Suite's empty text |
|
98 * |
|
99 * @since S60 v5.0 |
|
100 * @return empty text if defined o |
|
101 */ |
|
102 IMPORT_C const TDesC& EmptyText() const; |
|
103 |
|
104 /** |
|
105 * Sets the Suite's empty text |
|
106 * |
|
107 * @since S60 v5.0 |
|
108 * @param aName the name |
|
109 */ |
|
110 IMPORT_C void SetEmptyTextL( const TDesC& aName ); |
|
111 |
|
112 /** |
|
113 * Notifies all of the observers. |
|
114 * |
|
115 * @since S60 v5.0 |
|
116 * @param aEventType Event to be pushed to all observers. |
|
117 */ |
|
118 IMPORT_C void NotifyObserversL( THnCustomSuiteEvent aEventType ); |
|
119 |
|
120 /** |
|
121 * Method used to indicate that item evaluation has finished. |
|
122 * |
|
123 * @since S60 v5.0 |
|
124 * @param aModelItemNumber Index of the item model. |
|
125 * @return True if observers were notified. |
|
126 */ |
|
127 IMPORT_C TBool ItemEvaluationFinishedL( TInt aModelItemNumber ); |
|
128 |
|
129 /** |
|
130 * Method used to indicate that item evaluation has finished. |
|
131 * |
|
132 * @since S60 v5.0 |
|
133 */ |
|
134 IMPORT_C TBool SuiteEvaluationFinishedL(); |
|
135 |
|
136 /** |
|
137 * Return Suite's Widget type |
|
138 * |
|
139 * @since S60 v5.0 |
|
140 * @return the Widget type or EUnspecified if not set |
|
141 */ |
|
142 IMPORT_C TInt WidgetType() const; |
|
143 |
|
144 /** |
|
145 * Sets the Suite's Widget type |
|
146 * Also sets the correct template to the Widget Model |
|
147 * |
|
148 * @since S60 v5.0 |
|
149 * @param aWidgetType Suite's Widget type |
|
150 */ |
|
151 IMPORT_C void SetWidgetType( THnSuiteWidgetType aWidgetType ); |
|
152 |
|
153 /** |
|
154 * Gets menu structure for certain model |
|
155 * |
|
156 * @since S60 v5.0 |
|
157 * @param aItemId Id of the item model |
|
158 * @return Pointer to menu model |
|
159 */ |
|
160 IMPORT_C MHnMenuItemModelIterator* GetMenuStructureL( TInt aItemId ); |
|
161 |
|
162 /** |
|
163 * Adds item both to Aakash model and Matrix model. |
|
164 * |
|
165 * @since S60 v5.0 |
|
166 * @param aItemModel Item model. |
|
167 * @param aId Item id |
|
168 * @param aItemModelNumber Index of data model that creates the item. |
|
169 * @param aItemModelPosition Position in the particular data model |
|
170 */ |
|
171 IMPORT_C void AddItemL( TInt aId, CHnItemModel* aItemModel, |
|
172 TInt aItemModelNumber, TInt aItemModelPosition ); |
|
173 |
|
174 /** |
|
175 * Updates item template with template from suite model. |
|
176 * |
|
177 * @since S60 v5.0 |
|
178 * @param aId Id of the item to update template |
|
179 */ |
|
180 IMPORT_C void UpdateItemTemplateL( TInt aId ); |
|
181 |
|
182 /** |
|
183 * Updates item in Aakash model. |
|
184 * |
|
185 * @since S60 v5.0 |
|
186 * @param aPreviousItemCount Previous number of items in the suite. |
|
187 */ |
|
188 IMPORT_C void RefreshMulModelL( TInt aPreviousItemCount = 0 ); |
|
189 |
|
190 /** |
|
191 * Sets template for suite. |
|
192 * |
|
193 * @since S60 v5.0 |
|
194 * @param aValue template of the suite |
|
195 */ |
|
196 IMPORT_C void SetTemplateL( const TDesC8& aValue ); |
|
197 |
|
198 /** |
|
199 * Gets template. |
|
200 * |
|
201 * @since S60 v5.0 |
|
202 * @return template of the suite |
|
203 */ |
|
204 IMPORT_C const TDesC8& GetTemplate() const; |
|
205 |
|
206 /** |
|
207 * Remove model by id both from Aakash model and Matrix model. |
|
208 * |
|
209 * @since S60 v5.0 |
|
210 * @param aId Id of the item to remove |
|
211 */ |
|
212 IMPORT_C void RemoveItemL( TInt aId ); |
|
213 |
|
214 /** |
|
215 * Removes all items from the suite model. |
|
216 * |
|
217 * @since S60 v5.0 |
|
218 */ |
|
219 IMPORT_C void RemoveAllItems(); |
|
220 |
|
221 /** |
|
222 * Gets item model id by its position in Aakash model. |
|
223 * |
|
224 * @since S60 v5.0 |
|
225 * @param aIndex Index of visual item in Aakash model |
|
226 * @return Id of the item model for input parameter |
|
227 */ |
|
228 IMPORT_C TInt IdByIndex( TInt aIndex ); |
|
229 |
|
230 /** |
|
231 * Gets item model count. |
|
232 * |
|
233 * @since S60 v5.0 |
|
234 * @return Count of item models. |
|
235 */ |
|
236 IMPORT_C TInt GetItemModelsCount(); |
|
237 |
|
238 /** |
|
239 * Gets actions models. |
|
240 * |
|
241 * @return List of all actions for every event. |
|
242 */ |
|
243 IMPORT_C RHashMap< TInt, CArrayPtr<CHnActionModel>* >& GetActions(); |
|
244 |
|
245 /** |
|
246 * Gets actions models. |
|
247 * |
|
248 * @param aId Event id |
|
249 * @return Array of actions models corresponding to event id |
|
250 */ |
|
251 IMPORT_C CArrayPtr<CHnActionModel>* GetActions( TInt aId ); |
|
252 |
|
253 /** |
|
254 * Gets item model. |
|
255 * |
|
256 * @param aId Item model id |
|
257 * @return Item model corresponding to id, if not found returns NULL |
|
258 */ |
|
259 IMPORT_C CHnItemModel* GetItemModel( TInt aId ); |
|
260 |
|
261 /** |
|
262 * Returns visibility of toolbar for suite |
|
263 * |
|
264 * @return TRUE if visible, otherwise FALSE |
|
265 */ |
|
266 IMPORT_C TBool HasToolbar() const; |
|
267 |
|
268 /** |
|
269 * Registers suite observer. |
|
270 * |
|
271 * @param aObserver observer |
|
272 * @param aPriority priority |
|
273 */ |
|
274 IMPORT_C void RegisterSuiteObserverL( MHnSuiteObserver* aObserver, |
|
275 TThreadPriority aPriority = EPriorityNormal); |
|
276 |
|
277 /** |
|
278 * Unregisters suite observer |
|
279 * |
|
280 * @param aObserver observer |
|
281 */ |
|
282 IMPORT_C void UnregisterSuiteObserver( MHnSuiteObserver* aObserver); |
|
283 |
|
284 /** |
|
285 * Checks if one of items between aIndexStart and |
|
286 * aIndexEnd is move-locked |
|
287 * |
|
288 * @param aIndexStart starting item |
|
289 * @param aIndexEnd ending item |
|
290 * @return true if one of the preceeding items is locked |
|
291 */ |
|
292 IMPORT_C TBool IsItemBetweenMoveLocked( TInt aIndexStart, |
|
293 TInt aIndexEnd ); |
|
294 |
|
295 /** |
|
296 * Handles event. |
|
297 * |
|
298 * @since S60 5.0 |
|
299 * @param aEventId Event id. |
|
300 * @param aRecipientId Recipient Id. |
|
301 * @param aEventParameters Parameters to event. |
|
302 * @return Status code. |
|
303 */ |
|
304 TInt OfferHnEventL( |
|
305 const TInt aEventId, const TInt aRecipientId, |
|
306 CLiwGenericParamList* aEventParameters ); |
|
307 |
|
308 /** |
|
309 * Reorders item. |
|
310 * |
|
311 * @param aFromIndex Index of the item to move. |
|
312 * @param aToIndex Index of the item to shift to. |
|
313 */ |
|
314 IMPORT_C TInt ReorderItemsL( TInt aFromIndex, TInt aToIndex ); |
|
315 |
|
316 /** |
|
317 * Returns items order object. |
|
318 * |
|
319 * @return items order object from suite model |
|
320 */ |
|
321 IMPORT_C CHnItemsOrder* GetItemsOrder(); |
|
322 |
|
323 public: |
|
324 |
|
325 /** |
|
326 * Returns true if an item is move locked. |
|
327 * |
|
328 * @param aIndex item's index |
|
329 * @return true if an item is move-locked otherwise false |
|
330 */ |
|
331 IMPORT_C TBool IsItemMoveLocked( TInt aIndex ); |
|
332 |
|
333 /** |
|
334 * Returns type of an item. |
|
335 * |
|
336 * @param aIndex an item's index |
|
337 * @return item's type |
|
338 */ |
|
339 IMPORT_C TMcsItemType GetItemType( TInt aIndex ); |
|
340 |
|
341 /** |
|
342 * Returns highlighted item's id. |
|
343 * |
|
344 * @since S60 v5.0 |
|
345 * @return highlighted item's id |
|
346 */ |
|
347 IMPORT_C TInt GetSuiteHighlight(); |
|
348 |
|
349 /** |
|
350 * Set highlighted item's id. |
|
351 * |
|
352 * @since S60 v5.0 |
|
353 * @param aHighLight sets highlighted item's id |
|
354 */ |
|
355 IMPORT_C void SetSuiteHighlightL( TInt aHighLight ); |
|
356 |
|
357 /** |
|
358 * Add items index to focus queue. Item will be highlighted/focused |
|
359 * during evaluation. |
|
360 * |
|
361 * @since S60 v5.0 |
|
362 * @param aCustomId Custom Id of an item which will be highlighted |
|
363 */ |
|
364 IMPORT_C void QueueFocus( TInt aCustomId ); |
|
365 |
|
366 /** |
|
367 * Sets suite's custom id. |
|
368 * |
|
369 * @since S60 v5.0 |
|
370 * @param aCustomId Custom identifier to be set. |
|
371 */ |
|
372 IMPORT_C void SetCustomId( TInt64 aCustomId ); |
|
373 |
|
374 /** |
|
375 * Returns custom identifier of the suite. |
|
376 * |
|
377 * @since S60 v5.0 |
|
378 * @return Custom identifier of the suite. |
|
379 */ |
|
380 IMPORT_C TInt64 CustomId(); |
|
381 |
|
382 /** |
|
383 * Activates highlight handling. |
|
384 * Used for highlight events for items. |
|
385 * |
|
386 * @since S60 v5.0 |
|
387 * @param aActive ETrue if active. |
|
388 */ |
|
389 IMPORT_C void SetActiveL( TBool aActive ); |
|
390 |
|
391 /** |
|
392 * Returns the state of the suite. |
|
393 * |
|
394 * @since S60 v5.0 |
|
395 * @return ETrue if active. |
|
396 */ |
|
397 IMPORT_C TBool IsActive(); |
|
398 |
|
399 /** |
|
400 * Notifies the model that the suite is visible. |
|
401 * Used for highlight events for items. |
|
402 * |
|
403 * @since S60 v5.0 |
|
404 * @param aVisible ETrue if visible. |
|
405 */ |
|
406 IMPORT_C void SetVisibleL( TBool aVisible ); |
|
407 |
|
408 /** |
|
409 * Returns item model matching given criteria. |
|
410 * |
|
411 * @param aCustomId Item's custom id. |
|
412 * @param aIndex |
|
413 * @return Item model matching given custom_id, otherwise null. |
|
414 */ |
|
415 IMPORT_C CHnItemModel* GetMatchingItemModelL( TInt64 aCustomId, TInt& aIndex ); |
|
416 |
|
417 /** |
|
418 * Returns the suite's exit mode flag. |
|
419 */ |
|
420 IMPORT_C TExitMode ExitMode(); |
|
421 |
|
422 /** |
|
423 * Sets the exid mode. |
|
424 */ |
|
425 IMPORT_C void SetExitMode( TExitMode aExitMode ); |
|
426 |
|
427 /** |
|
428 * Removes all LIW objects owned by this object. |
|
429 * |
|
430 * LIW objects owned by non-LIW objects that are owned by |
|
431 * this object are also removed. |
|
432 * @since S60 5.0 |
|
433 */ |
|
434 void RemoveLiwObjects(); |
|
435 |
|
436 private: |
|
437 |
|
438 /** |
|
439 * Struct holding highlight information. |
|
440 * iWidgetIndex - index of the visible item in the UI widget. |
|
441 * iItemId - presentation model ID of the item. |
|
442 * iCustomId - custom ID from data provider. |
|
443 * |
|
444 * @since S60 v5.0 |
|
445 */ |
|
446 struct TSuiteHighlight |
|
447 { |
|
448 /** Widget index. */ |
|
449 TInt iWidgetIndex; |
|
450 /** Item Id. */ |
|
451 TInt iItemId; |
|
452 /** Custom Id. */ |
|
453 TInt64 iCustomId; |
|
454 }; |
|
455 |
|
456 /** |
|
457 * C++ default constructor. |
|
458 * |
|
459 * @since S60 v5.0 |
|
460 * @param aEventHandler Event handler. |
|
461 */ |
|
462 CHnSuiteModel( CHnEventHandler& aEventHandler ); |
|
463 |
|
464 /** |
|
465 * Standard symbian 2nd phase constructor. |
|
466 * |
|
467 * @since S60 v5.0 |
|
468 * @param aGenreName Genre name for model |
|
469 */ |
|
470 void ConstructL( const TDesC& aGenreName ); |
|
471 |
|
472 /** |
|
473 * Launches the appropriate action if allowed. |
|
474 * Used for highlight events for items. |
|
475 * |
|
476 * @since S60 v5.0 |
|
477 * @param aItemId ID of the item. |
|
478 * @param aFocused ETrue if focused. |
|
479 */ |
|
480 void HandleItemFocusL( TInt aItemId, TBool aFocused ); |
|
481 |
|
482 /** |
|
483 * Set highlight on item. |
|
484 * |
|
485 * @since S60 v5.0 |
|
486 * @param aCustomId Custom id of the item. |
|
487 */ |
|
488 void SetSuiteHighlightByCustomIdL( TInt64 aCustomId ); |
|
489 |
|
490 private: |
|
491 |
|
492 /** |
|
493 * Genre name. |
|
494 * Own. |
|
495 */ |
|
496 HBufC* iSuiteName; |
|
497 |
|
498 /** |
|
499 * Suite name. |
|
500 * Own. |
|
501 */ |
|
502 HBufC* iTitle; |
|
503 |
|
504 /** |
|
505 * Suite empty text |
|
506 * Own. |
|
507 */ |
|
508 HBufC* iEmptyText; |
|
509 |
|
510 /** |
|
511 * Suite Widget type |
|
512 */ |
|
513 THnSuiteWidgetType iWidgetType; |
|
514 |
|
515 /** |
|
516 * Template. |
|
517 */ |
|
518 RBuf8 iTemplate; |
|
519 |
|
520 /** |
|
521 * Holds models evaluated from CHnMdItem objects |
|
522 */ |
|
523 RHashMap< TInt, CHnItemModel* > iItemsModels; |
|
524 |
|
525 /** |
|
526 * Holds positions of item ids and suite id. |
|
527 * Own. |
|
528 */ |
|
529 CHnItemsOrder* iItemsOrder; |
|
530 |
|
531 /** |
|
532 * Actions corresponding to events |
|
533 * event id <=> array of actions models |
|
534 */ |
|
535 RHashMap< TInt, CArrayPtr<CHnActionModel>* > iActions; |
|
536 |
|
537 /** |
|
538 * Id of "empty" item |
|
539 */ |
|
540 TInt iEmptyItemId; |
|
541 |
|
542 /** |
|
543 * Suite observers. |
|
544 * Not own. |
|
545 */ |
|
546 RPointerArray<MHnSuiteObserver> iSuiteObservers; |
|
547 |
|
548 /** |
|
549 * Observer priorities array. |
|
550 */ |
|
551 RArray<TThreadPriority> iObserverPriorities; |
|
552 |
|
553 /** |
|
554 * Stores IDs of currently higlighted item. |
|
555 */ |
|
556 TSuiteHighlight iSuiteHighlight; |
|
557 |
|
558 /** |
|
559 * Focus queue. |
|
560 */ |
|
561 TInt iFocusQueue; |
|
562 |
|
563 /** |
|
564 * Custom id. |
|
565 */ |
|
566 TInt64 iCustomId; |
|
567 |
|
568 /** |
|
569 * Event Handler from Suite Container. |
|
570 * Used for executing item focused/unfocused events. |
|
571 * |
|
572 * Not Own. |
|
573 */ |
|
574 CHnEventHandler& iEventHandler; |
|
575 |
|
576 /** |
|
577 * Indicates if the suite is active. |
|
578 * Used for handling highlight events for items. |
|
579 */ |
|
580 TBool iIsActive; |
|
581 |
|
582 /** |
|
583 * Indicates if the suite is visible. |
|
584 * Used for handling highlight events for items. |
|
585 */ |
|
586 TBool iIsVisible; |
|
587 |
|
588 /** |
|
589 * Exit mode. |
|
590 */ |
|
591 TExitMode iExitMode; |
|
592 /** |
|
593 * Active Focus Handler. |
|
594 */ |
|
595 CHnItemFocusHandler* iItemFocusHandler; |
|
596 }; |
|
597 |
|
598 #endif // C_HNSUITEMODEL_H |
|