48
|
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.
|
|
205 |
iContainer->SetCurrentFeedL(*(iApiProvider.FeedsClientUtilities().CurrentFeed()), iInitialItem);
|
|
206 |
iApiProvider.SetLastActiveViewId(Id());
|
|
207 |
UpdateToolbarButtonsState();
|
|
208 |
}
|
|
209 |
|
|
210 |
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
// CFeedsTopicView::DoDeactivate
|
|
213 |
//
|
|
214 |
// Called when the view is deactivated.
|
|
215 |
// -----------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
void CFeedsTopicView::DoDeactivate()
|
|
218 |
{
|
|
219 |
if (iContainerOnStack)
|
|
220 |
{
|
|
221 |
AppUi()->RemoveFromViewStack(*this, iContainer);
|
|
222 |
iContainer->MakeVisible(EFalse);
|
|
223 |
iContainer->ClearNavigationPane();
|
|
224 |
iContainerOnStack = EFalse;
|
|
225 |
|
|
226 |
iInitialItem = iContainer->CurrentIndex();
|
|
227 |
}
|
|
228 |
}
|
|
229 |
|
|
230 |
|
|
231 |
// -----------------------------------------------------------------------------
|
|
232 |
// CFeedsTopicView::DynInitMenuPaneL
|
|
233 |
//
|
|
234 |
// Disables unrelated menu options.
|
|
235 |
// -----------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
void CFeedsTopicView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
|
|
238 |
{
|
|
239 |
|
|
240 |
|
|
241 |
if (aResourceId == R_FEEDS_TOPIC_VIEW_MENU)
|
|
242 |
{
|
|
243 |
// Refresh (same as update?)
|
|
244 |
iApiProvider.FeedsClientUtilities().AddItemL(*aMenuPane, EFeedsUpdate, R_FEEDS_UPDATE);
|
|
245 |
|
|
246 |
// Back to Page (if page loaded)
|
|
247 |
if ( iApiProvider.IsPageLoaded() )
|
|
248 |
{
|
|
249 |
iApiProvider.FeedsClientUtilities().AddItemL( *aMenuPane, EWmlCmdBackToPage, R_BROWSER_MENU_ITEM_BACK_TO_PAGE );
|
|
250 |
}
|
|
251 |
}
|
|
252 |
|
|
253 |
iApiProvider.FeedsClientUtilities().DynInitMenuPaneL(aResourceId, aMenuPane );
|
|
254 |
}
|
|
255 |
|
|
256 |
|
|
257 |
// -----------------------------------------------------------------------------
|
|
258 |
// CFeedsTopicView::SetCurrentFeedL
|
|
259 |
//
|
|
260 |
// Sets the current feed
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
void CFeedsTopicView::SetCurrentFeedL(const CFeedsEntity& aFeed, TInt aIndex)
|
|
264 |
{
|
|
265 |
iContainer->SetCurrentFeedL(aFeed, aIndex);
|
|
266 |
}
|
|
267 |
|
|
268 |
|
|
269 |
// -----------------------------------------------------------------------------
|
|
270 |
// CFeedsTopicView::SetInitialItem
|
|
271 |
//
|
|
272 |
// Sets the initial item once the view is activated.
|
|
273 |
// -----------------------------------------------------------------------------
|
|
274 |
//
|
|
275 |
void CFeedsTopicView::SetInitialItem(TInt aItemIndex)
|
|
276 |
{
|
|
277 |
iInitialItem = aItemIndex;
|
|
278 |
}
|
|
279 |
|
|
280 |
// -----------------------------------------------------------------------------
|
|
281 |
// CFeedsTopicView::UpdateToolbarButtonsState
|
|
282 |
//
|
|
283 |
// Updates the state of the toolbar buttons depending on the situation
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
//
|
|
286 |
|
|
287 |
void CFeedsTopicView::UpdateToolbarButtonsState()
|
|
288 |
{
|
|
289 |
#ifdef BRDO_SINGLE_CLICK_ENABLED_FF
|
|
290 |
Toolbar()->SetToolbarVisibility(EFalse,EFalse);
|
|
291 |
return;
|
|
292 |
#else
|
|
293 |
if (iApiProvider.IsPageLoaded())
|
|
294 |
{
|
|
295 |
Toolbar()->SetItemDimmed(EFeedsBackToPage, EFalse, ETrue);
|
|
296 |
}
|
|
297 |
else
|
|
298 |
{
|
|
299 |
Toolbar()->SetItemDimmed(EFeedsBackToPage, ETrue, ETrue);
|
|
300 |
}
|
|
301 |
if ((iApiProvider.FeedsClientUtilities().CurrentFeed()->GetChildren().Count()) > 0)
|
|
302 |
{
|
|
303 |
Toolbar()->SetItemDimmed(EFeedsOpen, EFalse, ETrue);
|
|
304 |
}
|
|
305 |
else
|
|
306 |
{
|
|
307 |
Toolbar()->SetItemDimmed(EFeedsOpen, ETrue, ETrue);
|
|
308 |
}
|
|
309 |
#endif
|
|
310 |
}
|
|
311 |
|
|
312 |
// ---------------------------------------------------------------------------
|
|
313 |
// CFeedsTopicView::CommandSetResourceIdL
|
|
314 |
// ---------------------------------------------------------------------------
|
|
315 |
TInt CFeedsTopicView::CommandSetResourceIdL()
|
|
316 |
{
|
|
317 |
// It is never called, but this function have to be implemented
|
|
318 |
return KWmlEmptyResourceId;
|
|
319 |
}
|
|
320 |
|
|
321 |
// ---------------------------------------------------------
|
|
322 |
// CFeedsTopicView::HandleClientRectChange
|
|
323 |
// ---------------------------------------------------------
|
|
324 |
//
|
|
325 |
void CFeedsTopicView::HandleClientRectChange()
|
|
326 |
{
|
|
327 |
if( iContainer )
|
|
328 |
{
|
|
329 |
iContainer->SetRect( ClientRect() );
|
|
330 |
}
|
|
331 |
}
|