|
1 /* |
|
2 * Copyright (c) 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 for mrui dynamic item selection list |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include "cesmrdynamicitemselectionlist.h" |
|
22 |
|
23 #include <aknlists.h> |
|
24 #include <aknPopup.h> |
|
25 #include <bautils.h> |
|
26 #include <esmrgui.rsg> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 |
|
29 #include "esmrhelper.h"//locateresourcefile |
|
30 |
|
31 // CONSTANTS |
|
32 // Unnamed namespace for local definitions |
|
33 namespace { // codescanner::namespace |
|
34 |
|
35 #ifdef _DEBUG |
|
36 _LIT( KESMRDynamicItemSelectionListPanicTxt, "ESMRDYNAMICITEMSELECTIONLIST" ); |
|
37 /** Enumeration for panic codes */ |
|
38 enum TESMRDynamicItemSelectionListPanicCode |
|
39 { |
|
40 // Errors |
|
41 EESMRDynamicItemSelectioListInvalidListType = 0 |
|
42 }; |
|
43 |
|
44 void Panic( TESMRDynamicItemSelectionListPanicCode aPanic ) |
|
45 { |
|
46 User::Panic ( KESMRDynamicItemSelectionListPanicTxt, aPanic ); |
|
47 } |
|
48 #endif |
|
49 |
|
50 // resource file: |
|
51 _LIT( KResourceFileName, "esmrgui.rsc" ); |
|
52 |
|
53 } // namespace |
|
54 |
|
55 // ======== MEMBER FUNCTIONS ======== |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CESMRAddressSelectionQuery::CESMRAddressSelectionQuery |
|
59 // C++ default constructor can NOT contain any code, that |
|
60 // might leave. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CESMRDynamicItemSelectionList::CESMRDynamicItemSelectionList() |
|
64 { |
|
65 FUNC_LOG; |
|
66 // Do nothing |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CESMRDynamicItemSelectionList::~CESMRDynamicItemSelectionList |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CESMRDynamicItemSelectionList::~CESMRDynamicItemSelectionList() |
|
74 { |
|
75 FUNC_LOG; |
|
76 iEnv->DeleteResourceFile( iResourceOffset ); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CESMRDynamicItemSelectionList::NewL |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CESMRDynamicItemSelectionList* CESMRDynamicItemSelectionList::NewL() |
|
84 { |
|
85 FUNC_LOG; |
|
86 CESMRDynamicItemSelectionList* self = |
|
87 new (ELeave) CESMRDynamicItemSelectionList(); |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL( ); |
|
90 CleanupStack::Pop( self ); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CESMRDynamicItemSelectionList::ConstructL |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CESMRDynamicItemSelectionList::ConstructL() |
|
99 { |
|
100 FUNC_LOG; |
|
101 TFileName filename; |
|
102 |
|
103 iEnv = CEikonEnv::Static(); // codescanner::eikonenvstatic |
|
104 |
|
105 ESMRHelper::LocateResourceFile( |
|
106 KResourceFileName, |
|
107 KDC_RESOURCE_FILES_DIR, |
|
108 filename, |
|
109 &iEnv->FsSession() ); |
|
110 |
|
111 //for localization |
|
112 BaflUtils::NearestLanguageFile(iEnv->FsSession(),filename); |
|
113 iResourceOffset = iEnv->AddResourceFileL(filename); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CESMRDynamicItemSelectionList::ExecuteL |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 TInt CESMRDynamicItemSelectionList::ExecuteL( // codescanner::intleaves |
|
121 const RPointerArray<HBufC>& aItemArray, |
|
122 const TESMRSelectionListType aType ) |
|
123 { |
|
124 FUNC_LOG; |
|
125 CPtrCArray* array = new (ELeave) CPtrCArray( 1 ); |
|
126 CleanupStack::PushL( array ); |
|
127 array->SetReserveL( aItemArray.Count() ); |
|
128 |
|
129 for ( TInt i = 0; i < aItemArray.Count(); ++i ) |
|
130 { |
|
131 array->AppendL( *aItemArray[i] ); |
|
132 } |
|
133 |
|
134 TInt retVal = ExecuteL( *array, aType ); |
|
135 CleanupStack::PopAndDestroy( array ); |
|
136 return retVal; |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CESMRDynamicItemSelectionList::ExecuteL |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 TInt CESMRDynamicItemSelectionList::ExecuteL( // codescanner::intleaves |
|
144 MDesCArray& aItemArray, |
|
145 const TESMRSelectionListType aType ) |
|
146 { |
|
147 FUNC_LOG; |
|
148 TInt response( KErrCancel ); |
|
149 |
|
150 CEikFormattedCellListBox* listBox = NULL; |
|
151 CAknPopupList* popupList = NULL; |
|
152 |
|
153 switch( aType ) |
|
154 { |
|
155 case EESMRAddressSelectionList: |
|
156 { |
|
157 listBox = new( ELeave )CAknDoublePopupMenuStyleListBox; |
|
158 CleanupStack::PushL( listBox ); |
|
159 |
|
160 popupList = CAknPopupList::NewL( listBox, |
|
161 R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, |
|
162 AknPopupLayouts::EMenuDoubleWindow ); |
|
163 CleanupStack::PushL( popupList ); |
|
164 |
|
165 popupList->SetTitleL( |
|
166 *iEnv->AllocReadResourceAsDes16LC( |
|
167 R_QTN_MEET_REQ_LOC_ADDRESS_SELECTION_TITLE ) ); |
|
168 CleanupStack::PopAndDestroy(); // Resource string //codescanner::cleanup |
|
169 break; |
|
170 } |
|
171 case EESMRRecentLocationList: |
|
172 { |
|
173 listBox = new( ELeave )CAknSinglePopupMenuStyleListBox; |
|
174 CleanupStack::PushL( listBox ); |
|
175 |
|
176 popupList = CAknPopupList::NewL( listBox, |
|
177 R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, |
|
178 AknPopupLayouts::EMenuWindow ); |
|
179 CleanupStack::PushL( popupList ); |
|
180 |
|
181 popupList->SetTitleL( |
|
182 *iEnv->AllocReadResourceAsDes16LC( |
|
183 R_QTN_MEET_REQ_RECENT_LOCATIONS_SELECTION_TITLE ) ); |
|
184 CleanupStack::PopAndDestroy(); // Resource string //codescanner::cleanup |
|
185 break; |
|
186 } |
|
187 default: |
|
188 { |
|
189 __ASSERT_DEBUG( |
|
190 EFalse, Panic( EESMRDynamicItemSelectioListInvalidListType )); |
|
191 break; |
|
192 } |
|
193 } |
|
194 |
|
195 listBox->ConstructL( popupList, EAknListBoxMenuList ); |
|
196 listBox->CreateScrollBarFrameL( ETrue ); |
|
197 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
198 CEikScrollBarFrame::EOff, |
|
199 CEikScrollBarFrame::EOn ); |
|
200 |
|
201 listBox->Model()->SetItemTextArray( &aItemArray ); |
|
202 listBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
203 |
|
204 // Show popup list |
|
205 TBool popupOk = popupList->ExecuteLD(); |
|
206 if ( popupOk ) |
|
207 { |
|
208 response = listBox->CurrentItemIndex(); |
|
209 } |
|
210 |
|
211 CleanupStack::Pop( popupList ); |
|
212 CleanupStack::PopAndDestroy( listBox ); |
|
213 |
|
214 return response; |
|
215 } |
|
216 |
|
217 // End of File |
|
218 |