1 /* |
|
2 * Copyright (c) 2006-2008 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: Setting list container in file manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <filemanager.rsg> |
|
22 #include <aknlists.h> |
|
23 #include <barsread.h> |
|
24 #include <eikclbd.h> |
|
25 #include <gulicon.h> |
|
26 #include <aknconsts.h> |
|
27 #include <AknIconArray.h> |
|
28 #include <avkon.mbg> |
|
29 #include <filemanager.mbg> |
|
30 #include <CFileManagerEngine.h> |
|
31 #include <FileManagerEngine.hrh> |
|
32 #include "FileManager.hrh" |
|
33 #include "CFileManagerDocument.h" |
|
34 #include "CFileManagerIconArray.h" |
|
35 #include "CFileManagerSettingListContainer.h" |
|
36 |
|
37 |
|
38 // needed because _LIT macro does not expand parameter, which is also macro |
|
39 #define _CREATE_LIT(a,b) _LIT(a,b) |
|
40 |
|
41 // CONSTANTS |
|
42 const TInt KRestoreIconListGranularity = 3; |
|
43 _CREATE_LIT( KFileManagerBitmapFile, filemanager_mbm_file_location ); |
|
44 |
|
45 |
|
46 // ============================ MEMBER FUNCTIONS =============================== |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CFileManagerSettingListContainer::CFileManagerSettingListContainer |
|
50 // C++ default constructor can NOT contain any code, that |
|
51 // might leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CFileManagerSettingListContainer::CFileManagerSettingListContainer( |
|
55 const TListType aType ) : |
|
56 iType( aType ) |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CFileManagerSettingListContainer::ConstructL |
|
62 // |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CFileManagerSettingListContainer::ConstructL( |
|
66 const TRect& aRect, |
|
67 const TInt aFocusedIndex, |
|
68 MDesCArray* aArray, |
|
69 const TDesC& aHelpContext ) |
|
70 { |
|
71 CFileManagerContainerBase::ConstructL( aRect, aFocusedIndex ); |
|
72 SetTextArray( aArray ); |
|
73 SetHelpContext( aHelpContext ); |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CFileManagerSettingListContainer::CreateListBoxL |
|
78 // |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CEikTextListBox* CFileManagerSettingListContainer::CreateListBoxL() |
|
82 { |
|
83 CEikTextListBox* listBox = NULL; |
|
84 |
|
85 switch ( iType ) |
|
86 { |
|
87 case EListBackup: |
|
88 { |
|
89 listBox = CreateBackupListBoxL(); |
|
90 break; |
|
91 } |
|
92 case EListRestore: |
|
93 { |
|
94 listBox = CreateRestoreListBoxL(); |
|
95 break; |
|
96 } |
|
97 default: |
|
98 { |
|
99 break; |
|
100 } |
|
101 } |
|
102 |
|
103 return listBox; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CFileManagerSettingListContainer::CreateBackupListBoxL |
|
108 // |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 CEikTextListBox* CFileManagerSettingListContainer::CreateBackupListBoxL() |
|
112 { |
|
113 CAknSettingStyleListBox* listBox = new( ELeave ) CAknSettingStyleListBox; |
|
114 CleanupStack::PushL( listBox ); |
|
115 listBox->SetContainerWindowL( *this ); |
|
116 listBox->ConstructL( this, EAknListBoxSelectionList ); |
|
117 listBox->ItemDrawer()->ColumnData()->SetSkinEnabledL( ETrue ); |
|
118 CleanupStack::Pop( listBox ); |
|
119 return listBox; |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CFileManagerSettingListContainer::CreateRestoreListBoxL |
|
124 // |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 CEikTextListBox* CFileManagerSettingListContainer::CreateRestoreListBoxL() |
|
128 { |
|
129 CAknAppUi* appUi = static_cast< CAknAppUi* >( ControlEnv()->AppUi() ); |
|
130 CFileManagerDocument* doc = |
|
131 static_cast< CFileManagerDocument* >( appUi->Document() ); |
|
132 CAknDoubleGraphicStyleListBox* listBox = |
|
133 new( ELeave ) CAknDoubleGraphicStyleListBox; |
|
134 CleanupStack::PushL( listBox ); |
|
135 listBox->SetContainerWindowL( *this ); |
|
136 listBox->ConstructL( this, EAknListBoxMultiselectionList ); |
|
137 listBox->ItemDrawer()->ColumnData()->SetSkinEnabledL( ETrue ); |
|
138 |
|
139 // Create icon array and icons |
|
140 CAknIconArray* iconArray = new( ELeave ) CAknIconArray( |
|
141 KRestoreIconListGranularity ); |
|
142 listBox->ItemDrawer()-> |
|
143 ColumnData()->SetIconArray( iconArray ); // changes ownership |
|
144 |
|
145 CGulIcon* icon = CFileManagerIconArray::LoadIconL( |
|
146 KAvkonBitmapFile, |
|
147 EMbmAvkonQgn_indi_checkbox_on, |
|
148 EMbmAvkonQgn_indi_checkbox_on_mask, |
|
149 KAknsIIDQgnIndiCheckboxOn.iMajor, |
|
150 KAknsIIDQgnIndiCheckboxOn.iMinor, |
|
151 ETrue ); |
|
152 CleanupStack::PushL( icon ); |
|
153 iconArray->AppendL( icon ); |
|
154 CleanupStack::Pop( icon ); |
|
155 |
|
156 icon = CFileManagerIconArray::LoadIconL( |
|
157 KAvkonBitmapFile, |
|
158 EMbmAvkonQgn_indi_checkbox_off, |
|
159 EMbmAvkonQgn_indi_checkbox_off_mask, |
|
160 KAknsIIDQgnIndiCheckboxOff.iMajor, |
|
161 KAknsIIDQgnIndiCheckboxOff.iMinor, |
|
162 ETrue ); |
|
163 CleanupStack::PushL( icon ); |
|
164 iconArray->AppendL( icon ); |
|
165 CleanupStack::Pop( icon ); |
|
166 |
|
167 icon = CFileManagerIconArray::LoadIconL( |
|
168 KFileManagerBitmapFile, |
|
169 EMbmFilemanagerQgn_indi_mmc_add, |
|
170 EMbmFilemanagerQgn_indi_mmc_add_mask, |
|
171 KAknsIIDQgnIndiMmcAdd.iMajor, |
|
172 KAknsIIDQgnIndiMmcAdd.iMinor, |
|
173 ETrue ); |
|
174 CleanupStack::PushL( icon ); |
|
175 iconArray->AppendL( icon ); |
|
176 CleanupStack::Pop( icon ); |
|
177 |
|
178 icon = CFileManagerIconArray::LoadIconL( |
|
179 KFileManagerBitmapFile, |
|
180 EMbmFilemanagerQgn_indi_usb_memc, |
|
181 EMbmFilemanagerQgn_indi_usb_memc_mask, |
|
182 KAknsIIDQgnIndiMmcAdd.iMajor, |
|
183 KAknsIIDQgnIndiMmcAdd.iMinor, |
|
184 ETrue ); |
|
185 CleanupStack::PushL( icon ); |
|
186 iconArray->AppendL( icon ); |
|
187 CleanupStack::Pop( icon ); |
|
188 |
|
189 // Disable lists MSK observer because the container will be used |
|
190 // as observer |
|
191 listBox->EnableMSKObserver( EFalse ); |
|
192 CleanupStack::Pop( listBox ); |
|
193 return listBox; |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CFileManagerSettingListContainer::NewL |
|
198 // Two-phased constructor. |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 CFileManagerSettingListContainer* CFileManagerSettingListContainer::NewL( |
|
202 const TRect& aRect, |
|
203 const TInt aFocusedIndex, |
|
204 const TListType aType, |
|
205 MDesCArray* aArray, |
|
206 const TDesC& aHelpContext ) |
|
207 { |
|
208 CFileManagerSettingListContainer* self = |
|
209 new( ELeave ) CFileManagerSettingListContainer( aType ); |
|
210 CleanupStack::PushL( self ); |
|
211 self->ConstructL( aRect, aFocusedIndex, aArray, aHelpContext ); |
|
212 CleanupStack::Pop( self ); |
|
213 return self; |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CFileManagerSettingListContainer::~CFileManagerSettingListContainer |
|
218 // Destructor |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 CFileManagerSettingListContainer::~CFileManagerSettingListContainer() |
|
222 { |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CFileManagerSettingListContainer::OfferKeyEventL |
|
227 // |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 TKeyResponse CFileManagerSettingListContainer::OfferKeyEventL( |
|
231 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
232 { |
|
233 TKeyResponse response = EKeyWasNotConsumed; |
|
234 |
|
235 switch( aKeyEvent.iCode ) |
|
236 { |
|
237 case EKeyEnter: // FALLTHROUGH |
|
238 case EKeyOK: |
|
239 { |
|
240 // Notify restore list about selection change |
|
241 if ( iType == EListRestore ) |
|
242 { |
|
243 static_cast< CAknAppUi* >( ControlEnv()->AppUi() )-> |
|
244 ProcessCommandL( EFileManagerSelectionKey ); |
|
245 response = EKeyWasConsumed; |
|
246 } |
|
247 else |
|
248 { |
|
249 response = ListBox().OfferKeyEventL( aKeyEvent, aType ); |
|
250 } |
|
251 break; |
|
252 } |
|
253 case EKeyApplicationF: |
|
254 { |
|
255 // Suppress this from listbox, |
|
256 // otherwise empty multiselection list sometimes works badly on exit |
|
257 break; |
|
258 } |
|
259 default: |
|
260 { |
|
261 response = CFileManagerContainerBase::OfferKeyEventL( |
|
262 aKeyEvent, aType ); |
|
263 } |
|
264 } |
|
265 return response; |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // CFileManagerSettingListContainer::HandleControlEventL |
|
270 // |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 void CFileManagerSettingListContainer::HandleControlEventL( |
|
274 CCoeControl* aControl, TCoeEvent aEventType ) |
|
275 { |
|
276 if ( iType == EListRestore && |
|
277 aEventType == EEventStateChanged ) |
|
278 { |
|
279 static_cast< CAknAppUi* >( ControlEnv()->AppUi() )-> |
|
280 ProcessCommandL( EFileManagerCheckMark ); |
|
281 } |
|
282 |
|
283 CFileManagerContainerBase::HandleControlEventL( |
|
284 aControl, aEventType ); |
|
285 } |
|
286 |
|
287 // End of File |
|