65
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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 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:
|
|
15 |
* Implementation of CBrowserBookmarksContainer.
|
|
16 |
*
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
|
|
23 |
#include <AknViewAppUi.h>
|
|
24 |
#include <aknsfld.h>
|
|
25 |
#include <avkon.mbg>
|
|
26 |
#include <BrowserNG.rsg>
|
|
27 |
#include <favouritesitem.h>
|
|
28 |
#include <FeatMgr.h>
|
|
29 |
#include "BrowserBookmarksView.h"
|
|
30 |
|
|
31 |
#include "CommonConstants.h"
|
|
32 |
#include "BrowserFavouritesView.h"
|
|
33 |
#include "BrowserBookmarksContainer.h"
|
|
34 |
#include "BrowserBookmarksGotoPane.h"
|
|
35 |
#include "BrowserFavouritesListbox.h"
|
|
36 |
#include "BrowserUtil.h"
|
|
37 |
#include "BrowserAppUi.h"
|
|
38 |
#include "BrowserBookmarksListboxIconHandler.h"
|
|
39 |
#ifdef __SERIES60_HELP
|
|
40 |
// Context-Sensitve Help File
|
|
41 |
#include "BrowserApplication.h"
|
|
42 |
#include <csxhelp/browser.hlp.hrh>
|
|
43 |
#endif // __SERIES60_HELP
|
|
44 |
#include "Logger.h"
|
|
45 |
#include <e32event.h>
|
|
46 |
#include <browseruisdkcrkeys.h>
|
|
47 |
#include <StringLoader.h>
|
|
48 |
|
|
49 |
// CONSTANTS
|
|
50 |
|
|
51 |
/// Tab index for Bookmarks View.
|
|
52 |
LOCAL_D const TInt KBookmarkTabIndex = 0;
|
|
53 |
const TInt KMaxTitleLength = 512;
|
|
54 |
|
|
55 |
// ================= MEMBER FUNCTIONS =======================
|
|
56 |
|
|
57 |
// ---------------------------------------------------------
|
|
58 |
// CBrowserBookmarksContainer::NewL
|
|
59 |
// ---------------------------------------------------------
|
|
60 |
//
|
|
61 |
CBrowserBookmarksContainer* CBrowserBookmarksContainer::NewL(
|
|
62 |
const TRect& aRect,
|
|
63 |
CBrowserFavouritesView& aView)
|
|
64 |
{
|
|
65 |
CBrowserBookmarksContainer* container =
|
|
66 |
new (ELeave) CBrowserBookmarksContainer;
|
|
67 |
CleanupStack::PushL( container );
|
|
68 |
container->ConstructL( aRect, aView );
|
|
69 |
CleanupStack::Pop(); // container
|
|
70 |
return container;
|
|
71 |
}
|
|
72 |
|
|
73 |
// ---------------------------------------------------------
|
|
74 |
// CBrowserBookmarksContainer::~CBrowserBookmarksContainer
|
|
75 |
// ---------------------------------------------------------
|
|
76 |
//
|
|
77 |
CBrowserBookmarksContainer::~CBrowserBookmarksContainer()
|
|
78 |
{
|
|
79 |
delete iGotoPane;
|
|
80 |
delete iSearchPane;
|
|
81 |
delete iDefaultSearchText;
|
|
82 |
}
|
|
83 |
|
|
84 |
// ---------------------------------------------------------
|
|
85 |
// CBrowserBookmarksContainer::SetGotoActiveL
|
|
86 |
// ---------------------------------------------------------
|
|
87 |
//
|
|
88 |
void CBrowserBookmarksContainer::SetGotoActiveL()
|
|
89 |
{
|
|
90 |
if( !iGotoPaneActive)
|
|
91 |
{
|
|
92 |
iGotoPaneActive = ETrue;
|
|
93 |
|
|
94 |
Listbox()->UpdateFilterL();
|
|
95 |
if( iSearchPane )
|
|
96 |
{
|
|
97 |
iGotoPane->SetVKBFlag( EFalse );
|
|
98 |
// Check for Search Configuration Changes //
|
|
99 |
if( View().ApiProvider().Preferences().GetIntValue( KBrowserSearchIconId )
|
|
100 |
!= iSearchIconId )
|
|
101 |
{
|
|
102 |
ConstructSearchPaneL();
|
|
103 |
}
|
|
104 |
|
|
105 |
iSearchPane->SetFocus( EFalse );
|
|
106 |
// only one editor can be active at a time //
|
|
107 |
iSearchPaneActive = EFalse;
|
|
108 |
// we still need to display search, when showing for first time //
|
|
109 |
iSearchPane->MakeVisible(ETrue);
|
|
110 |
iSearchPane->CancelEditingL();
|
|
111 |
}
|
|
112 |
|
|
113 |
// redraw
|
|
114 |
SizeChanged();
|
|
115 |
|
|
116 |
// It is important to set the Text and Italic property after SizeChanged, because
|
|
117 |
// iInputFrame->SetRect() event on GoTo/Search Pane calls the scalable version
|
|
118 |
// ( AknLayoutUtils::LayoutEdwinScalable ) which overwrites all the properties for
|
|
119 |
// Char and Para Formats.
|
|
120 |
if( iSearchPane )
|
|
121 |
{
|
|
122 |
iSearchPane->SetTextModeItalicL();
|
|
123 |
HBufC* text = iSearchPane->GetTextL();
|
|
124 |
CleanupStack::PushL( text );
|
|
125 |
if ( !text->Length() )
|
|
126 |
{
|
|
127 |
//TODO: read possible title valu from cenrep, if not found seyt the default text
|
|
128 |
HBufC* searchProvider = HBufC::NewLC( KMaxTitleLength );
|
|
129 |
TPtr searchProviderPtr = searchProvider->Des();
|
|
130 |
|
|
131 |
View().ApiProvider().Preferences().GetStringValueL( KBrowserSearchProviderTitle,
|
|
132 |
KMaxTitleLength , searchProviderPtr);
|
|
133 |
if( searchProvider->Length() == 0 )
|
|
134 |
{
|
|
135 |
iSearchPane->SetTextL( *iDefaultSearchText );
|
|
136 |
}
|
|
137 |
else
|
|
138 |
{
|
|
139 |
iSearchPane->SetTextL( searchProviderPtr );
|
|
140 |
}
|
|
141 |
CleanupStack::PopAndDestroy(searchProvider);
|
|
142 |
|
|
143 |
}
|
|
144 |
CleanupStack::PopAndDestroy( text );
|
|
145 |
}
|
|
146 |
|
|
147 |
iGotoPane->BeginEditingL();
|
|
148 |
DrawDeferred();
|
|
149 |
}
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------
|
|
153 |
// CBrowserBookmarksContainer::SetSearchActiveL
|
|
154 |
// ---------------------------------------------------------
|
|
155 |
//
|
|
156 |
void CBrowserBookmarksContainer::SetSearchActiveL()
|
|
157 |
{
|
|
158 |
if( ! iSearchPaneActive )
|
|
159 |
{
|
|
160 |
// Check for Search Configuration Changes //
|
|
161 |
if( View().ApiProvider().Preferences().GetIntValue( KBrowserSearchIconId )
|
|
162 |
!= iSearchIconId )
|
|
163 |
{
|
|
164 |
ConstructSearchPaneL();
|
|
165 |
}
|
|
166 |
|
|
167 |
iSearchPane->SetVKBFlag( EFalse );
|
|
168 |
iSearchPane->SetFocus( ETrue );
|
|
169 |
iSearchPaneActive = ETrue;
|
|
170 |
|
|
171 |
Listbox()->UpdateFilterL();
|
|
172 |
// only one editor can be active at a time
|
|
173 |
iGotoPaneActive = EFalse;
|
|
174 |
iGotoPane->MakeVisible(ETrue);
|
|
175 |
iGotoPane->SetFocus( EFalse );
|
|
176 |
iGotoPane->CancelEditingL();
|
|
177 |
|
|
178 |
// redraw
|
|
179 |
SizeChanged();
|
|
180 |
|
|
181 |
// Not Focused, so set the current Text Mode to italics.
|
|
182 |
iGotoPane->SetTextModeItalicL();
|
|
183 |
// if gotopane is empty add default text
|
|
184 |
HBufC* text = iGotoPane->GetTextL();
|
|
185 |
CleanupStack::PushL( text );
|
|
186 |
if ( !text->Length() )
|
|
187 |
{
|
|
188 |
iGotoPane->SetTextL( KWWWString );
|
|
189 |
}
|
|
190 |
CleanupStack::PopAndDestroy( text );
|
|
191 |
|
|
192 |
iSearchPane->BeginEditingL();
|
|
193 |
DrawDeferred();
|
|
194 |
}
|
|
195 |
|
|
196 |
}
|
|
197 |
|
|
198 |
|
|
199 |
// ---------------------------------------------------------
|
|
200 |
// CBrowserBookmarksContainer::SetGotoInactiveL();
|
|
201 |
// ---------------------------------------------------------
|
|
202 |
//
|
|
203 |
|
|
204 |
void CBrowserBookmarksContainer::SetGotoInactiveL()
|
|
205 |
{
|
|
206 |
if( iGotoPaneActive || iSearchPaneActive )
|
|
207 |
{
|
|
208 |
|
|
209 |
if( iSearchPane )
|
|
210 |
{
|
|
211 |
/* In Search Feature we have to move between the editors preserving the
|
|
212 |
* text added, clear the text when cancel is pressed.
|
|
213 |
*/
|
|
214 |
iGotoPane->SetTextL( KNullDesC , ETrue );
|
|
215 |
SetSearchInactiveL();
|
|
216 |
}
|
|
217 |
// Deactivate GoTo Pane
|
|
218 |
iGotoPaneActive = EFalse;
|
|
219 |
|
|
220 |
// Deactivate GoTo Pane
|
|
221 |
iGotoPane->MakeVisible( EFalse );
|
|
222 |
iGotoPane->CancelEditingL();
|
|
223 |
iGotoPane->SetFocus( EFalse );
|
|
224 |
|
|
225 |
// redraw
|
|
226 |
Listbox()->UpdateFilterL();
|
|
227 |
SizeChanged();
|
|
228 |
DrawDeferred();
|
|
229 |
}
|
|
230 |
}
|
|
231 |
|
|
232 |
void CBrowserBookmarksContainer::SetSearchInactiveL()
|
|
233 |
{
|
|
234 |
iSearchPaneActive = EFalse;
|
|
235 |
iSearchPane->SetTextL( KNullDesC , ETrue);
|
|
236 |
iSearchPane->MakeVisible( EFalse );
|
|
237 |
iSearchPane->CancelEditingL();
|
|
238 |
}
|
|
239 |
|
|
240 |
// ---------------------------------------------------------
|
|
241 |
// CBrowserBookmarksContainer::CountComponentControls
|
|
242 |
// ---------------------------------------------------------
|
|
243 |
//
|
|
244 |
TInt CBrowserBookmarksContainer::CountComponentControls() const
|
|
245 |
{
|
|
246 |
return (Listbox() ? 1 : 0) + (iGotoPane ? 1 : 0) + (iSearchPane? 1 : 0) ;
|
|
247 |
}
|
|
248 |
|
|
249 |
// ---------------------------------------------------------
|
|
250 |
// CBrowserBookmarksContainer::ComponentControl
|
|
251 |
// ---------------------------------------------------------
|
|
252 |
//
|
|
253 |
CCoeControl* CBrowserBookmarksContainer::ComponentControl
|
|
254 |
( TInt aIndex ) const
|
|
255 |
{
|
|
256 |
switch (aIndex)
|
|
257 |
{
|
|
258 |
case 0:
|
|
259 |
{
|
|
260 |
return Listbox();
|
|
261 |
}
|
|
262 |
|
|
263 |
case 1:
|
|
264 |
{
|
|
265 |
return iGotoPane;
|
|
266 |
}
|
|
267 |
case 2:
|
|
268 |
{
|
|
269 |
return iSearchPane;
|
|
270 |
}
|
|
271 |
default:
|
|
272 |
{
|
|
273 |
return NULL;
|
|
274 |
}
|
|
275 |
}
|
|
276 |
}
|
|
277 |
|
|
278 |
// ---------------------------------------------------------
|
|
279 |
// CBrowserBookmarksContainer::SizeChanged
|
|
280 |
// ---------------------------------------------------------
|
|
281 |
//
|
|
282 |
void CBrowserBookmarksContainer::SizeChanged()
|
|
283 |
{
|
|
284 |
TRect rect = Rect();
|
|
285 |
TInt unfilteredNumberOfItems = Listbox()->UnfilteredNumberOfItems();
|
|
286 |
|
|
287 |
// if goto pane is active
|
|
288 |
if( iGotoPaneActive || iSearchPaneActive )
|
|
289 |
{
|
|
290 |
if( iSearchPane )
|
|
291 |
{
|
|
292 |
TAknWindowLineLayout findPane = AknLayout::find_pane();
|
|
293 |
|
|
294 |
// Enable / disable line in Goto Pane (hide if listbox is empty).
|
|
295 |
iGotoPane->SetLineState( unfilteredNumberOfItems > 0 );
|
|
296 |
|
|
297 |
TAknWindowLineLayout listLayout = AknLayout::list_gen_pane( 1 );
|
|
298 |
|
|
299 |
TRect listBoxRect = AknLayoutUtils::RectFromCoords( rect,listLayout.il,
|
|
300 |
listLayout.it, listLayout.ir, listLayout.ib, listLayout.iW, listLayout.iH);
|
|
301 |
|
|
302 |
/* Now we need to make room for both Goto and Search Pane.
|
|
303 |
* No layout specification was suitable for this case, so
|
|
304 |
* substracting the height of pane.
|
|
305 |
*/
|
|
306 |
listBoxRect.iBr.iY -= findPane.iH;
|
|
307 |
|
|
308 |
// In Goto Mode, the listbox is laid out leaving space for Goto Pane.
|
|
309 |
Listbox()->SetRect( listBoxRect );
|
|
310 |
|
|
311 |
|
|
312 |
// Now Lay out Search Pane as if it was the old Find Pane.
|
|
313 |
AknLayoutUtils::LayoutControl( iSearchPane, rect, findPane );
|
|
314 |
|
|
315 |
TRect gotoRect = AknLayoutUtils::RectFromCoords( rect,findPane.il, findPane.it,
|
|
316 |
findPane.ir, findPane.ib, findPane.iW, findPane.iH);
|
|
317 |
|
|
318 |
// Calculate the new position for GoToPane.
|
|
319 |
gotoRect.iTl.iY -= ( findPane.iH );
|
|
320 |
gotoRect.iBr.iY -= ( findPane.iH );
|
|
321 |
iGotoPane->SetRect( gotoRect );
|
|
322 |
|
|
323 |
}
|
|
324 |
else
|
|
325 |
{
|
|
326 |
// Enable / disable line in Goto Pane (hide if listbox is empty).
|
|
327 |
iGotoPane->SetLineState( unfilteredNumberOfItems > 0 );
|
|
328 |
|
|
329 |
// In Goto Mode, the listbox is laid out leaving space for Goto Pane.
|
|
330 |
AknLayoutUtils::LayoutControl( Listbox(), rect, AknLayout::list_gen_pane( 1 ));
|
|
331 |
|
|
332 |
// Lay out Goto Pane as if it was the old Find Pane.
|
|
333 |
AknLayoutUtils::LayoutControl( iGotoPane, rect, AknLayout::find_pane() );
|
|
334 |
}
|
|
335 |
}
|
|
336 |
else
|
|
337 |
{
|
|
338 |
// Fall back upon default behavior in base-class, which lays out the bookmarks list only
|
|
339 |
CBrowserFavouritesContainer::SizeChanged();
|
|
340 |
}
|
|
341 |
}
|
|
342 |
|
|
343 |
// ---------------------------------------------------------
|
|
344 |
// CBrowserBookmarksContainer::OfferKeyEventL
|
|
345 |
// ---------------------------------------------------------
|
|
346 |
//
|
|
347 |
TKeyResponse CBrowserBookmarksContainer::OfferKeyEventL
|
|
348 |
( const TKeyEvent& aKeyEvent, TEventCode aType )
|
|
349 |
{
|
|
350 |
/*
|
|
351 |
LOG_ENTERFN( "BookmarksContainer::OfferKeyEventL" );
|
|
352 |
BROWSER_LOG( ( _L("aType: %d, aKeyEvent.iCode: %d, iScanCode: %d, iRepeats: %d"),
|
|
353 |
aType, aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iRepeats ) );
|
|
354 |
*/
|
|
355 |
TKeyResponse result = EKeyWasNotConsumed;
|
|
356 |
TKeyEvent keyEvent( aKeyEvent );
|
|
357 |
|
|
358 |
// Selection Key handling
|
|
359 |
if( keyEvent.iScanCode == EStdKeyDevice3 )
|
|
360 |
{
|
|
361 |
// it is possible to activate BookmarksView from ContentView
|
|
362 |
// via a long press of Selection key, so here we must capture
|
|
363 |
// the KeyDown. Long press processing will be done only if key
|
|
364 |
// was pressed originally in this view.
|
|
365 |
if( aType == EEventKeyDown )
|
|
366 |
{
|
|
367 |
iSelectionKeyDownPressed = ETrue;
|
|
368 |
result = EKeyWasConsumed;
|
|
369 |
}
|
|
370 |
else if( aType == EEventKeyUp )
|
|
371 |
{
|
|
372 |
if( !iSelectionKeyLongPress && iSelectionKeyDownPressed )
|
|
373 |
{
|
|
374 |
// short press of Selection key, pass it to GotoPane
|
|
375 |
keyEvent.iCode = EKeyOK;
|
|
376 |
result = EKeyWasNotConsumed;
|
|
377 |
}
|
|
378 |
else
|
|
379 |
{
|
|
380 |
// long press of Selection key was already processed
|
|
381 |
result = EKeyWasConsumed;
|
|
382 |
}
|
|
383 |
iSelectionKeyDownPressed = EFalse;
|
|
384 |
iSelectionKeyLongPress = EFalse;
|
|
385 |
}
|
|
386 |
else if( aType == EEventKey )
|
|
387 |
{
|
|
388 |
if( keyEvent.iRepeats && iSelectionKeyDownPressed )
|
|
389 |
{
|
|
390 |
const CFavouritesItem* item = Listbox()->CurrentItem();
|
|
391 |
if ( item )
|
|
392 |
{
|
|
393 |
// The option for the user to download the page in new window is disabled
|
|
394 |
CBrowserAppUi::Static()->FetchBookmarkL( *item );
|
|
395 |
}
|
|
396 |
iSelectionKeyLongPress = ETrue;
|
|
397 |
iSelectionKeyDownPressed = EFalse;
|
|
398 |
}
|
|
399 |
|
|
400 |
if ( (aKeyEvent.iScanCode == EStdKeyHash) ||
|
|
401 |
( aKeyEvent.iModifiers &
|
|
402 |
( EModifierShift | EModifierLeftShift | EModifierRightShift |
|
|
403 |
EModifierCtrl | EModifierLeftCtrl | EModifierRightCtrl ) ) )
|
|
404 |
{
|
|
405 |
|
|
406 |
// Hash key press will be used for Mark/UnMark functionality
|
|
407 |
// Let Platform Listbox handle this.
|
|
408 |
result = EKeyWasNotConsumed;
|
|
409 |
}
|
|
410 |
else
|
|
411 |
{
|
|
412 |
result = EKeyWasConsumed;
|
|
413 |
}
|
|
414 |
}
|
|
415 |
}
|
|
416 |
|
|
417 |
// If the Goto Pane exists and we're not fetching, decide
|
|
418 |
// if we should pass key event to the goto pane
|
|
419 |
if ( iGotoPane && ( !CBrowserAppUi::Static()->Fetching() || iGotoPaneActive ) )
|
|
420 |
{
|
|
421 |
// If the key hadn't been consumed, so far, determine if the keystroke
|
|
422 |
// should be handled by goto pane
|
|
423 |
if ( ( result == EKeyWasNotConsumed ) || iSearchPaneActive )
|
|
424 |
{
|
|
425 |
// Goto pane has highest priority; if it's active, arrow keys go there.
|
|
426 |
// If fetching is in progress, no key events are offered, to prevent it
|
|
427 |
// from getting the focus and popping up a new CBA.
|
|
428 |
|
|
429 |
// Enter Key now handled through HandleCommand in BrowserBookmarksView like MSK
|
|
430 |
// This change affects the enter key on the QWERTY keyboard when we run emulator
|
|
431 |
if ( EStdKeyEnter == aKeyEvent.iScanCode && EEventKey == aType &&
|
|
432 |
AknLayoutUtils::MSKEnabled() &&
|
|
433 |
( iGotoPaneActive || iSearchPaneActive ) )
|
|
434 |
{
|
|
435 |
// Handle MSK press
|
|
436 |
CEikButtonGroupContainer* myCba = CEikButtonGroupContainer::Current();
|
|
437 |
if ( myCba != NULL )
|
|
438 |
{
|
|
439 |
TInt cmdId = myCba->ButtonGroup()->CommandId(CEikButtonGroupContainer::EMiddleSoftkeyPosition);
|
|
440 |
View().HandleCommandL(cmdId);
|
|
441 |
result = EKeyWasConsumed;
|
|
442 |
}
|
|
443 |
}
|
|
444 |
else
|
|
445 |
{
|
|
446 |
if ( iSearchPane && iSearchPaneActive)
|
|
447 |
{
|
|
448 |
// Process separately for Search Feature
|
|
449 |
if ( iGotoPaneActive )
|
|
450 |
{
|
|
451 |
result = iGotoPane->OfferKeyEventL( keyEvent, aType );
|
|
452 |
}
|
|
453 |
else
|
|
454 |
{
|
|
455 |
result = iSearchPane->OfferKeyEventL( keyEvent, aType );
|
|
456 |
}
|
|
457 |
}
|
|
458 |
else
|
|
459 |
{
|
|
460 |
if ( iGotoPaneActive )
|
|
461 |
{
|
|
462 |
// Once activated let goto pane handle all the keys
|
|
463 |
result = iGotoPane->OfferKeyEventL( keyEvent, aType );
|
|
464 |
}
|
|
465 |
else // if ( !iGotoPaneActive )
|
|
466 |
{
|
|
467 |
// Only a valid digit or character should popup the goto pane.
|
|
468 |
// We will ignore h/w key events, i.e. camera cover, camera
|
|
469 |
// shutter, zoom, etc... iCode is only valid for EEventKey,
|
|
470 |
// not EEventKeyDown, so we have to use iScanCode. because
|
|
471 |
// the goto pane decides to popup on EEventKeyDown. Use
|
|
472 |
// upper case of iScanCode since there is no overlap of
|
|
473 |
// h/w scan codes and uppercase letters.
|
|
474 |
TChar inputCharCode( aKeyEvent.iScanCode );
|
|
475 |
TBool isDigit = inputCharCode.IsDigit();
|
|
476 |
TUint upperCase = inputCharCode.GetUpperCase();
|
|
477 |
if ( isDigit ||
|
|
478 |
(( upperCase >= 0x41 /*A*/ ) && ( upperCase <= 0x5A /*Z*/ )) )
|
|
479 |
{
|
|
480 |
// Valid digit or character was entered, let goto pane
|
|
481 |
// determine if it handles the keys from here on.
|
|
482 |
result = iGotoPane->OfferKeyEventL( aKeyEvent, aType );
|
|
483 |
if ( result == EKeyWasConsumed )
|
|
484 |
{
|
|
485 |
// goto pane is not active, make it active now
|
|
486 |
SetGotoActiveL();
|
|
487 |
}
|
|
488 |
}
|
|
489 |
}
|
|
490 |
}
|
|
491 |
}
|
|
492 |
}
|
|
493 |
|
|
494 |
if ( iSearchPane )
|
|
495 |
{
|
|
496 |
if ( ( iGotoPaneActive || iSearchPaneActive) &&
|
|
497 |
result == EKeyWasNotConsumed )
|
|
498 |
{
|
|
499 |
|
|
500 |
if ( aKeyEvent.iCode == EKeyUpArrow )
|
|
501 |
{
|
|
502 |
result = EKeyWasConsumed;
|
|
503 |
if ( iSearchPaneActive )
|
|
504 |
{
|
|
505 |
SetGotoActiveL();
|
|
506 |
iGotoPane->SetVKBFlag( ETrue );
|
|
507 |
}
|
|
508 |
}
|
|
509 |
|
|
510 |
if ( aKeyEvent.iCode == EKeyDownArrow )
|
|
511 |
{
|
|
512 |
result = EKeyWasConsumed;
|
|
513 |
if ( iGotoPaneActive )
|
|
514 |
{
|
|
515 |
SetSearchActiveL();
|
|
516 |
iSearchPane->SetVKBFlag( ETrue );
|
|
517 |
}
|
|
518 |
}
|
|
519 |
}
|
|
520 |
}
|
|
521 |
}
|
|
522 |
|
|
523 |
// For handling Enter key in emulator / Keyboard ( Enter key should behave similar to MSK )
|
|
524 |
if ( EStdKeyEnter == keyEvent.iScanCode && EEventKey == aType &&
|
|
525 |
AknLayoutUtils::MSKEnabled() && result == EKeyWasNotConsumed )
|
|
526 |
{
|
|
527 |
CEikButtonGroupContainer* myCba = CEikButtonGroupContainer::Current();
|
|
528 |
if(myCba != NULL)
|
|
529 |
{
|
|
530 |
TInt cmdId = myCba->ButtonGroup()->CommandId(CEikButtonGroupContainer::EMiddleSoftkeyPosition);
|
|
531 |
if(EAknSoftkeyContextOptions == cmdId)
|
|
532 |
{
|
|
533 |
View().MenuBar()->TryDisplayContextMenuBarL();
|
|
534 |
result = EKeyWasConsumed;
|
|
535 |
}
|
|
536 |
else if(Listbox()->Model()->ItemTextArray()->MdcaCount() == 0)
|
|
537 |
{
|
|
538 |
View().HandleCommandL(cmdId);
|
|
539 |
result = EKeyWasConsumed;
|
|
540 |
}
|
|
541 |
}
|
|
542 |
}
|
|
543 |
|
|
544 |
if ( result == EKeyWasNotConsumed )
|
|
545 |
{
|
|
546 |
// Otherwise, base class handles Find pane, arrows between folders and
|
|
547 |
// the listbox.
|
|
548 |
result = CBrowserFavouritesContainer::OfferKeyEventL( keyEvent, aType );
|
|
549 |
}
|
|
550 |
|
|
551 |
return result;
|
|
552 |
}
|
|
553 |
|
|
554 |
// ---------------------------------------------------------
|
|
555 |
// CBrowserBookmarksContainer::HandleCursorChangedL
|
|
556 |
// ---------------------------------------------------------
|
|
557 |
//
|
|
558 |
void CBrowserBookmarksContainer::HandleCursorChangedL
|
|
559 |
( CEikListBox*
|
|
560 |
#ifdef _DEBUG
|
|
561 |
aListBox // used only for debugging purposes
|
|
562 |
#endif
|
|
563 |
)
|
|
564 |
{
|
|
565 |
#ifdef _DEBUG
|
|
566 |
__ASSERT_DEBUG( aListBox == Listbox(),
|
|
567 |
Util::Panic( Util::EFavouritesBadListbox ) );
|
|
568 |
#endif
|
|
569 |
|
|
570 |
if ( iGotoPane->IsVisible() )
|
|
571 |
{
|
|
572 |
// Set Goto Pane text (URL or default http text) - this will cancel
|
|
573 |
// Goto Pane editing.
|
|
574 |
TPtrC url( KWWWString );
|
|
575 |
TBrowserFavouritesSelectionState selection =
|
|
576 |
Listbox()->SelectionStateL();
|
|
577 |
if ( !selection.AnyMarked() && selection.CurrentIsItem() )
|
|
578 |
{
|
|
579 |
// Exactly one item is selected.
|
|
580 |
const CFavouritesItem* item = Listbox()->CurrentItem();
|
|
581 |
if ( item ) // Sanity check.
|
|
582 |
{
|
|
583 |
// If one item is highlighted, set to current URL.
|
|
584 |
url.Set( Util::StripUrl( item->Url() ) );
|
|
585 |
}
|
|
586 |
}
|
|
587 |
iGotoPane->SetTextL( url, ETrue );
|
|
588 |
iGotoPane->SetFocus ( EFalse );
|
|
589 |
}
|
|
590 |
}
|
|
591 |
|
|
592 |
// ---------------------------------------------------------
|
|
593 |
// CBrowserBookmarksContainer::IsEditing
|
|
594 |
// ---------------------------------------------------------
|
|
595 |
//
|
|
596 |
TBool CBrowserBookmarksContainer::IsEditing()
|
|
597 |
{
|
|
598 |
TBool editing = EFalse;
|
|
599 |
editing = iGotoPane->IsEditing();
|
|
600 |
return editing;
|
|
601 |
}
|
|
602 |
|
|
603 |
// ---------------------------------------------------------
|
|
604 |
// CBrowserBookmarksContainer::IsEditingSearch
|
|
605 |
// ---------------------------------------------------------
|
|
606 |
//
|
|
607 |
TBool CBrowserBookmarksContainer::IsEditingSearch()
|
|
608 |
{
|
|
609 |
TBool editing = EFalse;
|
|
610 |
if( iSearchPane )
|
|
611 |
{
|
|
612 |
editing = iSearchPane->IsEditing();
|
|
613 |
}
|
|
614 |
return editing;
|
|
615 |
}
|
|
616 |
|
|
617 |
// ---------------------------------------------------------
|
|
618 |
// CBrowserBookmarksContainer::TabIndex
|
|
619 |
// ---------------------------------------------------------
|
|
620 |
//
|
|
621 |
TInt CBrowserBookmarksContainer::TabIndex()
|
|
622 |
{
|
|
623 |
return KBookmarkTabIndex;
|
|
624 |
}
|
|
625 |
|
|
626 |
// ---------------------------------------------------------
|
|
627 |
// CBrowserBookmarksContainer::ListboxEmptyTextResourceId
|
|
628 |
// ---------------------------------------------------------
|
|
629 |
//
|
|
630 |
TInt CBrowserBookmarksContainer::ListboxEmptyTextResourceId()
|
|
631 |
{
|
|
632 |
return R_BROWSER_BOOKMARKS_TEXT_NO_BOOKMARKS;
|
|
633 |
}
|
|
634 |
|
|
635 |
// ---------------------------------------------------------
|
|
636 |
// CBrowserBookmarksContainer::TitleResourceId
|
|
637 |
// ---------------------------------------------------------
|
|
638 |
//
|
|
639 |
TInt CBrowserBookmarksContainer::TitleResourceId()
|
|
640 |
{
|
|
641 |
return R_BROWSER_OPTION_BOOKMARKS;
|
|
642 |
}
|
|
643 |
|
|
644 |
// ---------------------------------------------------------
|
|
645 |
// CBrowserBookmarksContainer::CBrowserBookmarksContainer
|
|
646 |
// ---------------------------------------------------------
|
|
647 |
//
|
|
648 |
CBrowserBookmarksContainer::CBrowserBookmarksContainer()
|
|
649 |
: iGotoPaneActive( EFalse ),
|
|
650 |
iSearchPaneActive(EFalse)
|
|
651 |
{
|
|
652 |
}
|
|
653 |
|
|
654 |
// ---------------------------------------------------------
|
|
655 |
// CBrowserBookmarksContainer::ConstructComponentControlsL
|
|
656 |
// ---------------------------------------------------------
|
|
657 |
//
|
|
658 |
void CBrowserBookmarksContainer::ConstructComponentControlsL(
|
|
659 |
const TRect& aRect,
|
|
660 |
CBrowserFavouritesView& aView )
|
|
661 |
{
|
|
662 |
CBrowserFavouritesContainer::ConstructComponentControlsL
|
|
663 |
( aRect, aView );
|
|
664 |
|
|
665 |
|
|
666 |
// Construct Goto Pane.
|
|
667 |
|
|
668 |
//pass view to bookmarks goto pane
|
|
669 |
iGotoPane = CBrowserBookmarksGotoPane::NewL( *this, &aView, KAvkonBitmapFile,
|
|
670 |
EMbmAvkonQgn_indi_find_goto,
|
|
671 |
EMbmAvkonQgn_indi_find_goto_mask);
|
|
672 |
iGotoPane->SetFocus( EFalse );
|
|
673 |
|
|
674 |
if( View().ApiProvider().Preferences().SearchFeature() )
|
|
675 |
{
|
|
676 |
ConstructSearchPaneL();
|
|
677 |
iSearchPane->SetFocus( EFalse );
|
|
678 |
iDefaultSearchText = StringLoader::LoadL( R_IS_WEB_SEARCH );
|
|
679 |
}
|
|
680 |
}
|
|
681 |
|
|
682 |
// ---------------------------------------------------------
|
|
683 |
// CBrowserBookmarksContainer::CreateListboxIconHandlerL
|
|
684 |
// ---------------------------------------------------------
|
|
685 |
//
|
|
686 |
MBrowserFavouritesListboxIconHandler*
|
|
687 |
CBrowserBookmarksContainer::CreateListboxIconHandlerL()
|
|
688 |
{
|
|
689 |
return new (ELeave) TBrowserBookmarksListboxIconHandler;
|
|
690 |
}
|
|
691 |
|
|
692 |
#ifdef __SERIES60_HELP
|
|
693 |
// ---------------------------------------------------------
|
|
694 |
// CBrowserBookmarksContainer::GetHelpContext()
|
|
695 |
// ---------------------------------------------------------
|
|
696 |
//
|
|
697 |
void CBrowserBookmarksContainer::GetHelpContext( TCoeHelpContext& aContext ) const
|
|
698 |
{
|
|
699 |
aContext.iMajor = KUidBrowserApplication;
|
|
700 |
aContext.iContext = KOSS_HLP_BM_MAIN;
|
|
701 |
}
|
|
702 |
#endif // __SERIES60_HELP
|
|
703 |
|
|
704 |
// ---------------------------------------------------------
|
|
705 |
// CBrowserBookmarksContainer::FocusChanged()
|
|
706 |
// ---------------------------------------------------------
|
|
707 |
//
|
|
708 |
void CBrowserBookmarksContainer::FocusChanged( TDrawNow aDrawNow )
|
|
709 |
{
|
|
710 |
if ( IsEditing() )
|
|
711 |
{
|
|
712 |
iGotoPane->SetFocus( IsFocused(), aDrawNow );
|
|
713 |
}
|
|
714 |
else if( IsEditingSearch() )
|
|
715 |
{
|
|
716 |
iSearchPane->SetFocus( IsFocused(), aDrawNow );
|
|
717 |
}
|
|
718 |
else if ( Listbox() && Listbox()->IsVisible() )
|
|
719 |
{
|
|
720 |
Listbox()->SetFocus( IsFocused(), aDrawNow );
|
|
721 |
}
|
|
722 |
}
|
|
723 |
|
|
724 |
// ----------------------------------------------------------------------------
|
|
725 |
// CBrowserBookmarksContainer::HandlePointerEventL
|
|
726 |
// ----------------------------------------------------------------------------
|
|
727 |
//
|
|
728 |
void CBrowserBookmarksContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
729 |
{
|
|
730 |
if (AknLayoutUtils::PenEnabled())
|
|
731 |
{
|
|
732 |
// if goto is active, if a pointer event falls within its rect,
|
|
733 |
// pass all pointer events to it (such as, to bring up the editor's letter-entry)
|
|
734 |
//
|
|
735 |
// otherwise, if it falls within the listbox's rect
|
|
736 |
//
|
|
737 |
|
|
738 |
// Now we have two different panes so we have to check explicitly before passing controls
|
|
739 |
// to any panes.
|
|
740 |
if( iGotoPane && ( iGotoPaneActive || iSearchPaneActive) )
|
|
741 |
{
|
|
742 |
if( iSearchPane )//implies presence of search feature.
|
|
743 |
{
|
|
744 |
if( iGotoPane->Rect().Contains( aPointerEvent.iPosition) )
|
|
745 |
{
|
|
746 |
if( !iGotoPaneActive )
|
|
747 |
{
|
|
748 |
SetGotoActiveL();
|
|
749 |
}
|
|
750 |
#ifndef BRDO_SINGLE_CLICK_ENABLED_FF
|
|
751 |
else
|
|
752 |
{
|
|
753 |
#endif
|
|
754 |
iGotoPane->HandlePointerEventL(aPointerEvent);
|
|
755 |
#ifndef BRDO_SINGLE_CLICK_ENABLED_FF
|
|
756 |
}
|
|
757 |
#endif
|
|
758 |
|
|
759 |
iGotoPane->SetVKBFlag( ETrue );
|
|
760 |
}
|
|
761 |
else if( iSearchPane->Rect().Contains( aPointerEvent.iPosition) )
|
|
762 |
{
|
|
763 |
if( !iSearchPaneActive )
|
|
764 |
{
|
|
765 |
SetSearchActiveL();
|
|
766 |
}
|
|
767 |
#ifndef BRDO_SINGLE_CLICK_ENABLED_FF
|
|
768 |
else
|
|
769 |
{
|
|
770 |
#endif
|
|
771 |
iSearchPane->HandlePointerEventL(aPointerEvent);
|
|
772 |
#ifndef BRDO_SINGLE_CLICK_ENABLED_FF
|
|
773 |
}
|
|
774 |
#endif
|
|
775 |
|
|
776 |
iSearchPane->SetVKBFlag( ETrue );
|
|
777 |
}
|
|
778 |
else
|
|
779 |
{
|
|
780 |
if(aPointerEvent.iType == TPointerEvent::EButton1Down )
|
|
781 |
{
|
|
782 |
CBrowserAppUi::Static()->ActiveView()->HandleCommandL(EWmlCmdGotoPaneCancel);
|
|
783 |
SetGotoInactiveL();
|
|
784 |
}
|
|
785 |
}
|
|
786 |
}
|
|
787 |
else
|
|
788 |
{
|
|
789 |
iGotoPane->HandlePointerEventL(aPointerEvent);
|
|
790 |
}
|
|
791 |
}
|
|
792 |
else
|
|
793 |
{
|
|
794 |
// normally, pass all pointer events down to the listbox
|
|
795 |
Listbox()->HandlePointerEventL(aPointerEvent);
|
|
796 |
}
|
|
797 |
}
|
|
798 |
}
|
|
799 |
|
|
800 |
// ----------------------------------------------------------------------------
|
|
801 |
// CBrowserBookmarksContainer::ConstructSearchPaneL
|
|
802 |
// ----------------------------------------------------------------------------
|
|
803 |
//
|
|
804 |
|
|
805 |
void CBrowserBookmarksContainer::ConstructSearchPaneL()
|
|
806 |
{
|
|
807 |
TFileName iconFile;
|
|
808 |
MPreferences& preferences = View().ApiProvider().Preferences();
|
|
809 |
|
|
810 |
TInt iconId = preferences.GetIntValue( KBrowserSearchIconId );
|
|
811 |
// Get the Search Icon File Path.
|
|
812 |
preferences.GetStringValueL( KBrowserSearchIconPath, KMaxFileName, iconFile );
|
|
813 |
|
|
814 |
// If Icon File Path Changed or Icon Id Changed, Refresh the Icon for Search Pane.
|
|
815 |
// Comparing Icon File path as well, because it may be possible that two different
|
|
816 |
// Icon files have same icon id.
|
|
817 |
if( iconId != iSearchIconId
|
|
818 |
|| iSearchIconFilePath.Compare( iconFile ) != 0 )
|
|
819 |
{
|
|
820 |
|
|
821 |
TInt iconMaskId = preferences.GetIntValue( KBrowserSearchIconMaskId );
|
|
822 |
|
|
823 |
// Save IconId
|
|
824 |
iSearchIconId = iconId;
|
|
825 |
// Save Icon File
|
|
826 |
iSearchIconFilePath = iconFile;
|
|
827 |
|
|
828 |
|
|
829 |
// No Icon file or IconId or IconMaskId set , then it means no search provider is still
|
|
830 |
// selected and set by search application, in that case we use the default icon for Search.
|
|
831 |
if( ! iconFile.Length()
|
|
832 |
|| iconId == -1
|
|
833 |
|| iconMaskId == -1 )
|
|
834 |
{
|
|
835 |
iconId = EMbmAvkonQgn_indi_find_glass;
|
|
836 |
iconMaskId = EMbmAvkonQgn_indi_find_glass_mask;
|
|
837 |
iconFile = KAvkonBitmapFile;
|
|
838 |
}
|
|
839 |
|
|
840 |
if( iSearchPane )
|
|
841 |
{
|
|
842 |
delete iSearchPane;
|
|
843 |
iSearchPane = NULL;
|
|
844 |
}
|
|
845 |
|
|
846 |
|
|
847 |
// iSearchPane != NULL, implies presence of search feature, hence it can be
|
|
848 |
// used to validate search feature avoiding repetative calls to utils and
|
|
849 |
// avoiding need of separate variable.
|
|
850 |
iSearchPane = CBrowserBookmarksGotoPane::NewL( *this,
|
|
851 |
&(View()),
|
|
852 |
iconFile,
|
|
853 |
iconId,
|
|
854 |
iconMaskId,
|
|
855 |
GOTOPANE_POPUPLIST_DISABLE,
|
|
856 |
ETrue
|
|
857 |
);
|
|
858 |
|
|
859 |
CBrowserBookmarksView* bookmarkView = REINTERPRET_CAST( CBrowserBookmarksView* , &( View() ));
|
|
860 |
// Set Pane observer
|
|
861 |
iSearchPane->SetGPObserver( bookmarkView );
|
|
862 |
}
|
|
863 |
}
|
|
864 |
|
|
865 |
// ----------------------------------------------------------------------------
|
|
866 |
// CBrowserBookmarksContainer::HandleResourceChange
|
|
867 |
// ----------------------------------------------------------------------------
|
|
868 |
//
|
|
869 |
void CBrowserBookmarksContainer::HandleResourceChange(TInt aType)
|
|
870 |
{
|
|
871 |
CBrowserFavouritesContainer::HandleResourceChange( aType);
|
|
872 |
if( aType == KEikDynamicLayoutVariantSwitch)
|
|
873 |
{
|
|
874 |
// If search feature exsist
|
|
875 |
if( iSearchPane )
|
|
876 |
{
|
|
877 |
if( iSearchPaneActive )
|
|
878 |
{
|
|
879 |
iGotoPane->SetTextModeItalicL( );
|
|
880 |
}
|
|
881 |
else
|
|
882 |
{
|
|
883 |
iSearchPane->SetTextModeItalicL( );
|
|
884 |
}
|
|
885 |
}
|
|
886 |
}
|
|
887 |
}
|
|
888 |
// End of File
|