|
1 /* |
|
2 * Copyright (c) 2006 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: Text query dialog that accepts empty input |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "vimpstutilstextquerydialog.h" |
|
22 #include "uiservicetabtracer.h" |
|
23 |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CVIMPSTUtilsTextQueryDialog::CVIMPSTUtilsTextQueryDialog |
|
29 // C++ default constructor can NOT contain any code, that |
|
30 // might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 EXPORT_C CVIMPSTUtilsTextQueryDialog::CVIMPSTUtilsTextQueryDialog( TDes& aDataText, |
|
34 const TTone& aTone /*= ENoTone*/, |
|
35 TBool aLeftSoftkeyAlwaysVisible /*= ETrue*/, |
|
36 TBool aDomainSelectionQuery /*= EFalse*/ ) |
|
37 : CAknTextQueryDialog( aDataText, aTone ), |
|
38 iLeftSoftkeyAlwaysVisible( aLeftSoftkeyAlwaysVisible ), |
|
39 iDomainSelectionQuery( aDomainSelectionQuery ) |
|
40 { |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CVIMPSTUtilsTextQueryDialog::NewL |
|
45 // Two-phased constructor. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C CVIMPSTUtilsTextQueryDialog* CVIMPSTUtilsTextQueryDialog::NewL( TDes& aDataText, |
|
49 const TTone& aTone /*= ENoTone*/, |
|
50 TBool aLeftSoftkeyAlwaysVisible /*= ETrue*/, |
|
51 TBool aDomainSelectionQuery /*= EFalse*/ ) |
|
52 { |
|
53 TRACER_AUTO; |
|
54 CVIMPSTUtilsTextQueryDialog* self = new( ELeave ) CVIMPSTUtilsTextQueryDialog( |
|
55 aDataText, aTone, |
|
56 aLeftSoftkeyAlwaysVisible, |
|
57 aDomainSelectionQuery ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // Destructor |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 |
|
66 EXPORT_C CVIMPSTUtilsTextQueryDialog::~CVIMPSTUtilsTextQueryDialog() |
|
67 { |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CVIMPSTUtilsTextQueryDialog::UpdateLeftSoftKeyL |
|
72 // (other items were commented in a header). |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C void CVIMPSTUtilsTextQueryDialog::UpdateLeftSoftKeyL() |
|
76 { |
|
77 TRACER_AUTO; |
|
78 if ( iLeftSoftkeyAlwaysVisible ) |
|
79 { |
|
80 // do nothing so the left softkey is always visible |
|
81 return; |
|
82 } |
|
83 else |
|
84 { |
|
85 CAknTextQueryDialog::UpdateLeftSoftKeyL(); |
|
86 } |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CVIMPSTUtilsTextQueryDialog::OfferKeyEventL |
|
91 // (other items were commented in a header). |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 EXPORT_C TKeyResponse CVIMPSTUtilsTextQueryDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
95 TEventCode aType ) |
|
96 { |
|
97 TRACER_AUTO; |
|
98 TInt oldLen = 0; |
|
99 CEikEdwin* edwin = NULL; |
|
100 // If this is launched after domain selection query |
|
101 // check editor state |
|
102 if ( iDomainSelectionQuery ) |
|
103 { |
|
104 CCoeControl* ctrl = ControlOrNull( EGeneralQuery ); |
|
105 if ( ctrl ) |
|
106 { |
|
107 CAknQueryControl* query = static_cast<CAknQueryControl*>( ctrl ); |
|
108 ctrl = query->ControlByLayoutOrNull( EDataLayout ); |
|
109 if ( ctrl ) |
|
110 { |
|
111 edwin = static_cast<CEikEdwin*>( ctrl ); |
|
112 oldLen = edwin->TextLength(); |
|
113 } |
|
114 } |
|
115 } |
|
116 |
|
117 TKeyResponse response = |
|
118 CAknTextQueryDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
119 |
|
120 if ( iDomainSelectionQuery && edwin |
|
121 && aKeyEvent.iCode != EKeyOK ) |
|
122 { |
|
123 if ( oldLen > 0 |
|
124 && response == EKeyWasConsumed |
|
125 && edwin->TextLength() == 0 ) |
|
126 { |
|
127 // User has cleared editor -> exit dialog |
|
128 TryExitL( EAknSoftkeyExit ); |
|
129 } |
|
130 } |
|
131 |
|
132 return response; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CVIMPSTUtilsTextQueryDialog::OfferKeyEventL |
|
137 // (other items were commented in a header). |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 EXPORT_C TBool CVIMPSTUtilsTextQueryDialog::OkToExitL( TInt aButtonId ) |
|
141 { |
|
142 TRACER_AUTO; |
|
143 if ( aButtonId == EAknSoftkeyExit && iDomainSelectionQuery ) |
|
144 { |
|
145 return ETrue; |
|
146 } |
|
147 else |
|
148 { |
|
149 return CAknTextQueryDialog::OkToExitL( aButtonId ); |
|
150 } |
|
151 } |
|
152 // End of File |