author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 11:52:37 +0300 | |
branch | RCL_3 |
changeset 73 | c8382f7b54ef |
parent 64 | 3533d4323edc |
child 80 | 726fba06891a |
permissions | -rw-r--r-- |
64 | 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 |
||
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
140 |
TInt RepositionEntries( const CNcsAifEntry* aEntry ); |
64 | 141 |
void RepositionEntriesL( const CNcsAifEntry* aEntry ); |
142 |
||
143 |
void CheckAndRemoveInvalidEntriesL(); |
|
144 |
||
145 |
CNcsAifEntry* GetEntryAt( |
|
146 |
TInt aPos, |
|
147 |
TEntryDirection aDirection = EDirectionNone ) const; |
|
148 |
||
149 |
/** Browse backwards from given position and return the first found entry */ |
|
150 |
CNcsAifEntry* GetPreviousEntryFrom( TInt aPos ) const; |
|
151 |
||
152 |
HBufC* GetNonEntryTextLC() const; |
|
153 |
||
154 |
TKeyResponse CopyEntriesToClipboardL( |
|
155 |
const TKeyEvent& aKeyEvent, |
|
156 |
TEventCode aType ); |
|
157 |
||
158 |
void FindSelectedEntriesL( RPointerArray<CNcsAifEntry>& aEntries ); |
|
159 |
||
160 |
// <cmail> fixed CS high cat. finding |
|
161 |
void UpdateDuplicateEntryMarkingsL(); |
|
162 |
||
163 |
void HandleTextUpdateDeferred(); |
|
164 |
static TInt DoHandleTextUpdate( TAny* aSelf ); |
|
165 |
||
166 |
void HandleTextUpdateL(); |
|
167 |
/** |
|
168 |
* Handle addition of complete address. May result in complete redraw of the field. |
|
169 |
* @return ETrue if terminated recipient entry was found and added to array. |
|
170 |
*/ |
|
171 |
TBool HandleTextUpdateL( const TCursorSelection& aSelection ); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
172 |
// Moves inputted non-entry text to separate rows apart from entries. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
173 |
void MoveNonEntryTextToDedicatedRowsL( TUint aPosition ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
174 |
// Prepares for text input to given cursor position. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
175 |
void PrepareForTextInputL( TUint aPosition ); |
64 | 176 |
void HandleNavigationEventL(); |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
177 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
178 |
// Gets non-entry text at given document position. |
64 | 179 |
TCursorSelection NonEntryTextAtPos( TUint aPosition ) const; |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
180 |
// Gets non-entry text including surrounding whitespace at given position. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
181 |
TCursorSelection NonEntryTextAndSpaceAtPos( TUint aPosition ) const; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
182 |
// Gets non-enty text right before given document position. |
64 | 183 |
TCursorSelection NonEntryTextBeforePos( TUint aPosition ) const; |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
184 |
|
64 | 185 |
TBool IsSentinel( TChar aCharacter ) const; |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
186 |
TBool IsDelimiter( TChar aCharacter ) const; |
64 | 187 |
TBool IsWhitespace( TChar aCharacter ) const; |
188 |
TBool IsNavigationKey( const TKeyEvent& aKeyEvent ) const; |
|
189 |
TBool IsCharacterKey( const TKeyEvent& aKeyEvent ) const; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
190 |
|
64 | 191 |
void GetMatchingEntryCountsL( |
192 |
const CNcsAifEntry* aEntry, |
|
193 |
TInt& aNrOfMatchesInText, |
|
194 |
TInt& aNrOfMatchesInEntryArray ); |
|
195 |
void CompleteEntryL(); |
|
196 |
||
197 |
private: // data |
|
198 |
||
199 |
RPointerArray<CNcsAifEntry> iArray; |
|
200 |
||
201 |
RPointerArray<CNcsEmailAddressObject> iAddressArray; |
|
202 |
||
203 |
MNcsAddressPopupList* iAddressPopupList; |
|
204 |
||
205 |
CAsyncCallBack* iAsyncCallBack; |
|
206 |
||
207 |
TInt iLastTimeCursorPos; |
|
208 |
||
209 |
// Flag indicating whether add the leftover text to the end of the field |
|
210 |
TBool iAddLeftover; |
|
211 |
TCursorSelection iTextSelection; |
|
212 |
TBool iPartialRemove; |
|
213 |
}; |
|
214 |
||
215 |
||
216 |
/////////////////////////////////////////////////////////////////////// |
|
217 |
// CNcsAifEntry |
|
218 |
// This class represents a full entry in the AIF field. |
|
219 |
// It is derived from TCursorSelection which helps in atomizing the |
|
220 |
// items when the cursor moves over them. |
|
221 |
// NOTES: |
|
222 |
// iAnchorPosition is non-inclusive. This position represents |
|
223 |
// the anchor of a selection and is not included in the selection |
|
224 |
// count. So the selection would be iCursorPosition to iAnchorPosition |
|
225 |
// - 1. The SetSelection function will highlight anything left of the |
|
226 |
// anchor up to and including the cursor. |
|
227 |
// The idea is that if you were to use shift-cursor to select text, |
|
228 |
// The anchor would be the cursor you started to hold down the shift. |
|
229 |
// Since this location is not included in the selection, but rather |
|
230 |
// the first position left or right of this poistion, the anchor is |
|
231 |
// never included in the selection. |
|
232 |
class CNcsAifEntry : public CBase, public TCursorSelection |
|
233 |
{ |
|
234 |
public: |
|
235 |
||
236 |
static CNcsAifEntry* CNcsAifEntry::NewL( const CNcsEmailAddressObject& aAddr ); |
|
237 |
||
238 |
static CNcsAifEntry* CNcsAifEntry::NewL( |
|
239 |
const TDesC& aDn, |
|
240 |
const TDesC& aEml, |
|
241 |
TBool aDisplayFull ); |
|
242 |
||
243 |
CNcsAifEntry::~CNcsAifEntry(); |
|
244 |
||
245 |
private: |
|
246 |
||
247 |
CNcsAifEntry(); |
|
248 |
||
249 |
void ConstructL( const TDesC& aDn, const TDesC& aEml, TBool aDisplayFull ); |
|
250 |
||
251 |
void ConstructL( const CNcsEmailAddressObject& aAddress ); |
|
252 |
||
253 |
void ConstructL() ; |
|
254 |
||
255 |
void SetDisplayStringL(); |
|
256 |
||
257 |
public: |
|
258 |
||
259 |
inline TInt DisplayLength() const; |
|
260 |
||
261 |
inline const TDesC& DisplayString() const; |
|
262 |
||
263 |
inline TInt SetPos(TInt aPos); |
|
264 |
||
265 |
inline TBool Includes(TInt aPos) const; |
|
266 |
||
267 |
inline TInt Start() const; |
|
268 |
||
269 |
inline TInt End() const; |
|
270 |
||
271 |
inline const CNcsEmailAddressObject& Address() const; |
|
272 |
||
273 |
inline TBool IsDup() const; |
|
274 |
||
275 |
void SetDupL( TBool aDup = ETrue ); |
|
276 |
||
277 |
TBool IsSameDN(const CNcsAifEntry& aEntry) const; |
|
278 |
||
279 |
private: |
|
280 |
||
281 |
CNcsEmailAddressObject* iAddress; |
|
282 |
HBufC* iDisplayString; |
|
283 |
||
284 |
TBool iIsDup; |
|
285 |
}; |
|
286 |
||
287 |
#include "ncsaifeditor.inl" |
|
288 |
||
289 |
#endif // CNCSSUBJECTFIELD_H |
|
290 |
||
291 |
||
292 |
// End of File |