1 /* |
|
2 * Copyright (c) 2002 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: Profile index handler (for use of Settings Container |
|
15 * if multiple profiles are edited) |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CPROFILEINDEXHANDLER_H |
|
21 #define CPROFILEINDEXHANDLER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 class CProfileEngineHandler; |
|
28 class CEikListBox; |
|
29 |
|
30 // CLASS DECLARATION |
|
31 |
|
32 /** |
|
33 * Profile index handler. |
|
34 * For use of Settings Container if multiple profiles are edited. |
|
35 * |
|
36 * @lib ProfileSettingsView.lib |
|
37 * @since 2.5 |
|
38 */ |
|
39 class CProfileIndexHandler : public CBase |
|
40 { |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Symbian 2-phase constructor. |
|
45 * @param aEngineHandler An instance of Engine Handler. |
|
46 * @return Returns an instance of CProfileIndexHandler. |
|
47 */ |
|
48 IMPORT_C static CProfileIndexHandler* NewL( |
|
49 CProfileEngineHandler& aEngineHandler ); |
|
50 |
|
51 // Destructor |
|
52 ~CProfileIndexHandler(); |
|
53 |
|
54 public: // New methods |
|
55 |
|
56 /** |
|
57 * Returns the index of current profile. |
|
58 * @return Returns the index of current profile. |
|
59 */ |
|
60 IMPORT_C TInt CurrentProfileIndex() const; |
|
61 |
|
62 /** |
|
63 * Sets the index of current profile. |
|
64 * @param aIndex The index of the new current profile. |
|
65 */ |
|
66 IMPORT_C void SetCurrentProfileIndex( TInt aIndex ); |
|
67 |
|
68 /** |
|
69 * Creates the index array. |
|
70 */ |
|
71 void CreateIndexArrayL(); |
|
72 |
|
73 /** |
|
74 * Stores current indices (top item index and current item index). |
|
75 */ |
|
76 void StoreIndices(); |
|
77 |
|
78 /** |
|
79 * Loads previous indices. |
|
80 */ |
|
81 void LoadIndices(); |
|
82 |
|
83 /** |
|
84 * Indexes the index array. |
|
85 * @param aIndex Index of the item index. |
|
86 * @return Returns item index at index. |
|
87 */ |
|
88 TInt IndexAt( TInt aIndex ) const; |
|
89 |
|
90 /** |
|
91 * Indexes the top index array. |
|
92 * @param aIndex Index of the top item index. |
|
93 * @return Returns top item index at index. |
|
94 */ |
|
95 TInt TopIndexAt( TInt aIndex ) const; |
|
96 |
|
97 /** |
|
98 * Removes items from the index arrays and inserts a new ones. |
|
99 * @param aOldIndex Index of the old items to be removed. |
|
100 * @param aNewIndex Index of the new items to be added. |
|
101 * @param aIndexValue Value of the new item index. |
|
102 * @param aTopIndexValue Value of the new top item index. |
|
103 * @return Returns KErrNotFound if the old index is not found, |
|
104 * KErrArgument if the new index is out of bounds, |
|
105 * KErrNone if no errors. |
|
106 */ |
|
107 TInt RemoveAndInsert( |
|
108 TInt aOldIndex, TInt aNewIndex, |
|
109 TInt aIndexValue, TInt aTopIndexValue ); |
|
110 |
|
111 /** |
|
112 * Sets a list box pointer so indices can be stored and loaded. |
|
113 * @param aListBox The List box pointer. |
|
114 * Remember to set back to NULL when listbox is deleted! |
|
115 */ |
|
116 void SetListBox( CEikListBox* aListBox ); |
|
117 |
|
118 /** |
|
119 * Calls Engine Handler's ReadIdArrayL and re-arranges index array. |
|
120 * @return Returns the index of the edited profile after re-arrange. |
|
121 */ |
|
122 TInt ReadIdArrayAndUpdateL(); |
|
123 |
|
124 protected: |
|
125 |
|
126 /** |
|
127 * C++ constuctor. |
|
128 * @param aEngineHandler An instance of Engine Handler. |
|
129 */ |
|
130 CProfileIndexHandler( |
|
131 CProfileEngineHandler& aEngineHandler ); |
|
132 |
|
133 /** |
|
134 * By default Symbian 2nd phase constructor is private. |
|
135 */ |
|
136 void ConstructL(); |
|
137 |
|
138 private: // Data |
|
139 |
|
140 // Profile Engine handler. |
|
141 CProfileEngineHandler& iEngineHandler; |
|
142 |
|
143 // Index of the currently focused profile. |
|
144 TInt iCurrentProfileIndex; |
|
145 |
|
146 // Ref: Listbox pointer to load and store top item and current item indices. |
|
147 CEikListBox* iListBox; |
|
148 |
|
149 // Struct for one index |
|
150 struct TItem |
|
151 { |
|
152 // Current item index in listbox |
|
153 TInt iIndex; |
|
154 // Top item index in listbox |
|
155 // Value 0 means that the focused item is the first in view, |
|
156 // 1 means that it's the second and 2 the last. |
|
157 TInt iTopIndex; |
|
158 }; |
|
159 |
|
160 // Array of item indices. |
|
161 RArray<TItem> iIndexArray; |
|
162 |
|
163 }; |
|
164 |
|
165 #endif // CPROFILEINDEXHANDLER_H |
|
166 |
|
167 // End of File |
|