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: Phone number query for Call Divert view. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "GSCallDivertQuery.h" |
|
21 |
|
22 // CONSTANTS |
|
23 const TInt KCFQueryClosing = 1; |
|
24 const TInt KCFQueryRunning = 0; |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 // --------------------------------------------------------- |
|
28 // GSCallDivertQuery::NewL |
|
29 // --------------------------------------------------------- |
|
30 CGSCallDivertQuery* CGSCallDivertQuery::NewL( TDes& aDataText, |
|
31 const TTone& aTone, TInt aOKCba, TInt aDefaultCba ) |
|
32 { |
|
33 CGSCallDivertQuery* self = |
|
34 new ( ELeave ) CGSCallDivertQuery( |
|
35 aDataText, aTone, aOKCba, aDefaultCba ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------- |
|
40 // GSCallDivertQuery::GSCallDivertQuery |
|
41 // --------------------------------------------------------- |
|
42 CGSCallDivertQuery::CGSCallDivertQuery( |
|
43 TDes& aDataText, |
|
44 const TTone& aTone, |
|
45 TInt aOKCba, |
|
46 TInt aDefaultCba ) |
|
47 : CAknTextQueryDialog( aDataText, aTone ), |
|
48 iOKCba( aOKCba ), |
|
49 iDefaultCba( aDefaultCba ) |
|
50 { |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // GSCallDivertQuery::OfferKeyEventL |
|
55 // --------------------------------------------------------- |
|
56 TKeyResponse CGSCallDivertQuery::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
57 TEventCode aType ) |
|
58 { |
|
59 if ( aKeyEvent.iCode == EKeyEnter ) |
|
60 { |
|
61 CAknQueryControl* control = |
|
62 static_cast<CAknQueryControl*> ( Control( EGeneralQuery ) ); |
|
63 if ( control->GetTextLength() ) |
|
64 { |
|
65 TryExitL( EAknSoftkeyOk ); |
|
66 } |
|
67 else |
|
68 { |
|
69 TryExitL( EAknSoftkeySearch ); |
|
70 } |
|
71 |
|
72 return EKeyWasConsumed; |
|
73 } |
|
74 |
|
75 CAknTextQueryDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
76 |
|
77 if ( aKeyEvent.iCode != EKeyEscape ) |
|
78 { |
|
79 UpdateSoftkeysL(); |
|
80 } |
|
81 |
|
82 return EKeyWasConsumed; |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // GSCallDivertQuery::OfferKeyEventL |
|
88 // --------------------------------------------------------- |
|
89 TBool CGSCallDivertQuery::NeedToDismissQueryL( const TKeyEvent& aKeyEvent ) |
|
90 { |
|
91 if ( aKeyEvent.iCode == EKeyOK ) |
|
92 { |
|
93 CAknQueryControl* control = |
|
94 static_cast<CAknQueryControl*> ( Control( EGeneralQuery ) ); |
|
95 // check if the editor is empty or has some text |
|
96 if ( control && control->GetTextLength() ) |
|
97 { |
|
98 return EFalse; |
|
99 } |
|
100 else |
|
101 { |
|
102 return ETrue; |
|
103 } |
|
104 } |
|
105 else |
|
106 { |
|
107 return EFalse; |
|
108 } |
|
109 } |
|
110 |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // GSCallDivertQuery::PostLayoutDynInitL |
|
114 // --------------------------------------------------------- |
|
115 void CGSCallDivertQuery::PostLayoutDynInitL() |
|
116 { |
|
117 iCurrentCba = 0; |
|
118 iLeaving = KCFQueryRunning; |
|
119 CAknTextQueryDialog::PostLayoutDynInitL(); |
|
120 UpdateSoftkeysL(); |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // GSCallDivertQuery::UpdateSoftkeysL |
|
125 // --------------------------------------------------------- |
|
126 void CGSCallDivertQuery::UpdateSoftkeysL() |
|
127 { |
|
128 if ( iLeaving != KCFQueryRunning ) |
|
129 { |
|
130 return; |
|
131 } |
|
132 CAknQueryControl* control = |
|
133 static_cast<CAknQueryControl*> ( Control( EGeneralQuery ) ); |
|
134 if ( control && control->GetTextLength() ) |
|
135 { |
|
136 // There is text in cba; we can update softkeys to OK - Cancel. |
|
137 SetCbaL( iOKCba ); |
|
138 } |
|
139 else |
|
140 { |
|
141 // There is no text in cba; update softkeys to Search - Back. |
|
142 SetCbaL( iDefaultCba ); |
|
143 } |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------- |
|
147 // GSCallDivertQuery::OkToExitL |
|
148 // --------------------------------------------------------- |
|
149 TBool CGSCallDivertQuery::OkToExitL( TInt aButtonId ) |
|
150 { |
|
151 |
|
152 if ( aButtonId == EAknSoftkeySearch ) |
|
153 { |
|
154 return ETrue; |
|
155 } |
|
156 if ( aButtonId == EAknSoftkeyCancel ) |
|
157 { |
|
158 iLeaving = KCFQueryClosing; |
|
159 return ETrue; |
|
160 } |
|
161 if ( aButtonId == EAknSoftkeyBack ) |
|
162 { |
|
163 iLeaving = KCFQueryClosing; |
|
164 return ETrue; |
|
165 } |
|
166 iLeaving = KCFQueryClosing; |
|
167 return CAknTextQueryDialog::OkToExitL( aButtonId ); |
|
168 } |
|
169 |
|
170 |
|
171 // --------------------------------------------------------- |
|
172 // GSCallDivertQuery::SetCba |
|
173 // --------------------------------------------------------- |
|
174 void CGSCallDivertQuery::SetCbaL( TInt aCba ) |
|
175 { |
|
176 if ( iCurrentCba != aCba ) |
|
177 { |
|
178 CEikButtonGroupContainer& buttonGroup = ButtonGroupContainer(); |
|
179 buttonGroup.SetCommandSetL( aCba ); |
|
180 buttonGroup.DrawNow(); |
|
181 iCurrentCba = aCba; |
|
182 } |
|
183 MakeLeftSoftkeyVisible( ETrue ); |
|
184 } |
|
185 |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // GSCallDivertQuery::PreLayoutDynInitL |
|
189 // --------------------------------------------------------- |
|
190 void CGSCallDivertQuery::PreLayoutDynInitL() |
|
191 { |
|
192 iCurrentCba = 0; |
|
193 CAknTextQueryDialog::PreLayoutDynInitL(); |
|
194 |
|
195 if( this->Text().Length() ) |
|
196 { |
|
197 MakeLeftSoftkeyVisible( ETrue ); |
|
198 } |
|
199 } |
|
200 |
|
201 |
|
202 // --------------------------------------------------------- |
|
203 // GSCallDivertQuery::HandleQueryEditorStateEventL |
|
204 // --------------------------------------------------------- |
|
205 TBool CGSCallDivertQuery::HandleQueryEditorStateEventL( |
|
206 CAknQueryControl* aQueryControl, |
|
207 TQueryControlEvent aEventType, |
|
208 TQueryValidationStatus aStatus ) |
|
209 { |
|
210 CAknTextQueryDialog::HandleQueryEditorStateEventL( aQueryControl, |
|
211 aEventType, |
|
212 aStatus ); |
|
213 if( aEventType == EQueryControlEditorStateChanging && |
|
214 aStatus == EEditorValueValid ) |
|
215 { |
|
216 UpdateSoftkeysL(); |
|
217 } |
|
218 return EFalse; |
|
219 } |
|
220 |
|
221 |
|
222 // End of File |
|