|
1 /* |
|
2 * Copyright (c) 2005-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: Phonebook 2 search pane filter. This acts as a wrapper to the FindBox in |
|
15 * NameslistView. Info needs to be passed to this filter before the FindBox. |
|
16 * |
|
17 */ |
|
18 #ifndef CPBK2PREDICTIVESEARCHFILTER_H_ |
|
19 #define CPBK2PREDICTIVESEARCHFILTER_H_ |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <e32def.h> |
|
24 #include <w32std.h> |
|
25 #include <coecntrl.h> // CCoeControl |
|
26 #include <eikappui.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CAknSearchField; |
|
30 class MPbk2FilteredViewStack; |
|
31 class MPbk2ContactNameFormatter; |
|
32 class CRunAsynch; |
|
33 class MVPbkViewContact; |
|
34 class CPbk2PredictiveViewStack; |
|
35 |
|
36 /// Unnamed namespace for local definitions |
|
37 namespace { |
|
38 |
|
39 /// Search field length |
|
40 const TInt KSearchFieldLength = 40; |
|
41 |
|
42 } /// namespace |
|
43 |
|
44 /** |
|
45 * Phonebook 2 predictive search filter. |
|
46 */ |
|
47 |
|
48 NONSHARABLE_CLASS(CPbk2PredictiveSearchFilter) : public CCoeControl |
|
49 { |
|
50 |
|
51 enum TEditorMode |
|
52 { |
|
53 ENone = 0, |
|
54 EPaste |
|
55 }; |
|
56 |
|
57 public: // Constructors and destructor |
|
58 |
|
59 /** |
|
60 * Creates a new instance of this class. |
|
61 * |
|
62 * @return A new instance of this class. |
|
63 */ |
|
64 static CPbk2PredictiveSearchFilter* NewL(); |
|
65 |
|
66 /** |
|
67 * Destructor. |
|
68 */ |
|
69 ~CPbk2PredictiveSearchFilter(); |
|
70 |
|
71 public: // Implementation |
|
72 /** |
|
73 * Filters the KeyEvent |
|
74 * |
|
75 */ |
|
76 void FilterL( const TKeyEvent& aKeyEvent, TEventCode aType, CAknSearchField* aSearchField ); |
|
77 |
|
78 /** |
|
79 * Updates the FindPane Display text. |
|
80 * |
|
81 * Called when a character is added to or deleted from the FindPane. |
|
82 * The descriptor aFindPaneText contains the entire new inline text string, |
|
83 * not just the new text to be combined with the old inline text. |
|
84 * |
|
85 * @param aFindPaneText Descriptor which holds the entire new inline text string. |
|
86 * Once this function completes, this param will hold the |
|
87 * respective predictive search key which can be passed to |
|
88 * the ViewStack for the actual Search. |
|
89 * |
|
90 * |
|
91 * @returns ETrue, if the filter data is updated successfully. |
|
92 * Only then we need to pass the find query to the ViewStack |
|
93 */ |
|
94 TBool StartFindPaneInlineEditL( TDes& aFindPaneText ); |
|
95 |
|
96 /** |
|
97 * Handler to the Predictive Search Results when there is no match |
|
98 * found for a query |
|
99 * @param aQueryString - Holds the Actual Search Query |
|
100 * @param aMatchSeq - Holds the matched item. The aMatchSeq will be |
|
101 * empty, if there is no match found. |
|
102 */ |
|
103 void HandlePSNoMatchL( const TDesC& aQueryString, const TDesC& aMatchSeq ); |
|
104 |
|
105 /** |
|
106 * Sets the AKN FindPane |
|
107 * @param aSearchField : Ptr to the Avkon findPane |
|
108 */ |
|
109 void SetAknSearchFieldL( CAknSearchField* aSearchField ); |
|
110 |
|
111 /** |
|
112 * Checks if predictive search is supported |
|
113 * |
|
114 * @return ETrue if predictive input activated else EFalse |
|
115 * |
|
116 */ |
|
117 TBool IsPredictiveActivated() const; |
|
118 |
|
119 /** |
|
120 * Check whether the FindPane filter is locked or not |
|
121 * |
|
122 * Before passing any keys to the FindPane this Function |
|
123 * needs to be checked. Only Backspace should be passed |
|
124 * if the the findpane is locked, which will release the lock. |
|
125 * |
|
126 * @return ETrue if FindPane is locked else EFalse |
|
127 */ |
|
128 TBool IsLocked() const; |
|
129 |
|
130 /** |
|
131 * Reset the findPane Filter |
|
132 * The state of the FindPane filter is reset |
|
133 * This needs to be called along with the FindPane Reset |
|
134 */ |
|
135 void ResetL(); |
|
136 |
|
137 /** |
|
138 * Reset the FindPane |
|
139 */ |
|
140 void FindPaneResetL(); |
|
141 |
|
142 /** |
|
143 * Fills the aSearchText with the actual Search String. |
|
144 * NOTE: |
|
145 * ----- |
|
146 * When predictive search is enabled, the search text will be |
|
147 * different from the findpane text, since the findpane will show the |
|
148 * first matched item in the listbox and |
|
149 * not the excat chars for which the search was initiated. |
|
150 * If you want to get the FindPane text, use the API FindPaneTextL() |
|
151 * |
|
152 * When Predictive Search is Disabled, both GetSearchTextL & |
|
153 * FindPaneTextL will return the same data. |
|
154 * |
|
155 * @param aSearchText : This will be filled with the actual string |
|
156 * for which the search was initiated. |
|
157 */ |
|
158 void GetSearchTextL( RBuf& aSearchText ); |
|
159 |
|
160 /** |
|
161 * Is editor in Paste Mode |
|
162 * @return ETrue if the findpane is in PasteMode else EFalse |
|
163 */ |
|
164 TBool IsPasteMode(); |
|
165 |
|
166 /** |
|
167 * Is Filtering of FindPane Text is ongoing |
|
168 * Dont perforn any operation on the Findpane or FindPane filter |
|
169 * when Filtering is ongoing. |
|
170 * @return ETrue-if Filtering is ongoing else EFalse |
|
171 */ |
|
172 TBool IsFiltering(); |
|
173 |
|
174 |
|
175 /** |
|
176 * Commits the matched string to the FindPane |
|
177 * |
|
178 * aViewStack - Holds the items displayed on the NamesList |
|
179 * aNameFormatter - Phonebook 2 contact name formatter interface |
|
180 */ |
|
181 TInt CommitFindPaneTextL( MPbk2FilteredViewStack& aViewStack, |
|
182 MPbk2ContactNameFormatter& aNameFormatter ); |
|
183 |
|
184 /** |
|
185 * Commits the matched string of specific contact to the FindPane |
|
186 * |
|
187 * aViewStack - Holds the items displayed on the NamesList |
|
188 * aNameFormatter - Phonebook 2 contact name formatter interface |
|
189 */ |
|
190 void CommitFindPaneTextL( MPbk2FilteredViewStack& aViewStack, |
|
191 MPbk2ContactNameFormatter& aNameFormatter, |
|
192 const TInt aIndex ); |
|
193 |
|
194 |
|
195 /** |
|
196 * Foreground event handling function. |
|
197 * |
|
198 * @ param aForeground-Indicates the required focus state of the |
|
199 * control. |
|
200 */ |
|
201 void HandleForegroundEventL(TBool aForeground); |
|
202 |
|
203 /** |
|
204 * Gets the text in the find box. Returns NULL if not |
|
205 * applicable or there is no text in the box. |
|
206 * |
|
207 * @return Find box text or NULL. |
|
208 */ |
|
209 HBufC* FindPaneTextL(); |
|
210 |
|
211 /** |
|
212 * Redraws search box content |
|
213 */ |
|
214 void ReDrawL(TBool aAsynchronous = EFalse); |
|
215 |
|
216 void LookupL( const MVPbkViewContact& aContact, CPbk2PredictiveViewStack& aView, |
|
217 MPbk2ContactNameFormatter& aNameFormatter, TDes& aMatchSeqChr ); |
|
218 |
|
219 private: |
|
220 /* |
|
221 * Add this FindPane filter to the View Stack |
|
222 * This takes the high priority then FEP |
|
223 */ |
|
224 void AddToViewStackL(); |
|
225 |
|
226 /* |
|
227 * Remove the filter from the View Stack |
|
228 */ |
|
229 void RemoveFromViewStack(); |
|
230 |
|
231 void CommitFindPaneTextL( const TDesC& aMatchSeq ); |
|
232 |
|
233 TBool IsMirroredInputLang(); |
|
234 |
|
235 void SetSearchBoxTextL( const TDesC& aText, TInt aCursorPos, TBool aDrawNow = ETrue ); |
|
236 |
|
237 private: // Implementation |
|
238 CPbk2PredictiveSearchFilter(); |
|
239 void ConstructL(); |
|
240 |
|
241 public: // From CCoeControl |
|
242 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
243 |
|
244 private: // Data |
|
245 /// Own: Is true when filtering |
|
246 TBool iFiltering; |
|
247 |
|
248 /// Ref : eikappui |
|
249 CEikAppUi& iAppUi; |
|
250 |
|
251 /// Owns: Contains the actual string for which Predictive search was initiated |
|
252 RBuf iPredictiveTextEntered; |
|
253 |
|
254 ///Doesnt Own - FindPane |
|
255 CAknSearchField* iSearchField; |
|
256 |
|
257 /// To know whether Filter is locked or not |
|
258 TBool iLocked; |
|
259 |
|
260 /// To know the mode of the findPane filter |
|
261 TEditorMode iEditorMode; |
|
262 |
|
263 /// ETrue if the Filter has been added to the View Stack |
|
264 TBool iViewStack; |
|
265 |
|
266 /// ETrue if Predictive search is enabled |
|
267 TBool iPredictiveSearchEnabled; |
|
268 |
|
269 ///Identify a Long Key Press |
|
270 TBool iLongKeyPress; |
|
271 |
|
272 ///Serach Text which is displayed on the FindPane |
|
273 ///Display Text |
|
274 ///Owns |
|
275 HBufC* iSearchText; |
|
276 |
|
277 /// ETrue if the Filter should be added to the View Stack |
|
278 TBool iAddToViewStack; |
|
279 |
|
280 /// If ETrue space should be removed |
|
281 TBool iRemoveSpace; |
|
282 |
|
283 /// ETrue If virtual keyboard was used to tap query |
|
284 TBool iVKbUsed; |
|
285 |
|
286 // Own: Use to run method in asynchronous mode |
|
287 CRunAsynch* iRunAsynch; |
|
288 }; |
|
289 |
|
290 #endif /* CPBK2PREDICTIVESEARCHFILTER_H_ */ |