|
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: LandmarksUi Content File - |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <eikmenup.h> |
|
20 #include <eiktxlbx.h> |
|
21 #include <landmarks.rsg> |
|
22 #include "landmarks.hrh" |
|
23 #include "CLmkAppUi.h" |
|
24 #include "CLmkAppCategorySettingsImpl.h" |
|
25 #include "CLmkCategorySettingsContainer.h" |
|
26 #include "CLmkCategorySettingsView.h" |
|
27 #include "CLmkCategoryContentsView.h" |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 // ---------------------------------------------------------------------------- |
|
31 // CLmkCategorySettingsView::NewLC( MLmkKeyProcessor& aKeyProcessor ) |
|
32 // Two-phased constructor. |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 CLmkCategorySettingsView* CLmkCategorySettingsView::NewLC( |
|
36 MLmkKeyProcessor& aKeyProcessor) |
|
37 { |
|
38 CLmkCategorySettingsView* self = new (ELeave) CLmkCategorySettingsView( |
|
39 aKeyProcessor); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 return self; |
|
43 } |
|
44 // ---------------------------------------------------------------------------- |
|
45 // CLmkCategorySettingsView::CLmkCategorySettingsView |
|
46 // C++ default constructor can NOT contain any code, that |
|
47 // might leave. |
|
48 // ---------------------------------------------------------------------------- |
|
49 // |
|
50 CLmkCategorySettingsView::CLmkCategorySettingsView( |
|
51 MLmkKeyProcessor& aKeyProcessor) : |
|
52 CLmkBaseView(aKeyProcessor) |
|
53 { |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // CLmkCategorySettingsView::ConstructL |
|
58 // Symbian 2nd phase constructor can leave. |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 void CLmkCategorySettingsView::ConstructL() |
|
62 { |
|
63 BaseConstructL(R_LMK_CATEGORY_SETTINGS_VIEW); |
|
64 } |
|
65 |
|
66 // ---------------------------------------------------------------------------- |
|
67 // CLmkCategorySettingsView::~CLmkCategorySettingsView |
|
68 // ---------------------------------------------------------------------------- |
|
69 // |
|
70 CLmkCategorySettingsView::~CLmkCategorySettingsView() |
|
71 { |
|
72 if (iContainer) |
|
73 { |
|
74 AppUi()->RemoveFromViewStack(*this, iContainer); |
|
75 } |
|
76 delete iContainer; |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CLmkCategorySettingsView::ProcessKeyEventL |
|
81 // ---------------------------------------------------------------------------- |
|
82 // |
|
83 TBool CLmkCategorySettingsView::ProcessKeyEventL(const TKeyEvent& aKeyEvent, |
|
84 TEventCode aType) |
|
85 { |
|
86 return CLmkBaseView::ProcessKeyEventL(aKeyEvent, aType); |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // TUid CLmkCategorySettingsView::Id |
|
91 // ---------------------------------------------------------------------------- |
|
92 // |
|
93 TUid CLmkCategorySettingsView::Id() const |
|
94 { |
|
95 return TUid::Uid(ELmkCategorySettingsView); |
|
96 } |
|
97 |
|
98 // ---------------------------------------------------------------------------- |
|
99 // CLmkCategorySettingsView::HandleCommandL |
|
100 // ---------------------------------------------------------------------------- |
|
101 // |
|
102 void CLmkCategorySettingsView::HandleCommandL(TInt aCommand) |
|
103 { |
|
104 AknSelectionService::HandleMarkableListProcessCommandL(aCommand, |
|
105 &(iContainer->ListBox())); |
|
106 |
|
107 switch (aCommand) |
|
108 { |
|
109 case EAknSoftkeyBack: |
|
110 { |
|
111 if (iPrevViewId == ELmkCategoryContentsView) |
|
112 { |
|
113 CLmkCategoryContentsView |
|
114 * view = |
|
115 static_cast<CLmkCategoryContentsView*> (AppUi()->View( |
|
116 TUid::Uid(iPrevViewId))); |
|
117 if (view->IsContainerPtrValid()) |
|
118 { |
|
119 AppUi()->ActivateLocalViewL(TUid::Uid(iPrevViewId)); |
|
120 } |
|
121 else |
|
122 { |
|
123 AppUi()->ActivateLocalViewL(TUid::Uid(ELmkByCategoryView)); |
|
124 } |
|
125 } |
|
126 else |
|
127 { |
|
128 AppUi()->ActivateLocalViewL(TUid::Uid(iPrevViewId)); |
|
129 } |
|
130 break; |
|
131 } |
|
132 case ELmkCmdNewCategory: |
|
133 case ELmkCmdChangeIcon: |
|
134 case ELmkCmdRenameCat: |
|
135 case ELmkCmdDeleteCat: |
|
136 { |
|
137 iContainer->SelectorImpl().ProcessCommandL(aCommand); |
|
138 break; |
|
139 } |
|
140 default: |
|
141 { |
|
142 (static_cast<CLmkAppUi*> (AppUi()))->HandleCommandL(aCommand); |
|
143 break; |
|
144 } |
|
145 } |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------- |
|
149 // CLmkCategorySettingsView::DynInitMenuPaneL |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 void CLmkCategorySettingsView::DynInitMenuPaneL(TInt aResourceId, |
|
153 CEikMenuPane* aMenuPane) |
|
154 { |
|
155 CEikTextListBox& listbox = iContainer->ListBox(); |
|
156 AknSelectionService::HandleMarkableListDynInitMenuPane(aResourceId, |
|
157 aMenuPane, &listbox); |
|
158 |
|
159 TInt count(listbox.Model()->NumberOfItems()); |
|
160 TInt markedCount = listbox.SelectionIndexes()->Count(); |
|
161 CLmkAppCategorySettingsImpl& LCategorySettingsImpl = |
|
162 iContainer->SelectorImpl(); |
|
163 // Checkif the category is a global category only when some items present |
|
164 TBool retVal = EFalse; |
|
165 |
|
166 if (count > 0) |
|
167 { |
|
168 retVal = LCategorySettingsImpl.IsPredefinedCategoryL(); |
|
169 } |
|
170 |
|
171 switch (aResourceId) |
|
172 { |
|
173 case R_LMK_CATEGORY_SETTINGS_MENU1: |
|
174 { |
|
175 if (retVal || count == 0) |
|
176 { |
|
177 aMenuPane->SetItemDimmed(ELmkCmdRenameCat, ETrue); |
|
178 aMenuPane->SetItemDimmed(ELmkCmdDeleteCat, ETrue); |
|
179 } |
|
180 else |
|
181 { |
|
182 if (markedCount > 0) |
|
183 { |
|
184 aMenuPane->SetItemDimmed(ELmkCmdRenameCat, ETrue); |
|
185 } |
|
186 } |
|
187 break; |
|
188 } |
|
189 case R_LMK_CATEGORY_SETTINGS_MENU2: |
|
190 { |
|
191 if (count == 0) |
|
192 { |
|
193 aMenuPane->SetItemDimmed(ELmkCmdChangeIcon, ETrue); |
|
194 } |
|
195 break; |
|
196 } |
|
197 case R_LMK_CATEGORY_SETTINGS_OK_MENU: |
|
198 { |
|
199 aMenuPane->SetItemDimmed(ELmkCmdNewCategory, ETrue); |
|
200 if (retVal) |
|
201 { |
|
202 aMenuPane->SetItemDimmed(ELmkCmdRenameCat, ETrue); |
|
203 aMenuPane->SetItemDimmed(ELmkCmdDeleteCat, ETrue); |
|
204 } |
|
205 if (count == 0) |
|
206 { |
|
207 aMenuPane->SetItemDimmed(ELmkCmdRenameCat, ETrue); |
|
208 aMenuPane->SetItemDimmed(ELmkCmdDeleteCat, ETrue); |
|
209 aMenuPane->SetItemDimmed(ELmkCmdChangeIcon, ETrue); |
|
210 } |
|
211 else |
|
212 { |
|
213 if (markedCount > 1) |
|
214 { |
|
215 aMenuPane->SetItemDimmed(ELmkCmdRenameCat, ETrue); |
|
216 } |
|
217 } |
|
218 break; |
|
219 } |
|
220 case R_LMK_MAIN_MENU: |
|
221 { |
|
222 CLmkBaseView::HandleHelpFeature(aMenuPane); |
|
223 break; |
|
224 } |
|
225 default: |
|
226 { |
|
227 break; |
|
228 } |
|
229 } |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------------------------- |
|
233 // CLmkCategorySettingsView::DoActivateL |
|
234 // ---------------------------------------------------------------------------- |
|
235 // |
|
236 void CLmkCategorySettingsView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
237 TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) |
|
238 { |
|
239 iPrevViewId = aPrevViewId.iViewUid.iUid; |
|
240 |
|
241 #ifdef _DEBUG |
|
242 RDebug::Print(_L( "CLmkCategorySettingsView::DoActivateL() called" )); |
|
243 #endif |
|
244 |
|
245 if (!iContainer) |
|
246 { |
|
247 iContainer = CLmkCategorySettingsContainer::NewL(*this, this, |
|
248 ClientRect(), *this); |
|
249 |
|
250 AppUi()->AddToStackL(*this, iContainer); |
|
251 #ifdef RD_SCALABLE_UI_V2 |
|
252 //for touch event |
|
253 iContainer->ListBox().SetListBoxObserver(this); |
|
254 #endif//RD_SCALABLE_UI_V2 |
|
255 } |
|
256 } |
|
257 |
|
258 // ---------------------------------------------------------------------------- |
|
259 // CLmkCategorySettingsView::DoDeactivate |
|
260 // ---------------------------------------------------------------------------- |
|
261 // |
|
262 void CLmkCategorySettingsView::DoDeactivate() |
|
263 { |
|
264 if (iContainer) |
|
265 { |
|
266 AppUi()->RemoveFromViewStack(*this, iContainer); |
|
267 } |
|
268 delete iContainer; |
|
269 iContainer = NULL; |
|
270 } |
|
271 // ---------------------------------------------------------------------------- |
|
272 // CLmkCategorySettingsView::Update() |
|
273 // ---------------------------------------------------------------------------- |
|
274 // |
|
275 void CLmkCategorySettingsView::Update() |
|
276 { |
|
277 iContainer->SetRect(ClientRect()); |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------- |
|
281 // CLmkBaseView::EnableMskMenuL() |
|
282 // --------------------------------------------------------- |
|
283 // |
|
284 void CLmkCategorySettingsView::EnableMskMenuL(TBool aEnable) |
|
285 { |
|
286 CEikButtonGroupContainer* cbaGrp = Cba(); |
|
287 if (aEnable) |
|
288 { |
|
289 cbaGrp->SetCommandSetL(R_LMK_SOFTKEYS_OPTIONS_BACK_CONTEXTOPTIONS); |
|
290 //cbaGrp->MakeCommandVisible(EAknSoftkeyContextOptions,ETrue); |
|
291 cbaGrp->DrawDeferred(); |
|
292 MenuBar()->SetContextMenuTitleResourceId( |
|
293 R_LMK_CATEGORY_SETTINGS_CONTEXT_MENUBAR); |
|
294 } |
|
295 else |
|
296 { |
|
297 cbaGrp->MakeCommandVisible(EAknSoftkeyContextOptions, EFalse); |
|
298 } |
|
299 } |
|
300 |
|
301 #ifdef RD_SCALABLE_UI_V2 |
|
302 // --------------------------------------------------------- |
|
303 // CLmkCategorySettingsView::HandleListBoxEventL() |
|
304 // --------------------------------------------------------- |
|
305 // |
|
306 void CLmkCategorySettingsView::HandleListBoxEventL(CEikListBox* aListBox, |
|
307 TListBoxEvent aEventType) |
|
308 { |
|
309 TInt count(aListBox->Model()->NumberOfItems()); |
|
310 if( count == 0 ) |
|
311 return; |
|
312 |
|
313 TInt markedCount = aListBox->SelectionIndexes()->Count(); |
|
314 |
|
315 switch (aEventType) |
|
316 { |
|
317 case EEventItemSingleClicked: |
|
318 { |
|
319 if( markedCount > 0 ) |
|
320 { |
|
321 CEikMenuBar* menubar = MenuBar(); |
|
322 if (menubar) |
|
323 { |
|
324 menubar->SetContextMenuTitleResourceId(R_LMK_CATEGORY_SETTINGS_OK_MENUBAR); |
|
325 TRAP_IGNORE( menubar->TryDisplayContextMenuBarL() ); |
|
326 } |
|
327 } |
|
328 else |
|
329 { |
|
330 CLmkAppCategorySettingsImpl& LCategorySettingsImpl = |
|
331 iContainer->SelectorImpl(); |
|
332 // Checkif the category is a global category only when some items present |
|
333 TBool retVal = LCategorySettingsImpl.IsPredefinedCategoryL(); |
|
334 if( retVal ) |
|
335 HandleCommandL( ELmkCmdChangeIcon ); |
|
336 else |
|
337 HandleCommandL( ELmkCmdRenameCat ); |
|
338 } |
|
339 break; |
|
340 } |
|
341 default: |
|
342 break; |
|
343 } |
|
344 } |
|
345 #endif//RD_SCALABLE_UI_V2 |
|
346 // End of File |