author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:32:09 +0300 | |
branch | RCL_3 |
changeset 75 | 01504893d9cb |
parent 60 | 5b3385a43d68 |
permissions | -rw-r--r-- |
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: Implementation of Grid view |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
||
22 |
// INCLUDE FILES |
|
23 |
#include <aknbutton.h> |
|
24 |
#include <StringLoader.h> |
|
25 |
#include <AknsBasicBackgroundControlContext.h> |
|
26 |
||
27 |
//Gallery Headers |
|
28 |
#include <glxactivemedialistregistry.h> // For medialist registry |
|
29 |
#include <glxcommandhandlers.hrh> // For EGlxCmdFullScreenBack |
|
30 |
#include <glxgridviewdata.rsg> // Gridview resource |
|
31 |
||
32 |
#include <mglxmedialist.h> // CGlxMedialist |
|
33 |
#include <glxsetappstate.h> |
|
34 |
#include <glxtracer.h> // For Tracer |
|
35 |
#include <glxlog.h> |
|
36 |
||
37 |
// User Includes |
|
38 |
#include "glxgridviewimp.h" |
|
39 |
#include "glxgridviewmlobserver.h" // medialist observer for Hg Grid |
|
40 |
#include "glxgridviewcontainer.h" |
|
41 |
||
42 |
// For transition effects |
|
43 |
#include <akntranseffect.h> |
|
44 |
#include <gfxtranseffect/gfxtranseffect.h> |
|
45 |
#include "glxgfxtranseffect.h" // For transition effects |
|
46 |
||
47 |
const TInt KGlxToolbarButtonUnLatched = 0; // Toolbar mark button's unlatched state defined in the rss file |
|
48 |
||
49 |
// ======== MEMBER FUNCTIONS ======== |
|
50 |
||
51 |
// --------------------------------------------------------------------------- |
|
52 |
// Two-phased constructor. |
|
53 |
// --------------------------------------------------------------------------- |
|
54 |
// |
|
55 |
CGlxGridViewImp* CGlxGridViewImp::NewL( |
|
56 |
MGlxMediaListFactory* aMediaListFactory, |
|
57 |
const TGridViewResourceIds& aResourceIds, |
|
58 |
TInt aViewUID, |
|
59 |
const TDesC& aTitle) |
|
60 |
{ |
|
61 |
TRACER("CGlxGridViewImp::NewL"); |
|
62 |
CGlxGridViewImp* self = CGlxGridViewImp::NewLC(aMediaListFactory, |
|
63 |
aResourceIds, |
|
64 |
aViewUID, |
|
65 |
aTitle); |
|
66 |
CleanupStack::Pop(self); |
|
67 |
return self; |
|
68 |
} |
|
69 |
||
70 |
// --------------------------------------------------------------------------- |
|
71 |
// Two-phased constructor. |
|
72 |
// --------------------------------------------------------------------------- |
|
73 |
// |
|
74 |
CGlxGridViewImp* CGlxGridViewImp::NewLC( |
|
75 |
MGlxMediaListFactory* aMediaListFactory, |
|
76 |
const TGridViewResourceIds& aResourceIds, |
|
77 |
TInt aViewUID, |
|
78 |
const TDesC& aTitle) |
|
79 |
{ |
|
80 |
TRACER("CGlxGridViewImp::NewLC()"); |
|
81 |
CGlxGridViewImp* self = |
|
82 |
new (ELeave) CGlxGridViewImp(aResourceIds, aViewUID); |
|
83 |
CleanupStack::PushL(self); |
|
84 |
self->ConstructL(aMediaListFactory, aTitle); |
|
85 |
return self; |
|
86 |
} |
|
87 |
||
88 |
// --------------------------------------------------------------------------- |
|
89 |
// C++ default constructor can NOT contain any code, that |
|
90 |
// might leave. |
|
91 |
// --------------------------------------------------------------------------- |
|
92 |
// |
|
93 |
CGlxGridViewImp::CGlxGridViewImp(const TGridViewResourceIds& aResourceIds, |
|
94 |
TInt aViewUID) : |
|
95 |
iResourceIds(aResourceIds), |
|
96 |
iViewUID(aViewUID), |
|
97 |
iPreviousFocusChangeType(NGlxListDefs::EUnknown) |
|
98 |
{ |
|
99 |
TRACER("CGlxGridViewImp::CGlxGridViewImp()"); |
|
100 |
} |
|
101 |
||
102 |
// --------------------------------------------------------------------------- |
|
103 |
// Symbian 2nd phase constructor can leave. |
|
104 |
// --------------------------------------------------------------------------- |
|
105 |
// |
|
106 |
void CGlxGridViewImp::ConstructL(MGlxMediaListFactory* aMediaListFactory, |
|
107 |
const TDesC& aTitle) |
|
108 |
{ |
|
109 |
TRACER("CGlxGridViewImp::ConstructL()"); |
|
110 |
BaseConstructL(iResourceIds.iViewId); |
|
111 |
ViewBaseConstructL(); |
|
112 |
MLViewBaseConstructL(aMediaListFactory, aTitle); |
|
113 |
||
114 |
// Get object that stores the active media list registry |
|
115 |
iActiveMediaListRegistry = CGlxActiveMediaListRegistry::InstanceL(); |
|
116 |
} |
|
117 |
||
118 |
// --------------------------------------------------------------------------- |
|
119 |
// From CAknView |
|
120 |
// Handles a view activation. |
|
121 |
// --------------------------------------------------------------------------- |
|
122 |
// |
|
123 |
void CGlxGridViewImp::DoMLViewActivateL( |
|
124 |
const TVwsViewId& /*aPrevViewId*/, |
|
125 |
TUid /* aCustomMessageId */, |
|
126 |
const TDesC8& aCustomMessage) |
|
127 |
{ |
|
128 |
TRACER("CGlxGridViewImp::DoMLViewActivateL()"); |
|
129 |
||
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
130 |
TUint transitionID = (iUiUtility->ViewNavigationDirection()== |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
131 |
EGlxNavigationForwards)?KActivateTransitionId:KFSDeActivateTransitionId; |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
132 |
|
60 | 133 |
HBufC8* activationParam = HBufC8::NewLC(KMaxUidName); |
134 |
activationParam->Des().AppendNum(KGlxActivationCmdShowAll); |
|
135 |
||
136 |
if (aCustomMessage.Compare(activationParam->Des()) == 0) |
|
137 |
{ |
|
138 |
// Launched from Camera App, Check if there is any existing filter |
|
139 |
// and clear the 'MaxCount' filter, if supported to show all images. |
|
140 |
GLX_DEBUG1("CGlxGridViewImp::DoMLViewActivateL() - " |
|
141 |
"Launched From Camera"); |
|
142 |
CMPXFilter* filter = iMediaList->Filter(); |
|
143 |
if (filter && filter->IsSupported(KGlxFilterGeneralMaxCount)) |
|
144 |
{ |
|
145 |
GLX_DEBUG1( "CGlxGridViewImp::DoMLViewActivateL()- " |
|
146 |
"Clear MaxCount filter"); |
|
147 |
filter->SetTObjectValueL<TInt> (KGlxFilterGeneralMaxCount, 0); |
|
148 |
iMediaList->SetFilterL(filter); |
|
149 |
} |
|
150 |
} |
|
151 |
||
152 |
||
153 |
if(StatusPane()) |
|
154 |
{ |
|
155 |
StatusPane()->MakeVisible(ETrue); |
|
156 |
CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
157 |
CAknTitlePane* titlePane = ( CAknTitlePane* )statusPane->ControlL( |
|
158 |
TUid::Uid( EEikStatusPaneUidTitle )); |
|
159 |
const TDesC* titleText = titlePane->Text(); |
|
160 |
HBufC* tempTitle = titleText->AllocLC(); |
|
161 |
TPtr titleptr = tempTitle->Des(); |
|
162 |
titleptr.Trim(); |
|
163 |
if(!tempTitle->Length()) |
|
164 |
{ |
|
165 |
if( iTitletext ) |
|
166 |
{ |
|
167 |
// Set the required Title |
|
168 |
titlePane->SetTextL( *iTitletext ); |
|
169 |
} |
|
170 |
} |
|
171 |
CleanupStack::PopAndDestroy(tempTitle); |
|
172 |
} |
|
173 |
||
174 |
GlxSetAppState::SetState(EGlxInCarouselView); |
|
175 |
// Setting the Context sensitive menu id |
|
176 |
MenuBar()->SetContextMenuTitleResourceId( iResourceIds.iOkOptionsMenuId ); |
|
177 |
iActiveMediaListRegistry->RegisterActiveMediaList(iMediaList); |
|
178 |
if(!iToolbar) |
|
179 |
{ |
|
180 |
iToolbar = CAknToolbar::NewL(R_GLX_GRID_VIEW_TOOLBAR); |
|
181 |
SetGridToolBar(iToolbar); |
|
182 |
SetToolbarObserver(this); |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
183 |
//Make the toolbar visible only when the medialist is populated |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
184 |
iToolbar->SetToolbarVisibility(iMediaList->IsPopulated()); |
60 | 185 |
} |
186 |
//Create gridview container |
|
187 |
iGlxGridViewContainer = CGlxGridViewContainer::NewL(iMediaList, |
|
188 |
iUiUtility, *this, iToolbar); |
|
189 |
iEikonEnv->AppUi()->AddToStackL(*this,iGlxGridViewContainer); |
|
190 |
iUiUtility->DestroyScreenClearer(); |
|
191 |
||
192 |
// Start Animating the view when launched from other views |
|
193 |
// except if launched from Camera App. |
|
194 |
if (aCustomMessage.Compare(activationParam->Des()) != 0) |
|
195 |
{ |
|
196 |
GfxTransEffect::BeginFullScreen( transitionID, TRect(), |
|
197 |
AknTransEffect::EParameterType, |
|
198 |
AknTransEffect::GfxTransParam( KPhotosUid, |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
199 |
AknTransEffect::TParameter::EEnableEffects) ); |
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
200 |
GfxTransEffect::EndFullScreen(); |
60 | 201 |
} |
202 |
CleanupStack::PopAndDestroy(activationParam); |
|
203 |
} |
|
204 |
||
205 |
// --------------------------------------------------------------------------- |
|
206 |
// From CAknView |
|
207 |
// View deactivation function. |
|
208 |
// --------------------------------------------------------------------------- |
|
209 |
// |
|
210 |
void CGlxGridViewImp::DoMLViewDeactivate() |
|
211 |
{ |
|
212 |
TRACER("CGlxGridViewImp::DoMLViewDeactivate"); |
|
213 |
if(StatusPane()) |
|
214 |
{ |
|
215 |
if(iTitletext) |
|
216 |
{ |
|
217 |
delete iTitletext; |
|
218 |
iTitletext = NULL; |
|
219 |
} |
|
220 |
CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
221 |
TRAP_IGNORE(CAknTitlePane* titlePane = ( CAknTitlePane* )statusPane->ControlL( |
|
222 |
TUid::Uid( EEikStatusPaneUidTitle )); |
|
223 |
iTitletext = titlePane->Text()->AllocL()); |
|
224 |
} |
|
225 |
// Deregister active media list pointer |
|
226 |
iActiveMediaListRegistry->DeregisterActiveMediaList(iMediaList); |
|
227 |
if(iToolbar) |
|
228 |
{ |
|
229 |
delete iToolbar; |
|
230 |
iToolbar = NULL; |
|
231 |
//set the gridtoolbar to NULL in viewbase. |
|
232 |
SetGridToolBar(iToolbar); |
|
233 |
} |
|
234 |
// Destroy Grid widget before going to next view |
|
235 |
DestroyGridWidget(); |
|
236 |
} |
|
237 |
||
238 |
// --------------------------------------------------------------------------- |
|
239 |
// DestroyGridWidget |
|
240 |
// --------------------------------------------------------------------------- |
|
241 |
// |
|
242 |
void CGlxGridViewImp::DestroyGridWidget() |
|
243 |
{ |
|
244 |
TRACER("CGlxGridViewImp::DestroyGridWidget()"); |
|
245 |
//while view deactivating need to remove from the control stack. |
|
246 |
iEikonEnv->AppUi()->RemoveFromViewStack(*this,iGlxGridViewContainer); |
|
247 |
delete iGlxGridViewContainer; |
|
248 |
iGlxGridViewContainer = NULL; |
|
249 |
} |
|
250 |
||
251 |
// --------------------------------------------------------------------------- |
|
252 |
// Destructor |
|
253 |
// --------------------------------------------------------------------------- |
|
254 |
// |
|
255 |
CGlxGridViewImp::~CGlxGridViewImp() |
|
256 |
{ |
|
257 |
TRACER("CGlxGridViewImp::~CGlxGridViewImp"); |
|
258 |
delete iTitletext; |
|
259 |
if(iToolbar) |
|
260 |
{ |
|
261 |
delete iToolbar; |
|
262 |
iToolbar = NULL; |
|
263 |
} |
|
264 |
if (iActiveMediaListRegistry) |
|
265 |
{ |
|
266 |
iActiveMediaListRegistry->Close(); |
|
267 |
} |
|
268 |
} |
|
269 |
||
270 |
// --------------------------------------------------------------------------- |
|
271 |
// From CAknView |
|
272 |
// Returns views id. |
|
273 |
// --------------------------------------------------------------------------- |
|
274 |
TUid CGlxGridViewImp::Id() const |
|
275 |
{ |
|
276 |
TRACER("CGlxGridViewImp::Id()"); |
|
277 |
return TUid::Uid(iViewUID); |
|
278 |
} |
|
279 |
||
280 |
// --------------------------------------------------------------------------- |
|
281 |
// From CAknView |
|
282 |
// Command handling function. |
|
283 |
// --------------------------------------------------------------------------- |
|
284 |
TBool CGlxGridViewImp::HandleViewCommandL(TInt aCommand) |
|
285 |
{ |
|
286 |
TRACER("CGlxGridViewImp::HandleViewCommandL()"); |
|
287 |
GLX_LOG_INFO1( "CGlxGridViewImp::HandleViewCommandL(%x) entering", aCommand ); |
|
288 |
return iGlxGridViewContainer->HandleViewCommandL(aCommand); |
|
289 |
} |
|
290 |
||
291 |
// --------------------------------------------------------------------------- |
|
292 |
// From CAknView |
|
293 |
// HandleForegroundEventL |
|
294 |
// Foreground event handling function. |
|
295 |
// --------------------------------------------------------------------------- |
|
296 |
// |
|
297 |
void CGlxGridViewImp::HandleForegroundEventL(TBool aForeground) |
|
298 |
{ |
|
299 |
TRACER("CGlxGridViewImp::HandleForegroundEventL()"); |
|
300 |
if(iMMCState) |
|
301 |
{ |
|
302 |
iMMCState = EFalse; |
|
303 |
ProcessCommandL(EAknSoftkeyClose); |
|
304 |
} |
|
305 |
CAknView::HandleForegroundEventL(aForeground); |
|
306 |
} |
|
307 |
||
308 |
// --------------------------------------------------------------------------- |
|
309 |
// From MGlxHandleGridEvents |
|
310 |
// HandleGridEventsL() |
|
311 |
// handles processcommandL related commands |
|
312 |
// ----------------------------------------------------------------------------- |
|
313 |
// |
|
314 |
void CGlxGridViewImp::HandleGridEventsL(TInt aCmd) |
|
315 |
{ |
|
316 |
TRACER("CGlxGridViewImp::HandleGridEventsL()"); |
|
317 |
//do processcmd related event handling |
|
318 |
if(EAknSoftkeyClose == aCmd) |
|
319 |
{ |
|
320 |
iMMCState = ETrue; |
|
321 |
} |
|
322 |
ProcessCommandL(aCmd); |
|
323 |
} |
|
324 |
||
325 |
// --------------------------------------------------------------------------- |
|
326 |
// From MGlxHandleButtonMark |
|
327 |
// HandleLatchToolbar() |
|
328 |
// sets toolbar mark unmark status |
|
329 |
// ----------------------------------------------------------------------------- |
|
330 |
// |
|
331 |
void CGlxGridViewImp::HandleLatchToolbar() |
|
332 |
{ |
|
333 |
TRACER("CGlxGridViewImp::HandleLatchToolbarL()"); |
|
334 |
CAknButton* markButton = |
|
335 |
static_cast<CAknButton*> (iToolbar->ControlOrNull( |
|
336 |
EGlxCmdStartMultipleMarking)); |
|
337 |
||
338 |
if(markButton) |
|
339 |
{ |
|
340 |
GLX_DEBUG1("CGlxGridViewImp::HandleLatchToolbar() - UnLatch"); |
|
341 |
markButton->SetCurrentState( KGlxToolbarButtonUnLatched, ETrue ); |
|
342 |
} |
|
343 |
} |
|
344 |
// End of File |