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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef UIARRAYSGENERATOR_H |
|
20 #define UIARRAYSGENERATOR_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 class CAknIconArray; |
|
25 class CDesC16ArrayFlat; |
|
26 class CVCModel; |
|
27 class CGulIcon; |
|
28 |
|
29 /** |
|
30 * Encapsulates the listbox element. Including icon, first and second line of the text |
|
31 */ |
|
32 class CUiEntryData : public CBase |
|
33 { |
|
34 public: |
|
35 /** |
|
36 * @param aIcon. Ownership is tranfered. I.e. the icon will be destroyed, |
|
37 * when this object is destroyed |
|
38 * @param aFirstLine |
|
39 * @param aSecondLine |
|
40 */ |
|
41 static CUiEntryData* NewL( CGulIcon* aIcon, const TDesC& aFirstLine, |
|
42 const TDesC& aSecondLine = KNullDesC ); |
|
43 |
|
44 static CUiEntryData* NewLC( CGulIcon* aIcon, const TDesC& aFirstLine, |
|
45 const TDesC& aSecondLine = KNullDesC ); |
|
46 |
|
47 virtual ~CUiEntryData(); |
|
48 |
|
49 /** |
|
50 * Compares entries alphabetically on the first line value basis. Comparison |
|
51 * is done with the respect to the locale rules. @see TDesC16::CompareC |
|
52 * |
|
53 * @return 1. zero, if the two objects are equal. |
|
54 * 2. a negative value, if the first object is less than the second. |
|
55 * 3. a positive value, if the first object is greater than the second. |
|
56 */ |
|
57 TInt CompareByFirstLine( const CUiEntryData& aAnotherEntry ) const; |
|
58 |
|
59 static TInt CompareByFirstLine( const CUiEntryData& entry1, const CUiEntryData& entry2 ); |
|
60 |
|
61 /** |
|
62 * Returns the entry icon and tranfers the responsibility to the caller |
|
63 * I.e. after calling this method, this object is not responsible for deleting |
|
64 * the icon anymore |
|
65 */ |
|
66 CGulIcon* ReleaseIcon(); |
|
67 |
|
68 const TDesC& FirstLine() const; |
|
69 |
|
70 const TDesC& SecondLine() const; |
|
71 |
|
72 /** |
|
73 * Construct a text ready to be used in the listbox |
|
74 * i.e. "<icon index>\t\FirstLine\tSecondLine" |
|
75 * @param aIconIndex Number to use before the first tab character |
|
76 */ |
|
77 TDesC* ConstructListboxItemStringLC( TInt aIconIndex ) const; |
|
78 |
|
79 protected: |
|
80 CUiEntryData( CGulIcon* aIcon, const TDesC& aFirstLine, |
|
81 const TDesC& aSecondLine ); |
|
82 |
|
83 private: |
|
84 CGulIcon* iIcon; |
|
85 const TDesC& iFirstLine; |
|
86 const TDesC& iSecondLine; |
|
87 }; |
|
88 |
|
89 class CUiArraysGenerator : public CBase |
|
90 { |
|
91 public: |
|
92 static CUiArraysGenerator* NewLC(); |
|
93 |
|
94 /** |
|
95 * Parses the model into a set of arrays required by the VCommand app ui |
|
96 * I.e. basing on the "current folder" prepares the arrays for the listbox |
|
97 * If "current" folder is the main one, it means including all the sub-folders and main |
|
98 * folder commands. Otherwise, it means including all the current folder commands only |
|
99 * |
|
100 * Both folders and commands are alphabetially sorted. |
|
101 * All the target arrays are ResetAndDestroyed before the parsing |
|
102 * |
|
103 * @param aSource Model to parse |
|
104 * @param aCurrentFolderTitle KNullDesC if "curent" folder is the main one |
|
105 * @param aIconArray icons to display in the listbox. Order is not specified |
|
106 * @param aFolderTitles List of folder titles in the alphabetical order |
|
107 * @param aItemIsFolder List of boolean values for all the listbox elements from top |
|
108 * to bottom. ETrue for every folder, EFalse for every command |
|
109 * @param aItemArray List of strings in the listbox expected |
|
110 * format ( @see LB_SINGLE_GRAPHIC_HEADING ). Includes: |
|
111 * * a refence to the icon - zero-based index from the aIconArray |
|
112 * * written text of the command |
|
113 * * user-specified alternative text or KNullDesC if |
|
114 * |
|
115 */ |
|
116 virtual void FillArraysL( const CVCModel& aSource, const TDesC& aCurrentFolderTitle, |
|
117 CAknIconArray& aIconArray, CDesC16ArrayFlat& aFolderTitles, |
|
118 RArray<TBool>& aItemIsFolder, CDesC16ArrayFlat& aItemArray ); |
|
119 |
|
120 /** |
|
121 * Updates a set of arrays required by the VCommand app ui to match current folder names |
|
122 * I.e. basing on the "current folder" prepares the arrays for the listbox |
|
123 * If "current" folder is the main one, it means including all the sub-folders and main |
|
124 * folder commands. Otherwise, it means including all the current folder commands only |
|
125 * |
|
126 * Both folders and commands are alphabetially sorted. |
|
127 * |
|
128 * @param aSource Model to parse |
|
129 * @param aCurrentFolderTitle KNullDesC if "curent" folder is the main one |
|
130 * @param aIconArray icons to display in the listbox. Order is not specified |
|
131 * @param aFolderTitles List of folder titles in the alphabetical order |
|
132 * @param aItemIsFolder List of boolean values for all the listbox elements from top |
|
133 * to bottom. ETrue for every folder, EFalse for every command |
|
134 * @param aItemArray List of strings in the listbox expected |
|
135 * format ( @see LB_SINGLE_GRAPHIC_HEADING ). Includes: |
|
136 * * a refence to the icon - zero-based index from the aIconArray |
|
137 * * written text of the command |
|
138 * * user-specified alternative text or KNullDesC if |
|
139 * |
|
140 */ |
|
141 void UpdateFolderArraysL( const CVCModel& aSource, const TDesC& aCurrentFolderTitle, |
|
142 CAknIconArray& aIconArray, CDesC16ArrayFlat& aFolderTitles, |
|
143 RArray<TBool>& aItemIsFolder, CDesC16ArrayFlat& aItemArray ); |
|
144 |
|
145 protected: |
|
146 /** |
|
147 * Create entries for all the subfolders in the given folder and sort the entries |
|
148 * alphabetically |
|
149 * @param aSource Model to parse |
|
150 * @param aCurrentFolderTitle KNullDesC for the main folder |
|
151 * @return The array of entries pushed to CS two times. First PopAndDestroy |
|
152 * will ResetAndDestroy, the second one will delete the array itself |
|
153 */ |
|
154 virtual RPointerArray<CUiEntryData>* ExtractFoldersAndSortLC2( const CVCModel& aSource, |
|
155 const TDesC& aCurrentFolderTitle = KNullDesC ); |
|
156 |
|
157 /** |
|
158 * Create entries for all the subfolders in the given folder and sort the entries |
|
159 * alphabetically |
|
160 * @param aSource Model to parse |
|
161 * @param aCurrentFolderTitle KNullDesC for the main folder |
|
162 * @return The array of entries pushed to CS two times. First PopAndDestroy |
|
163 * will ResetAndDestroy, the second one will delete the array itself |
|
164 */ |
|
165 virtual RPointerArray<CUiEntryData>* ExtractCommandsAndSortLC2( const CVCModel& aSource, |
|
166 const TDesC& aCurrentFolderTitle = KNullDesC ); |
|
167 |
|
168 /** |
|
169 * Fills the arrays required by the ui side with the information from entries |
|
170 * @param aEntries Must contain folder entries only |
|
171 * FirstLine is FolderListedName |
|
172 * @leave KErrCorrupt if in the aModel there is no command with the folder listed name |
|
173 * from aEntries |
|
174 */ |
|
175 virtual void FillFolderTitlesL( RArray<TBool>& aItemIsFolder, |
|
176 CDesC16ArrayFlat& aFolderTitles, const CVCModel& aModel, |
|
177 const RPointerArray<CUiEntryData>& aEntries ); |
|
178 |
|
179 }; |
|
180 |
|
181 #endif //UIARRAYSGENERATOR_H |
|
182 |
|
183 // End of File |
|
184 |
|
185 |
|