|
1 /* |
|
2 * Copyright (c) 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: This file defines class CNcsAifEntry. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CNCSAIFEDITOR_H |
|
21 #define CNCSAIFEDITOR_H |
|
22 |
|
23 |
|
24 #include "ncseditor.h" |
|
25 |
|
26 |
|
27 class CNcsEmailAddressObject; |
|
28 class MNcsAddressPopupList; |
|
29 class CNcsAifEntry; |
|
30 |
|
31 |
|
32 /** |
|
33 * CNcsAifEditor class. |
|
34 */ |
|
35 class CNcsAifEditor: public CNcsEditor, public MEikEdwinObserver |
|
36 { |
|
37 public: // constructors/destructor |
|
38 |
|
39 CNcsAifEditor( MNcsFieldSizeObserver* aSizeObserver, const TDesC& aCaptionText ); |
|
40 |
|
41 void ConstructL( const CCoeControl* aParent, |
|
42 TInt aNumberOfLines, |
|
43 TInt aTextLimit ); |
|
44 |
|
45 virtual ~CNcsAifEditor(); |
|
46 |
|
47 public: // from CoeControl |
|
48 |
|
49 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
50 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
51 |
|
52 public: // from MEikEdwinObserver |
|
53 |
|
54 void HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType); |
|
55 |
|
56 public: // new functions |
|
57 |
|
58 virtual TInt LineCount() const; |
|
59 |
|
60 virtual TInt CursorLineNumber() const; |
|
61 |
|
62 void UpdateAddressListAllL(); |
|
63 |
|
64 void CopyToStoreL( |
|
65 CStreamStore& aStore, |
|
66 CStreamDictionary& aDict ); |
|
67 |
|
68 void CheckAddressWhenFocusLostL(); |
|
69 |
|
70 void ParseNewAddressL(); |
|
71 |
|
72 TKeyResponse HandleContactDeletionL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
73 |
|
74 const CNcsEmailAddressObject* EmailAddressObjectBySelection() const; |
|
75 |
|
76 /** |
|
77 * Get the text to match in either the local address book |
|
78 * or the remote directory server |
|
79 */ |
|
80 HBufC* GetLookupTextLC() const; |
|
81 |
|
82 void AddAddressL( |
|
83 const TDesC& aDN, |
|
84 const TDesC& aEmail, |
|
85 TBool aDisplayFull = EFalse, |
|
86 TBool aUpdateEditorText = ETrue ); |
|
87 |
|
88 void AddAddressL( const CNcsEmailAddressObject& aAddress, TBool aUpdateEditorText = ETrue ); |
|
89 |
|
90 void SetAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress ); |
|
91 |
|
92 void AppendAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress ); |
|
93 |
|
94 const RPointerArray<CNcsEmailAddressObject>& GetAddressesL(); |
|
95 |
|
96 void RecalculateEntryPositions(); |
|
97 |
|
98 inline void SetPopupList(MNcsAddressPopupList* aPopupList); |
|
99 |
|
100 private: // new functions |
|
101 |
|
102 enum TEntryDirection |
|
103 { |
|
104 EDirectionNone, |
|
105 EDirectionRight, |
|
106 EDirectionLeft |
|
107 }; |
|
108 |
|
109 void UpdateAddressAutoCompletionL(); |
|
110 void UpdateAddressAutoCompletionL( const TCursorSelection& aSelection ); |
|
111 |
|
112 void DoCharChangeL(); |
|
113 |
|
114 TChar CharAtPos( TInt aPos ) const; |
|
115 |
|
116 void AddAddressL( CNcsAifEntry* aEntry, TBool aUpdateEditorText ); |
|
117 |
|
118 TKeyResponse SetEditorSelectionL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
119 |
|
120 TInt CalculateAddressListLength( |
|
121 RPointerArray<CNcsAifEntry>& aEntries, |
|
122 TBool aDisplayList = ETrue ) const; |
|
123 |
|
124 /** |
|
125 * Creates formatted address list of given entries. |
|
126 * |
|
127 * @param aEntries Entries from which list is constructed. |
|
128 * @param aDisplayList If ETrue, constructs list of display names |
|
129 * of the addresses. If EFalse, constructs list |
|
130 * of email addresses. |
|
131 */ |
|
132 HBufC* GetFormattedAddressListLC( |
|
133 RPointerArray<CNcsAifEntry>& aEntries, |
|
134 TBool aDisplayList = ETrue ) const; |
|
135 |
|
136 HBufC* GetFormattedAddressListL( |
|
137 RPointerArray<CNcsAifEntry>& aEntries, |
|
138 TBool aDisplayList = ETrue ) const; |
|
139 |
|
140 void RepositionEntriesL( const CNcsAifEntry* aEntry ); |
|
141 |
|
142 void CheckAndRemoveInvalidEntriesL(); |
|
143 |
|
144 CNcsAifEntry* GetEntryAt( |
|
145 TInt aPos, |
|
146 TEntryDirection aDirection = EDirectionNone ) const; |
|
147 |
|
148 /** Browse backwards from given position and return the first found entry */ |
|
149 CNcsAifEntry* GetPreviousEntryFrom( TInt aPos ) const; |
|
150 |
|
151 HBufC* GetNonEntryTextLC() const; |
|
152 |
|
153 TKeyResponse CopyEntriesToClipboardL( |
|
154 const TKeyEvent& aKeyEvent, |
|
155 TEventCode aType ); |
|
156 |
|
157 void FindSelectedEntriesL( RPointerArray<CNcsAifEntry>& aEntries ); |
|
158 |
|
159 // <cmail> fixed CS high cat. finding |
|
160 void UpdateDuplicateEntryMarkingsL(); |
|
161 |
|
162 void HandleTextUpdateDeferred(); |
|
163 static TInt DoHandleTextUpdate( TAny* aSelf ); |
|
164 |
|
165 void HandleTextUpdateL(); |
|
166 /** |
|
167 * Handle addition of complete address. May result in complete redraw of the field. |
|
168 * @return ETrue if terminated recipient entry was found and added to array. |
|
169 */ |
|
170 TBool HandleTextUpdateL( const TCursorSelection& aSelection ); |
|
171 void HandleNavigationEventL(); |
|
172 TCursorSelection NonEntryTextAtPos( TUint aPosition ) const; |
|
173 TCursorSelection NonEntryTextBeforePos( TUint aPosition ) const; |
|
174 TBool IsSentinel( TChar aCharacter ) const; |
|
175 TBool IsWhitespace( TChar aCharacter ) const; |
|
176 TBool IsNavigationKey( const TKeyEvent& aKeyEvent ) const; |
|
177 TBool IsCharacterKey( const TKeyEvent& aKeyEvent ) const; |
|
178 void GetMatchingEntryCountsL( |
|
179 const CNcsAifEntry* aEntry, |
|
180 TInt& aNrOfMatchesInText, |
|
181 TInt& aNrOfMatchesInEntryArray ); |
|
182 void CompleteEntryL(); |
|
183 |
|
184 private: // data |
|
185 |
|
186 RPointerArray<CNcsAifEntry> iArray; |
|
187 |
|
188 RPointerArray<CNcsEmailAddressObject> iAddressArray; |
|
189 |
|
190 MNcsAddressPopupList* iAddressPopupList; |
|
191 |
|
192 CAsyncCallBack* iAsyncCallBack; |
|
193 |
|
194 TInt iLastTimeCursorPos; |
|
195 |
|
196 // Flag indicating whether add the leftover text to the end of the field |
|
197 TBool iAddLeftover; |
|
198 TCursorSelection iTextSelection; |
|
199 TBool iPartialRemove; |
|
200 }; |
|
201 |
|
202 |
|
203 /////////////////////////////////////////////////////////////////////// |
|
204 // CNcsAifEntry |
|
205 // This class represents a full entry in the AIF field. |
|
206 // It is derived from TCursorSelection which helps in atomizing the |
|
207 // items when the cursor moves over them. |
|
208 // NOTES: |
|
209 // iAnchorPosition is non-inclusive. This position represents |
|
210 // the anchor of a selection and is not included in the selection |
|
211 // count. So the selection would be iCursorPosition to iAnchorPosition |
|
212 // - 1. The SetSelection function will highlight anything left of the |
|
213 // anchor up to and including the cursor. |
|
214 // The idea is that if you were to use shift-cursor to select text, |
|
215 // The anchor would be the cursor you started to hold down the shift. |
|
216 // Since this location is not included in the selection, but rather |
|
217 // the first position left or right of this poistion, the anchor is |
|
218 // never included in the selection. |
|
219 class CNcsAifEntry : public CBase, public TCursorSelection |
|
220 { |
|
221 public: |
|
222 |
|
223 static CNcsAifEntry* CNcsAifEntry::NewL( const CNcsEmailAddressObject& aAddr ); |
|
224 |
|
225 static CNcsAifEntry* CNcsAifEntry::NewL( |
|
226 const TDesC& aDn, |
|
227 const TDesC& aEml, |
|
228 TBool aDisplayFull ); |
|
229 |
|
230 CNcsAifEntry::~CNcsAifEntry(); |
|
231 |
|
232 private: |
|
233 |
|
234 CNcsAifEntry(); |
|
235 |
|
236 void ConstructL( const TDesC& aDn, const TDesC& aEml, TBool aDisplayFull ); |
|
237 |
|
238 void ConstructL( const CNcsEmailAddressObject& aAddress ); |
|
239 |
|
240 void ConstructL() ; |
|
241 |
|
242 void SetDisplayStringL(); |
|
243 |
|
244 public: |
|
245 |
|
246 inline TInt DisplayLength() const; |
|
247 |
|
248 inline const TDesC& DisplayString() const; |
|
249 |
|
250 inline TInt SetPos(TInt aPos); |
|
251 |
|
252 inline TBool Includes(TInt aPos) const; |
|
253 |
|
254 inline TInt Start() const; |
|
255 |
|
256 inline TInt End() const; |
|
257 |
|
258 inline const CNcsEmailAddressObject& Address() const; |
|
259 |
|
260 inline TBool IsDup() const; |
|
261 |
|
262 void SetDupL( TBool aDup = ETrue ); |
|
263 |
|
264 TBool IsSameDN(const CNcsAifEntry& aEntry) const; |
|
265 |
|
266 private: |
|
267 |
|
268 CNcsEmailAddressObject* iAddress; |
|
269 HBufC* iDisplayString; |
|
270 |
|
271 TBool iIsDup; |
|
272 }; |
|
273 |
|
274 #include "ncsaifeditor.inl" |
|
275 |
|
276 #endif // CNCSSUBJECTFIELD_H |
|
277 |
|
278 |
|
279 // End of File |