author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:35:16 +0300 | |
branch | RCL_3 |
changeset 71 | a45dccb283c5 |
parent 65 | 8e6fa1719340 |
permissions | -rw-r--r-- |
65 | 1 |
/* |
2 |
* Copyright (c) 2005-2008 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 the License "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: A view to browse a feed's topics. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
#include <aknviewappui.h> |
|
21 |
#include <aknutils.h> |
|
22 |
#include <AknToolbar.h> |
|
23 |
#include <eikbtgpc.h> |
|
24 |
#include <eikmenup.h> |
|
25 |
#include <hlplch.h> |
|
26 |
||
27 |
#include "Browser.hrh" |
|
28 |
#include <BrowserNG.rsg> |
|
29 |
#include <feedattributes.h> |
|
30 |
#include <folderattributes.h> |
|
31 |
#include "BrowserAppUi.h" |
|
32 |
#include "CommonConstants.h" |
|
33 |
||
34 |
#include "FeedsTopicView.h" |
|
35 |
#include "FeedsTopicContainer.h" |
|
36 |
||
37 |
||
38 |
// ----------------------------------------------------------------------------- |
|
39 |
// CFeedsTopicView::NewL |
|
40 |
// |
|
41 |
// Two-phased constructor. |
|
42 |
// ----------------------------------------------------------------------------- |
|
43 |
// |
|
44 |
CFeedsTopicView* CFeedsTopicView::NewL( MApiProvider& aApiProvider, TRect& aRect ) |
|
45 |
{ |
|
46 |
CFeedsTopicView* self = new (ELeave) CFeedsTopicView(aApiProvider); |
|
47 |
||
48 |
CleanupStack::PushL(self); |
|
49 |
self->ConstructL(aRect); |
|
50 |
CleanupStack::Pop(); |
|
51 |
||
52 |
return self; |
|
53 |
} |
|
54 |
||
55 |
||
56 |
// ----------------------------------------------------------------------------- |
|
57 |
// CFeedsTopicView::CFeedsTopicView |
|
58 |
// |
|
59 |
// C++ default constructor. |
|
60 |
// ----------------------------------------------------------------------------- |
|
61 |
// |
|
62 |
CFeedsTopicView::CFeedsTopicView(MApiProvider& aApiProvider): |
|
63 |
CBrowserViewBase( aApiProvider ),iPenEnabled(EFalse) |
|
64 |
{ |
|
65 |
iPenEnabled = AknLayoutUtils::PenEnabled(); |
|
66 |
} |
|
67 |
||
68 |
||
69 |
// ----------------------------------------------------------------------------- |
|
70 |
// CFeedsTopicView::ConstructL |
|
71 |
// |
|
72 |
// Symbian 2nd phase constructor can leave. |
|
73 |
// ----------------------------------------------------------------------------- |
|
74 |
// |
|
75 |
void CFeedsTopicView::ConstructL(TRect& aRect) |
|
76 |
{ |
|
77 |
BaseConstructL(R_FEEDS_TOPIC_VIEW); |
|
78 |
||
79 |
#ifndef BRDO_SINGLE_CLICK_ENABLED_FF |
|
80 |
iContainer = CFeedsTopicContainer::NewL( this, ApiProvider(), aRect ); |
|
81 |
iContainer->MakeVisible(EFalse); |
|
82 |
||
83 |
if(iPenEnabled) |
|
84 |
{ |
|
85 |
Toolbar()->SetToolbarObserver(this); |
|
86 |
} |
|
87 |
#endif |
|
88 |
} |
|
89 |
||
90 |
||
91 |
// ----------------------------------------------------------------------------- |
|
92 |
// CFeedsTopicView::~CFeedsTopicView |
|
93 |
// |
|
94 |
// Deconstructor. |
|
95 |
// ----------------------------------------------------------------------------- |
|
96 |
// |
|
97 |
CFeedsTopicView::~CFeedsTopicView() |
|
98 |
{ |
|
99 |
DoDeactivate(); |
|
100 |
||
101 |
delete iContainer; |
|
102 |
} |
|
103 |
||
104 |
// ----------------------------------------------------------------------------- |
|
105 |
// CFeedsTopicView::Id |
|
106 |
// |
|
107 |
// Returns the id of the view. |
|
108 |
// ----------------------------------------------------------------------------- |
|
109 |
// |
|
110 |
TUid CFeedsTopicView::Id() const |
|
111 |
{ |
|
112 |
return KUidBrowserFeedsTopicViewId; |
|
113 |
} |
|
114 |
||
115 |
// ----------------------------------------------------------------------------- |
|
116 |
// CFeedsTopicView::HandleCommandL |
|
117 |
// |
|
118 |
// Processes commands. |
|
119 |
// ----------------------------------------------------------------------------- |
|
120 |
// |
|
121 |
void CFeedsTopicView::HandleCommandL(TInt aCommand) |
|
122 |
{ |
|
123 |
TBool handled = EFalse; |
|
124 |
||
125 |
// Handle softkeys and other Symbian commands first. |
|
126 |
switch (aCommand) |
|
127 |
{ |
|
128 |
case EAknSoftkeyBack: |
|
129 |
iApiProvider.FeedsClientUtilities().ShowFolderViewLocalL(); |
|
130 |
handled = ETrue; |
|
131 |
break; |
|
132 |
||
133 |
#ifdef __SERIES60_HELP |
|
134 |
case EAknCmdHelp: |
|
135 |
{ |
|
136 |
iApiProvider.SetLastActiveViewId(Id()); |
|
137 |
HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), |
|
138 |
AppUi()->AppHelpContextL()); |
|
139 |
handled = ETrue; |
|
140 |
break; |
|
141 |
} |
|
142 |
#endif //__SERIES60_HELP |
|
143 |
} |
|
144 |
||
145 |
if (handled) |
|
146 |
{ |
|
147 |
return; |
|
148 |
} |
|
149 |
||
150 |
// Handle menu commands. |
|
151 |
switch (aCommand) |
|
152 |
{ |
|
153 |
case EFeedsOpen: |
|
154 |
if ((iApiProvider.FeedsClientUtilities().CurrentFeed()->GetChildren().Count()) > 0) |
|
155 |
{ |
|
156 |
iContainer->HandleOpenL(); |
|
157 |
} |
|
158 |
break; |
|
159 |
||
160 |
case EFeedsUpdate: |
|
161 |
iContainer->HandleUpdateFeedL(); |
|
162 |
break; |
|
163 |
||
164 |
case EFeedsBackToPage: |
|
165 |
iApiProvider.FeedsClientUtilities().HandleCommandL(Id(), EWmlCmdBackToPage ); |
|
166 |
break; |
|
167 |
||
168 |
default: |
|
169 |
iApiProvider.FeedsClientUtilities().HandleCommandL(Id(),aCommand); |
|
170 |
break; |
|
171 |
} |
|
172 |
} |
|
173 |
||
174 |
||
175 |
// ----------------------------------------------------------------------------- |
|
176 |
// CFeedsTopicView::DoActivateL |
|
177 |
// |
|
178 |
// Called when the view is activated. |
|
179 |
// ----------------------------------------------------------------------------- |
|
180 |
// |
|
181 |
void CFeedsTopicView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, |
|
182 |
TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) |
|
183 |
{ |
|
184 |
||
185 |
#ifdef BRDO_SINGLE_CLICK_ENABLED_FF |
|
186 |
if (!iContainer) |
|
187 |
{ |
|
188 |
iContainer = CFeedsTopicContainer::NewL( this, ApiProvider(), ClientRect() ); |
|
189 |
iContainer->MakeVisible(EFalse); |
|
190 |
} |
|
191 |
Toolbar()->SetToolbarVisibility(EFalse,EFalse); |
|
192 |
#endif |
|
193 |
// If need be, add the container to the control stack. |
|
194 |
if (!iContainerOnStack) |
|
195 |
{ |
|
196 |
AppUi()->AddToViewStackL(*this, iContainer); |
|
197 |
iContainer->SetRect(ClientRect()); |
|
198 |
iContainer->MakeVisible(ETrue); |
|
199 |
iContainerOnStack = ETrue; |
|
200 |
// resize screen after calling SetRect. This way looks better |
|
201 |
iContainer->HandleResourceChange(KEikDynamicLayoutVariantSwitch); |
|
202 |
} |
|
203 |
||
204 |
// Set the current feed. |
|
71
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
205 |
if(iInitialItem >= 0) |
a45dccb283c5
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
65
diff
changeset
|
206 |
iContainer->SetCurrentFeedL(*(iApiProvider.FeedsClientUtilities().CurrentFeed()), iInitialItem); |
65 | 207 |
iApiProvider.SetLastActiveViewId(Id()); |
208 |
UpdateToolbarButtonsState(); |
|
209 |
} |
|
210 |
||
211 |
||
212 |
// ----------------------------------------------------------------------------- |
|
213 |
// CFeedsTopicView::DoDeactivate |
|
214 |
// |
|
215 |
// Called when the view is deactivated. |
|
216 |
// ----------------------------------------------------------------------------- |
|
217 |
// |
|
218 |
void CFeedsTopicView::DoDeactivate() |
|
219 |
{ |
|
220 |
if (iContainerOnStack) |
|
221 |
{ |
|
222 |
AppUi()->RemoveFromViewStack(*this, iContainer); |
|
223 |
iContainer->MakeVisible(EFalse); |
|
224 |
iContainer->ClearNavigationPane(); |
|
225 |
iContainerOnStack = EFalse; |
|
226 |
||
227 |
iInitialItem = iContainer->CurrentIndex(); |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
||
232 |
// ----------------------------------------------------------------------------- |
|
233 |
// CFeedsTopicView::DynInitMenuPaneL |
|
234 |
// |
|
235 |
// Disables unrelated menu options. |
|
236 |
// ----------------------------------------------------------------------------- |
|
237 |
// |
|
238 |
void CFeedsTopicView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
239 |
{ |
|
240 |
||
241 |
||
242 |
if (aResourceId == R_FEEDS_TOPIC_VIEW_MENU) |
|
243 |
{ |
|
244 |
// Refresh (same as update?) |
|
245 |
iApiProvider.FeedsClientUtilities().AddItemL(*aMenuPane, EFeedsUpdate, R_FEEDS_UPDATE); |
|
246 |
||
247 |
// Back to Page (if page loaded) |
|
248 |
if ( iApiProvider.IsPageLoaded() ) |
|
249 |
{ |
|
250 |
iApiProvider.FeedsClientUtilities().AddItemL( *aMenuPane, EWmlCmdBackToPage, R_BROWSER_MENU_ITEM_BACK_TO_PAGE ); |
|
251 |
} |
|
252 |
} |
|
253 |
||
254 |
iApiProvider.FeedsClientUtilities().DynInitMenuPaneL(aResourceId, aMenuPane ); |
|
255 |
} |
|
256 |
||
257 |
||
258 |
// ----------------------------------------------------------------------------- |
|
259 |
// CFeedsTopicView::SetCurrentFeedL |
|
260 |
// |
|
261 |
// Sets the current feed |
|
262 |
// ----------------------------------------------------------------------------- |
|
263 |
// |
|
264 |
void CFeedsTopicView::SetCurrentFeedL(const CFeedsEntity& aFeed, TInt aIndex) |
|
265 |
{ |
|
266 |
iContainer->SetCurrentFeedL(aFeed, aIndex); |
|
267 |
} |
|
268 |
||
269 |
||
270 |
// ----------------------------------------------------------------------------- |
|
271 |
// CFeedsTopicView::SetInitialItem |
|
272 |
// |
|
273 |
// Sets the initial item once the view is activated. |
|
274 |
// ----------------------------------------------------------------------------- |
|
275 |
// |
|
276 |
void CFeedsTopicView::SetInitialItem(TInt aItemIndex) |
|
277 |
{ |
|
278 |
iInitialItem = aItemIndex; |
|
279 |
} |
|
280 |
||
281 |
// ----------------------------------------------------------------------------- |
|
282 |
// CFeedsTopicView::UpdateToolbarButtonsState |
|
283 |
// |
|
284 |
// Updates the state of the toolbar buttons depending on the situation |
|
285 |
// ----------------------------------------------------------------------------- |
|
286 |
// |
|
287 |
||
288 |
void CFeedsTopicView::UpdateToolbarButtonsState() |
|
289 |
{ |
|
290 |
#ifdef BRDO_SINGLE_CLICK_ENABLED_FF |
|
291 |
Toolbar()->SetToolbarVisibility(EFalse,EFalse); |
|
292 |
return; |
|
293 |
#else |
|
294 |
if (iApiProvider.IsPageLoaded()) |
|
295 |
{ |
|
296 |
Toolbar()->SetItemDimmed(EFeedsBackToPage, EFalse, ETrue); |
|
297 |
} |
|
298 |
else |
|
299 |
{ |
|
300 |
Toolbar()->SetItemDimmed(EFeedsBackToPage, ETrue, ETrue); |
|
301 |
} |
|
302 |
if ((iApiProvider.FeedsClientUtilities().CurrentFeed()->GetChildren().Count()) > 0) |
|
303 |
{ |
|
304 |
Toolbar()->SetItemDimmed(EFeedsOpen, EFalse, ETrue); |
|
305 |
} |
|
306 |
else |
|
307 |
{ |
|
308 |
Toolbar()->SetItemDimmed(EFeedsOpen, ETrue, ETrue); |
|
309 |
} |
|
310 |
#endif |
|
311 |
} |
|
312 |
||
313 |
// --------------------------------------------------------------------------- |
|
314 |
// CFeedsTopicView::CommandSetResourceIdL |
|
315 |
// --------------------------------------------------------------------------- |
|
316 |
TInt CFeedsTopicView::CommandSetResourceIdL() |
|
317 |
{ |
|
318 |
// It is never called, but this function have to be implemented |
|
319 |
return KWmlEmptyResourceId; |
|
320 |
} |
|
321 |
||
322 |
// --------------------------------------------------------- |
|
323 |
// CFeedsTopicView::HandleClientRectChange |
|
324 |
// --------------------------------------------------------- |
|
325 |
// |
|
326 |
void CFeedsTopicView::HandleClientRectChange() |
|
327 |
{ |
|
328 |
if( iContainer ) |
|
329 |
{ |
|
330 |
iContainer->SetRect( ClientRect() ); |
|
331 |
} |
|
332 |
} |