|
1 /* |
|
2 * Copyright (c) 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: Container class for vcommand app |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CVCGENERICCONTAINER_H |
|
21 #define CVCGENERICCONTAINER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <coecntrl.h> |
|
25 #include <coedef.h> |
|
26 #include <bamdesca.h> |
|
27 #include <barsread.h> |
|
28 #include <badesca.h> |
|
29 #include <aknlists.h> |
|
30 #include <AknIconArray.h> |
|
31 #include <eiksbobs.h> |
|
32 #include <AknWaitDialog.h> |
|
33 #include <AknInfoPopupNoteController.h> |
|
34 #include <data_caging_path_literals.hrh> |
|
35 #include <csxhelp/vc.hlp.hrh> |
|
36 |
|
37 #include "vcgenericview.h" |
|
38 #include "vcommandconstants.h" |
|
39 #include "vcmodel.h" |
|
40 |
|
41 |
|
42 // CONSTANTS |
|
43 |
|
44 // FORWARD DECLARATIONS |
|
45 class CEikTextListBox; |
|
46 class CEikFormattedCellListBox; |
|
47 |
|
48 // CLASS DECLARATION |
|
49 |
|
50 /** |
|
51 * CVCommandGenericContainer container control class. |
|
52 */ |
|
53 class CVCGenericContainer : public CCoeControl, |
|
54 public MCoeControlObserver, |
|
55 public MEikListBoxObserver, |
|
56 public MEikScrollBarObserver |
|
57 { |
|
58 |
|
59 public: // Constructors and destructor |
|
60 |
|
61 /** |
|
62 * C++ constructor. |
|
63 * |
|
64 * @param aMenubar a menubar |
|
65 * @param aView a pointer to view class |
|
66 */ |
|
67 CVCGenericContainer::CVCGenericContainer( CEikMenuBar* aMenuBar, |
|
68 CVCModel& aModel, |
|
69 CVCGenericView& aView ); |
|
70 |
|
71 /** |
|
72 * Symbian default constructor. |
|
73 * |
|
74 * @param aRect Frame rectangle for container. |
|
75 */ |
|
76 void ConstructL( const TRect& aRect ); |
|
77 |
|
78 /** |
|
79 * Destructor. |
|
80 */ |
|
81 ~CVCGenericContainer(); |
|
82 |
|
83 public: // Functions from base classes |
|
84 |
|
85 /** |
|
86 * From CoeControl |
|
87 * |
|
88 * @see CCoeControl for more information |
|
89 */ |
|
90 void GetHelpContext( TCoeHelpContext& aContext ) const; |
|
91 |
|
92 |
|
93 public: // New functions |
|
94 |
|
95 /** |
|
96 * Returns the focused item on listbox |
|
97 * |
|
98 * @return TInt Id of the focused item |
|
99 */ |
|
100 TInt CurrentSelection() const; |
|
101 |
|
102 /** |
|
103 * Sets the focused item on listbox |
|
104 * |
|
105 * @return void |
|
106 */ |
|
107 void SetCurrentSelection( TInt aIndex ); |
|
108 |
|
109 /** |
|
110 * |
|
111 * @return TInt the number of items in the list box |
|
112 */ |
|
113 TInt ListBoxCount() const; |
|
114 |
|
115 /** |
|
116 * Returns the first line name. |
|
117 * |
|
118 * @param aIndex list item index |
|
119 * @return const TDesC& first row name |
|
120 */ |
|
121 TDesC* GetFirstRowNameLC( TInt aIndex ) const; |
|
122 |
|
123 /** |
|
124 * Returns the second line name. |
|
125 * |
|
126 * @param aIndex list item index |
|
127 * @return const TDesC& second row name |
|
128 */ |
|
129 TDesC* GetSecondRowNameLC( TInt aIndex ) const; |
|
130 |
|
131 /** |
|
132 * Returns a title that is to be shown in folder view. |
|
133 * |
|
134 * @param aIndex list item index |
|
135 * @return TPtrC folder title name |
|
136 */ |
|
137 TPtrC GetFolderTitle( TInt aIndex ); |
|
138 |
|
139 /** |
|
140 * Returns true if pointed listbox item is a folder. |
|
141 * |
|
142 * @param aListBoxIndex index of listbox item |
|
143 * @return ETrue if item is a folder |
|
144 */ |
|
145 TBool IsItemFolderL( TInt aListBoxIndex ) const; |
|
146 |
|
147 /** |
|
148 * Shows the Edit command text query. |
|
149 * |
|
150 * @return void |
|
151 */ |
|
152 void ShowEditTextL(); |
|
153 |
|
154 /** |
|
155 * Shows delete application query |
|
156 * and handles the voice tag deletion |
|
157 * |
|
158 * @return void |
|
159 */ |
|
160 void DeleteVCommandL(); |
|
161 |
|
162 /** |
|
163 * Returns ETrue if event is under processing at the moment. |
|
164 * |
|
165 * @return ETrue if event handling process is running |
|
166 */ |
|
167 TBool IsHandlingKeyPressInProgress(); |
|
168 |
|
169 /** |
|
170 * Sets event handling state. |
|
171 * |
|
172 * @param aValue new status for event handling process |
|
173 * @return void |
|
174 */ |
|
175 void SetHandlingKeyPressInProgress( TBool aValue ); |
|
176 |
|
177 void RefreshListboxL( CVCommandUiEntryArray& oldCommands, |
|
178 CVCommandUiEntryArray& newCommands ); |
|
179 |
|
180 /** |
|
181 * Shows tooltip text for item. |
|
182 * |
|
183 * @param aItemIndex index of the listbox item |
|
184 */ |
|
185 void ShowTooltipL( TInt aItemIndex ); |
|
186 |
|
187 |
|
188 protected: // Functions from base classes |
|
189 |
|
190 /** |
|
191 * From MEikListBoxObserver |
|
192 * @see MEikListBoxObserver for more information |
|
193 */ |
|
194 void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType ); |
|
195 |
|
196 /** |
|
197 * From MEikScrollBarObserver |
|
198 * @see MEikScrollBarObserver for more information |
|
199 */ |
|
200 void HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent aEventType ); |
|
201 |
|
202 /** |
|
203 * From CCoeControl. |
|
204 * |
|
205 * @see CCoeControl for more information |
|
206 */ |
|
207 void FocusChanged( TDrawNow aDrawNow ); |
|
208 |
|
209 /** |
|
210 * From CCoeControl. |
|
211 * |
|
212 * @see CCoeControl for more information |
|
213 */ |
|
214 void SizeChanged(); |
|
215 |
|
216 /** |
|
217 * From CoeControl. |
|
218 * |
|
219 * @see CCoeControl for more information |
|
220 */ |
|
221 TInt CountComponentControls() const; |
|
222 |
|
223 /** |
|
224 * From CCoeControl. |
|
225 * |
|
226 * @see CCoeControl for more information |
|
227 */ |
|
228 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
229 |
|
230 /** |
|
231 * From MCoeControlObserver. |
|
232 * |
|
233 * @see MCoeControlObserver for more information |
|
234 */ |
|
235 void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType ); |
|
236 |
|
237 /** |
|
238 * From CCoeControl |
|
239 * |
|
240 * @see CCoeControl for more information |
|
241 */ |
|
242 void HandleResourceChangeL( TInt aType ); |
|
243 |
|
244 /** |
|
245 * From CCoeControl |
|
246 * |
|
247 * @see CCoeControl for more information |
|
248 */ |
|
249 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
250 |
|
251 private: // New functions |
|
252 |
|
253 /** |
|
254 * Constructs status pane |
|
255 * |
|
256 * @param aResourceId |
|
257 */ |
|
258 void SetTitlePaneL( TInt aResourceId ) const; |
|
259 |
|
260 /** |
|
261 * Constructs the listbox. |
|
262 */ |
|
263 void ConstructListBoxL(); |
|
264 |
|
265 /** |
|
266 * Initializes the listbox. |
|
267 */ |
|
268 void PopulateListBoxL(); |
|
269 |
|
270 /** |
|
271 * Checks if the user edited name is valid. |
|
272 * |
|
273 * @param aName name to check |
|
274 * @return TBool ETrue if name exists or is too short. |
|
275 */ |
|
276 TBool CheckNameValidityL( const TDesC& aName ); |
|
277 |
|
278 /** |
|
279 * Sets the new text to the list. |
|
280 * |
|
281 * @param aIndex The index of an application |
|
282 * @param aNewText the text that replaces the old one |
|
283 * @param aOldText the old text |
|
284 */ |
|
285 void UpdateTextL( TInt aIndex, const TDesC& aNewText, |
|
286 const TDesC& aOldText ); |
|
287 |
|
288 /** |
|
289 * Sorts the contents of the iItemNameArray to an alphabetical order. |
|
290 */ |
|
291 void SortItemListL(); |
|
292 |
|
293 /** |
|
294 * Finds the commands that should be added to the listbox |
|
295 * @param oldCommands A list of commands before an update |
|
296 * @param newCommands A list of commands after an update |
|
297 * @return RArray<CVCommand> Commands that need to be removed from the |
|
298 * listbox |
|
299 */ |
|
300 RArray<CVCommandUiEntry> FindCommandsToBeAddedL( |
|
301 CVCommandUiEntryArray& oldCommands, CVCommandUiEntryArray& newCommands ); |
|
302 |
|
303 /** |
|
304 * Adds items to the listbox. |
|
305 * @param aCommands Commands to be added |
|
306 */ |
|
307 void AddCommandsL( RArray<CVCommandUiEntry>& aCommands ); |
|
308 |
|
309 /** |
|
310 * Finds the commands that should be removed from the listbox |
|
311 * @param oldCommands A list of commands before an update |
|
312 * @param newCommands A list of commands after an update |
|
313 * @return RArray<CVCommand> Commands that need to be added to the |
|
314 * listbox |
|
315 */ |
|
316 RArray<CVCommandUiEntry> FindCommandsToBeRemovedL( |
|
317 CVCommandUiEntryArray& oldCommands, CVCommandUiEntryArray& newCommands ); |
|
318 |
|
319 /** |
|
320 * Removes items from listbox |
|
321 * @param aCommands Commands to be removed |
|
322 */ |
|
323 void RemoveCommands( RArray<CVCommandUiEntry>& aCommands ); |
|
324 |
|
325 /** |
|
326 * Searches for a string in listbox item array. |
|
327 * @param aText The search string |
|
328 * @return TInt Index in the array where the string was found. |
|
329 * KErrNotFound if the string was not found. |
|
330 */ |
|
331 TInt SearchItemArrayL( const TDesC& aText ); |
|
332 |
|
333 /** |
|
334 * Utility function for listbox item creation |
|
335 * @param aIconArrayIndex Icon array index for this item |
|
336 * @param aFirstRow First row for this item |
|
337 * @param aSecondRow Second row for this item |
|
338 * @return TDesC* A new listbox item |
|
339 */ |
|
340 TDesC* CreateListboxItemLC( TInt aIconArrayIndex, |
|
341 const TDesC& aFirstRow, |
|
342 const TDesC& aSecondRow ); |
|
343 |
|
344 /** |
|
345 * Checks for critical level flash and shows "no memory" note if needed |
|
346 * |
|
347 * @return ETrue if CL would be reached after this operation. |
|
348 */ |
|
349 TBool CheckCriticalLevelL(); |
|
350 |
|
351 private: // data |
|
352 |
|
353 CEikMenuBar* iMenuBar; // Not owned |
|
354 CVCGenericView& iView; |
|
355 |
|
356 CVCModel& iModel; |
|
357 |
|
358 //CEikTextListBox* iListBox; // Owned |
|
359 CEikFormattedCellListBox* iListBox; // Owned |
|
360 |
|
361 // Displayed names for the items in listbox |
|
362 CDesC16ArrayFlat* iItemArray; // Not owned |
|
363 |
|
364 // Titles for different folders in folder view |
|
365 CDesC16ArrayFlat* iFolderTitles; |
|
366 |
|
367 // Corresponds index by index with the items in iItemNameArray. |
|
368 // Stores information on whether an item is a folder |
|
369 RArray<TBool> iItemIsFolder; |
|
370 |
|
371 CAknInfoPopupNoteController* iPopupController; // Owned |
|
372 |
|
373 TBool iHandlingKeyPressInProgress; |
|
374 |
|
375 }; |
|
376 |
|
377 #endif // CVCGENERICCONTAINER_H |
|
378 |
|
379 // End of File |
|
380 |