|
1 /* |
|
2 * Copyright (c) 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 the License "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: UI level handler for category data.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VCXHGMYVIDEOSCATEGORYMODELHANDLER_H |
|
21 #define VCXHGMYVIDEOSCATEGORYMODELHANDLER_H |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "vcxhgmyvideoscategorymodelobserver.h" |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CMPXMedia; |
|
28 class CVcxHgMyVideosModel; |
|
29 class CHgScroller; |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * UI level handler for category data. |
|
35 * |
|
36 * @lib vcxhgmyvideos.lib |
|
37 */ |
|
38 NONSHARABLE_CLASS( CVcxHgMyVideosCategoryModelHandler ) : |
|
39 public CBase, |
|
40 public MVcxHgMyVideosCategoryModelObserver |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Default constructor |
|
46 * |
|
47 * @param aModel Application model |
|
48 * @param aScroller Hg list component. |
|
49 */ |
|
50 CVcxHgMyVideosCategoryModelHandler( |
|
51 CVcxHgMyVideosModel& aModel, |
|
52 CHgScroller& aScroller ); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CVcxHgMyVideosCategoryModelHandler(); |
|
58 |
|
59 /** |
|
60 * Activates category model. |
|
61 */ |
|
62 void DoModelActivateL(); |
|
63 |
|
64 /** |
|
65 * Deactivates category model. |
|
66 */ |
|
67 void DoModelDeactivate(); |
|
68 |
|
69 /** |
|
70 * Makes sure model has correct category list. |
|
71 */ |
|
72 void GetCategoryListL(); |
|
73 |
|
74 /** |
|
75 * Gets list highlight. |
|
76 * |
|
77 * @return Highlight. |
|
78 */ |
|
79 TInt Highlight(); |
|
80 |
|
81 /** |
|
82 * Returns category index corresponding the Ganes index. |
|
83 * |
|
84 * @param Ganes scroller list index |
|
85 * @return Index of category |
|
86 */ |
|
87 TInt ResolveCategoryId( TInt aScrollerIndex ); |
|
88 |
|
89 public: // From MVcxHgMyVideosCategoryModelObserver |
|
90 |
|
91 /** |
|
92 * Called when a list of categories is available. |
|
93 * Ownership of array is transferred. |
|
94 * |
|
95 * @param aCategoryList List of categories |
|
96 */ |
|
97 void NewCategoryListL( CMPXMediaArray* aCategoryList ); |
|
98 |
|
99 /** |
|
100 * Called when the list of categories has been modified. |
|
101 */ |
|
102 void CategoryListModifiedL(); |
|
103 |
|
104 /** |
|
105 * Called when a single category has been modified (add/remove/modify). |
|
106 * |
|
107 * @param aEventType Type of modification event (add/remove/modify). |
|
108 * @param aMpxItemId MPX Item Id of the modified item. |
|
109 */ |
|
110 void CategoryModifiedL( TMPXChangeEventType aEventType, |
|
111 TMPXItemId& aMpxItemId ); |
|
112 |
|
113 private: |
|
114 |
|
115 /** |
|
116 * Loads name of category from resources. |
|
117 * |
|
118 * @param aIndex Index of category. |
|
119 * @return Name of category. |
|
120 */ |
|
121 HBufC* GetCategoryNameLC( TInt aIndex ); |
|
122 |
|
123 /** |
|
124 * Formats second row text for categories. |
|
125 * |
|
126 * @param aMedia MPX media object for row. |
|
127 * @return Second row text for category. |
|
128 */ |
|
129 HBufC* FormatCategorySecondRowLC( CMPXMedia& aMedia ); |
|
130 |
|
131 /** |
|
132 * Translates MPX Item Id to index on UI list. |
|
133 * |
|
134 * @param aMpxItemId MPX Item Id. |
|
135 * @return Index on UI, or KErrNotFound. |
|
136 */ |
|
137 TInt UiIndexFromMpxItemId( TMPXItemId& aMpxItemId ); |
|
138 |
|
139 /** |
|
140 * Updates the whole category list. |
|
141 */ |
|
142 void UpdateCategoryListL(); |
|
143 |
|
144 /** |
|
145 * Updates list item from specified index. |
|
146 * |
|
147 * @param aListIndex Item's index on UI list. |
|
148 */ |
|
149 void UpdateCategoryListItemL( TInt aListIndex ); |
|
150 |
|
151 /** |
|
152 * Removes list item from specefied index. |
|
153 * |
|
154 * @param aListIndex Item's index on UI list. |
|
155 */ |
|
156 void RemoveCategoryListItem( TInt aListIndex ); |
|
157 |
|
158 /** |
|
159 * Goes through given number of categories and |
|
160 * fills iCategoryIdArray from the accepted ones |
|
161 * |
|
162 * @param aCategoriesAvailable Number of categories |
|
163 */ |
|
164 void MakeCategoryIdArray( TInt aCategoriesAvailable ); |
|
165 |
|
166 /** |
|
167 * Checks if the given category is accepted or not. |
|
168 * |
|
169 * @param aCategoryId category id |
|
170 * @return TBool if accepted |
|
171 */ |
|
172 TBool AcceptCategory( TInt aCategoryId ); |
|
173 |
|
174 /** |
|
175 * Finds correct array index for given category id |
|
176 * from iCategoryIdAraay |
|
177 * |
|
178 * @param aCategoryId category id to be found |
|
179 * @return Array index |
|
180 */ |
|
181 TInt ResolveCategoryArrayIndexById( TInt aCategoryId ); |
|
182 |
|
183 private: |
|
184 |
|
185 /** |
|
186 * Application model. |
|
187 * Not own. |
|
188 */ |
|
189 CVcxHgMyVideosModel& iModel; |
|
190 |
|
191 /** |
|
192 * Reference to Hg list component. |
|
193 * Not own. |
|
194 */ |
|
195 CHgScroller& iScroller; |
|
196 |
|
197 /** |
|
198 * Array of categories. |
|
199 * Own. |
|
200 */ |
|
201 CMPXMediaArray* iCategoryList; |
|
202 |
|
203 /** |
|
204 * TArray containing category ID's. Each index |
|
205 * corresponds to the scroller list (eg. correct |
|
206 * category ID for the 1st item in scroller list can |
|
207 * be found from index 0). |
|
208 */ |
|
209 RArray<TInt> iCategoryIdArray; |
|
210 }; |
|
211 |
|
212 #endif // VCXHGMYVIDEOSCATEGORYMODELHANDLER_H |