|
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: Selection popup |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __GLXMEDIASELECTIONPOPUP_H__ |
|
22 #define __GLXMEDIASELECTIONPOPUP_H__ |
|
23 |
|
24 // INCLUDE FILES |
|
25 |
|
26 #include <aknlists.h> |
|
27 #include <aknPopup.h> |
|
28 #include <bamdesca.h> |
|
29 #include <e32std.h> |
|
30 #include <eiklbx.h> |
|
31 #include <glxmediaid.h> |
|
32 #include <glxmedialistiterator.h> |
|
33 #include <mglxmedialist.h> |
|
34 #include <mglxmedialistobserver.h> |
|
35 #include <mglxmedialistprovider.h> |
|
36 #include <mpxcollectionobserver.h> |
|
37 #include <mpxcollectionpath.h> |
|
38 #include <mpxcollectionutility.h> |
|
39 #include <mpxmedia.h> |
|
40 #include <mpxmediaarray.h> |
|
41 |
|
42 // FORWARD DECLARATION |
|
43 class CAknPopupList; |
|
44 class CAknSinglePopupMenuStyleListBox; |
|
45 class CGlxAttributeContext; |
|
46 class CGlxMediaSelectionItem; |
|
47 class CGlxNewMediaPopup; |
|
48 class CGlxStaticMediaList; |
|
49 |
|
50 const TInt KMaxTitleStringLength = 80; |
|
51 |
|
52 /** |
|
53 * CGlxMediaListAdaptor |
|
54 * |
|
55 * Allows the titles in a media list |
|
56 * to be accessed via the MDesCArray interface. |
|
57 * The array elements are formatted for use by |
|
58 * a CAknSingleGraphicPopupMenuStyleListBox. |
|
59 * i.e. "<n>\t Camera Album" where <n> is the index of |
|
60 * an icon in the icon array. |
|
61 * |
|
62 * @internal reviewed 06/06/2007 by Dave Schofield |
|
63 */ |
|
64 NONSHARABLE_CLASS( CGlxMediaListAdaptor ) |
|
65 : public CBase, public MDesCArray |
|
66 { |
|
67 public: |
|
68 /** |
|
69 * Constructor |
|
70 * @param aMediaList a static media list |
|
71 * @param aMultiSelection set multi selection icon indices. |
|
72 */ |
|
73 IMPORT_C CGlxMediaListAdaptor(const MGlxMediaList* aMediaList, TBool aMultiSelection); |
|
74 |
|
75 /** |
|
76 * Enabled / Disable the CGlxMediaListAdaptor |
|
77 * if the adaptor is disabled, MdcaCount() will return 0 |
|
78 * even if there are items in the media list. |
|
79 * @param aEnabled ETrue to enable EFalse to disable. |
|
80 **/ |
|
81 void SetEnabled(TBool aEnabled); |
|
82 |
|
83 /** |
|
84 * Returns a pointer to the media list. |
|
85 */ |
|
86 const MGlxMediaList* MediaList(); |
|
87 |
|
88 /** |
|
89 * Returns ETrue if multi selection is |
|
90 * enabled else EFalse. |
|
91 */ |
|
92 TBool MultiSelectionEnabled(); |
|
93 |
|
94 public: // from MDesCArray |
|
95 /** See @ref MDesCArray::MdcaCount */ |
|
96 IMPORT_C TInt MdcaCount() const; |
|
97 /** See @ref MDesCArray::MdcaPoint */ |
|
98 IMPORT_C TPtrC MdcaPoint(TInt aIndex) const; |
|
99 |
|
100 private: |
|
101 const MGlxMediaList* iMediaList; // not owned |
|
102 |
|
103 /** |
|
104 * A temporary buffer to store the current title string |
|
105 */ |
|
106 mutable TBuf<KMaxTitleStringLength> iCurrentTitleString; |
|
107 |
|
108 /** |
|
109 * ETrue if multi selection is enabled else EFalse |
|
110 */ |
|
111 TBool iMultiSelection; |
|
112 |
|
113 /** |
|
114 * If ETrue, MdcaCount() returns the number of items in |
|
115 * the media list (iMediaList). If EFasle MdcaCount() |
|
116 * returns 0. |
|
117 */ |
|
118 TBool iEnabled; |
|
119 }; |
|
120 |
|
121 /** |
|
122 * CGlxSingleGraphicPopupMenuStyleListBox |
|
123 * |
|
124 * Adds behaviour to CAknSingleGraphicPopupMenuStyleListBox: |
|
125 * If the currently selected item has a TMPXGeneralCateroy |
|
126 * equal to EMPXCommand, item selection will be disabled; Pressing |
|
127 * the OK key will result in the item being actioned. |
|
128 * |
|
129 * This is achieved by disabling multiple selection if the OK is |
|
130 * pressed when the currently selected item has TMPXGeneralCateroy equal |
|
131 * to EMPXCommand. |
|
132 * |
|
133 * @internal reviewed 06/06/2007 by Dave Schofield |
|
134 */ |
|
135 NONSHARABLE_CLASS( CGlxSingleGraphicPopupMenuStyleListBox ) |
|
136 : public CAknSingleGraphicPopupMenuStyleListBox, |
|
137 public MEikListBoxObserver |
|
138 { |
|
139 public: // new |
|
140 /** |
|
141 * Determines if a particular item is visible. |
|
142 * @param aItemIndex index of the item |
|
143 * @return ETrue if the item is visible, else EFalse |
|
144 */ |
|
145 TBool IsVisible(TInt aItemIndex); |
|
146 |
|
147 /** |
|
148 * Populates iPopupList with the parameter passed. |
|
149 * @param aPopupList Pointer to CAknPopupList object |
|
150 */ |
|
151 void SetPopupList(CAknPopupList* aPopupList); |
|
152 |
|
153 public: // from CCoeControl |
|
154 /** See @ref CCoeControl::OfferKeyEventL */ |
|
155 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
156 //From MEikListBoxObserver |
|
157 void HandleListBoxEventL (CEikListBox *aListBox, TListBoxEvent aEventType) ; |
|
158 void HandlePointerEventL(const TPointerEvent& aPointerEvent) ; |
|
159 |
|
160 private: |
|
161 |
|
162 /** |
|
163 * The popup list. (Owned) |
|
164 */ |
|
165 CAknPopupList* iPopupList; |
|
166 |
|
167 }; |
|
168 |
|
169 /** |
|
170 * CGlxMediaSelectionPopup |
|
171 * |
|
172 * Generic Selection popup class definition. Shows a popup from user |
|
173 * can select a media object, or to create a new one. Retrieves |
|
174 * popup title and "new item" text from collection plugin, |
|
175 * to avoid need for client to configure the class. |
|
176 * |
|
177 * @image html glx_command_media_selection_popup_class_diagram.png |
|
178 * @image rtf glx_command_media_selection_popup_class_diagram.png |
|
179 * |
|
180 * The media selection popup uses CGlxCommandHandlerNewMedia to create |
|
181 * a new media object |
|
182 * |
|
183 * @image html glx_command_select_media_sequence_diagram.png |
|
184 * @image rtf glx_command_select_media_sequence_diagram.png |
|
185 * |
|
186 * @lib glxcommoncommandhandlers.lib |
|
187 * |
|
188 * @internal reviewed 06/06/2007 by Dave Schofield |
|
189 */ |
|
190 NONSHARABLE_CLASS(CGlxMediaSelectionPopup) |
|
191 : public CActive , |
|
192 public MGlxMediaListObserver, |
|
193 public MListBoxItemChangeObserver, |
|
194 public MGlxMediaListProvider |
|
195 { |
|
196 public: |
|
197 IMPORT_C CGlxMediaSelectionPopup(); |
|
198 |
|
199 /** |
|
200 * Execute the popup. |
|
201 * The L in the method name indicates the function might leave. |
|
202 * The D in the method name indicates that the method will destroy the object it is called on. i.e |
|
203 * delete the this pointer. |
|
204 * @param aPath a path containing the UID of the collection to select items from. |
|
205 * @param aAccepted will be set to ETrue if OK was pressed on the dialog else EFalse. |
|
206 * @param aMultiSelection Create a multi selection dialog. |
|
207 * @param aEnableContainerCreation Enable container creation. |
|
208 * @param aFilter Filter items displayed by the popup. |
|
209 * @return if aAccepted is ETrue: A CMPXCollectionPath containing the selection |
|
210 * (the caller takes ownership of this object). |
|
211 * if aAccepted is EFalse: NULL |
|
212 **/ |
|
213 IMPORT_C CMPXCollectionPath* ExecuteLD(CMPXCollectionPath& aPath, |
|
214 TBool& aAccepted, |
|
215 TBool aMultiSelection, |
|
216 TBool aEnableContainerCreation, |
|
217 CMPXFilter* aFilter = NULL); |
|
218 private: |
|
219 /** |
|
220 * Destructor |
|
221 */ |
|
222 ~CGlxMediaSelectionPopup(); |
|
223 |
|
224 public: // from CActive |
|
225 /** See @ref CActive::RunL */ |
|
226 void RunL(); |
|
227 /** See @ref CActive::DoCancel */ |
|
228 void DoCancel(); |
|
229 |
|
230 private: // from MListBoxItemChangeObserver |
|
231 /** see @ref MListBoxItemChangeObserverL::ListBoxItemsChanged **/ |
|
232 void ListBoxItemsChanged(CEikListBox* aListBox); |
|
233 |
|
234 private: // from MGlxMediaListObserver |
|
235 /** see @ref MGlxMediaListObserver::HandleItemAddedL **/ |
|
236 void HandleItemAddedL( TInt aStartIndex, TInt aEndIndex, |
|
237 MGlxMediaList* aList ); |
|
238 |
|
239 /** see @ref MGlxMediaListObserver::HandleMediaL **/ |
|
240 void HandleMediaL( TInt aListIndex, MGlxMediaList* aList ); |
|
241 |
|
242 /** see @ref MGlxMediaListObserver::HandleItemRemovedL **/ |
|
243 void HandleItemRemovedL( TInt aStartIndex, TInt aEndIndex, |
|
244 MGlxMediaList* aList ); |
|
245 |
|
246 /** see @ref MGlxMediaListObserver::HandleItemModifiedL **/ |
|
247 void HandleItemModifiedL( const RArray<TInt>& aItemIndexes, |
|
248 MGlxMediaList* aList ); |
|
249 |
|
250 /** see @ref MGlxMediaListObserver::HandleAttributesAvailableL **/ |
|
251 void HandleAttributesAvailableL( TInt aItemIndex, |
|
252 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList ); |
|
253 |
|
254 /** see @ref MGlxMediaListObserver::HandleFocusChangedL **/ |
|
255 void HandleFocusChangedL( NGlxListDefs::TFocusChangeType aType, |
|
256 TInt aNewIndex, TInt aOldIndex, MGlxMediaList* aList ); |
|
257 |
|
258 /** see @ref MGlxMediaListObserver::HandleItemSelectedL **/ |
|
259 void HandleItemSelectedL( TInt aIndex, TBool aSelected, |
|
260 MGlxMediaList* aList ); |
|
261 |
|
262 /** see @ref MGlxMediaListObserver::HandleMessageL **/ |
|
263 void HandleMessageL( const CMPXMessage& aMessage, MGlxMediaList* aList ); |
|
264 |
|
265 /** see @ref MGlxMediaListObserver::HandleError **/ |
|
266 void HandleError( TInt aError ); |
|
267 |
|
268 private: // from MGlxMediaListProvider |
|
269 /** see @ref MGlxMediaList::MediaList **/ |
|
270 MGlxMediaList& MediaList(); |
|
271 |
|
272 private: |
|
273 /** |
|
274 * Adds the glxcommoncommandhandlers resource file. |
|
275 */ |
|
276 void AddResourceFileL(); |
|
277 |
|
278 /** |
|
279 * Instantiates the attirbute context and adds it to the |
|
280 * static media list. |
|
281 */ |
|
282 void SetupAttributeContextL(); |
|
283 |
|
284 /** |
|
285 * Initialises the icon array. |
|
286 */ |
|
287 void InitIconsL(); |
|
288 |
|
289 /** |
|
290 * Adds the static item(s) to the static |
|
291 * media list. The static item represent |
|
292 * the creation of a new container (album |
|
293 * or tag) |
|
294 */ |
|
295 void AddNewMediaCreationItemL(); |
|
296 |
|
297 /** |
|
298 * Complete the active object. |
|
299 * Invokes an asynchronous call to RunL() |
|
300 */ |
|
301 void CompleteSelf(); |
|
302 |
|
303 /** |
|
304 * Fetches the 'New Media Item Title' and the 'Media Popup Title'. |
|
305 */ |
|
306 void FetchTitlesL(); |
|
307 |
|
308 /** |
|
309 * Instantiates the CAknPopupList and |
|
310 * CGlxSingleGraphicPopupMenuStyleListBox |
|
311 * @param aMultiSelection Create a multi selection dialog. |
|
312 */ |
|
313 void ConstructPopupListL(TBool aMultiSelection); |
|
314 |
|
315 private: |
|
316 /** |
|
317 * The list of selected items. (Owned) |
|
318 */ |
|
319 CGlxMediaListAdaptor* iMediaListAdaptor; |
|
320 |
|
321 /** |
|
322 * The list box used by popup. (Owned) |
|
323 */ |
|
324 CGlxSingleGraphicPopupMenuStyleListBox* iListBox; |
|
325 |
|
326 /** |
|
327 * The popup list. (Owned) |
|
328 */ |
|
329 CAknPopupList* iPopupList; |
|
330 |
|
331 /** |
|
332 * Resource offset |
|
333 */ |
|
334 TInt iResourceOffset; |
|
335 |
|
336 /** |
|
337 * Media list. (Owned) |
|
338 */ |
|
339 MGlxMediaList* iMediaList; |
|
340 |
|
341 /** |
|
342 * Attribute context. (Owned) |
|
343 */ |
|
344 CGlxAttributeContext* iAttributeContext; |
|
345 |
|
346 /** |
|
347 * Sequential iterator. |
|
348 */ |
|
349 TGlxSequentialIterator iIterator; |
|
350 |
|
351 /** |
|
352 * Enable container creation. |
|
353 * ETrue if container creation is enabled. |
|
354 */ |
|
355 TBool iEnableContainerCreation; |
|
356 |
|
357 /** |
|
358 * Media popup title. (Owned) |
|
359 */ |
|
360 HBufC* iSelectMediaPopupTitle; |
|
361 |
|
362 /** |
|
363 * New media item title. (Owned) |
|
364 */ |
|
365 HBufC* iNewMediaItemTitle; |
|
366 |
|
367 /** |
|
368 * The ID of the collection used to retrieve collection |
|
369 * specific attributes. |
|
370 */ |
|
371 TGlxMediaId iCollectionId; |
|
372 |
|
373 /** |
|
374 * A call to HandleItemAdditionL on the list box |
|
375 * is required when title attributes become available. |
|
376 */ |
|
377 TBool iHandleItemAdditionRequired; |
|
378 }; |
|
379 |
|
380 #endif // __GLXMEDIASELECTIONPOPUP_H__ |