|
1 /* |
|
2 * Copyright (c) 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: search fields editor implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cvimpstuisearchquerydialog.h" |
|
21 |
|
22 #include "cvimpstuisearchfieldaray.h" |
|
23 #include "vimpstui.hrh" |
|
24 #include "vimpstutils.h" |
|
25 // resource |
|
26 #include <vimpstuires.rsg> |
|
27 |
|
28 // System includes |
|
29 #include <akntitle.h> |
|
30 #include <aknnavi.h> |
|
31 #include <StringLoader.h> |
|
32 #include <eikcapc.h> |
|
33 #include <barsread.h> |
|
34 #include <aknnotewrappers.h> |
|
35 #include <hlplch.h> |
|
36 |
|
37 |
|
38 |
|
39 // -------------------------------------------------------------------------- |
|
40 // CVIMPSTUiSearchQueryDialog::CVIMPSTUiSearchQueryDialog |
|
41 // -------------------------------------------------------------------------- |
|
42 // |
|
43 CVIMPSTUiSearchQueryDialog::CVIMPSTUiSearchQueryDialog(CVIMPSTUiSearchFieldArray& aUiFieldArray ) |
|
44 : iUiFieldArray( aUiFieldArray ) |
|
45 { |
|
46 } |
|
47 |
|
48 // -------------------------------------------------------------------------- |
|
49 // CVIMPSTUiSearchQueryDialog::~CVIMPSTUiSearchQueryDialog |
|
50 // -------------------------------------------------------------------------- |
|
51 // |
|
52 CVIMPSTUiSearchQueryDialog::~CVIMPSTUiSearchQueryDialog() |
|
53 { |
|
54 // Restore the titlepane text |
|
55 if (iTitlePane && iStoredTitlePaneText) |
|
56 { |
|
57 // iTitlePane takes ownership of iStoredTitlePaneText |
|
58 TRAP_IGNORE( iTitlePane->SetTextL( iStoredTitlePaneText->Des() ) ); |
|
59 delete iStoredTitlePaneText; |
|
60 } |
|
61 // Remove empty status pane |
|
62 if (iNaviContainer) |
|
63 { |
|
64 iNaviContainer->Pop(); |
|
65 } |
|
66 |
|
67 } |
|
68 |
|
69 |
|
70 // -------------------------------------------------------------------------- |
|
71 // CVIMPSTUiSearchQueryDialog::NewL |
|
72 // -------------------------------------------------------------------------- |
|
73 // |
|
74 CVIMPSTUiSearchQueryDialog* CVIMPSTUiSearchQueryDialog::NewL(CVIMPSTUiSearchFieldArray& aUiFieldArray ) |
|
75 { |
|
76 CVIMPSTUiSearchQueryDialog* self = |
|
77 new ( ELeave ) CVIMPSTUiSearchQueryDialog(aUiFieldArray); |
|
78 CleanupStack::PushL(self); |
|
79 self->ConstructL(); |
|
80 CleanupStack::Pop(self); |
|
81 return self; |
|
82 } |
|
83 |
|
84 |
|
85 // -------------------------------------------------------------------------- |
|
86 // CVIMPSTUiSearchQueryDialog::ConstructL |
|
87 // -------------------------------------------------------------------------- |
|
88 // |
|
89 void CVIMPSTUiSearchQueryDialog::ConstructL() |
|
90 { |
|
91 CAknDialog::ConstructL(R_SEARCH_EDITOR_MENUBAR); |
|
92 |
|
93 StoreTitlePaneTextL(); |
|
94 |
|
95 ConstructNaviPaneL(); |
|
96 |
|
97 iSearchType = iUiFieldArray.GetSearchType(); |
|
98 |
|
99 if( !IsBasicFieldAvailableL() ) |
|
100 { |
|
101 iSearchType = EIMAdvancedSearch ; |
|
102 iUiFieldArray.SetSearchType( EIMAdvancedSearch ); |
|
103 } |
|
104 } |
|
105 |
|
106 // -------------------------------------------------------------------------- |
|
107 // CVIMPSTUiSearchQueryDialog::ExecuteLD |
|
108 // -------------------------------------------------------------------------- |
|
109 // |
|
110 void CVIMPSTUiSearchQueryDialog::ExecuteLD() |
|
111 { |
|
112 CleanupStack::PushL( this ); |
|
113 |
|
114 // Set status pane layout to the Phonebook 2 one |
|
115 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
116 if (statusPane) |
|
117 { |
|
118 statusPane->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL); |
|
119 } |
|
120 CleanupStack::Pop( this ); |
|
121 |
|
122 CAknForm::ExecuteLD(R_SEARCH_ENTRY_DIALOG); |
|
123 } |
|
124 |
|
125 // -------------------------------------------------------------------------- |
|
126 // CVIMPSTUiSearchQueryDialog::OfferKeyEventL |
|
127 // -------------------------------------------------------------------------- |
|
128 // |
|
129 TKeyResponse CVIMPSTUiSearchQueryDialog::OfferKeyEventL |
|
130 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
131 { |
|
132 TKeyResponse ret(EKeyWasNotConsumed); |
|
133 |
|
134 ret = CAknForm::OfferKeyEventL( aKeyEvent, aType ); |
|
135 isEndKeyPressed = ETrue; |
|
136 if ( ret == EKeyWasConsumed && aKeyEvent.iCode != EKeyEscape ) |
|
137 { |
|
138 isEndKeyPressed = EFalse; |
|
139 UpdateCbasL(); |
|
140 } |
|
141 return ret; |
|
142 } |
|
143 |
|
144 |
|
145 // -------------------------------------------------------------------------- |
|
146 // CVIMPSTUiSearchQueryDialog::PreLayoutDynInitL |
|
147 // -------------------------------------------------------------------------- |
|
148 // |
|
149 void CVIMPSTUiSearchQueryDialog::PreLayoutDynInitL() |
|
150 { |
|
151 SetEditableL(ETrue); |
|
152 |
|
153 iUiFieldArray.CreateUiFieldsFromArrayL( *this ); |
|
154 |
|
155 ShowSearchUiFieldsL(); |
|
156 |
|
157 } |
|
158 |
|
159 // -------------------------------------------------------------------------- |
|
160 // CVIMPSTUiSearchQueryDialog::PostLayoutDynInitL |
|
161 // -------------------------------------------------------------------------- |
|
162 // |
|
163 void CVIMPSTUiSearchQueryDialog::PostLayoutDynInitL() |
|
164 { |
|
165 UpdateTitleL(); |
|
166 } |
|
167 // -------------------------------------------------------------------------- |
|
168 // CVIMPSTUiSearchQueryDialog::SetInitialCurrentLineL |
|
169 // -------------------------------------------------------------------------- |
|
170 // |
|
171 void CVIMPSTUiSearchQueryDialog::SetInitialCurrentLineL() |
|
172 { |
|
173 ActivateFirstPageL(); |
|
174 |
|
175 CAknForm::SetInitialCurrentLine(); |
|
176 |
|
177 iUiFieldArray.SetFocusL(0); |
|
178 |
|
179 } |
|
180 |
|
181 // -------------------------------------------------------------------------- |
|
182 // CVIMPSTUiSearchQueryDialog::OkToExitL |
|
183 // -------------------------------------------------------------------------- |
|
184 // |
|
185 TBool CVIMPSTUiSearchQueryDialog::OkToExitL( TInt aKeycode ) |
|
186 { |
|
187 TBool ret = EFalse; |
|
188 switch( aKeycode ) |
|
189 { |
|
190 case EAknSoftkeyEmpty : |
|
191 { |
|
192 ret = EFalse; |
|
193 break; |
|
194 } |
|
195 case EEikCmdExit : |
|
196 case EAknSoftkeyExit : |
|
197 case EAknSoftkeyCancel : |
|
198 { |
|
199 ret = ETrue; |
|
200 break; |
|
201 } |
|
202 case EAknSoftkeyDone : |
|
203 case EAknSoftkeyOk : |
|
204 { |
|
205 CmdDoneL( ); |
|
206 ret = ETrue; |
|
207 break; |
|
208 } |
|
209 |
|
210 case EBasicSearch : |
|
211 { |
|
212 iSearchType = EIMBasicSearch; |
|
213 ShowSearchUiFieldsL(); |
|
214 UpdateTitleL(); |
|
215 ret = EFalse; |
|
216 break; |
|
217 } |
|
218 case EAdvancedSearch : |
|
219 { |
|
220 iSearchType = EIMAdvancedSearch ; |
|
221 ShowSearchUiFieldsL(); |
|
222 UpdateTitleL(); |
|
223 ret = EFalse; |
|
224 break; |
|
225 } |
|
226 default : |
|
227 { |
|
228 ret = CAknForm::OkToExitL( aKeycode ) ; |
|
229 } |
|
230 } |
|
231 iUiFieldArray.SetSearchType( iSearchType ); |
|
232 UpdateCbasL(); |
|
233 return ret; |
|
234 } |
|
235 |
|
236 // -------------------------------------------------------------------------- |
|
237 // CVIMPSTUiSearchQueryDialog::CreateLineL |
|
238 // -------------------------------------------------------------------------- |
|
239 // |
|
240 CCoeControl* CVIMPSTUiSearchQueryDialog::CreateLineL |
|
241 ( const TDesC& aCaption, TInt aControlId, TInt aControlType ) |
|
242 { |
|
243 return CreateLineByTypeL( aCaption, aControlId, aControlType, NULL ); |
|
244 } |
|
245 |
|
246 |
|
247 // -------------------------------------------------------------------------- |
|
248 // CVIMPSTUiSearchQueryDialog::LineControl |
|
249 // -------------------------------------------------------------------------- |
|
250 // |
|
251 CEikCaptionedControl* CVIMPSTUiSearchQueryDialog::LineControl |
|
252 ( TInt aControlId ) const |
|
253 { |
|
254 return Line( aControlId ); |
|
255 } |
|
256 |
|
257 // -------------------------------------------------------------------------- |
|
258 // CVIMPSTUiSearchQueryDialog::SetEditableL |
|
259 // -------------------------------------------------------------------------- |
|
260 // |
|
261 void CVIMPSTUiSearchQueryDialog::SetEditableL( TBool aState ) |
|
262 { |
|
263 CAknForm::SetEditableL( aState ); |
|
264 } |
|
265 |
|
266 // -------------------------------------------------------------------------- |
|
267 // CVIMPSTUiSearchQueryDialog::AreAllControlsEmptyL |
|
268 // -------------------------------------------------------------------------- |
|
269 // |
|
270 TBool CVIMPSTUiSearchQueryDialog::AreAllControlsEmptyL() const |
|
271 { |
|
272 // before saving entered data |
|
273 return iUiFieldArray.AreAllUiControlsEmptyL(); |
|
274 } |
|
275 |
|
276 // -------------------------------------------------------------------------- |
|
277 // CVIMPSTUiSearchQueryDialog::ConstructContextMenuL |
|
278 // -------------------------------------------------------------------------- |
|
279 // |
|
280 inline void CVIMPSTUiSearchQueryDialog::ConstructContextMenuL() |
|
281 { |
|
282 CEikMenuBar* newMenuBar = new ( ELeave ) CEikMenuBar(); |
|
283 CleanupStack::PushL( newMenuBar ); |
|
284 newMenuBar->ConstructL |
|
285 ( this, NULL, R_SEARCH_EDITOR_CONTEXT_MENUBAR ); |
|
286 iEikonEnv->EikAppUi()->AddToStackL( newMenuBar, ECoeStackPriorityMenu, |
|
287 ECoeStackFlagRefusesFocus ); |
|
288 iContextMenuBar = newMenuBar; |
|
289 CleanupStack::Pop( newMenuBar ); |
|
290 } |
|
291 |
|
292 // -------------------------------------------------------------------------- |
|
293 // CVIMPSTUiSearchQueryDialog::ConstructNaviPaneL |
|
294 // -------------------------------------------------------------------------- |
|
295 // |
|
296 inline void CVIMPSTUiSearchQueryDialog::ConstructNaviPaneL() |
|
297 { |
|
298 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
299 if (statusPane && statusPane->PaneCapabilities |
|
300 ( TUid::Uid( EEikStatusPaneUidNavi ) ).IsPresent() ) |
|
301 { |
|
302 // Create a default empty status pane, otherwise sync field will show |
|
303 iNaviContainer = static_cast<CAknNavigationControlContainer *> |
|
304 ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
305 iNaviContainer->PushDefaultL(); |
|
306 } |
|
307 } |
|
308 |
|
309 // -------------------------------------------------------------------------- |
|
310 // CVIMPSTUiSearchQueryDialog::UpdateTitleL |
|
311 // -------------------------------------------------------------------------- |
|
312 // |
|
313 void CVIMPSTUiSearchQueryDialog::UpdateTitleL() |
|
314 { |
|
315 if (iTitlePane) |
|
316 { |
|
317 HBufC* titleText = NULL; |
|
318 if( iSearchType == EIMBasicSearch ) |
|
319 { |
|
320 titleText = VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_SEARCH_BASIC ); |
|
321 iTitlePane->SetTextL( *titleText ); |
|
322 } |
|
323 else |
|
324 { |
|
325 titleText = VIMPSTUtils::LoadResourceL( R_QTN_SERVTAB_SEARCH_ADVANCED ); |
|
326 iTitlePane->SetTextL( *titleText); |
|
327 } |
|
328 delete titleText; |
|
329 DrawNow(); |
|
330 } |
|
331 |
|
332 } |
|
333 |
|
334 // -------------------------------------------------------------------------- |
|
335 // CVIMPSTUiSearchQueryDialog::CmdDoneL |
|
336 // -------------------------------------------------------------------------- |
|
337 // |
|
338 void CVIMPSTUiSearchQueryDialog::CmdDoneL( ) |
|
339 { |
|
340 TInt count = iUiFieldArray.Count(); |
|
341 for( TInt i = 0; i< count ; i++ ) |
|
342 { |
|
343 HBufC* data = iUiFieldArray.At(i).ControlTextL() ; |
|
344 if(data) |
|
345 { |
|
346 iUiFieldArray.At(i).SetFieldDataL( *data ) ; |
|
347 delete data; |
|
348 } |
|
349 } |
|
350 } |
|
351 |
|
352 // -------------------------------------------------------------------------- |
|
353 // CVIMPSTUiSearchQueryDialog::TryChangeFocusL |
|
354 // -------------------------------------------------------------------------- |
|
355 // |
|
356 void CVIMPSTUiSearchQueryDialog::TryChangeFocusL( |
|
357 TInt aControlId ) |
|
358 { |
|
359 if ( ControlOrNull( aControlId ) ) |
|
360 { |
|
361 TryChangeFocusToL( aControlId ); |
|
362 } |
|
363 } |
|
364 // -------------------------------------------------------------------------- |
|
365 // CVIMPSTUiSearchQueryDialog::SetCurrentLineCaptionL |
|
366 // -------------------------------------------------------------------------- |
|
367 // |
|
368 void CVIMPSTUiSearchQueryDialog::SetCurrentLineCaptionL( |
|
369 const TDesC& aText ) |
|
370 { |
|
371 SetControlCaptionL(IdOfFocusControl(), aText); |
|
372 } |
|
373 // -------------------------------------------------------------------------- |
|
374 // CVIMPSTUiSearchQueryDialog::Control |
|
375 // -------------------------------------------------------------------------- |
|
376 // |
|
377 CCoeControl* CVIMPSTUiSearchQueryDialog::Control( |
|
378 TInt aControlId ) const |
|
379 { |
|
380 return ControlOrNull(aControlId); |
|
381 } |
|
382 // -------------------------------------------------------------------------- |
|
383 // CVIMPSTUiSearchQueryDialog::StoreTitlePaneTextL |
|
384 // -------------------------------------------------------------------------- |
|
385 // |
|
386 inline void CVIMPSTUiSearchQueryDialog::StoreTitlePaneTextL() |
|
387 { |
|
388 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
389 if (statusPane && statusPane->PaneCapabilities( |
|
390 TUid::Uid(EEikStatusPaneUidTitle)).IsPresent()) |
|
391 { |
|
392 iTitlePane = static_cast<CAknTitlePane*> |
|
393 (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle))); |
|
394 if (iTitlePane->Text()) |
|
395 { |
|
396 iStoredTitlePaneText = iTitlePane->Text()->AllocL(); |
|
397 } |
|
398 } |
|
399 } |
|
400 |
|
401 |
|
402 // -------------------------------------------------------------------------- |
|
403 // CVIMPSTUiSearchQueryDialog::UpdateCbasL |
|
404 // -------------------------------------------------------------------------- |
|
405 // |
|
406 void CVIMPSTUiSearchQueryDialog::UpdateCbasL() |
|
407 { |
|
408 if ( !AreAllControlsEmptyL() ) |
|
409 { |
|
410 if ( iCbaCommandSet != R_AVKON_SOFTKEYS_OK_CANCEL__OK ) |
|
411 { |
|
412 SetCbaCommandSetL( R_AVKON_SOFTKEYS_OK_CANCEL__OK ); |
|
413 } |
|
414 } |
|
415 else |
|
416 { |
|
417 if( iSearchType == EIMBasicSearch && iCbaCommandSet != R_SEARCH_SOFTKEYS_ADVANCED_CANCEL__EDIT ) |
|
418 { |
|
419 SetCbaCommandSetL( R_SEARCH_SOFTKEYS_ADVANCED_CANCEL__EDIT ); |
|
420 } |
|
421 else if( iSearchType == EIMAdvancedSearch && iCbaCommandSet != R_SEARCH_SOFTKEYS_BASIC_CANCEL__EDIT ) |
|
422 { |
|
423 SetCbaCommandSetL( R_SEARCH_SOFTKEYS_BASIC_CANCEL__EDIT ); |
|
424 } |
|
425 } |
|
426 |
|
427 } |
|
428 |
|
429 // -------------------------------------------------------------------------- |
|
430 // CVIMPSTUiSearchQueryDialog::SetCbaCommandSetL |
|
431 // -------------------------------------------------------------------------- |
|
432 // |
|
433 void CVIMPSTUiSearchQueryDialog::SetCbaCommandSetL( TInt aResourceId ) |
|
434 { |
|
435 CEikButtonGroupContainer& cba = ButtonGroupContainer(); |
|
436 cba.SetCommandSetL( aResourceId ); |
|
437 iCbaCommandSet = aResourceId; |
|
438 cba.DrawDeferred(); |
|
439 } |
|
440 // -------------------------------------------------------------------------- |
|
441 // CVIMPSTUiSearchQueryDialog::SetLineDimmed |
|
442 // -------------------------------------------------------------------------- |
|
443 // |
|
444 void CVIMPSTUiSearchQueryDialog::SetLineDimmed( |
|
445 TInt aControlId , TBool aDimmed) |
|
446 { |
|
447 SetLineDimmedNow(aControlId, aDimmed); |
|
448 } |
|
449 // -------------------------------------------------------------------------- |
|
450 // CVIMPSTUiSearchQueryDialog::ShowSearchUiFieldsL |
|
451 // -------------------------------------------------------------------------- |
|
452 // |
|
453 void CVIMPSTUiSearchQueryDialog::ShowSearchUiFieldsL() |
|
454 { |
|
455 TInt count = iUiFieldArray.Count(); |
|
456 for( TInt i = 0; i< count; i++ ) |
|
457 { |
|
458 MVIMPSTUiSearchField& field = iUiFieldArray.At(i); |
|
459 if( iSearchType == EIMBasicSearch ) |
|
460 { |
|
461 if( !field.IsBasicField() ) |
|
462 { |
|
463 SetLineDimmed( field.ControlId(), ETrue ); |
|
464 } |
|
465 } |
|
466 else |
|
467 { |
|
468 SetLineDimmed( field.ControlId(), EFalse ); |
|
469 } |
|
470 } |
|
471 SetInitialCurrentLineL(); |
|
472 UpdateCbasL(); |
|
473 } |
|
474 |
|
475 // -------------------------------------------------------------------------- |
|
476 // CVIMPSTUiSearchQueryDialog::IsBasicFieldAvailableL |
|
477 // -------------------------------------------------------------------------- |
|
478 // |
|
479 TBool CVIMPSTUiSearchQueryDialog::IsBasicFieldAvailableL() |
|
480 { |
|
481 TInt count = iUiFieldArray.Count(); |
|
482 for( TInt i = 0; i< count; i++ ) |
|
483 { |
|
484 MVIMPSTUiSearchField& field = iUiFieldArray.At(i); |
|
485 if( field.IsBasicField() ) |
|
486 { |
|
487 return ETrue; |
|
488 } |
|
489 } |
|
490 return EFalse; |
|
491 } |
|
492 |
|
493 // -------------------------------------------------------------------------- |
|
494 // CVIMPSTUiSearchQueryDialog::IsEndKeyPressed() |
|
495 // -------------------------------------------------------------------------- |
|
496 // |
|
497 TBool CVIMPSTUiSearchQueryDialog::IsEndKeyPressed() |
|
498 { |
|
499 return isEndKeyPressed; |
|
500 } |
|
501 // End of File |