|
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 contact editor dialog implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPBK2ADAPTIVESEARCHGRIDFILLER_H |
|
20 #define CPBK2ADAPTIVESEARCHGRIDFILLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <aknsfld.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CAknSearchField; |
|
28 class CFindUtil; |
|
29 class CPbk2AdaptiveGrid; |
|
30 class MVPbkContactViewBase; |
|
31 class MPbk2ContactNameFormatter; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * Phonebook 2 adaptive search grid filler. |
|
37 * |
|
38 * This class used to create adaptive search grid used to |
|
39 * search contacts from Phonebook 2. |
|
40 */ |
|
41 NONSHARABLE_CLASS(CPbk2AdaptiveSearchGridFiller) : public CActive |
|
42 { |
|
43 public: // Constructors and destructor |
|
44 |
|
45 /** |
|
46 * Creates a new instance of this class. |
|
47 * |
|
48 * @param aField Search field where adaptive search grid is updated. |
|
49 */ |
|
50 static CPbk2AdaptiveSearchGridFiller* NewL( CAknSearchField& aField, MPbk2ContactNameFormatter& aNameFormatter ); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 virtual ~CPbk2AdaptiveSearchGridFiller(); |
|
56 |
|
57 public: // Interface |
|
58 |
|
59 /** |
|
60 * Start creating adaptive search grid |
|
61 * |
|
62 * Grid will be created asynchronously. When the grid is updated, it is |
|
63 * automatically updated to the CAknSearchField object provided in the |
|
64 * construction of this object. Client will not be notified when constructing |
|
65 * of the grid is ready. |
|
66 * |
|
67 * @param aModel contains contacts shown in the list box, this is used |
|
68 * to create adaptive search grid |
|
69 * @param aFindText is text user has entered in the find pane. |
|
70 */ |
|
71 void StartFilling( const MVPbkContactViewBase& aView, const TDesC& aSearchString ); |
|
72 |
|
73 |
|
74 /** |
|
75 * Stop creating adaptive search grid |
|
76 */ |
|
77 void StopFilling(); |
|
78 |
|
79 /** |
|
80 * Clear adaptive search grid cache. |
|
81 * |
|
82 * Data set (contacts shown in the list box) has changed, e.g. contact is removed or added. |
|
83 * This means that adaptive search grids used before, cannot be reused. |
|
84 */ |
|
85 void ClearCache(); |
|
86 |
|
87 |
|
88 /** |
|
89 * Invalidate Adaptive Search Grid |
|
90 * |
|
91 * This means that even if the adaptive search grid doesn't set, it is still given again to the |
|
92 * Avkon component. If this is not called, then the grid is given to Avkon components only when |
|
93 * it changes. |
|
94 */ |
|
95 void InvalidateAdaptiveSearchGrid(); |
|
96 |
|
97 |
|
98 /** |
|
99 * Change focus back to Adaptive Search Grid |
|
100 * |
|
101 * This means that even if the "C" key is pressed,the focus will be change to parent control. |
|
102 * But actually this operation is done to Adaptive Search Grid. So set the focus back to it. |
|
103 */ |
|
104 void SetFocusToAdaptiveSearchGrid(); |
|
105 |
|
106 |
|
107 private: // from CActive |
|
108 |
|
109 void RunL(); |
|
110 void DoCancel(); |
|
111 TInt RunError( TInt aError ); |
|
112 |
|
113 private: // Implementation |
|
114 |
|
115 CPbk2AdaptiveSearchGridFiller( CAknSearchField& aField, MPbk2ContactNameFormatter& aNameFormatter ); |
|
116 void ConstructL(); |
|
117 |
|
118 CPbk2AdaptiveGrid* KeyMapFromCache( const TDesC& aFindText ); |
|
119 void AddKeyMapToCacheL( const TDesC& aFindText, const TDesC& aKeyMap ); |
|
120 void SetAdaptiveGridCharsL( const TInt aMaxSpacesNumber ); |
|
121 CDesC16Array* SplitContactFieldTextIntoArrayLC( const TDesC& aText ); |
|
122 void BuildGridL( const TDesC& aContactTitle, const TDesC& aSearchString, HBufC*& aKeyMap ); |
|
123 TInt NumberOfSpacesInString( const TDesC& aSearchString ); |
|
124 // Used to judge if this contact's title include drgraphs |
|
125 TBool IsDigraphContactsTitleL(const TDesC& aContactTitle); |
|
126 private: // Data |
|
127 |
|
128 /// Own: Containts adaptive search grid. |
|
129 HBufC* iKeyMap; |
|
130 |
|
131 /// Own: Contacts in the model are processed in a steps, this variable is |
|
132 /// used to hold the next step. |
|
133 TInt iCounter; |
|
134 |
|
135 /// Ref: Search field where use enters the text. Responsible to show adaptive search grid. |
|
136 CAknSearchField& iSearchField; |
|
137 |
|
138 /// Own: Cache adaptive grid keymaps |
|
139 RPointerArray<CPbk2AdaptiveGrid> iAdaptiveGridCache; |
|
140 |
|
141 /// Ref: View containing contacts. |
|
142 const MVPbkContactViewBase* iView; |
|
143 |
|
144 /// Ref: Used to format contact name |
|
145 MPbk2ContactNameFormatter& iNameFormatter; |
|
146 |
|
147 /// Own: Search string used to match contacts |
|
148 HBufC* iSearchString; |
|
149 |
|
150 /// Own: Find util used to match contacts and construct character grid |
|
151 CFindUtil* iFindUtil; |
|
152 |
|
153 /// Own: Current adaptive search grid. Used to prevent setting same grid multiple times. |
|
154 HBufC* iCurrentGrid; |
|
155 |
|
156 /// Used to invalidate grid, even if the grid remains same, it is anyway set if this is set to |
|
157 /// ETrue |
|
158 TBool iInvalidateAdaptiveSearchGrid; |
|
159 |
|
160 /// Used to get the focus for the search pane,when it is true, the search pane will be drawn and get |
|
161 /// the focus |
|
162 TBool iSetFocusToSearchGrid; |
|
163 /// Used to save the contacts' title which include drgraphs |
|
164 RPointerArray<HBufC> iDigraphContactsTitleArray; |
|
165 }; |
|
166 |
|
167 #endif // CPBK2ADAPTIVESEARCHGRIDFILLER_H |
|
168 |
|
169 // End of File |