author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 68 | 9da50d567e3c |
parent 63 | f4a778e096c2 |
child 85 | 38bb213f60ba |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2005-2007 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: Phonebook 2 Group UI extension group view. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "CPguGroupView.h" |
|
20 |
||
21 |
// Phonebook 2 |
|
22 |
#include "Pbk2GroupUi.hrh" |
|
23 |
#include <CPbk2UIExtensionView.h> |
|
24 |
#include <CPbk2AppUiBase.h> |
|
25 |
#include <CPbk2NamesListControl.h> |
|
26 |
#include <CPbk2ViewState.h> |
|
27 |
#include <CPbk2ControlContainer.h> |
|
28 |
#include <MPbk2ViewActivationTransaction.h> |
|
29 |
#include <MPbk2ViewExplorer.h> |
|
30 |
#include <CPbk2StoreConfiguration.h> |
|
68
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
31 |
#include <pbk2groupuires.rsg> |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
32 |
#include <pbk2commonui.rsg> |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
33 |
#include <pbk2commands.rsg> |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
34 |
#include <pbk2uicontrols.rsg> |
63 | 35 |
#include <csxhelp/phob.hlp.hrh> |
36 |
#include <MPbk2CommandHandler.h> |
|
37 |
#include <Pbk2UID.h> |
|
38 |
#include <MPbk2AppUi.h> |
|
39 |
#include <CPbk2ViewStateTransformer.h> |
|
40 |
#include <MPbk2StartupMonitor.h> |
|
41 |
#include <CPbk2StorePropertyArray.h> |
|
42 |
#include <CPbk2StoreProperty.h> |
|
43 |
#include <MPbk2ApplicationServices.h> |
|
44 |
#include <MPbk2ContactViewSupplier.h> |
|
45 |
#include <CPbk2ApplicationServices.h> |
|
46 |
#include <MPbk2StoreValidityInformer.h> |
|
47 |
#include <Pbk2MenuFilteringFlags.hrh> |
|
48 |
||
49 |
// Virtual Phonebook |
|
50 |
#include <MVPbkContactStoreList.h> |
|
51 |
#include <CVPbkContactStoreUriArray.h> |
|
52 |
#include <MVPbkContactStore.h> |
|
53 |
#include <CVPbkContactManager.h> |
|
54 |
#include <TVPbkContactStoreUriPtr.h> |
|
55 |
#include <MVPbkContactStoreProperties.h> |
|
56 |
#include <VPbkContactStoreUris.h> |
|
57 |
#include <MVPbkContactViewBase.h> |
|
58 |
#include <MVPbkViewContact.h> |
|
59 |
||
60 |
// System includes |
|
61 |
#include <eikmenup.h> |
|
62 |
#include <eikbtgpc.h> |
|
63 |
#include <avkon.rsg> |
|
64 |
#include <featmgr.h> |
|
65 |
#include <StringLoader.h> |
|
66 |
#include <AiwCommon.hrh> |
|
67 |
#include <eikmenub.h> |
|
68 |
#include <AknUtils.h> |
|
69 |
#include <eiklbx.h> |
|
70 |
#include <eiklbo.h> |
|
71 |
#include <coecntrl.h> |
|
72 |
#include <touchfeedback.h> |
|
73 |
||
74 |
/// Unnamed namespace for local definitions |
|
75 |
namespace { |
|
76 |
||
77 |
_LIT( KNewline, "\n" ); |
|
78 |
||
79 |
/** |
|
80 |
* Returns ETrue if shift is depressed in given key event. |
|
81 |
* |
|
82 |
* @param aKeyEvent Key event |
|
83 |
* @return ETrue if shift is depressed. |
|
84 |
*/ |
|
85 |
inline TBool ShiftDown( const TKeyEvent& aKeyEvent ) |
|
86 |
{ |
|
87 |
return ( aKeyEvent.iModifiers & |
|
88 |
( EModifierShift|EModifierLeftShift|EModifierRightShift ) ) != 0; |
|
89 |
} |
|
90 |
||
91 |
} /// namespace |
|
92 |
||
93 |
// -------------------------------------------------------------------------- |
|
94 |
// CPguGroupView::CPguGroupView |
|
95 |
// -------------------------------------------------------------------------- |
|
96 |
// |
|
97 |
CPguGroupView::CPguGroupView( CPbk2UIExtensionView& aView ) : |
|
98 |
iView( aView ) |
|
99 |
{ |
|
100 |
} |
|
101 |
||
102 |
// -------------------------------------------------------------------------- |
|
103 |
// CPguGroupView::~CPguGroupView |
|
104 |
// -------------------------------------------------------------------------- |
|
105 |
// |
|
106 |
CPguGroupView::~CPguGroupView() |
|
107 |
{ |
|
108 |
if ( iStoreConfiguration ) |
|
109 |
{ |
|
110 |
iStoreConfiguration->RemoveObserver( *this ); |
|
111 |
} |
|
112 |
||
113 |
delete iControlState; |
|
114 |
delete iParamState; |
|
115 |
||
116 |
if ( iContainer ) |
|
117 |
{ |
|
118 |
CCoeEnv::Static()->AppUi()->RemoveFromStack( iContainer ); |
|
119 |
delete iContainer; |
|
120 |
} |
|
121 |
} |
|
122 |
||
123 |
// -------------------------------------------------------------------------- |
|
124 |
// CPguGroupView::NewL |
|
125 |
// -------------------------------------------------------------------------- |
|
126 |
// |
|
127 |
CPguGroupView* CPguGroupView::NewL( CPbk2UIExtensionView& aView ) |
|
128 |
{ |
|
129 |
CPguGroupView* self = new ( ELeave ) CPguGroupView( aView ); |
|
130 |
CleanupStack::PushL( self ); |
|
131 |
self->ConstructL(); |
|
132 |
CleanupStack::Pop( self ); |
|
133 |
return self; |
|
134 |
} |
|
135 |
||
136 |
// -------------------------------------------------------------------------- |
|
137 |
// CPguGroupView::ConstructL |
|
138 |
// -------------------------------------------------------------------------- |
|
139 |
// |
|
140 |
inline void CPguGroupView::ConstructL() |
|
141 |
{ |
|
142 |
iStoreConfiguration = &Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
143 |
StoreConfiguration(); |
|
144 |
||
145 |
iStoreConfiguration->AddObserverL( *this ); |
|
146 |
||
147 |
iCommandHandler = Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
148 |
CommandHandlerL(); |
|
149 |
||
150 |
// Attach AIW providers |
|
151 |
iCommandHandler->RegisterAiwInterestL |
|
152 |
( KAiwCmdPoC, R_PHONEBOOK2_GROUPVIEWS_POC_MENU, |
|
153 |
R_PHONEBOOK2_POCUI_AIW_INTEREST, ETrue ); |
|
154 |
} |
|
155 |
||
156 |
// -------------------------------------------------------------------------- |
|
157 |
// CPguGroupView::HandleStatusPaneSizeChange |
|
158 |
// -------------------------------------------------------------------------- |
|
159 |
// |
|
160 |
void CPguGroupView::HandleStatusPaneSizeChange() |
|
161 |
{ |
|
162 |
// Resize the container to fill the client rectangle |
|
163 |
if ( iContainer ) |
|
164 |
{ |
|
165 |
iContainer->SetRect( iView.ClientRect() ); |
|
166 |
} |
|
167 |
} |
|
168 |
||
169 |
// -------------------------------------------------------------------------- |
|
170 |
// CPguGroupView::ViewStateLC |
|
171 |
// -------------------------------------------------------------------------- |
|
172 |
// |
|
173 |
CPbk2ViewState* CPguGroupView::ViewStateLC() const |
|
174 |
{ |
|
175 |
CPbk2ViewState* state = iControl->ControlStateL(); |
|
176 |
CleanupStack::PushL( state ); |
|
177 |
return state; |
|
178 |
} |
|
179 |
||
180 |
// -------------------------------------------------------------------------- |
|
181 |
// CPguGroupView::HandleCommandKeyL |
|
182 |
// -------------------------------------------------------------------------- |
|
183 |
// |
|
184 |
TBool CPguGroupView::HandleCommandKeyL |
|
185 |
( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
186 |
{ |
|
187 |
TBool result = EFalse; |
|
188 |
TBool itemSpecEnabled = |
|
189 |
Phonebook2::Pbk2AppUi()->ActiveView()->MenuBar()->ItemSpecificCommandsEnabled(); |
|
190 |
if ( itemSpecEnabled && (EStdKeyHash == aKeyEvent.iScanCode) ) |
|
191 |
{ |
|
192 |
//make sure Hash key won't be passed to default keyHandler |
|
193 |
return ETrue; |
|
194 |
} |
|
195 |
if ( aType == EEventKey ) |
|
196 |
{ |
|
197 |
switch ( aKeyEvent.iCode ) |
|
198 |
{ |
|
199 |
case EKeyBackspace: |
|
200 |
{ |
|
201 |
if ( itemSpecEnabled && ( iControl->NumberOfContacts() > 0 ) && |
|
202 |
( iControl->FindTextL() == KNullDesC ) ) |
|
203 |
{ |
|
204 |
HandleCommandL( EPbk2CmdRemoveGroup ); |
|
205 |
result = ETrue; |
|
206 |
} |
|
207 |
break; |
|
208 |
} |
|
209 |
case EKeyEnter: // FALLTHROUGH |
|
210 |
case EKeyOK: |
|
211 |
{ |
|
212 |
if ( !ShiftDown( aKeyEvent ) // pure OK or ENTER key |
|
213 |
&& iControl->NumberOfContacts() == 0 ) |
|
214 |
{ |
|
215 |
result = ETrue; |
|
216 |
} |
|
217 |
break; |
|
218 |
} |
|
219 |
default: |
|
220 |
{ |
|
221 |
break; |
|
222 |
} |
|
223 |
} |
|
224 |
} |
|
225 |
return result; |
|
226 |
} |
|
227 |
||
228 |
||
229 |
||
230 |
// ---------------------------------------------------------------------------- |
|
231 |
// CPguGroupView::HandleListBoxEventL |
|
232 |
// ---------------------------------------------------------------------------- |
|
233 |
// |
|
234 |
void CPguGroupView::HandleListBoxEventL(CEikListBox* /*aListBox*/,TListBoxEvent aEventType) |
|
235 |
{ |
|
236 |
||
237 |
||
238 |
if( AknLayoutUtils::PenEnabled() ) |
|
239 |
{ |
|
240 |
switch ( aEventType ) |
|
241 |
{ |
|
242 |
case EEventItemSingleClicked: |
|
243 |
{ |
|
244 |
ShowContextMenuL(); |
|
245 |
break; |
|
246 |
} |
|
247 |
case EEventItemClicked: //Happens after focus changed |
|
248 |
break; |
|
249 |
case EEventEnterKeyPressed: |
|
250 |
{ |
|
251 |
// Select key is mapped to "Open Group" command |
|
252 |
HandleCommandL( EPbk2CmdOpenGroup ); |
|
253 |
break; |
|
254 |
} |
|
255 |
default: |
|
256 |
break; |
|
257 |
} |
|
258 |
} |
|
259 |
||
260 |
||
261 |
||
262 |
} |
|
263 |
||
264 |
||
265 |
// -------------------------------------------------------------------------- |
|
266 |
// CPguGroupView::HandlePointerEventL |
|
267 |
// -------------------------------------------------------------------------- |
|
268 |
// |
|
269 |
void CPguGroupView::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
270 |
{ |
|
271 |
if ( AknLayoutUtils::PenEnabled() ) |
|
272 |
{ |
|
273 |
if ( iPointerEventInspector->FocusableItemPointed() && iContainer ) |
|
274 |
{ |
|
275 |
iContainer->LongTapDetectorL().PointerEventL( aPointerEvent ); |
|
276 |
} |
|
277 |
if ( iControl->NumberOfContacts()==0) |
|
278 |
{ |
|
279 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
280 |
{ |
|
281 |
MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
282 |
if ( feedback ) |
|
283 |
{ |
|
284 |
feedback->InstantFeedback( ETouchFeedbackNone ); |
|
285 |
} |
|
286 |
} |
|
287 |
else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
288 |
{ |
|
289 |
ShowContextMenuL(); |
|
290 |
} |
|
291 |
} |
|
292 |
||
293 |
} |
|
294 |
} |
|
295 |
||
296 |
||
297 |
||
298 |
||
299 |
||
300 |
||
301 |
// -------------------------------------------------------------------------- |
|
302 |
// CPguGroupView::ShowContextMenuL |
|
303 |
// -------------------------------------------------------------------------- |
|
304 |
// |
|
305 |
void CPguGroupView::ShowContextMenuL() |
|
306 |
{ |
|
307 |
||
308 |
if ( iStylusPopupMenuLaunched ) |
|
309 |
{ |
|
310 |
// Absorb EButton1Up event if we already launched the stylus |
|
311 |
// popup menu |
|
312 |
iStylusPopupMenuLaunched = EFalse; |
|
313 |
} |
|
314 |
else if ( !iPointerEventInspector->SearchFieldPointed() ) |
|
315 |
{ |
|
316 |
if ( iControl->NumberOfContacts() > 0 ) |
|
317 |
{ |
|
318 |
if ( iPointerEventInspector->FocusedItemPointed() ) |
|
319 |
{ |
|
320 |
// Open group |
|
321 |
HandleCommandL(EPbk2CmdOpenGroup); |
|
322 |
} |
|
323 |
} |
|
324 |
} |
|
325 |
} |
|
326 |
||
327 |
||
328 |
||
329 |
// -------------------------------------------------------------------------- |
|
330 |
// CPguGroupView::GetViewSpecificMenuFilteringFlagsL |
|
331 |
// -------------------------------------------------------------------------- |
|
332 |
// |
|
333 |
TInt CPguGroupView::GetViewSpecificMenuFilteringFlagsL() const |
|
334 |
{ |
|
335 |
TInt flags( 0 ); |
|
336 |
flags |= CurrentStoreSupportsGroupsL(); |
|
337 |
if ( iControl ) |
|
338 |
{ |
|
339 |
flags |= iControl->GetMenuFilteringFlagsL(); |
|
340 |
const MVPbkViewContact* contact = iControl->FocusedViewContactL(); |
|
341 |
if( contact && contact->Expandable() ) |
|
342 |
{ |
|
343 |
flags |= KPbk2FocusedItemIsExpandable; |
|
344 |
} |
|
345 |
} |
|
346 |
return flags; |
|
347 |
} |
|
348 |
||
349 |
// -------------------------------------------------------------------------- |
|
350 |
// CPguGroupView::DoActivateL |
|
351 |
// -------------------------------------------------------------------------- |
|
352 |
// |
|
353 |
void CPguGroupView::DoActivateL |
|
354 |
( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, |
|
355 |
const TDesC8& aCustomMessage ) |
|
356 |
{ |
|
357 |
// Add this view to observe menu command events |
|
358 |
iCommandHandler->AddMenuCommandObserver(*this); |
|
359 |
||
360 |
HBufC* title = StringLoader::LoadLC( R_QTN_PHOB_TITLE ); |
|
361 |
||
362 |
MPbk2ViewActivationTransaction* viewActivationTransaction = |
|
363 |
Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC |
|
364 |
( iView.Id(), aPrevViewId, title, NULL, |
|
365 |
Phonebook2::EUpdateNaviPane | Phonebook2::EUpdateTitlePane | |
|
366 |
Phonebook2::EUpdateContextPane ); |
|
367 |
||
368 |
// Check activation parameters |
|
369 |
delete iParamState; |
|
370 |
iParamState = NULL; |
|
371 |
if ( aCustomMessageId == CPbk2ViewState::Uid() ) |
|
372 |
{ |
|
373 |
iParamState = CPbk2ViewState::NewL( aCustomMessage ); |
|
374 |
} |
|
375 |
else if (aCustomMessageId == TUid::Uid(KPbkViewStateUid)) |
|
376 |
{ |
|
377 |
// Handle legacy view state |
|
378 |
CPbk2ViewStateTransformer* transformer = CPbk2ViewStateTransformer::NewLC |
|
379 |
( Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager() ); |
|
380 |
iParamState = transformer-> |
|
381 |
TransformLegacyViewStateToPbk2ViewStateLC( aCustomMessage ); |
|
382 |
CleanupStack::Pop(); |
|
383 |
CleanupStack::PopAndDestroy( transformer ); |
|
384 |
} |
|
385 |
||
386 |
// Notifies startup monitor of view activation |
|
387 |
if (Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()) |
|
388 |
{ |
|
389 |
Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()-> |
|
390 |
NotifyViewActivationL( iView.Id(), |
|
391 |
*Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
392 |
ViewSupplier().AllGroupsViewL() ); |
|
393 |
} |
|
394 |
||
395 |
CreateControlsL(); |
|
396 |
iContainer->ActivateL(); |
|
397 |
||
398 |
||
399 |
CCoeControl* ctrl=iControl->ComponentControl(0); |
|
400 |
CEikListBox* listbox=static_cast <CEikListBox*> (ctrl); |
|
401 |
listbox->SetListBoxObserver( this ); |
|
402 |
||
403 |
||
404 |
viewActivationTransaction->Commit(); |
|
405 |
CleanupStack::PopAndDestroy( 2 ); //title, viewActivationTransaction |
|
406 |
||
407 |
// Should be here because in NOT READY case view does not become ready |
|
408 |
// and cbas are not updated without this. |
|
409 |
UpdateCbasL(); |
|
410 |
} |
|
411 |
||
412 |
// -------------------------------------------------------------------------- |
|
413 |
// CPguGroupView::DoDeactivate |
|
414 |
// -------------------------------------------------------------------------- |
|
415 |
// |
|
416 |
void CPguGroupView::DoDeactivate() |
|
417 |
{ |
|
418 |
iCommandHandler->RemoveMenuCommandObserver( *this ); |
|
419 |
// Trash the old states |
|
420 |
delete iParamState; |
|
421 |
iParamState = NULL; |
|
422 |
delete iControlState; |
|
423 |
iControlState = NULL; |
|
424 |
||
425 |
if ( iContainer ) |
|
426 |
{ |
|
427 |
CCoeEnv::Static()->AppUi()->RemoveFromStack( iContainer ); |
|
428 |
// Store current state, safe to ignore. There's no real harm, |
|
429 |
// if theres no stored state when activating this view again |
|
430 |
TRAP_IGNORE( StoreStateL() ); |
|
431 |
delete iContainer; |
|
432 |
iContainer = NULL; |
|
433 |
iControl = NULL; |
|
434 |
} |
|
435 |
} |
|
436 |
||
437 |
// -------------------------------------------------------------------------- |
|
438 |
// CPguGroupView::HandleCommandL |
|
439 |
// -------------------------------------------------------------------------- |
|
440 |
// |
|
441 |
void CPguGroupView::HandleCommandL( TInt aCommand ) |
|
442 |
{ |
|
443 |
// this will leave if control is NULL due to e.g. bad view switch |
|
444 |
CheckUiControlL(); |
|
445 |
switch( aCommand ) |
|
446 |
{ |
|
447 |
case EAknCmdExit: |
|
448 |
case EAknSoftkeyExit: |
|
449 |
case EPbk2CmdExit: |
|
450 |
case EAknCmdHideInBackground: |
|
451 |
{ |
|
452 |
// AppUi will send the application to background. |
|
453 |
// Because the control is not destroyed it must be reset so that |
|
454 |
// when the view comes foreground again it will look like a fresh |
|
455 |
// and brand new control. |
|
456 |
iControl->Reset(); |
|
457 |
break; |
|
458 |
} |
|
459 |
default: |
|
460 |
break; |
|
461 |
} |
|
462 |
// No command handling in this class, forward to Commands |
|
463 |
if ( !iCommandHandler->HandleCommandL( aCommand, *iControl, &iView ) ) |
|
464 |
{ |
|
465 |
iControl->ProcessCommandL( aCommand ); |
|
466 |
Phonebook2::Pbk2AppUi()->HandleCommandL( aCommand ); |
|
467 |
UpdateCbasL(); |
|
468 |
} |
|
469 |
} |
|
470 |
||
471 |
// -------------------------------------------------------------------------- |
|
472 |
// CPguGroupView::DynInitMenuPaneL |
|
473 |
// -------------------------------------------------------------------------- |
|
474 |
// |
|
475 |
void CPguGroupView::DynInitMenuPaneL( |
|
476 |
TInt aResourceId, |
|
477 |
CEikMenuPane* aMenuPane ) |
|
478 |
{ |
|
479 |
||
480 |
// this will leave if control is NULL due to e.g. bad view switch |
|
481 |
CheckUiControlL(); |
|
482 |
||
483 |
||
484 |
if ( iControl ) |
|
485 |
{ |
|
486 |
// Ask the control do control specific filtering |
|
487 |
// (for example call HandleMarkableListDynInitMenuPane if needed) |
|
488 |
iControl->DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
489 |
} |
|
490 |
||
491 |
switch ( aResourceId ) |
|
492 |
{ |
|
493 |
case R_PHONEBOOK2_GROUPSLIST_MENU: |
|
494 |
{ |
|
495 |
if ( !CurrentStoreSupportsGroupsL() ) |
|
496 |
{ |
|
497 |
aMenuPane->SetItemDimmed( EPbk2CmdCreateNewGroup, ETrue ); |
|
498 |
} |
|
499 |
// Weed out commands not meant to be used with empty list |
|
500 |
if ( iControl->NumberOfContacts() == 0 ) |
|
501 |
{ |
|
502 |
aMenuPane->SetItemDimmed( EPbk2CmdOpenGroup, ETrue ); |
|
503 |
aMenuPane->SetItemDimmed( EPbk2CmdWriteGroup, ETrue ); |
|
504 |
aMenuPane->SetItemDimmed( EPbk2CmdRemoveGroup, ETrue ); |
|
505 |
aMenuPane->SetItemDimmed( EPbk2CmdRenameGroup, ETrue ); |
|
506 |
aMenuPane->SetItemDimmed( EPbk2CmdSetToneToGroup, ETrue ); |
|
507 |
} |
|
508 |
break; |
|
509 |
} |
|
510 |
||
511 |
case R_PHONEBOOK2_GROUPLIST_CONTEXT_MENU: |
|
512 |
{ |
|
513 |
if( !CurrentStoreSupportsGroupsL() ) |
|
514 |
{ |
|
515 |
aMenuPane->SetItemDimmed( EPbk2CmdCreateNewGroup, ETrue ); |
|
516 |
} |
|
517 |
break; |
|
518 |
} |
|
519 |
case R_PHONEBOOK2_INFO_MENU: |
|
520 |
{ |
|
521 |
// If there are no available stores, "memory details" should not be shown in Options menu |
|
522 |
if( !CurrentStoreIsAvailableL() ) |
|
523 |
{ |
|
524 |
aMenuPane->SetItemDimmed( EPbk2CmdPhonebook2Info, ETrue ); |
|
525 |
} |
|
526 |
break; |
|
527 |
} |
|
528 |
default: |
|
529 |
{ |
|
530 |
// Phonebook 2 menu filtering happens in Commands |
|
531 |
iCommandHandler->DynInitMenuPaneL( |
|
532 |
aResourceId, aMenuPane, iView, *iControl ); |
|
533 |
} |
|
534 |
} |
|
535 |
} |
|
536 |
||
537 |
// -------------------------------------------------------------------------- |
|
538 |
// CPguGroupView::HandleLongTapEventL |
|
539 |
// -------------------------------------------------------------------------- |
|
540 |
// |
|
541 |
void CPguGroupView::HandleLongTapEventL( |
|
542 |
const TPoint& /*aPenEventLocation*/, |
|
543 |
const TPoint& aPenEventScreenLocation ) |
|
544 |
{ |
|
545 |
if( iControl->ContactsMarked() ) |
|
546 |
{ |
|
547 |
//if there are marked contacts, context menu should not open |
|
548 |
return; |
|
549 |
} |
|
550 |
} |
|
551 |
||
552 |
// -------------------------------------------------------------------------- |
|
553 |
// CPguGroupView::HandleControlEventL |
|
554 |
// -------------------------------------------------------------------------- |
|
555 |
// |
|
556 |
void CPguGroupView::HandleControlEventL |
|
557 |
( MPbk2ContactUiControl& /*aControl*/, |
|
558 |
const TPbk2ControlEvent& aEvent ) |
|
559 |
{ |
|
560 |
switch ( aEvent.iEventType ) |
|
561 |
{ |
|
562 |
case TPbk2ControlEvent::EReady: |
|
563 |
{ |
|
564 |
UpdateCbasL(); |
|
565 |
||
566 |
// Restore control state |
|
567 |
RestoreStateL(); |
|
568 |
break; |
|
569 |
} |
|
570 |
case TPbk2ControlEvent::EItemAdded: |
|
571 |
case TPbk2ControlEvent::EItemRemoved: |
|
572 |
case TPbk2ControlEvent::EContactSetChanged: |
|
573 |
{ |
|
574 |
UpdateCbasL(); |
|
575 |
break; |
|
576 |
} |
|
577 |
case TPbk2ControlEvent::EControlStateChanged: |
|
578 |
{ |
|
579 |
UpdateCbasL(); |
|
580 |
iListControlState = aEvent.iInt; |
|
581 |
UpdateListEmptyTextL(); |
|
582 |
iContainer->Control()->DrawDeferred(); |
|
583 |
break; |
|
584 |
} |
|
585 |
default: |
|
586 |
{ |
|
587 |
// Do nothing |
|
588 |
break; |
|
589 |
} |
|
590 |
} |
|
591 |
} |
|
592 |
||
593 |
// -------------------------------------------------------------------------- |
|
594 |
// CPguGroupView::ConfigurationChanged |
|
595 |
// -------------------------------------------------------------------------- |
|
596 |
// |
|
597 |
void CPguGroupView::ConfigurationChanged() |
|
598 |
{ |
|
599 |
if ( iContainer ) |
|
600 |
{ |
|
601 |
iContainer->Control()->Reset(); |
|
602 |
} |
|
603 |
} |
|
604 |
||
605 |
// -------------------------------------------------------------------------- |
|
606 |
// CPguGroupView::ConfigurationChangedComplete |
|
607 |
// -------------------------------------------------------------------------- |
|
608 |
// |
|
609 |
void CPguGroupView::ConfigurationChangedComplete() |
|
610 |
{ |
|
611 |
if ( iContainer ) |
|
612 |
{ |
|
613 |
TRAPD( error, HandleConfigurationChangeL() ); |
|
614 |
if ( error != KErrNone ) |
|
615 |
{ |
|
616 |
CCoeEnv::Static()->HandleError( error ); |
|
617 |
iContainer->Control()->Reset(); |
|
618 |
} |
|
619 |
} |
|
620 |
} |
|
621 |
||
622 |
// -------------------------------------------------------------------------- |
|
623 |
// CPguGroupView::PreCommandExecutionL |
|
624 |
// -------------------------------------------------------------------------- |
|
625 |
// |
|
626 |
void CPguGroupView::PreCommandExecutionL |
|
627 |
( const MPbk2Command& /*aCommand*/ ) |
|
628 |
{ |
|
629 |
// Do nothing |
|
630 |
} |
|
631 |
||
632 |
// -------------------------------------------------------------------------- |
|
633 |
// CPguGroupMembersView::PostCommandExecutionL |
|
634 |
// -------------------------------------------------------------------------- |
|
635 |
// |
|
636 |
void CPguGroupView::PostCommandExecutionL |
|
637 |
( const MPbk2Command& /*aCommand*/ ) |
|
638 |
{ |
|
639 |
UpdateCbasL(); |
|
640 |
} |
|
641 |
||
642 |
// -------------------------------------------------------------------------- |
|
643 |
// CPguGroupView::CurrentStoreSupportsGroupsL |
|
644 |
// -------------------------------------------------------------------------- |
|
645 |
// |
|
646 |
TBool CPguGroupView::CurrentStoreSupportsGroupsL() const |
|
647 |
{ |
|
648 |
TBool ret = EFalse; |
|
649 |
MVPbkContactStoreList& stores = |
|
650 |
Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
651 |
ContactManager().ContactStoresL(); |
|
652 |
CVPbkContactStoreUriArray* uris = |
|
653 |
iStoreConfiguration->CurrentConfigurationL(); |
|
654 |
CleanupStack::PushL( uris ); |
|
655 |
||
656 |
const TInt count = uris->Count(); |
|
657 |
for ( TInt i = count - 1; i >= 0; --i ) |
|
658 |
{ |
|
659 |
MVPbkContactStore* store = stores.Find( ( *uris )[i] ); |
|
660 |
if ( store ) |
|
661 |
{ |
|
662 |
// If we found atleast one store having groups we |
|
663 |
// return the flag. |
|
664 |
if ( store->StoreProperties().SupportsContactGroups() ) |
|
665 |
{ |
|
666 |
ret = ETrue; |
|
667 |
break; |
|
668 |
} |
|
669 |
} |
|
670 |
} |
|
671 |
||
672 |
CleanupStack::PopAndDestroy( uris ); |
|
673 |
return ret; |
|
674 |
} |
|
675 |
||
676 |
// -------------------------------------------------------------------------- |
|
677 |
// CPguGroupView::CurrentStoreIsAvailable |
|
678 |
// -------------------------------------------------------------------------- |
|
679 |
// |
|
680 |
TBool CPguGroupView::CurrentStoreIsAvailableL() const |
|
681 |
{ |
|
682 |
TBool ret = ETrue; |
|
683 |
CPbk2ApplicationServices* appServices = CPbk2ApplicationServices::InstanceLC(); |
|
684 |
||
685 |
// Returns the stores that are currently available and open(selected by user in Settings). |
|
686 |
CVPbkContactStoreUriArray* aValidStores = appServices->StoreValidityInformer().CurrentlyValidStoresL(); |
|
687 |
CleanupStack::PushL( aValidStores ); |
|
688 |
if( 0 == aValidStores->Count() ) |
|
689 |
{ |
|
690 |
ret = EFalse; |
|
691 |
} |
|
692 |
CleanupStack::PopAndDestroy(); // aValidStores |
|
693 |
CleanupStack::PopAndDestroy(); // appServices |
|
694 |
return ret; |
|
695 |
} |
|
696 |
||
697 |
// -------------------------------------------------------------------------- |
|
698 |
// CPguGroupView::CreateControlsL |
|
699 |
// -------------------------------------------------------------------------- |
|
700 |
// |
|
701 |
void CPguGroupView::CreateControlsL() |
|
702 |
{ |
|
703 |
if ( !iContainer ) |
|
704 |
{ |
|
705 |
// Create the container and control |
|
706 |
CContainer* container = CContainer::NewLC( &iView, &iView, iView ); |
|
707 |
||
708 |
container->SetHelpContext( TCoeHelpContext |
|
709 |
( iView.ApplicationUid(), KPHOB_HLP_GROUP_LIST ) ); |
|
710 |
||
711 |
MPbk2ApplicationServices& appServices = |
|
712 |
Phonebook2::Pbk2AppUi()->ApplicationServices(); |
|
713 |
||
714 |
CPbk2NamesListControl* control = CPbk2NamesListControl::NewL |
|
715 |
( R_PBK2_GROUPS_LIST_CONTROL, container, |
|
716 |
appServices.ContactManager(), |
|
717 |
*appServices.ViewSupplier().AllGroupsViewL(), |
|
718 |
appServices.NameFormatter(), |
|
719 |
appServices.StoreProperties() ); |
|
720 |
CleanupStack::PushL( control ); |
|
721 |
||
722 |
control->AddObserverL( *this ); |
|
723 |
// takes ownership |
|
724 |
container->SetControl( control, iView.ClientRect() ); |
|
725 |
CleanupStack::Pop( control ); |
|
726 |
||
727 |
CCoeEnv::Static()->AppUi()->AddToStackL( iView, container ); |
|
728 |
CleanupStack::Pop( container ); |
|
729 |
iContainer = container; |
|
730 |
iControl = control; |
|
731 |
iPointerEventInspector = control; |
|
732 |
} |
|
733 |
} |
|
734 |
||
735 |
// -------------------------------------------------------------------------- |
|
736 |
// CPguGroupView::StoreStateL |
|
737 |
// -------------------------------------------------------------------------- |
|
738 |
// |
|
739 |
void CPguGroupView::StoreStateL() |
|
740 |
{ |
|
741 |
CPbk2ViewState* state = ViewStateLC(); |
|
742 |
CleanupStack::Pop(state); |
|
743 |
if ( state ) |
|
744 |
{ |
|
745 |
delete iControlState; |
|
746 |
iControlState = state; |
|
747 |
} |
|
748 |
} |
|
749 |
||
750 |
// -------------------------------------------------------------------------- |
|
751 |
// CPguGroupView::RestoreStateL |
|
752 |
// -------------------------------------------------------------------------- |
|
753 |
// |
|
754 |
void CPguGroupView::RestoreStateL() |
|
755 |
{ |
|
756 |
iControl->RestoreControlStateL( iControlState ); |
|
757 |
iControl->RestoreControlStateL( iParamState); |
|
758 |
delete iControlState; |
|
759 |
iControlState = NULL; |
|
760 |
} |
|
761 |
||
762 |
// -------------------------------------------------------------------------- |
|
763 |
// CPguGroupView::UpdateCbasL |
|
764 |
// -------------------------------------------------------------------------- |
|
765 |
// |
|
766 |
void CPguGroupView::UpdateCbasL() |
|
767 |
{ |
|
768 |
if ( iControl ) |
|
769 |
{ |
|
770 |
if ( iControl->NumberOfContacts() > 0 ) |
|
771 |
{ |
|
772 |
// Set middle softkey as Open. |
|
773 |
iView.Cba()->SetCommandSetL( R_PGU_SOFTKEYS_OPTIONS_EXIT_OPEN ); |
|
774 |
iView.Cba()->DrawDeferred(); |
|
775 |
} |
|
776 |
else |
|
777 |
{ |
|
778 |
// Set middle softkey as Context menu. |
|
779 |
iView.Cba()->SetCommandSetL( |
|
780 |
R_PBK2_SOFTKEYS_OPTIONS_EXIT_CONTEXT ); |
|
781 |
iView.Cba()->DrawDeferred(); |
|
782 |
// Change context menu when nameslist is empty |
|
783 |
iView.MenuBar()->SetContextMenuTitleResourceId |
|
784 |
( R_PHONEBOOK2_GROUPLIST_CONTEXT_MENUBAR ); |
|
785 |
} |
|
786 |
} |
|
787 |
} |
|
788 |
||
789 |
||
790 |
// -------------------------------------------------------------------------- |
|
791 |
// CPguGroupView::UpdateListEmptyTextL |
|
792 |
// -------------------------------------------------------------------------- |
|
793 |
// |
|
794 |
void CPguGroupView::UpdateListEmptyTextL() |
|
795 |
{ |
|
796 |
HBufC* text = NULL; |
|
797 |
switch ( iListControlState ) |
|
798 |
{ |
|
799 |
case CPbk2NamesListControl::EStateEmpty: |
|
800 |
case CPbk2NamesListControl::EStateNotReady: |
|
801 |
{ |
|
802 |
text = StringLoader::LoadLC( R_QTN_PHOB_NO_GROUPS ); |
|
803 |
||
804 |
CVPbkContactStoreUriArray* uris = |
|
805 |
iStoreConfiguration->CurrentConfigurationL(); |
|
806 |
CleanupStack::PushL( uris ); |
|
807 |
||
808 |
HBufC* helpText = NULL; |
|
809 |
TInt numberOfStores = uris->Count(); |
|
810 |
if ( CurrentStoreSupportsGroupsL() ) |
|
811 |
{ |
|
812 |
// At least one memory in use which supports groups |
|
813 |
helpText = StringLoader::LoadLC( R_QTN_PHOB_NO_GROUPS_LONGER ); |
|
814 |
} |
|
815 |
else if ( numberOfStores > 1 ) |
|
816 |
{ |
|
817 |
// More than one memories in use, but none of them support groups |
|
818 |
helpText = StringLoader::LoadLC( R_QTN_PHOB_NO_GROUPS_STORES ); |
|
819 |
} |
|
820 |
else if ( numberOfStores == 1 ) |
|
821 |
{ |
|
822 |
// The only used memory does not support groups |
|
823 |
const CPbk2StoreProperty* props = |
|
824 |
Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
825 |
StoreProperties().FindProperty( (*uris)[0] ); |
|
826 |
if ( props ) |
|
827 |
{ |
|
828 |
helpText = StringLoader::LoadLC( |
|
829 |
R_QTN_PHOB_NO_GROUPS_STORE, props->StoreName() ); |
|
830 |
} |
|
831 |
} |
|
832 |
||
833 |
if ( !helpText ) |
|
834 |
{ |
|
835 |
CleanupStack::PopAndDestroy(); // uris |
|
836 |
} |
|
837 |
else |
|
838 |
{ |
|
839 |
TInt newLength = text->Length() |
|
840 |
+ KNewline().Length() |
|
841 |
+ helpText->Length(); |
|
842 |
||
843 |
text = text->ReAllocL( newLength ); |
|
844 |
// note: no leaves beyond this point, otherwise |
|
845 |
text->Des().Append( KNewline ); |
|
846 |
text->Des().Append( *helpText ); |
|
847 |
||
848 |
CleanupStack::PopAndDestroy( 2 ); // helpText, uris |
|
849 |
// update the reallocated 'text' pointer in cleanup stack |
|
850 |
CleanupStack::Pop(); // text |
|
851 |
CleanupStack::PushL( text ); |
|
852 |
} |
|
853 |
break; |
|
854 |
} |
|
855 |
default: |
|
856 |
{ |
|
857 |
text = KNullDesC().AllocLC(); |
|
858 |
break; |
|
859 |
} |
|
860 |
} |
|
861 |
if ( text ) |
|
862 |
{ |
|
863 |
iControl->SetTextL( *text ); |
|
864 |
CleanupStack::PopAndDestroy(); // text |
|
865 |
} |
|
866 |
} |
|
867 |
||
868 |
// -------------------------------------------------------------------------- |
|
869 |
// CPguGroupView::HandleConfigurationChangeL |
|
870 |
// -------------------------------------------------------------------------- |
|
871 |
// |
|
872 |
void CPguGroupView::HandleConfigurationChangeL() |
|
873 |
{ |
|
874 |
// Force empty list text update after configuration change |
|
875 |
UpdateListEmptyTextL(); |
|
876 |
||
877 |
UpdateCbasL(); |
|
878 |
if ( iContainer && iContainer->Control() ) |
|
879 |
{ |
|
880 |
iContainer->Control()->SetViewL |
|
881 |
( *Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
882 |
ViewSupplier().AllGroupsViewL() ); |
|
883 |
iContainer->Control()->DrawNow(); |
|
884 |
} |
|
885 |
} |
|
886 |
||
887 |
||
888 |
// -------------------------------------------------------------------------- |
|
889 |
// CPguGroupView::UiControlL |
|
890 |
// -------------------------------------------------------------------------- |
|
891 |
// |
|
892 |
void CPguGroupView::CheckUiControlL() |
|
893 |
{ |
|
894 |
||
895 |
// check if we have invalid control |
|
896 |
if (iControl==NULL) |
|
897 |
{ |
|
898 |
// leave with bad handle error since iControl is missing |
|
899 |
User::Leave(KErrBadHandle); |
|
900 |
} |
|
901 |
} |
|
902 |
||
903 |
||
904 |
// End of File |