|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * Memory selection setting page for Phonebook 2. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "CPbk2MemorySelectionSettingPage.h" |
|
21 |
|
22 // system includes |
|
23 #include <akncheckboxsettingpage.h> |
|
24 |
|
25 namespace |
|
26 { |
|
27 #ifdef _DEBUG |
|
28 enum TPanicCode |
|
29 { |
|
30 EPanic_InvalidIndex = 1 |
|
31 }; |
|
32 |
|
33 void Panic( TPanicCode aCode ) |
|
34 { |
|
35 _LIT( KPanicCat, "CPbk2MemorySelectionSettingPage" ); |
|
36 User::Panic( KPanicCat, aCode ); |
|
37 } |
|
38 #endif // _DEBUG |
|
39 } |
|
40 |
|
41 |
|
42 CPbk2MemorySelectionSettingPage::CPbk2MemorySelectionSettingPage( |
|
43 TInt aResourceID, |
|
44 CSelectionItemList* aItemArray ) : |
|
45 CAknCheckBoxSettingPage( aResourceID, aItemArray ), |
|
46 iItemsArray( aItemArray ) |
|
47 { |
|
48 } |
|
49 |
|
50 CPbk2MemorySelectionSettingPage::~CPbk2MemorySelectionSettingPage() |
|
51 { |
|
52 } |
|
53 |
|
54 void CPbk2MemorySelectionSettingPage::UpdateSettingL() |
|
55 { |
|
56 CAknCheckBoxSettingPage::UpdateSettingL(); |
|
57 UpdateCbaL(); |
|
58 } |
|
59 |
|
60 void CPbk2MemorySelectionSettingPage::UpdateCbaL() |
|
61 { |
|
62 TBool validLabels = EFalse; |
|
63 if ( InvalidDataCbaResourceId() != DefaultCbaResourceId() ) |
|
64 { |
|
65 // Check that atleast one of the items is marked |
|
66 const TInt count( iItemsArray->Count() ); |
|
67 for ( TInt i(0); i < count; ++i ) |
|
68 { |
|
69 if ( iItemsArray->At( i )->SelectionStatus() ) |
|
70 { |
|
71 validLabels = ETrue; |
|
72 break; |
|
73 } |
|
74 } |
|
75 } |
|
76 |
|
77 TInt selectedItem( ListBoxControl()->CurrentItemIndex() ); |
|
78 |
|
79 __ASSERT_DEBUG( selectedItem > KErrNotFound |
|
80 && selectedItem < iItemsArray->Count(), Panic( EPanic_InvalidIndex ) ); |
|
81 |
|
82 if ( iItemsArray->At( selectedItem )->SelectionStatus() ) |
|
83 { |
|
84 Cba()->SetCommandSetL( DefaultCbaResourceId() ); |
|
85 } |
|
86 else |
|
87 { |
|
88 if ( validLabels ) |
|
89 { |
|
90 Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OK_CANCEL__MARK ); |
|
91 } |
|
92 else |
|
93 { |
|
94 Cba()->SetCommandSetL( InvalidDataCbaResourceId() ); |
|
95 } |
|
96 } |
|
97 Cba()->DrawDeferred(); |
|
98 } |
|
99 |
|
100 |
|
101 void CPbk2MemorySelectionSettingPage::HandleControlEventL( |
|
102 CCoeControl* /*aControl*/, |
|
103 TCoeEvent aEventType ) |
|
104 { |
|
105 if ( aEventType == EEventStateChanged ) |
|
106 { |
|
107 UpdateCbaL(); |
|
108 } |
|
109 } |
|
110 |
|
111 void CPbk2MemorySelectionSettingPage::ProcessCommandL( TInt aCommandId ) |
|
112 { |
|
113 switch( aCommandId ) |
|
114 { |
|
115 case EAknSoftkeyUnmark: // FALLTHROUGH |
|
116 case EAknSoftkeyMark: |
|
117 { |
|
118 // Map these events to select event. |
|
119 aCommandId = EAknSoftkeySelect; |
|
120 break; |
|
121 } |
|
122 default:; |
|
123 } |
|
124 CAknCheckBoxSettingPage::ProcessCommandL( aCommandId ); |
|
125 } |
|
126 |
|
127 // End of File |