60
|
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: Media List Command Handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef __C_GLXMEDIALISTCOMMANDHANDLER_H
|
|
22 |
#define __C_GLXMEDIALISTCOMMANDHANDLER_H
|
|
23 |
|
|
24 |
#include "glxcommandhandler.h"
|
|
25 |
|
|
26 |
#include <e32base.h>
|
|
27 |
#include <mpxcollectionobserver.h>
|
|
28 |
#include <mpxmediageneraldefs.h>
|
|
29 |
#include <mglxmedialistobserver.h>
|
|
30 |
|
|
31 |
class MGlxMediaList;
|
|
32 |
class CAknProgressDialog;
|
|
33 |
class MGlxMediaListProvider;
|
|
34 |
class CEikProgressInfo;
|
|
35 |
class UT_CGlxMediaListCommandHandler;
|
|
36 |
class t_cglxcommandhandlercopytohomenetwork;
|
|
37 |
|
|
38 |
/**
|
|
39 |
* @class CGlxMediaListCommandHandler
|
|
40 |
*
|
|
41 |
* Command handler that acts on a media list. This class handles basic
|
|
42 |
* and most common command filtering, i.e., checking whether the
|
|
43 |
* command is active based on a selection
|
|
44 |
*
|
|
45 |
* @ingroup glx_group_command_handlers
|
|
46 |
*
|
|
47 |
* Filters:
|
|
48 |
* - Disable if selection contains only system items (see @ref glx_colifspec_medial)
|
|
49 |
* - This allows disabling commands that are not allowed for system items (such as favourites album)
|
|
50 |
* - Disable if selection size is too small or too large
|
|
51 |
* - This allows filtering out an empty view (except for marking commands)
|
|
52 |
* - This allows filtering out static items (except for marking commands)
|
|
53 |
* - This allows filtering when other than 1 item has been selected
|
|
54 |
* - Use case: rename item, and play video
|
|
55 |
* - Disable for static item
|
|
56 |
* - This can be achieved by setting minimum selection lenght to 1 (or more), since
|
|
57 |
* static items are not part of selection
|
|
58 |
* - Specific static item disabling should only be required when dealing with marking commands,
|
|
59 |
* since static items do not belong to the selection. There is a selection,
|
|
60 |
* all commands (except marking commands) act on the selected items. If nothing
|
|
61 |
* is selected, focus is treated as selection. If nothing is selected, and
|
|
62 |
* a static item is focused, selection size will be 0.
|
|
63 |
* Hence, it is faster and simpler to use selection size min and max to filter out
|
|
64 |
* static items.
|
|
65 |
* - Disabling when view is empty can be achieved via min and max selection length, except
|
|
66 |
* for marking commands, which need to if view is empty:
|
|
67 |
* - (Mark all and Mark multiple need to be available also when there is no selection
|
|
68 |
* zero and focus is on a static item, but not if the view is empty, hence a
|
|
69 |
* separate check for empty view is needed for marking.)
|
|
70 |
* - Disable if system item
|
|
71 |
* - Disable by item type: Image/video/static item/album/tag
|
|
72 |
* - Use case: Filter out static items for marking command handler
|
|
73 |
*
|
|
74 |
* @lib glxviewbase.lib
|
|
75 |
*/
|
|
76 |
class CGlxMediaListCommandHandler : public CGlxCommandHandler
|
|
77 |
{
|
|
78 |
public:
|
|
79 |
/**
|
|
80 |
* Command info. Represents one command id.
|
|
81 |
* Command is enabled by default, unless member variables are modified
|
|
82 |
*/
|
|
83 |
struct TCommandInfo
|
|
84 |
{
|
|
85 |
/**
|
|
86 |
* Constructor that sets all filters not to apply, so
|
|
87 |
* command is enabled by default
|
|
88 |
*/
|
|
89 |
IMPORT_C TCommandInfo(TInt aCommandId);
|
|
90 |
|
|
91 |
/// Supported command id
|
|
92 |
TInt iCommandId;
|
|
93 |
|
|
94 |
/// Stop GIF animation before execution
|
|
95 |
TBool iStopAnimationForExecution;
|
|
96 |
|
|
97 |
/// Disable command if only system items in selection
|
|
98 |
TBool iDisallowSystemItems;
|
|
99 |
|
|
100 |
/// Disable command if only DRM-protected items in selection
|
|
101 |
TBool iDisallowDRM;
|
|
102 |
|
|
103 |
/// Disable command if selection smaller than. Default 0.
|
|
104 |
TInt iMinSelectionLength;
|
|
105 |
/// Disable command if selection larger than. Default KMaxTInt.
|
|
106 |
TInt iMaxSelectionLength;
|
|
107 |
|
|
108 |
/// Enable only if selected container(s) contains this or more items
|
|
109 |
TInt iMinSlideshowPlayableContainedItemCount;
|
|
110 |
|
|
111 |
/// Filter out animated GIFs
|
|
112 |
TBool iDisallowAnimatedGIFs;
|
|
113 |
|
|
114 |
/// Disable if <b>focused</b> item is / is not of the category
|
|
115 |
/// See @ref CGlxMediaListCommandHandler::iCategoryRule
|
|
116 |
/// Default is EMPXNoCategory
|
|
117 |
TMPXGeneralCategory iCategoryFilter;
|
|
118 |
|
|
119 |
/// If ETrue,
|
|
120 |
/// If EFalse, disables command if all items ARE of category
|
|
121 |
/// Default
|
|
122 |
/// See @ref CGlxMediaListCommandHandler::iCategoryFilter
|
|
123 |
enum TCategoryRule
|
|
124 |
{
|
|
125 |
EIgnore, // Ignore category
|
|
126 |
ERequireAll, // disables command if all items are NOT of category
|
|
127 |
EForbidAll // disables command if all items ARE of category
|
|
128 |
};
|
|
129 |
TCategoryRule iCategoryRule;
|
|
130 |
|
|
131 |
/// Viewing Statws. Used to filter what commands are on display
|
|
132 |
/// relative to Browsing or Viewing
|
|
133 |
/// These are bitwise to enable a command to declare more than
|
|
134 |
/// one state at a time.
|
|
135 |
enum TViewingState
|
|
136 |
{
|
|
137 |
EViewingStateUndefined = 0xFFFFFFFF,
|
|
138 |
EViewingStateBrowse = 0x01, // Tile View
|
|
139 |
EViewingStateView = 0x02 // Full Screen view
|
|
140 |
};
|
|
141 |
|
|
142 |
// Records the current viewing state
|
|
143 |
TViewingState iViewingState;
|
|
144 |
};
|
|
145 |
|
|
146 |
public:
|
|
147 |
/**
|
|
148 |
* Destructor
|
|
149 |
*/
|
|
150 |
IMPORT_C virtual ~CGlxMediaListCommandHandler();
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Constructor
|
|
154 |
* @param aMediaListProvider The owner of the media list to use
|
|
155 |
*/
|
|
156 |
IMPORT_C CGlxMediaListCommandHandler( MGlxMediaListProvider* aMediaListProvider,
|
|
157 |
TBool aIsToolbarCommand = EFalse );
|
|
158 |
|
|
159 |
public: // From MGlxCommandHandler
|
|
160 |
/// See @ref MGlxCommandHandler::ExecuteL */
|
|
161 |
IMPORT_C virtual TBool ExecuteL(TInt aCommand);
|
|
162 |
|
|
163 |
/// See @ref MGlxCommandHandler::DynInitMenuPaneL */
|
|
164 |
IMPORT_C virtual void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane,
|
|
165 |
TBool aIsBrowseMode);
|
|
166 |
|
|
167 |
/**
|
|
168 |
* See @ref MGlxCommandHandler::Deactivate
|
|
169 |
* Default implementation does nothing
|
|
170 |
*/
|
|
171 |
IMPORT_C virtual void Deactivate();
|
|
172 |
|
|
173 |
/**
|
|
174 |
* See @ref MGlxCommandHandler::OfferKeyEventL
|
|
175 |
* Default implementation does nothing
|
|
176 |
*/
|
|
177 |
IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
|
|
178 |
|
|
179 |
/**
|
|
180 |
* See @ref MGlxCommandHandler::PreDynInitMenuPaneL
|
|
181 |
* Default implementation does nothing
|
|
182 |
* @param aResourceId Menu resource id.
|
|
183 |
*/
|
|
184 |
IMPORT_C virtual void PreDynInitMenuPaneL( TInt aResourceId );
|
|
185 |
|
|
186 |
/**
|
|
187 |
* See @ref MGlxCommandHandler::GetRequiredAttributesL
|
|
188 |
*/
|
|
189 |
IMPORT_C void GetRequiredAttributesL(RArray< TMPXAttribute >& aAttributes,
|
|
190 |
TBool aFilterUsingSelection,
|
|
191 |
TBool aFilterUsingCommandId,
|
|
192 |
TInt aCommandId = 0) const;
|
|
193 |
|
|
194 |
protected:
|
|
195 |
/**
|
|
196 |
* Execute the command, if applicable. Called after basic filtering
|
|
197 |
* @param aCommand The command to handle
|
|
198 |
* @return ETrue iff command was handled
|
|
199 |
* @see BypassFiltersForExecute
|
|
200 |
*/
|
|
201 |
virtual TBool DoExecuteL(TInt aCommandId, MGlxMediaList& aList) = 0;
|
|
202 |
|
|
203 |
/**
|
|
204 |
* See @ref CGlxCommandHandler::DoActivateL
|
|
205 |
* Default implementation does nothing
|
|
206 |
*/
|
|
207 |
IMPORT_C virtual void DoActivateL( TInt aViewId );
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Check if command is disabled. Allows deriving class to provide
|
|
211 |
* more elaborate filtering that supported by this class.
|
|
212 |
* Default implementation returns EFalse.
|
|
213 |
* @return ETrue if command is disabled
|
|
214 |
*/
|
|
215 |
IMPORT_C virtual TBool DoIsDisabled(TInt aCommandId, MGlxMediaList& aList) const;
|
|
216 |
|
|
217 |
/**
|
|
218 |
* Allow deriving classes to make any further alterations to the menu pane.
|
|
219 |
* Only called on classes with at least on enabled command present in menu
|
|
220 |
* @param aResourceId The resource ID of the menu
|
|
221 |
* @param aMenuPane The in-memory representation of the menu pane
|
|
222 |
* @see BypassFiltersForMenu
|
|
223 |
*/
|
|
224 |
IMPORT_C virtual void DoDynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
|
|
225 |
|
|
226 |
/**
|
|
227 |
* If deriving class returns true for this, ALL commands will be sent to DoExecuteL
|
|
228 |
* @return Whether to bypass filters for command execution
|
|
229 |
*/
|
|
230 |
IMPORT_C virtual TBool BypassFiltersForExecute() const;
|
|
231 |
|
|
232 |
/**
|
|
233 |
* If deriving class returns true for this, ALL menus will be passed to DoDynInitMenuPaneL
|
|
234 |
* @return Whether to bypass filters for menu initialization
|
|
235 |
*/
|
|
236 |
IMPORT_C virtual TBool BypassFiltersForMenu() const;
|
|
237 |
|
|
238 |
/**
|
|
239 |
* Optionally implemented by deriving classes to specify attributes that should be retrieved
|
|
240 |
* @param aAttributes array to append attributes to.
|
|
241 |
* @param aFilterUsingSelection If ETrue, the deriving class should only append
|
|
242 |
* attributes relevant to the current selection, If EFalse all attributes
|
|
243 |
* should be appended.
|
|
244 |
*/
|
|
245 |
IMPORT_C virtual void DoGetRequiredAttributesL( RArray<TMPXAttribute>& aAttributes, TBool aFilterUsingSelection) const;
|
|
246 |
|
|
247 |
protected:
|
|
248 |
/**
|
|
249 |
* Returns a reference to the current media list
|
|
250 |
* @return reference to the current media list
|
|
251 |
*/
|
|
252 |
IMPORT_C MGlxMediaList& MediaList();
|
|
253 |
|
|
254 |
/**
|
|
255 |
* Returns a const reference to the current media list
|
|
256 |
* @return const reference to the current media list
|
|
257 |
*/
|
|
258 |
IMPORT_C const MGlxMediaList& MediaList() const;
|
|
259 |
/**
|
|
260 |
* AddCommandL
|
|
261 |
*/
|
|
262 |
IMPORT_C void AddCommandL(const TCommandInfo& aCommand);
|
|
263 |
|
|
264 |
/**
|
|
265 |
* Check if the command handler is currently disabled
|
|
266 |
*/
|
|
267 |
IMPORT_C TBool IsDisabledL(TInt aCommandId, MGlxMediaList& aList) const;
|
|
268 |
|
|
269 |
/**
|
|
270 |
* @return ETrue if command is handled by this command handler
|
|
271 |
*/
|
|
272 |
IMPORT_C TBool IsSupported(TInt aCommandId) const;
|
|
273 |
|
|
274 |
/**
|
|
275 |
* @return the length of selection
|
|
276 |
* If static item is focused, length is 0
|
|
277 |
* If list is empty, lenght is 0
|
|
278 |
* If no items are selected, but a non-static item is focused length is 1
|
|
279 |
*/
|
|
280 |
IMPORT_C TInt SelectionLength() const;
|
|
281 |
|
|
282 |
/**
|
|
283 |
* @return command info by index
|
|
284 |
*/
|
|
285 |
IMPORT_C TCommandInfo& CommandInfo(TInt aIndex);
|
|
286 |
|
|
287 |
/**
|
|
288 |
* @return the current viewing state.
|
|
289 |
*/
|
|
290 |
|
|
291 |
IMPORT_C TCommandInfo::TViewingState ViewingState() const;
|
|
292 |
|
|
293 |
/**
|
|
294 |
* @return command info by index
|
|
295 |
*/
|
|
296 |
const TCommandInfo& CommandInfo(TInt aIndex) const;
|
|
297 |
|
|
298 |
private:
|
|
299 |
/**
|
|
300 |
* @return index of command in command info array or KErrNotFound
|
|
301 |
*/
|
|
302 |
TInt CommandInfoIndex(TInt aCommandId) const;
|
|
303 |
|
|
304 |
/**
|
|
305 |
* Check if a given command (menu option) is viewable in the current view
|
|
306 |
* @param aInfo The command in question.
|
|
307 |
* @return ETrue if viewable, EFalse if not.
|
|
308 |
*/
|
|
309 |
|
|
310 |
TBool IsViewable(const TCommandInfo& aInfo) const;
|
|
311 |
|
|
312 |
/**
|
|
313 |
* Checks to see if the command handler is disabled
|
|
314 |
* based on the selection and IsViewable(). Other
|
|
315 |
* conditions may also disable the command handler.
|
|
316 |
* @param aInfo The command in question.
|
|
317 |
* @return ETrue, if the command handler is disabled
|
|
318 |
* EFalse if the command handler may not be disabled.
|
|
319 |
*/
|
|
320 |
TBool IsDisabled(const TCommandInfo& aInfo) const;
|
|
321 |
|
|
322 |
/**
|
|
323 |
* Append required attributes to aAttributes
|
|
324 |
* @param aAttributes array to append attributes to.
|
|
325 |
* @param aFilterUsingSelection If ETrue, the deriving class should only append
|
|
326 |
* attributes relevant to the current selection, If EFalse all attributes
|
|
327 |
* should be appended.
|
|
328 |
*/
|
|
329 |
void GetRequiredAttributesL(RArray< TMPXAttribute >& aAttributes,
|
|
330 |
TBool aFilterUsingSelection) const;
|
|
331 |
|
|
332 |
/**
|
|
333 |
* Check if the command handler is currently disabled in browse mode
|
|
334 |
* @param aCommandId command ID of the command.
|
|
335 |
* @param aMediaList Medialist instance to check the counts
|
|
336 |
* @param aIsContextItem ETrue if the current item is an context menu item.
|
|
337 |
*/
|
|
338 |
TBool CGlxMediaListCommandHandler::CheckDisabledForBrowseModeL(
|
|
339 |
TInt aCommandId,
|
|
340 |
MGlxMediaList& aMediaList,
|
|
341 |
TBool aIsContextItem);
|
|
342 |
|
|
343 |
private:
|
|
344 |
|
|
345 |
/** Provider of media list */
|
|
346 |
MGlxMediaListProvider* iMediaListProvider;
|
|
347 |
|
|
348 |
/** Command info array */
|
|
349 |
RArray<TCommandInfo> iCommandInfoArray;
|
|
350 |
|
|
351 |
/** Current viewing state */
|
|
352 |
TCommandInfo::TViewingState iCurrentViewingState;
|
|
353 |
|
|
354 |
friend class UT_CGlxMediaListCommandHandler;
|
|
355 |
friend class t_cglxcommandhandlercopytohomenetwork;
|
|
356 |
};
|
|
357 |
|
|
358 |
#endif // __C_GLXMEDIALISTCOMMANDHANDLER_H
|