|
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: Delete command handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "glxcommandhandlerdelete.h" |
|
22 |
|
23 #include <AknUtils.h> |
|
24 #include <bautils.h> |
|
25 #include <data_caging_path_literals.hrh> |
|
26 #include <glxcommandhandlers.hrh> |
|
27 #include <glxuiutility.h> |
|
28 #include <glxuistd.h> |
|
29 #include <glxuiutilities.rsg> |
|
30 #include <mglxmedialist.h> |
|
31 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
|
32 #include <glxscreenfurniture.h> |
|
33 #include <mpxcollectionpath.h> |
|
34 #include <StringLoader.h> |
|
35 |
|
36 #include <glxicons.mbg> |
|
37 #include <glxtracer.h> |
|
38 #include <glxnavigationalstate.h> |
|
39 #include <mpxcollectionpath.h> |
|
40 #include <glxcollectionpluginimageviewer.hrh> |
|
41 #include "glxcommandfactory.h" |
|
42 #include <glximageviewermanager.h> |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Two-phased constructor. |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C CGlxCommandHandlerDelete* CGlxCommandHandlerDelete::NewL( |
|
50 MGlxMediaListProvider* aMediaListProvider, TBool aContainerList, |
|
51 TBool aHasToolbarItem, const TDesC& aFileName) |
|
52 { |
|
53 /// @todo Minor: Rowland Cook 06/06/07 no use of glx logging |
|
54 CGlxCommandHandlerDelete* self = new (ELeave) CGlxCommandHandlerDelete( |
|
55 aMediaListProvider, aHasToolbarItem); |
|
56 CleanupStack::PushL(self); |
|
57 self->ConstructL(aContainerList, aFileName); |
|
58 CleanupStack::Pop(self); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // C++ default constructor can NOT contain any code, that |
|
64 // might leave. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CGlxCommandHandlerDelete::CGlxCommandHandlerDelete(MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem) |
|
68 : CGlxMpxCommandCommandHandler( aMediaListProvider, aHasToolbarItem ) |
|
69 { |
|
70 // Don't do anything. |
|
71 } |
|
72 |
|
73 |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // Symbian 2nd phase constructor can leave. |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CGlxCommandHandlerDelete::ConstructL(TBool aIsContainerList, |
|
80 const TDesC& aFileName) |
|
81 { |
|
82 iIsContainerList = aIsContainerList; |
|
83 iUiUtility = CGlxUiUtility::UtilityL(); |
|
84 |
|
85 // Load resource file |
|
86 iResourceOffset = CCoeEnv::Static()->AddResourceFileL(aFileName); |
|
87 |
|
88 // Add supported command |
|
89 TCommandInfo info(EGlxCmdDelete); |
|
90 // Filter out static items |
|
91 info.iMinSelectionLength = 1; |
|
92 info.iDisallowSystemItems = aIsContainerList; |
|
93 AddCommandL(info); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // Destructor |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C CGlxCommandHandlerDelete::~CGlxCommandHandlerDelete() |
|
101 { |
|
102 if (iResourceOffset) |
|
103 { |
|
104 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
|
105 } |
|
106 if(iUiUtility) |
|
107 { |
|
108 iUiUtility->Close(); |
|
109 } |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // Create an add to container command |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 CMPXCommand* CGlxCommandHandlerDelete::CreateCommandL(TInt /*aCommandId*/, |
|
117 MGlxMediaList& aMediaList, TBool& /*aConsume*/) const |
|
118 { |
|
119 CMPXCollectionPath* path = aMediaList.PathLC( NGlxListDefs::EPathFocusOrSelection ); |
|
120 CMPXCommand* command = TGlxCommandFactory::DeleteCommandLC(*path); |
|
121 CleanupStack::Pop(command); |
|
122 CleanupStack::PopAndDestroy(path); |
|
123 return command; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // Return default progress string |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 HBufC* CGlxCommandHandlerDelete::ProgressTextL(TInt /*aCommandId*/) const |
|
131 { |
|
132 return StringLoader::LoadL(R_QTN_FLDR_DELETING_WAIT_NOTE); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // Return confirmation string |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 HBufC* CGlxCommandHandlerDelete::ConfirmationTextL(TInt /*aCommandId*/, |
|
140 TBool aMultiSelection) const |
|
141 { |
|
142 // Return appropriate confirmation note |
|
143 HBufC* text = NULL; |
|
144 if (aMultiSelection) |
|
145 { |
|
146 if (iIsContainerList) |
|
147 { |
|
148 // Delete multiple containers string |
|
149 text = StringLoader::LoadL(R_GLX_CONFIRMATION_DELETE_CONTAINER_MULTIPLE); |
|
150 } |
|
151 else |
|
152 { |
|
153 // Delete multiple items string |
|
154 text = StringLoader::LoadL(R_GLX_CONFIRMATION_DELETE_MULTIPLE); |
|
155 } |
|
156 } |
|
157 else |
|
158 { |
|
159 if (iIsContainerList) |
|
160 { |
|
161 // Delete one container string |
|
162 text = StringLoader::LoadL(R_GLX_CONFIRMATION_DELETE_CONTAINER_SINGLE); |
|
163 } |
|
164 else |
|
165 { |
|
166 // Delete one item string |
|
167 text = StringLoader::LoadL(R_GLX_CONFIRMATION_DELETE_SINGLE); |
|
168 } |
|
169 } |
|
170 return text; |
|
171 } |
|
172 |
|
173 // ---------------------------------------------------------------------------- |
|
174 // DoActivateL |
|
175 // ---------------------------------------------------------------------------- |
|
176 void CGlxCommandHandlerDelete::DoActivateL(TInt /*aViewId*/) |
|
177 { |
|
178 |
|
179 } |
|
180 |
|
181 // ---------------------------------------------------------------------------- |
|
182 // OfferKeyEventL |
|
183 // ---------------------------------------------------------------------------- |
|
184 TKeyResponse CGlxCommandHandlerDelete::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
185 TEventCode aType) |
|
186 { |
|
187 TKeyResponse response = EKeyWasNotConsumed; |
|
188 // Is the key event from the Cancel (Backspace) key |
|
189 if (aKeyEvent.iCode == EKeyBackspace && aType == EEventKey) |
|
190 { |
|
191 // try to execute the delete command |
|
192 if(ExecuteL( EGlxCmdDelete )) |
|
193 { |
|
194 response = EKeyWasConsumed; |
|
195 } |
|
196 } |
|
197 return response; |
|
198 } |
|
199 |
|
200 // ---------------------------------------------------------------------------- |
|
201 // PopulateToolbar |
|
202 // ---------------------------------------------------------------------------- |
|
203 // |
|
204 void CGlxCommandHandlerDelete::PopulateToolbarL() |
|
205 { |
|
206 TRACER( "CGlxCommandHandlerRename::PopulateToolbar" ); |
|
207 |
|
208 iUiUtility->ScreenFurniture()->SetTooltipL( EGlxCmdDelete, CAknButton::EPositionLeft ); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // DoIsDisabled |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TBool CGlxCommandHandlerDelete::DoIsDisabled(TInt aCommandId, |
|
216 MGlxMediaList& aList) const |
|
217 { |
|
218 TRACER( "CGlxCommandHandlerDelete::DoIsDisabled" ); |
|
219 TBool disable = EFalse; |
|
220 |
|
221 CGlxNavigationalState* navState = CGlxNavigationalState::InstanceL(); |
|
222 CleanupClosePushL(*navState); |
|
223 CMPXCollectionPath* path = navState->StateLC(); |
|
224 |
|
225 if ( path->Levels() >= 1) |
|
226 { |
|
227 CGlxImageViewerManager* viewerInstance = CGlxImageViewerManager::InstanceL(); |
|
228 if (path->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid) |
|
229 && viewerInstance->IsPrivate()) |
|
230 { |
|
231 //it means we are in image viewer private path. |
|
232 disable = ETrue; |
|
233 } |
|
234 viewerInstance->DeleteInstance(); |
|
235 } |
|
236 CleanupStack::PopAndDestroy(path); |
|
237 CleanupStack::PopAndDestroy(navState); |
|
238 |
|
239 if (EGlxCmdDelete==aCommandId && 0 == aList.Count()) |
|
240 { |
|
241 disable = ETrue; |
|
242 } |
|
243 return disable; |
|
244 } |
|
245 //end of file |
|
246 |