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