|
1 /* |
|
2 * Copyright (c) 2008-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: Show commmand handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "glxcommandhandlerfilterimagesorvideos.h" |
|
22 |
|
23 #include <eikmenup.h> |
|
24 |
|
25 #include <glxcommandhandlers.hrh> |
|
26 #include <glxtracer.h> |
|
27 #include <glxuiutility.h> |
|
28 #include <mglxmedialist.h> |
|
29 #include <mglxmedialistprovider.h> |
|
30 #include <glxfilterfactory.h> |
|
31 #include <bldvariant.hrh> // for feature flags |
|
32 |
|
33 /** |
|
34 * @internal reviewed 08/02/2008 by Rhodri Byles |
|
35 */ |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // C++ default constructor. Inlined to save a bit of rom, note that for inline |
|
39 // it needs to be before its use in NewL |
|
40 // --------------------------------------------------------------------------- |
|
41 inline |
|
42 CGlxCommandHandlerFilterImagesOrVideos::CGlxCommandHandlerFilterImagesOrVideos( |
|
43 MGlxMediaListProvider* aMediaListProvider, |
|
44 CGlxUiUtility& aUiUtility ) |
|
45 : CGlxMediaListCommandHandler( aMediaListProvider ), |
|
46 iUiUtility( aUiUtility ) |
|
47 { |
|
48 // No implentation |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // Two-phased constructor. |
|
53 // --------------------------------------------------------------------------- |
|
54 EXPORT_C CGlxCommandHandlerFilterImagesOrVideos* |
|
55 CGlxCommandHandlerFilterImagesOrVideos::NewL( |
|
56 MGlxMediaListProvider* aMediaListProvider ) |
|
57 { |
|
58 // get Hui utility, if it fails we leave the whole construction |
|
59 CGlxUiUtility* utility = CGlxUiUtility::UtilityL(); |
|
60 // put utility to cleanupstack in case allocating self fails |
|
61 CleanupClosePushL( *utility ); |
|
62 // we have HUI utility so create the class next, give the |
|
63 // dereferenced hui utility for it so self takes ownership |
|
64 CGlxCommandHandlerFilterImagesOrVideos* self = |
|
65 new( ELeave ) CGlxCommandHandlerFilterImagesOrVideos( |
|
66 aMediaListProvider, |
|
67 *utility ); |
|
68 // take utility out of stack as ownership transferred to this class |
|
69 CleanupStack::PopAndDestroy( utility ); |
|
70 // perform 2nd phase |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 CleanupStack::Pop( self ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // Destructor |
|
79 // --------------------------------------------------------------------------- |
|
80 EXPORT_C CGlxCommandHandlerFilterImagesOrVideos::~CGlxCommandHandlerFilterImagesOrVideos() |
|
81 { |
|
82 TRACER("CGlxCommandHandlerFilterImagesOrVideos::~CGlxCommandHandlerFilterImagesOrVideos"); |
|
83 // remember to close the instance of huiutility |
|
84 iUiUtility.Close(); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // ConstructL |
|
89 // ----------------------------------------------------------------------------- |
|
90 void CGlxCommandHandlerFilterImagesOrVideos::ConstructL() |
|
91 { |
|
92 // create the commands |
|
93 TCommandInfo info( EGlxCmdShowAll ); |
|
94 // show only in Grid view |
|
95 info.iViewingState = TCommandInfo::EViewingStateBrowse; |
|
96 // Enable for any item count |
|
97 info.iMinSelectionLength = 0; |
|
98 AddCommandL( info ); |
|
99 |
|
100 info.iCommandId = EGlxCmdShowImages; |
|
101 AddCommandL( info ); |
|
102 |
|
103 info.iCommandId = EGlxCmdShowVideos; |
|
104 AddCommandL( info ); |
|
105 |
|
106 info.iCommandId = EGlxCmdShow; |
|
107 AddCommandL( info ); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // DynInitMenuPaneL |
|
112 // ----------------------------------------------------------------------------- |
|
113 void CGlxCommandHandlerFilterImagesOrVideos::DynInitMenuPaneL( |
|
114 TInt /*aResourceId*/, CEikMenuPane* aMenuPane ) |
|
115 { |
|
116 if( iInFullScreen ) |
|
117 { |
|
118 // We are is Full screen so dim/hide the "Show" menu |
|
119 // this dims/hides the cascade as well |
|
120 if( aMenuPane ) |
|
121 { |
|
122 TInt pos; |
|
123 if ( aMenuPane->MenuItemExists( EGlxCmdShow, pos ) ) |
|
124 { |
|
125 aMenuPane->SetItemDimmed( EGlxCmdShow, ETrue ); |
|
126 } |
|
127 } |
|
128 } |
|
129 else |
|
130 { |
|
131 // We are in the Grid View so Filter out the menu options accordingly |
|
132 |
|
133 // Get the orginal filter used by the media list |
|
134 CMPXFilter* orgFilter = MediaList().Filter(); |
|
135 TGlxFilterItemType currentItemType = EGlxFilterVideoAndImages; |
|
136 |
|
137 // If a filter is used get the current itemtype |
|
138 // If no filter is used the everything is displayed which is the same |
|
139 // as EGlxFilterVideoAndImages |
|
140 if( orgFilter ) |
|
141 { |
|
142 if( orgFilter->IsSupported( KGlxFilterGeneralItemType ) ) |
|
143 { |
|
144 currentItemType = *(orgFilter->Value<TGlxFilterItemType>( |
|
145 KGlxFilterGeneralItemType ) ); |
|
146 } |
|
147 } |
|
148 // This will contain the Id of the command to dim/hide |
|
149 TInt commandIdToDim = 0; |
|
150 switch( currentItemType ) |
|
151 { |
|
152 case EGlxFilterVideoAndImages: |
|
153 { |
|
154 // As the current filter type is EGlxFilterVideoAndImages we |
|
155 // should remove the "All" option from the menu |
|
156 commandIdToDim = EGlxCmdShowAll; |
|
157 break; |
|
158 } |
|
159 case EGlxFilterImage: |
|
160 { |
|
161 // As the current filter type is EGlxFilterImage we |
|
162 // should remove the "Images" option from the menu |
|
163 commandIdToDim = EGlxCmdShowImages; |
|
164 break; |
|
165 } |
|
166 case EGlxFilterVideo: |
|
167 { |
|
168 // As the current filter type is EGlxFilterVideo we |
|
169 // should remove the "Videos" option from the menu |
|
170 commandIdToDim = EGlxCmdShowVideos; |
|
171 break; |
|
172 } |
|
173 default: |
|
174 { |
|
175 // This case does not happen in real life. |
|
176 // If it does then all three options get displayed on the menu |
|
177 break; |
|
178 } |
|
179 } |
|
180 |
|
181 // Now dim/hide the required menu option |
|
182 if (commandIdToDim && aMenuPane) |
|
183 { |
|
184 TInt pos; |
|
185 if ( aMenuPane->MenuItemExists(commandIdToDim, pos) ) |
|
186 { |
|
187 aMenuPane->SetItemDimmed(commandIdToDim, ETrue); |
|
188 } |
|
189 } |
|
190 } |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // DoActivateL |
|
195 // ----------------------------------------------------------------------------- |
|
196 void CGlxCommandHandlerFilterImagesOrVideos::DoActivateL( TInt /*aViewId*/ ) |
|
197 { |
|
198 // If the Direction is forwards then we have come from the list view |
|
199 // In which case we make sure the filter is displaying both Images and Videos |
|
200 TGlxNavigationDirection navDir = iUiUtility.ViewNavigationDirection(); |
|
201 if( EGlxNavigationForwards == navDir ) |
|
202 { |
|
203 SetItemTypeInMediaListL( EGlxFilterVideoAndImages ); |
|
204 } |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // ExecuteL |
|
209 // ----------------------------------------------------------------------------- |
|
210 TBool CGlxCommandHandlerFilterImagesOrVideos::DoExecuteL( |
|
211 TInt aCommandId, MGlxMediaList& /*aList*/ ) |
|
212 { |
|
213 TRACER("CGlxCommandHandlerFilterImagesOrVideos::ExecuteL"); |
|
214 |
|
215 TBool consume = EFalse; |
|
216 // Create an Item Type and set it to something invalid (within this context) |
|
217 TGlxFilterItemType itemType = EGlxFilterMediaTypeSuppliedInFilter; |
|
218 |
|
219 switch( aCommandId ) |
|
220 { |
|
221 case EGlxCmdShowAll: |
|
222 { |
|
223 // Set ItemType to Display All |
|
224 itemType = EGlxFilterVideoAndImages; |
|
225 consume = ETrue; |
|
226 break; |
|
227 } |
|
228 case EGlxCmdShowImages: |
|
229 { |
|
230 // Set ItemType to Display Images |
|
231 itemType = EGlxFilterImage; |
|
232 consume = ETrue; |
|
233 break; |
|
234 } |
|
235 case EGlxCmdShowVideos: |
|
236 { |
|
237 // Set ItemType to Display Videos |
|
238 itemType = EGlxFilterVideo; |
|
239 consume = ETrue; |
|
240 break; |
|
241 } |
|
242 case EGlxCmdStateView: |
|
243 { |
|
244 // We are now in Full Screen mode |
|
245 iInFullScreen = ETrue; |
|
246 consume = ETrue; |
|
247 break; |
|
248 } |
|
249 case EGlxCmdStateBrowse: |
|
250 { |
|
251 // We are now in the Grid view |
|
252 iInFullScreen = EFalse; |
|
253 consume = ETrue; |
|
254 break; |
|
255 } |
|
256 default: // No need to do anything |
|
257 { |
|
258 break; |
|
259 } |
|
260 } |
|
261 |
|
262 // Has the item type been set |
|
263 if( EGlxFilterMediaTypeSuppliedInFilter != itemType ) |
|
264 { |
|
265 // Inform media list of ItemType change |
|
266 SetItemTypeInMediaListL( itemType ); |
|
267 } |
|
268 |
|
269 return consume; |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // SetItemTypeInMediaListL |
|
274 // ----------------------------------------------------------------------------- |
|
275 void CGlxCommandHandlerFilterImagesOrVideos::SetItemTypeInMediaListL( |
|
276 TGlxFilterItemType aItemType) |
|
277 { |
|
278 CMPXFilter* currentFilter = MediaList().Filter(); |
|
279 if( currentFilter ) |
|
280 { |
|
281 // Examine the item type used |
|
282 if( currentFilter->IsSupported( KGlxFilterGeneralItemType ) ) |
|
283 { |
|
284 TGlxFilterItemType itemType = EGlxFilterVideoAndImages; |
|
285 itemType = *(currentFilter->Value<TGlxFilterItemType>( |
|
286 KGlxFilterGeneralItemType)); |
|
287 |
|
288 // Is the itemType already set to what we want. |
|
289 if( aItemType != itemType ) |
|
290 { |
|
291 // No it's not so change it. |
|
292 // Create a TGlxFilterProperties with the correct itemType |
|
293 TGlxFilterProperties filterProperties; |
|
294 filterProperties.iItemType = aItemType; |
|
295 |
|
296 // Create a Filter based on the current filter but with the |
|
297 // new itemType |
|
298 CMPXFilter* newFilter = TGlxFilterFactory::CreateCombinedFilterL( |
|
299 filterProperties, |
|
300 currentFilter, |
|
301 ETrue); |
|
302 CleanupStack::PushL(newFilter); |
|
303 |
|
304 // Set this filter in the media list |
|
305 MediaList().SetFilterL( newFilter ); |
|
306 CleanupStack::PopAndDestroy( newFilter ); |
|
307 } |
|
308 } |
|
309 } |
|
310 else |
|
311 { |
|
312 // There is no filter set. So everything is displayed |
|
313 // Check if this is what we want. |
|
314 // If no filter is set and we need to display everything then there is |
|
315 // no need to do anything. |
|
316 if( EGlxFilterVideoAndImages != aItemType ) |
|
317 { |
|
318 // We do not want all so change it. |
|
319 // Create a TGlxFilterProperties with the correct itemType |
|
320 TGlxFilterProperties filterProperties; |
|
321 filterProperties.iItemType = aItemType; |
|
322 |
|
323 // Create a Filter with the new itemType |
|
324 CMPXFilter* newFilter = |
|
325 TGlxFilterFactory::CreateCombinedFilterL( filterProperties ); |
|
326 CleanupStack::PushL( newFilter ); |
|
327 |
|
328 // Set this filter in the media list |
|
329 MediaList().SetFilterL( newFilter ); |
|
330 CleanupStack::PopAndDestroy( newFilter ); |
|
331 } |
|
332 } |
|
333 } |
|
334 |
|
335 |
|
336 //End of file |