|
1 /* |
|
2 * Copyright (c) 2002-2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef FINDITEMCONTROLLER_H |
|
20 #define FINDITEMCONTROLLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <finditemengine.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CPlainText; |
|
28 class CRichText; |
|
29 class MFindItemDialogCallBack; |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * FindItem's controller class. |
|
35 * - Takes care of communication between dialog and engine classes |
|
36 * - Updates editor (directly or inderectly using the dialog class) |
|
37 */ |
|
38 NONSHARABLE_CLASS(CFindItemController) :public CBase |
|
39 { |
|
40 public: // Constructors and destructor |
|
41 |
|
42 /** |
|
43 * Two-phased constructor. |
|
44 * |
|
45 * @param aDialog Callback pointer to a dialog class |
|
46 * @param aRichText Pointer to richtext that needs to be edited (underlined) |
|
47 * @param aText Text that needs to be parsed |
|
48 * @param aSearchCase Identifies what items are we looking for: |
|
49 * EFindItemSearchPhoneNumber |
|
50 * EFindItemSearchMailAddress |
|
51 * EFindItemSearchURL |
|
52 * |
|
53 * @return Pointer to constructed controller |
|
54 */ |
|
55 static CFindItemController* NewL( |
|
56 MFindItemDialogCallBack* aDialog, |
|
57 CRichText* aRichText, |
|
58 const TDesC& aText, |
|
59 const CFindItemEngine::TFindItemSearchCase aSearchCase ); |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 virtual ~CFindItemController(); |
|
65 |
|
66 public: // New functions |
|
67 /** |
|
68 * Gives the currently 'selected' item |
|
69 * |
|
70 * @param aItem Holds currently selected item |
|
71 * |
|
72 * @return EFalse if no items were found |
|
73 */ |
|
74 inline TBool Item( CFindItemEngine::SFoundItem& aItem ) const; |
|
75 |
|
76 /** |
|
77 * Moves the selection to next item |
|
78 * |
|
79 * @return EFalse if there's no next item. |
|
80 */ |
|
81 TBool NextItemL(); |
|
82 |
|
83 /** |
|
84 * Moves the selections to previous item |
|
85 * |
|
86 * @return EFalse if there's no previous item. |
|
87 */ |
|
88 TBool PrevItemL(); |
|
89 |
|
90 /** |
|
91 * Move into next row, where found item is |
|
92 */ |
|
93 void MoveDownL(); |
|
94 |
|
95 /** |
|
96 * Move into previous row, where found item is |
|
97 */ |
|
98 void MoveUpL(); |
|
99 |
|
100 /** |
|
101 * Marks found items |
|
102 * - Underlines all found strings |
|
103 * - Updates the selection |
|
104 * |
|
105 * @return Returns EFalse if zero items were found |
|
106 */ |
|
107 void MarkFoundItemsL(); |
|
108 |
|
109 /** |
|
110 * Fills array with items (TInts) which causes scrollbar to move |
|
111 * i.e. items that are not in the same line |
|
112 * |
|
113 * @param aArray Array that needs to be filled |
|
114 */ |
|
115 void FillScrollBarItemsArrayL( CArrayFixFlat<TInt>* aArray ); |
|
116 |
|
117 /** |
|
118 * Position and count methods |
|
119 */ |
|
120 inline const TInt Position() const; // Returns current position |
|
121 inline const TBool FirstItem() const; // Returns ETrue if at first item |
|
122 inline const TBool LastItem() const; // Returns ETrue if at last item |
|
123 |
|
124 inline const TInt ItemCount() const; // Returns the number of found items |
|
125 |
|
126 /** |
|
127 * Check if item is at the same line as first item |
|
128 * Needed for Scrollbar (if text's length is over 2000 chars) |
|
129 */ |
|
130 TBool IsAtSameLineAsFirstItem(); |
|
131 |
|
132 /** |
|
133 * Check if item is at the same line as last item |
|
134 * Needed for Scrollbar (if text's length is over 2000 chars) |
|
135 */ |
|
136 TBool IsAtSameLineAsLastItem(); |
|
137 |
|
138 /* |
|
139 * Moves the selections to tapped item. |
|
140 * |
|
141 * @return EFalse if no tapped item selected. |
|
142 */ |
|
143 TBool TappedItemL( const TInt index ); |
|
144 |
|
145 /** |
|
146 * Get indexed item from find engine. |
|
147 * |
|
148 * @param aIndex Item index in engine side. |
|
149 * @param aItem item to be retrieved. |
|
150 * |
|
151 * @return EFalse if no item was found. |
|
152 */ |
|
153 TBool Item( |
|
154 const TInt aIndex, |
|
155 CFindItemEngine::SFoundItem& aItem ) const; |
|
156 |
|
157 private: |
|
158 |
|
159 /** |
|
160 * C++ default constructor. |
|
161 */ |
|
162 CFindItemController(); |
|
163 |
|
164 /** |
|
165 * EPOC constructor |
|
166 * |
|
167 * @param aText Text that will be parsed |
|
168 * @param aSearchCase Identifies what items are we looking for: |
|
169 * EFindItemSearchPhoneNumber |
|
170 * EFindItemSearchMailAddress |
|
171 * EFindItemSearchURL |
|
172 */ |
|
173 void ConstructL( |
|
174 const TDesC& aText, |
|
175 const CFindItemEngine::TFindItemSearchCase aSearchCase ); |
|
176 |
|
177 /** |
|
178 * Get minimum number of digits to find. |
|
179 */ |
|
180 TInt GetMinDigitsToFindL(); |
|
181 |
|
182 |
|
183 private: // Data |
|
184 // Engine |
|
185 CFindItemEngine* iEngine; |
|
186 // Found item |
|
187 CFindItemEngine::SFoundItem iItem; |
|
188 // Association to EEikRichTextEditor's RichText |
|
189 CRichText* iRichText; |
|
190 // CallBack to dialog |
|
191 MFindItemDialogCallBack* iDialog; |
|
192 |
|
193 }; |
|
194 |
|
195 #include "finditemcontroller.inl" // inline methods |
|
196 |
|
197 #endif // FINDITEMCONTROLLER_H |
|
198 |
|
199 // End of File |