|
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 item list observer interface |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "glxtoolbarcontroller.h" |
|
22 #include <aknbutton.h> |
|
23 #include <akntoolbar.h> // For Toolbar |
|
24 #include <glxcommandhandlers.hrh> // For Command ids |
|
25 #include <glxtracer.h> // For Logs |
|
26 #include <mglxmedialist.h> |
|
27 |
|
28 #include <glxnavigationalstate.h> |
|
29 #include <mpxcollectionpath.h> |
|
30 #include <glxcollectionpluginimageviewer.hrh> |
|
31 const TInt KGlxToolbarButtonUnLatched = 0; // As per the states in resource file |
|
32 const TInt KGlxToolbarButtonLatched = 1 ; |
|
33 |
|
34 //---------------------------------------------------------------------------------- |
|
35 // NewL |
|
36 //---------------------------------------------------------------------------------- |
|
37 // |
|
38 CGlxToolbarController* CGlxToolbarController::NewL() |
|
39 { |
|
40 TRACER("CGlxToolbarController::NewL"); |
|
41 |
|
42 CGlxToolbarController *self = new( ELeave ) CGlxToolbarController (); |
|
43 return self; |
|
44 } |
|
45 |
|
46 //---------------------------------------------------------------------------------- |
|
47 // Default Constructor |
|
48 //---------------------------------------------------------------------------------- |
|
49 // |
|
50 CGlxToolbarController::CGlxToolbarController( ) |
|
51 { |
|
52 TRACER("CGlxToolbarController::Default constructor"); |
|
53 |
|
54 } |
|
55 |
|
56 //---------------------------------------------------------------------------------- |
|
57 // AddToObserver |
|
58 //---------------------------------------------------------------------------------- |
|
59 // |
|
60 void CGlxToolbarController::AddToObserverL (MGlxMediaList& aList, CAknToolbar* aToolbar) |
|
61 { |
|
62 TRACER("CGlxToolbarController::AddToObserverL"); |
|
63 |
|
64 iToolbar = aToolbar; |
|
65 iAttributeAvailable = EFalse; |
|
66 iToolbar->SetDimmed(ETrue); |
|
67 iToolbar->DrawNow(); |
|
68 aList.AddMediaListObserverL ( this ); |
|
69 } |
|
70 |
|
71 //---------------------------------------------------------------------------------- |
|
72 // RemoveFromObserver |
|
73 //---------------------------------------------------------------------------------- |
|
74 // |
|
75 void CGlxToolbarController::RemoveFromObserver (MGlxMediaList& aList) |
|
76 { |
|
77 TRACER("CGlxToolbarController::RemoveFromObserver"); |
|
78 |
|
79 if( aList.SelectionCount()<= 0 ) |
|
80 { |
|
81 EnableLatch( EGlxCmdStartMultipleMarking, EFalse ); |
|
82 } |
|
83 |
|
84 aList.RemoveMediaListObserver ( this ); |
|
85 } |
|
86 |
|
87 //---------------------------------------------------------------------------- |
|
88 // HandleItemAddedL |
|
89 //---------------------------------------------------------------------------- |
|
90 // |
|
91 void CGlxToolbarController::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, |
|
92 MGlxMediaList* /*aList*/) |
|
93 { |
|
94 TRACER("CGlxToolbarController::HandleItemAddedL"); |
|
95 |
|
96 } |
|
97 |
|
98 //---------------------------------------------------------------------------- |
|
99 // HandleMediaL |
|
100 //---------------------------------------------------------------------------- |
|
101 // |
|
102 void CGlxToolbarController::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/) |
|
103 { |
|
104 TRACER("CGlxToolbarController::HandleMediaL"); |
|
105 |
|
106 } |
|
107 |
|
108 //---------------------------------------------------------------------------- |
|
109 // HandleItemRemovedL |
|
110 //---------------------------------------------------------------------------- |
|
111 // |
|
112 void CGlxToolbarController::HandleItemRemovedL(TInt /*aStartIndex*/, |
|
113 TInt /*aEndIndex*/, MGlxMediaList* aList) |
|
114 { |
|
115 TRACER("CGlxToolbarController::HandleItemRemovedL"); |
|
116 |
|
117 if( aList->Count() <= 0 ) |
|
118 { |
|
119 iToolbar->SetDimmed(ETrue); |
|
120 iToolbar->DrawNow(); |
|
121 } |
|
122 } |
|
123 |
|
124 //---------------------------------------------------------------------------- |
|
125 // HandleItemModifiedL |
|
126 //---------------------------------------------------------------------------- |
|
127 // |
|
128 void CGlxToolbarController::HandleItemModifiedL(const RArray<TInt>& /*aItemIndexes*/, |
|
129 MGlxMediaList* /*aList*/) |
|
130 { |
|
131 TRACER("CGlxToolbarController::HandleItemModifiedL"); |
|
132 |
|
133 } |
|
134 |
|
135 //---------------------------------------------------------------------------- |
|
136 // HandleAttributesAvailableL |
|
137 //---------------------------------------------------------------------------- |
|
138 // |
|
139 void CGlxToolbarController::HandleAttributesAvailableL(TInt aItemIndex, |
|
140 const RArray<TMPXAttribute>& /*aAttributes*/, |
|
141 MGlxMediaList* aList) |
|
142 { |
|
143 TRACER("CGlxToolbarController::HandleAttributesAvailableL"); |
|
144 |
|
145 if( aItemIndex == aList->FocusIndex() ) |
|
146 { |
|
147 iAttributeAvailable = ETrue; |
|
148 SetStatusL(aList); |
|
149 } |
|
150 } |
|
151 |
|
152 //---------------------------------------------------------------------------- |
|
153 // HandleFocusChangedL |
|
154 //---------------------------------------------------------------------------- |
|
155 // |
|
156 void CGlxToolbarController::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /*aType*/, |
|
157 TInt aNewIndex, TInt /*aOldIndex*/, |
|
158 MGlxMediaList* aList) |
|
159 { |
|
160 TRACER("CGlxToolbarController::HandleFocusChangedL"); |
|
161 |
|
162 // If new index is not equal to -1 (i.e., if there are some items present), |
|
163 // then check the media item |
|
164 if( (aNewIndex == aList->FocusIndex()) && (KErrNotFound != aNewIndex) ) |
|
165 { |
|
166 //Get the current media item from medialist |
|
167 const TGlxMedia& mediaItem = aList->Item(aList->FocusIndex()); |
|
168 //Check whether media item is a system item, for example Favourites album |
|
169 TBool isSystemItem = EFalse; |
|
170 mediaItem.GetSystemItem(isSystemItem); |
|
171 if( mediaItem.IsStatic() ) |
|
172 { |
|
173 iToolbar->SetDimmed(ETrue); |
|
174 } |
|
175 else if( iToolbar->IsDimmed() ) |
|
176 { |
|
177 iToolbar->SetDimmed(EFalse); |
|
178 } |
|
179 if( isSystemItem ) |
|
180 { |
|
181 iToolbar->SetItemDimmed( EGlxCmdRename, ETrue, ETrue ); |
|
182 } |
|
183 else |
|
184 { |
|
185 iToolbar->SetItemDimmed( EGlxCmdRename, EFalse, ETrue ); |
|
186 } |
|
187 } |
|
188 //DrawNow must be called since SetDimmed does not redraw the toolbar |
|
189 iToolbar->DrawNow(); |
|
190 } |
|
191 |
|
192 //---------------------------------------------------------------------------- |
|
193 // HandleItemSelectedL |
|
194 //---------------------------------------------------------------------------- |
|
195 // |
|
196 void CGlxToolbarController::HandleItemSelectedL(TInt /*aIndex*/, TBool /*aSelected*/, |
|
197 MGlxMediaList* aList) |
|
198 { |
|
199 TRACER("CGlxToolbarController::HandleItemSelectedL"); |
|
200 |
|
201 // If atleast 1 item is marked, or if Mark All is called, then Latch the mark button. |
|
202 if((aList->SelectionCount() == 1 ) || (aList->SelectionCount() == aList->Count())) |
|
203 { |
|
204 EnableLatch( EGlxCmdStartMultipleMarking, ETrue ); |
|
205 } |
|
206 /* single clk chngs |
|
207 * check the current view status. |
|
208 * need to disable upload button in toolbar for grid by default |
|
209 */ |
|
210 if(!IsFullScreenView()) |
|
211 { |
|
212 if(aList->SelectionCount() >= 1 ) |
|
213 { |
|
214 iToolbar->SetItemDimmed(EGlxCmdUpload,EFalse , ETrue); |
|
215 } |
|
216 else |
|
217 { |
|
218 iToolbar->SetItemDimmed(EGlxCmdUpload,ETrue , ETrue); |
|
219 } |
|
220 } |
|
221 |
|
222 //DrawNow must be called since SetDimmed does not redraw the toolbar |
|
223 iToolbar->DrawNow(); |
|
224 } |
|
225 |
|
226 //---------------------------------------------------------------------------- |
|
227 // HandleMessageL |
|
228 //---------------------------------------------------------------------------- |
|
229 // |
|
230 void CGlxToolbarController::HandleMessageL(const CMPXMessage& /*aMessage*/, |
|
231 MGlxMediaList* /*aList*/) |
|
232 { |
|
233 TRACER("CGlxToolbarController::HandleMessageL"); |
|
234 |
|
235 } |
|
236 |
|
237 //---------------------------------------------------------------------------- |
|
238 // Destructor |
|
239 //---------------------------------------------------------------------------- |
|
240 // |
|
241 CGlxToolbarController::~CGlxToolbarController() |
|
242 { |
|
243 TRACER("CGlxToolbarController Destructor"); |
|
244 |
|
245 } |
|
246 |
|
247 //---------------------------------------------------------------------------- |
|
248 // SetStatusOnViewActivationL |
|
249 //---------------------------------------------------------------------------- |
|
250 // |
|
251 void CGlxToolbarController::SetStatusOnViewActivationL( MGlxMediaList* aList ) |
|
252 { |
|
253 TRACER("CGlxToolbarController::SetStatusOnViewActivationL"); |
|
254 |
|
255 // When going back from fullscreen to grid, when the attributes are already |
|
256 // available in the cache, there is no HandleAttributeAvailable callback. Hence, |
|
257 // checking for medialist count. |
|
258 if( !iAttributeAvailable && (aList->Count(NGlxListDefs::ECountNonStatic) > 0)) |
|
259 { |
|
260 SetStatusL(aList); |
|
261 } |
|
262 } |
|
263 |
|
264 //---------------------------------------------------------------------------- |
|
265 //SetStatusL |
|
266 //---------------------------------------------------------------------------- |
|
267 // |
|
268 void CGlxToolbarController::SetStatusL(MGlxMediaList* aList) |
|
269 { |
|
270 TRACER("CGlxToolbarController::SetStatusL"); |
|
271 if(KErrNotFound != aList->FocusIndex()) |
|
272 { |
|
273 //Get the current media item from medialist |
|
274 const TGlxMedia& mediaItem = aList->Item(aList->FocusIndex()); |
|
275 |
|
276 //Check whether media item is a system item, for example Favourites album |
|
277 TBool isSystemItem = EFalse; |
|
278 mediaItem.GetSystemItem(isSystemItem); |
|
279 |
|
280 if(!mediaItem.IsStatic() && iToolbar->IsDimmed()) |
|
281 { |
|
282 //Activate (Undim) the toolbar if item in focus is not static |
|
283 iToolbar->SetDimmed(EFalse); |
|
284 } |
|
285 |
|
286 |
|
287 if( isSystemItem ) |
|
288 { |
|
289 iToolbar->SetItemDimmed( EGlxCmdRename, ETrue, ETrue ); |
|
290 } |
|
291 else |
|
292 { |
|
293 iToolbar->SetItemDimmed( EGlxCmdRename, EFalse, ETrue ); |
|
294 } |
|
295 } |
|
296 /* single clk chngs |
|
297 * enable/disable upload button as per selection count, only in grid view |
|
298 */ |
|
299 if(aList->SelectionCount()== 0 && !IsFullScreenView()) |
|
300 { |
|
301 iToolbar->SetItemDimmed(EGlxCmdUpload,ETrue , ETrue); |
|
302 } |
|
303 |
|
304 //DrawNow must be called since SetDimmed does not redraw the toolbar |
|
305 iToolbar->DrawNow(); |
|
306 } |
|
307 |
|
308 //---------------------------------------------------------------------------- |
|
309 // EnableLatch |
|
310 //---------------------------------------------------------------------------- |
|
311 // |
|
312 void CGlxToolbarController::EnableLatch( TInt aCommandId, TInt aLatched ) |
|
313 { |
|
314 CAknButton* toolbarButton = static_cast<CAknButton*> |
|
315 (iToolbar->ControlOrNull( aCommandId )); |
|
316 |
|
317 if( toolbarButton ) |
|
318 { |
|
319 if(aLatched) |
|
320 { |
|
321 toolbarButton->SetCurrentState( KGlxToolbarButtonLatched, ETrue ); |
|
322 } |
|
323 else |
|
324 { |
|
325 toolbarButton->SetCurrentState( KGlxToolbarButtonUnLatched, ETrue ); |
|
326 } |
|
327 } |
|
328 } |
|
329 //---------------------------------------------------------------------------- |
|
330 // Check for current view mode .Grid/fullscreen/imgviewer |
|
331 //---------------------------------------------------------------------------- |
|
332 // |
|
333 TBool CGlxToolbarController::IsFullScreenView() |
|
334 { |
|
335 TBool fullscreenViewingMode = EFalse; |
|
336 |
|
337 CGlxNavigationalState* aNavigationalState = CGlxNavigationalState::InstanceL(); |
|
338 CMPXCollectionPath* naviState = aNavigationalState->StateLC(); |
|
339 |
|
340 if ( naviState->Levels() >= 1) |
|
341 { |
|
342 if (aNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) |
|
343 { |
|
344 // For image viewer collection, goto view mode |
|
345 if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) |
|
346 { |
|
347 // current view mode is img vwr |
|
348 fullscreenViewingMode = ETrue; |
|
349 } |
|
350 else |
|
351 { |
|
352 //current view mode is Grid |
|
353 fullscreenViewingMode = EFalse; |
|
354 } |
|
355 } |
|
356 else |
|
357 { |
|
358 //current view mode is Fullscreen |
|
359 fullscreenViewingMode = ETrue; |
|
360 } |
|
361 } |
|
362 CleanupStack::PopAndDestroy( naviState ); |
|
363 aNavigationalState->Close(); |
|
364 return fullscreenViewingMode; |
|
365 } |
|
366 //end os file |
|
367 |