|
1 /* |
|
2 * Copyright (c) 2007-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: Implementation of CWsfWlanSsidSelectionDlg2 |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // EXTERNAL INCLUDES |
|
21 #include <avkon.mbg> |
|
22 #include <AknIconUtils.h> |
|
23 #include <wsfwlaninfosorting.rsg> |
|
24 #include <AknIconArray.h> // CAknIcon |
|
25 #include <akntitle.h> // akntitle pane |
|
26 #include <aknlists.h> // CAknSingleGraphicStyleListBox |
|
27 |
|
28 // CLASS HEADER |
|
29 #include "wsfwlanssidselectiondlg2.h" |
|
30 |
|
31 // INTERNAL INCLUDES |
|
32 #include "wsfwlaninfosorting.hrh" |
|
33 #include "wsflogger.h" |
|
34 |
|
35 |
|
36 /** |
|
37 * Format string for listbox items |
|
38 */ |
|
39 _LIT( KFormatString, "1\t%S" ); |
|
40 |
|
41 /** |
|
42 * Number of icons used |
|
43 */ |
|
44 static const TInt KNumIcons = 2; |
|
45 |
|
46 |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // CWsfWlanSsidSelectionDlg2::NewL |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 CWsfWlanSsidSelectionDlg2* CWsfWlanSsidSelectionDlg2::NewL( |
|
53 CDesCArrayFlat& aSsidArray, |
|
54 CListBoxView::CSelectionIndexArray& aSelectionIndexArray ) |
|
55 { |
|
56 CWsfWlanSsidSelectionDlg2* self = NewLC( aSsidArray, |
|
57 aSelectionIndexArray ); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // CWsfWlanSsidSelectionDlg2::NewLC |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 CWsfWlanSsidSelectionDlg2* CWsfWlanSsidSelectionDlg2::NewLC( |
|
68 CDesCArrayFlat& aSsidArray, |
|
69 CListBoxView::CSelectionIndexArray& aSelectionIndexArray ) |
|
70 { |
|
71 CWsfWlanSsidSelectionDlg2* self = new (ELeave) CWsfWlanSsidSelectionDlg2( |
|
72 aSsidArray, aSelectionIndexArray ); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(); |
|
75 return self; |
|
76 } |
|
77 |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CWsfWlanSsidSelectionDlg2::ConstructL |
|
81 // ---------------------------------------------------------------------------- |
|
82 // |
|
83 void CWsfWlanSsidSelectionDlg2::ConstructL() |
|
84 { |
|
85 } |
|
86 |
|
87 |
|
88 // ---------------------------------------------------------------------------- |
|
89 // CWsfWlanSsidSelectionDlg2::CWsfWlanSsidSelectionDlg2 |
|
90 // ---------------------------------------------------------------------------- |
|
91 // |
|
92 CWsfWlanSsidSelectionDlg2::CWsfWlanSsidSelectionDlg2( |
|
93 CDesCArrayFlat& aSsidArray, |
|
94 CListBoxView::CSelectionIndexArray& aSelectionIndexArray ): |
|
95 CAknListQueryDialog( &aSelectionIndexArray ), |
|
96 iSsidArray( &aSsidArray ), |
|
97 iSelectedItems( &aSelectionIndexArray ) |
|
98 { |
|
99 } |
|
100 |
|
101 |
|
102 // ---------------------------------------------------------------------------- |
|
103 // CWsfWlanSsidSelectionDlg2::~CWsfWlanSsidSelectionDlg2 |
|
104 // ---------------------------------------------------------------------------- |
|
105 // |
|
106 CWsfWlanSsidSelectionDlg2::~CWsfWlanSsidSelectionDlg2() |
|
107 { |
|
108 // restore the title.... |
|
109 if ( iTitle && iPane ) |
|
110 { |
|
111 iPane->SetText( iTitle ); |
|
112 } |
|
113 |
|
114 iPane = NULL; |
|
115 iTitle = NULL; |
|
116 iSsidArray = NULL; |
|
117 iSelectedItems = NULL; |
|
118 } |
|
119 |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // CWsfWlanSsidSelectionDlg2::PreLayoutDynInitL |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 void CWsfWlanSsidSelectionDlg2::PreLayoutDynInitL() |
|
126 { |
|
127 LOG_ENTERFN( "CWsfWlanSsidSelectionDlg2::PreLayoutDynInitL" ); |
|
128 |
|
129 CAknListQueryDialog::PreLayoutDynInitL(); |
|
130 |
|
131 CAknListQueryControl *control = static_cast<CAknListQueryControl*>( |
|
132 Control( EListQueryControl ) ); |
|
133 CEikListBox* listBox = control->Listbox(); |
|
134 |
|
135 CDesCArrayFlat *formattedSsids = new (ELeave) CDesCArrayFlat( |
|
136 iSsidArray->Count() ); |
|
137 CleanupStack::PushL( formattedSsids ); |
|
138 CopyAndFormatArrayContentsL( iSsidArray, formattedSsids ); |
|
139 |
|
140 SetItemTextArray( formattedSsids ); |
|
141 |
|
142 CleanupStack::Pop( formattedSsids ); |
|
143 |
|
144 CAknIconArray* iconArray = CreateQueryIconArrayL(); |
|
145 CleanupStack::PushL( iconArray ); |
|
146 SetIconArrayL( iconArray ); |
|
147 CleanupStack::Pop( iconArray ); |
|
148 |
|
149 for (TInt i = 0; i < iSelectedItems->Count(); i++) |
|
150 { |
|
151 listBox->View()->SelectItemL( (*iSelectedItems)[i] ); |
|
152 } |
|
153 |
|
154 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
155 iPane = (CAknTitlePane*) statusPane->ControlL( |
|
156 TUid::Uid( EEikStatusPaneUidTitle ) ); |
|
157 iTitle = iPane->Text()->AllocL(); |
|
158 } |
|
159 |
|
160 |
|
161 // ---------------------------------------------------------------------------- |
|
162 // CWsfWlanSsidSelectionDlg2::CopyAndFormatArrayContentsL |
|
163 // ---------------------------------------------------------------------------- |
|
164 // |
|
165 void CWsfWlanSsidSelectionDlg2::CopyAndFormatArrayContentsL( |
|
166 CDesCArrayFlat* aSource, |
|
167 CDesCArrayFlat* aDest ) |
|
168 { |
|
169 TBuf<80> lineBuffer; |
|
170 TInt sourceCount( aSource->Count() ); |
|
171 for ( TInt i( 0 ) ; i < sourceCount ; i++ ) |
|
172 { |
|
173 const TDesC& item = aSource->MdcaPoint( i ); |
|
174 lineBuffer.Format(KFormatString, &item ); |
|
175 aDest->AppendL( lineBuffer ); |
|
176 } |
|
177 } |
|
178 |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CWsfWlanSsidSelectionDlg2::CreateQueryIconArrayL |
|
182 // ---------------------------------------------------------------------------- |
|
183 // |
|
184 CAknIconArray* CWsfWlanSsidSelectionDlg2::CreateQueryIconArrayL() |
|
185 { |
|
186 CAknIconArray* iconarray = new( ELeave )CAknIconArray( KNumIcons ); |
|
187 CleanupStack::PushL( iconarray ); |
|
188 |
|
189 const TDesC& iconfilename = AknIconUtils::AvkonIconFileName(); |
|
190 |
|
191 // empty |
|
192 iconarray->AppendL( CreateIconLC( iconfilename, |
|
193 EMbmAvkonQgn_prop_checkbox_on, |
|
194 EMbmAvkonQgn_prop_checkbox_on_mask, |
|
195 KAknsIIDQgnPropEmpty )); |
|
196 CleanupStack::Pop(); // icon |
|
197 |
|
198 // copying |
|
199 iconarray->AppendL(CreateIconLC( iconfilename, |
|
200 EMbmAvkonQgn_prop_checkbox_off, |
|
201 EMbmAvkonQgn_prop_checkbox_off_mask, |
|
202 KAknsIIDNone )); |
|
203 CleanupStack::Pop(); // icon |
|
204 CleanupStack::Pop(); // iconarray |
|
205 |
|
206 |
|
207 return iconarray; |
|
208 } |
|
209 |
|
210 |
|
211 // ---------------------------------------------------------------------------- |
|
212 // CWsfWlanSsidSelectionDlg2::CreateIconLC |
|
213 // ---------------------------------------------------------------------------- |
|
214 // |
|
215 CGulIcon* CWsfWlanSsidSelectionDlg2::CreateIconLC( const TDesC& aFileName, |
|
216 TInt aIcon, |
|
217 TInt aMask, |
|
218 const TAknsItemID& aID ) |
|
219 { |
|
220 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
221 |
|
222 CGulIcon* icon = AknsUtils::CreateGulIconL( skinInstance, aID, aFileName, |
|
223 aIcon, aMask ); |
|
224 CleanupStack::PushL( icon ); |
|
225 |
|
226 return icon; |
|
227 } |
|
228 |
|
229 |
|
230 // ---------------------------------------------------------------------------- |
|
231 // CWsfWlanSsidSelectionDlg2::HandleListBoxEventL |
|
232 // ---------------------------------------------------------------------------- |
|
233 // |
|
234 void CWsfWlanSsidSelectionDlg2::HandleListBoxEventL( CEikListBox* aListBox, |
|
235 TListBoxEvent aEventType ) |
|
236 { |
|
237 LOG_ENTERFN( "CWsfWlanSsidSelectionDlg2::HandleListBoxEventL" ); |
|
238 |
|
239 switch ( aEventType ) |
|
240 { |
|
241 case EEventEnterKeyPressed: |
|
242 case EEventItemClicked: |
|
243 // both handled in the same way for now... |
|
244 { |
|
245 // An item should be marked/unmarked. |
|
246 LOG_WRITE( "selection toggle" ); |
|
247 CEikListBox* listBox = ListBox(); |
|
248 TInt index = listBox->View()->CurrentItemIndex(); |
|
249 |
|
250 if ( listBox->View()->ItemIsSelected( index ) ) |
|
251 { |
|
252 // if the item was unmarked select |
|
253 listBox->View()->SelectItemL( index ); |
|
254 } |
|
255 else |
|
256 { |
|
257 // if the item was marked deselect |
|
258 listBox->View()->DeselectItem( index ); |
|
259 } |
|
260 |
|
261 listBox->DrawDeferred(); |
|
262 break; |
|
263 } |
|
264 case EEventItemDoubleClicked: |
|
265 { |
|
266 break; |
|
267 } |
|
268 case EEventEditingStarted: |
|
269 { |
|
270 break; |
|
271 } |
|
272 case EEventEditingStopped: |
|
273 { |
|
274 break; |
|
275 } |
|
276 default: |
|
277 { |
|
278 CAknListQueryDialog::HandleListBoxEventL( aListBox, aEventType ); |
|
279 break; |
|
280 }; |
|
281 }; |
|
282 } |
|
283 |