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 CBrowserFavouritesView.
|
|
16 |
*
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include <aknappui.h>
|
|
23 |
#include <akntitle.h>
|
|
24 |
#include <eikenv.h>
|
|
25 |
#include <eikspane.h>
|
|
26 |
|
|
27 |
#include <aknsfld.h>
|
|
28 |
#include <eikbtgpc.h>
|
|
29 |
#include <eikmenub.h>
|
|
30 |
#include <aknviewappui.h>
|
|
31 |
#include <Avkon.hrh>
|
|
32 |
#include <Uikon.hrh>
|
|
33 |
#include <eikmenup.h>
|
|
34 |
#include <AknForm.h>
|
|
35 |
#include <AknQueryDialog.h>
|
|
36 |
#include <BrowserNG.rsg>
|
|
37 |
#include <avkon.rsg>
|
|
38 |
#include <favouriteslimits.h>
|
|
39 |
#include <favouritesdb.h>
|
|
40 |
#include <favouritesitem.h>
|
|
41 |
#include <favouritesitemlist.h>
|
|
42 |
#include <internetconnectionmanager.h>
|
|
43 |
#include <FeatMgr.h>
|
|
44 |
#include <centralrepository.h>
|
|
45 |
#include <nifman.h>
|
|
46 |
|
|
47 |
#include "BrowserUiPrivateCRKeys.h"
|
|
48 |
#include "BrowserUtil.h"
|
|
49 |
#include "BrowserDialogs.h"
|
|
50 |
#include "BrowserFavouritesView.h"
|
|
51 |
#include "BrowserFavouritesFolderSelector.h"
|
|
52 |
#include "BrowserFavouritesContainer.h"
|
|
53 |
#include "BrowserFavouritesListbox.h"
|
|
54 |
#include "BrowserFavouritesListboxState.h"
|
|
55 |
#include "BrowserFavouritesModel.h"
|
|
56 |
#include "Browser.hrh"
|
|
57 |
#include "BrowserAppUi.h"
|
|
58 |
#include "BrowserApplication.h"
|
|
59 |
#include "BrowserFavouritesIncrementalDelete.h"
|
|
60 |
#include "BrowserFavouritesIncrementalMove.h"
|
|
61 |
#include "BrowserUIVariant.hrh"
|
|
62 |
#include "BrowserWindowManager.h"
|
|
63 |
#include "CommandVisibility.h"
|
|
64 |
#include "CommonConstants.h"
|
|
65 |
#include "CommsModel.h"
|
|
66 |
#include "Display.h"
|
|
67 |
#include "Preferences.h"
|
|
68 |
#include "logger.h"
|
|
69 |
|
|
70 |
#include "eikon.hrh"
|
|
71 |
|
|
72 |
|
|
73 |
// MACROS
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Defining this macro shows "Unmark all", even if nothing is marked (except
|
|
77 |
* if there are no items at all).
|
|
78 |
*/
|
|
79 |
//#define SHOW_UNMARK_ALL_ALWAYS
|
|
80 |
/**
|
|
81 |
* Defining this macro shows "Mark all", even if all is marked (except
|
|
82 |
* if there are no items at all).
|
|
83 |
*/
|
|
84 |
//#define SHOW_MARK_ALL_ALWAYS
|
|
85 |
|
|
86 |
/// Cosmetic purpose macro (resource names are overly too long).
|
|
87 |
#define _R(str) R_BROWSER_FAVOURITES_ ## str
|
|
88 |
|
|
89 |
// CONSTANTS
|
|
90 |
/// Granularity of Uid lists used in managing multiple bookmarks.
|
|
91 |
LOCAL_C const TInt KGranularityUids = 4;
|
|
92 |
|
|
93 |
/// Estimated FFS overhead for deleting (in bytes).
|
|
94 |
LOCAL_C const TInt KEstimatedDeleteFfsOverhead = 16 * 1024;
|
|
95 |
|
|
96 |
// ==================== LOCAL FUNCTIONS ====================
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Create a new empty list for Uids and push it on the cleanup stack.
|
|
100 |
* @return The constructed empty list.
|
|
101 |
*/
|
|
102 |
LOCAL_C CArrayFix<TInt>* NewUidListLC()
|
|
103 |
{
|
|
104 |
// Not inline - go for size, not speed.
|
|
105 |
CArrayFixFlat<TInt>* list;
|
|
106 |
list = new (ELeave) CArrayFixFlat<TInt> ( KGranularityUids );
|
|
107 |
CleanupStack::PushL( list );
|
|
108 |
return list;
|
|
109 |
}
|
|
110 |
|
|
111 |
// ================= MEMBER FUNCTIONS =======================
|
|
112 |
|
|
113 |
// ---------------------------------------------------------
|
|
114 |
// CBrowserFavouritesView::~CBrowserFavouritesView
|
|
115 |
// ---------------------------------------------------------
|
|
116 |
//
|
|
117 |
CBrowserFavouritesView::~CBrowserFavouritesView()
|
|
118 |
{
|
|
119 |
delete iFavViewRefresh;
|
|
120 |
delete iIncrementalOp;
|
|
121 |
delete iContainer;
|
|
122 |
delete iModel;
|
|
123 |
delete iSavedListboxState;
|
|
124 |
}
|
|
125 |
|
|
126 |
// ---------------------------------------------------------------------------
|
|
127 |
// CBrowserFavouritesView::CommandSetResourceIdL
|
|
128 |
// ---------------------------------------------------------------------------
|
|
129 |
TInt CBrowserFavouritesView::CommandSetResourceIdL()
|
|
130 |
{
|
|
131 |
// for 5.0, BrowserBookmarksView takes over cba-assignment duties
|
|
132 |
// this function should not be called. We now route though BrowserBookmarksView.
|
|
133 |
return R_AVKON_SOFTKEYS_EMPTY;
|
|
134 |
}
|
|
135 |
|
|
136 |
// ---------------------------------------------------------
|
|
137 |
// CBrowserFavouritesView::HandleCommandL
|
|
138 |
// ---------------------------------------------------------
|
|
139 |
//
|
|
140 |
void CBrowserFavouritesView::HandleCommandL( TInt aCommand )
|
|
141 |
{
|
|
142 |
switch ( aCommand )
|
|
143 |
{
|
|
144 |
case EWmlCmdBackFromFolder:
|
|
145 |
{
|
|
146 |
if ( ApiProvider().IsEmbeddedModeOn() )
|
|
147 |
{
|
|
148 |
AppUi()->HandleCommandL( EWmlCmdCloseBrowser );
|
|
149 |
}
|
|
150 |
else
|
|
151 |
{
|
|
152 |
CloseCurrentFolderL();
|
|
153 |
}
|
|
154 |
break;
|
|
155 |
}
|
|
156 |
|
|
157 |
case EWmlCmdOpenFolder:
|
|
158 |
{
|
|
159 |
OpenCurrentFolderL();
|
|
160 |
break;
|
|
161 |
}
|
|
162 |
|
|
163 |
case EWmlCmdOpenMarkedFolder:
|
|
164 |
{
|
|
165 |
OpenMarkedFolderL();
|
|
166 |
break;
|
|
167 |
}
|
|
168 |
|
|
169 |
case EWmlCmdFavourites:
|
|
170 |
{
|
|
171 |
ApiProvider().SetViewToBeActivatedIfNeededL( KUidBrowserBookmarksViewId );
|
|
172 |
break;
|
|
173 |
}
|
|
174 |
|
|
175 |
case EWmlCmdMark:
|
|
176 |
case EWmlCmdUnmark:
|
|
177 |
case EWmlCmdMarkAll:
|
|
178 |
case EWmlCmdUnmarkAll:
|
|
179 |
{
|
|
180 |
iContainer->Listbox()->HandleMarkableListCommandL( aCommand );
|
|
181 |
iContainer->HandleCursorChangedL( iContainer->Listbox() );
|
|
182 |
UpdateCbaL();
|
|
183 |
break;
|
|
184 |
}
|
|
185 |
|
|
186 |
case EWmlCmdDelete:
|
|
187 |
{
|
|
188 |
DeleteMarkedItemsL();
|
|
189 |
break;
|
|
190 |
}
|
|
191 |
|
|
192 |
case EWmlCmdNewFolder:
|
|
193 |
{
|
|
194 |
(void)AddNewFolderL();
|
|
195 |
break;
|
|
196 |
}
|
|
197 |
|
|
198 |
case EWmlCmdMoveToFolder:
|
|
199 |
{
|
|
200 |
MoveMarkedItemsL();
|
|
201 |
break;
|
|
202 |
}
|
|
203 |
|
|
204 |
|
|
205 |
case EWmlCmdRename:
|
|
206 |
{
|
|
207 |
RenameCurrentItemL();
|
|
208 |
break;
|
|
209 |
}
|
|
210 |
|
|
211 |
case EWmlCmdSetPreferredBookmark:
|
|
212 |
{
|
|
213 |
SetPreferedCurrentItemL();
|
|
214 |
break;
|
|
215 |
}
|
|
216 |
|
|
217 |
case EWmlCmdSetUnPreferredBookmark:
|
|
218 |
{
|
|
219 |
SetUnPreferedCurrentItemL();
|
|
220 |
break;
|
|
221 |
}
|
|
222 |
|
|
223 |
case EWmlCmdPreferences:
|
|
224 |
{
|
|
225 |
iSaveStateOnDeactivate = ETrue;
|
|
226 |
AppUi()->HandleCommandL( aCommand );
|
|
227 |
break;
|
|
228 |
}
|
|
229 |
default :
|
|
230 |
{
|
|
231 |
AppUi()->HandleCommandL( aCommand );
|
|
232 |
break;
|
|
233 |
}
|
|
234 |
}
|
|
235 |
}
|
|
236 |
|
|
237 |
// ----------------------------------------------------------------------------
|
|
238 |
// CBrowserFavouritesView::CBrowserFavouritesView
|
|
239 |
// ----------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
CBrowserFavouritesView::CBrowserFavouritesView( MApiProvider& aApiProvider,
|
|
242 |
TInt aInitialFolderId )
|
|
243 |
: CBrowserViewBase( aApiProvider ),
|
|
244 |
iPreferredHighlightUid( KFavouritesNullUid ),
|
|
245 |
iShowOkOptions( EFalse ),
|
|
246 |
iCurrentFolder( aInitialFolderId ),
|
|
247 |
iIsActivated( EFalse ),
|
|
248 |
iLastSelection( 0 ),
|
|
249 |
iUpdatePending( EFalse ),
|
|
250 |
iFavViewRefresh(0),
|
|
251 |
iRefresh( ETrue )
|
|
252 |
|
|
253 |
{
|
|
254 |
}
|
|
255 |
|
|
256 |
// ---------------------------------------------------------
|
|
257 |
// CBrowserFavouritesView::ConstructL
|
|
258 |
// ---------------------------------------------------------
|
|
259 |
//
|
|
260 |
void CBrowserFavouritesView::ConstructL( TInt aViewResourceId )
|
|
261 |
{
|
|
262 |
BaseConstructL( aViewResourceId );
|
|
263 |
iModel = CreateModelL();
|
|
264 |
iInitialFolder = iCurrentFolder;
|
|
265 |
// Ap model cannot be created without opening it; so that's not done here.
|
|
266 |
// DoActivateL / DoDecativateL does that.
|
|
267 |
Cba()->MakeVisible(EFalse); // avoid multiple redraws
|
|
268 |
}
|
|
269 |
|
|
270 |
// ---------------------------------------------------------
|
|
271 |
// CBrowserFavouritesView::GetItemsLC
|
|
272 |
// ---------------------------------------------------------
|
|
273 |
//
|
|
274 |
CFavouritesItemList* CBrowserFavouritesView::GetItemsLC( TInt aFolder )
|
|
275 |
{
|
|
276 |
CFavouritesItemList* items = new (ELeave) CFavouritesItemList();
|
|
277 |
CleanupStack::PushL( items );
|
|
278 |
iModel->Database().GetAll( *items, aFolder );
|
|
279 |
iModel->SortL( *items );
|
|
280 |
return items;
|
|
281 |
}
|
|
282 |
|
|
283 |
// ---------------------------------------------------------
|
|
284 |
// CBrowserFavouritesView::GetSeamlessFolderResourceID
|
|
285 |
// ---------------------------------------------------------
|
|
286 |
//
|
|
287 |
TInt CBrowserFavouritesView::GetSeamlessFolderResourceID( TInt aContextID )
|
|
288 |
{
|
|
289 |
TInt resId = 0;
|
|
290 |
|
|
291 |
switch( aContextID ) // Check if the item is a seamless link folder
|
|
292 |
{
|
|
293 |
case KFavouritesApplicationContextId:
|
|
294 |
{
|
|
295 |
resId = R_BROWSERBM_FOLDER_DOWNLOAD_APPLICATIONS;
|
|
296 |
break;
|
|
297 |
}
|
|
298 |
case KFavouritesImageContextId:
|
|
299 |
{
|
|
300 |
resId = R_BROWSERBM_FOLDER_DOWNLOAD_IMAGES;
|
|
301 |
break;
|
|
302 |
}
|
|
303 |
case KFavouritesAudioContextId:
|
|
304 |
{
|
|
305 |
resId = R_BROWSERBM_FOLDER_DOWNLOAD_TONES;
|
|
306 |
break;
|
|
307 |
}
|
|
308 |
case KFavouritesVideoContextId:
|
|
309 |
{
|
|
310 |
resId = R_BROWSERBM_FOLDER_DOWNLOAD_VIDEOS;
|
|
311 |
break;
|
|
312 |
}
|
|
313 |
case KFavouritesSkinContextId:
|
|
314 |
{
|
|
315 |
resId = R_BROWSERBM_FOLDER_DOWNLOAD_SKINS;
|
|
316 |
break;
|
|
317 |
}
|
|
318 |
case KFavouritesMusicContextId:
|
|
319 |
{
|
|
320 |
resId = R_BROWSERBM_FOLDER_DOWNLOAD_MUSIC;
|
|
321 |
break;
|
|
322 |
}
|
|
323 |
case KFavouritesServiceContextId:
|
|
324 |
{
|
|
325 |
resId = R_IS_RECOMMENDATIONS;
|
|
326 |
break;
|
|
327 |
}
|
|
328 |
default:
|
|
329 |
{
|
|
330 |
break; // not a seamless link folder.
|
|
331 |
}
|
|
332 |
}
|
|
333 |
|
|
334 |
return resId;
|
|
335 |
}
|
|
336 |
|
|
337 |
|
|
338 |
// ---------------------------------------------------------
|
|
339 |
// CBrowserFavouritesView::GetSeamlessFolderTitleResourceID
|
|
340 |
// ---------------------------------------------------------
|
|
341 |
//
|
|
342 |
TInt CBrowserFavouritesView::GetSeamlessFolderTitleResourceID( TInt aContextID )
|
|
343 |
{
|
|
344 |
TInt resId = 0;
|
|
345 |
|
|
346 |
switch( aContextID ) // Check if the item is a seamless link folder
|
|
347 |
{
|
|
348 |
case KFavouritesApplicationContextId:
|
|
349 |
{
|
|
350 |
resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_APPLICATIONS;
|
|
351 |
break;
|
|
352 |
}
|
|
353 |
case KFavouritesImageContextId:
|
|
354 |
{
|
|
355 |
resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_IMAGES;
|
|
356 |
break;
|
|
357 |
}
|
|
358 |
case KFavouritesAudioContextId:
|
|
359 |
{
|
|
360 |
resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_TONES;
|
|
361 |
break;
|
|
362 |
}
|
|
363 |
case KFavouritesVideoContextId:
|
|
364 |
{
|
|
365 |
resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_VIDEOS;
|
|
366 |
break;
|
|
367 |
}
|
|
368 |
case KFavouritesSkinContextId:
|
|
369 |
{
|
|
370 |
resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_SKINS;
|
|
371 |
break;
|
|
372 |
}
|
|
373 |
case KFavouritesMusicContextId:
|
|
374 |
{
|
|
375 |
resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_MUSIC;
|
|
376 |
break;
|
|
377 |
}
|
|
378 |
default:
|
|
379 |
{
|
|
380 |
break; // not a seamless link folder.
|
|
381 |
}
|
|
382 |
}
|
|
383 |
|
|
384 |
return resId;
|
|
385 |
}
|
|
386 |
|
|
387 |
|
|
388 |
// ---------------------------------------------------------
|
|
389 |
// CBrowserFavouritesView::IsSeamlessFolder
|
|
390 |
// ---------------------------------------------------------
|
|
391 |
//
|
|
392 |
TInt CBrowserFavouritesView::IsSeamlessFolder( TInt aContextID )
|
|
393 |
{
|
|
394 |
return GetSeamlessFolderResourceID( aContextID ) != 0 ? ETrue : EFalse;
|
|
395 |
}
|
|
396 |
|
|
397 |
// ---------------------------------------------------------
|
|
398 |
// CBrowserFavouritesView::HighlightPreferredL
|
|
399 |
// ---------------------------------------------------------
|
|
400 |
//
|
|
401 |
void CBrowserFavouritesView::HighlightPreferredL()
|
|
402 |
{
|
|
403 |
if (( iContainer->Listbox()->HighlightUidNow( iPreferredHighlightUid ) ) &&
|
|
404 |
( iPreferredHighlightUid != KFavouritesNullUid ))
|
|
405 |
{
|
|
406 |
// Have a preferred uid...
|
|
407 |
// Successfully highlighted; clear preferred now.
|
|
408 |
iPreferredHighlightUid = KFavouritesNullUid;
|
|
409 |
iContainer->HandleCursorChangedL( iContainer->Listbox() );
|
|
410 |
}
|
|
411 |
}
|
|
412 |
|
|
413 |
// ---------------------------------------------------------
|
|
414 |
// CBrowserFavouritesView::RefreshL
|
|
415 |
// ---------------------------------------------------------
|
|
416 |
//
|
|
417 |
void CBrowserFavouritesView::RefreshL( TBool aDbErrorNote /*=EFalse*/ )
|
|
418 |
{
|
|
419 |
// Do the refresh only if activated; otherwise ignore.
|
|
420 |
// (This is a sanity-check like functionality, but is really used.
|
|
421 |
// Bookmarks View observes changes in active and default AP-s, even if
|
|
422 |
// not activated (and tries to refresh); but this "activated-check" is
|
|
423 |
// made here, not in Bookmarks View, because it makes things more safe and
|
|
424 |
// "future-proof".)
|
|
425 |
if ( iIsActivated )
|
|
426 |
{
|
|
427 |
iUpdatePending = ETrue;
|
|
428 |
if ( !iIncrementalOp )
|
|
429 |
{
|
|
430 |
// During an incremental operation we should never do the update
|
|
431 |
// and refill the listbox because some of the operations holds
|
|
432 |
// pointers to listbox items. Update is pending then.
|
|
433 |
if ( iModel->BeginL( /*aWrite=*/EFalse, aDbErrorNote ) ==
|
|
434 |
KErrNone )
|
|
435 |
{
|
|
436 |
TInt folderExists;
|
|
437 |
iModel->Database().FolderExists( iCurrentFolder, folderExists );
|
|
438 |
if ( folderExists )
|
|
439 |
{
|
|
440 |
// Current folder is still OK. Refresh.
|
|
441 |
FillListboxL( iCurrentFolder, /*aKeepState=*/ETrue );
|
|
442 |
}
|
|
443 |
else
|
|
444 |
{
|
|
445 |
// Cannot access current folder (maybe deleted).
|
|
446 |
// Go to root.
|
|
447 |
OpenFolderL( KFavouritesRootUid );
|
|
448 |
}
|
|
449 |
iModel->CommitL();
|
|
450 |
iUpdatePending = EFalse;
|
|
451 |
}
|
|
452 |
// iUpdatePending stays ETrue if unsuccessful.
|
|
453 |
}
|
|
454 |
}
|
|
455 |
}
|
|
456 |
|
|
457 |
// ---------------------------------------------------------
|
|
458 |
// CBrowserFavouritesView::DoActivateL
|
|
459 |
// ---------------------------------------------------------
|
|
460 |
//
|
|
461 |
void CBrowserFavouritesView::DoActivateL(
|
|
462 |
const TVwsViewId& /*aPrevViewId*/,
|
|
463 |
TUid /*aCustomMessageId*/,
|
|
464 |
const TDesC8& /*aCustomMessage*/ )
|
|
465 |
{
|
|
466 |
iPreviousViewID = ApiProvider().LastActiveViewId( );
|
|
467 |
ApiProvider().SetLastActiveViewId( Id() );
|
|
468 |
ApiProvider().CommsModel().AddObserverL( *this );
|
|
469 |
iContainer = CreateContainerL(); // can this be created during construct ?
|
|
470 |
iModel->AddObserverL( *this );
|
|
471 |
AppUi()->AddToViewStackL( *this, iContainer );
|
|
472 |
|
|
473 |
ApiProvider().StartProgressAnimationL();
|
|
474 |
|
|
475 |
if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
|
|
476 |
== KErrNone )
|
|
477 |
{
|
|
478 |
// Disable redraw to avoid flickering.
|
|
479 |
// (OpenFolderL and the listbox's SetStateL both
|
|
480 |
// wants to redraw the listbox. Do it once only.)
|
|
481 |
TBool redrawDisabled =
|
|
482 |
iContainer->Listbox()->View()->RedrawDisabled();
|
|
483 |
iContainer->Listbox()->View()->SetDisableRedraw( ETrue );
|
|
484 |
// Open folder first.
|
|
485 |
OpenFolderL( iCurrentFolder );
|
|
486 |
iModel->CommitL();
|
|
487 |
|
|
488 |
// Now set back redraw and draw the listbox.
|
|
489 |
if ( (iLastSelection >=0 ))
|
|
490 |
{
|
|
491 |
if ( iLastSelection > iContainer->Listbox()->BottomItemIndex() )
|
|
492 |
{
|
|
493 |
iLastSelection = 0;
|
|
494 |
}
|
|
495 |
iContainer->Listbox()->SetCurrentItemIndex( iLastSelection );
|
|
496 |
}
|
|
497 |
|
|
498 |
iContainer->Listbox()->View()->SetDisableRedraw( redrawDisabled );
|
|
499 |
iContainer->Listbox()->DrawDeferred();
|
|
500 |
}
|
|
501 |
else
|
|
502 |
{
|
|
503 |
// No folder is opened; update CBA and Navi Pane now.
|
|
504 |
if ( iLastSelection >=0 )
|
|
505 |
{
|
|
506 |
iContainer->Listbox()->SetCurrentItemIndex( iLastSelection );
|
|
507 |
UpdateGotoPaneL();
|
|
508 |
}
|
|
509 |
UpdateCbaL();
|
|
510 |
UpdateNaviPaneL();
|
|
511 |
}
|
|
512 |
|
|
513 |
if (iSavedListboxState)
|
|
514 |
{
|
|
515 |
iContainer->Listbox()->SetStateL(*iSavedListboxState);
|
|
516 |
}
|
|
517 |
iIsActivated = ETrue;
|
|
518 |
|
|
519 |
#ifndef BRDO_PERF_IMPROVEMENTS_ENABLED_FF
|
|
520 |
// TODO: Remove this crapy refresh once favicon callback interface
|
|
521 |
// with engine is implemented.
|
|
522 |
if(!iFavViewRefresh)
|
|
523 |
iFavViewRefresh = CIdle::NewL( CActive::EPriorityIdle );
|
|
524 |
iFavViewRefresh ->Start( TCallBack( RefeshFavoriteListBox, this ) );
|
|
525 |
#endif
|
|
526 |
}
|
|
527 |
|
|
528 |
|
|
529 |
TInt CBrowserFavouritesView::RefeshFavoriteListBox(TAny* aFavouritesView)
|
|
530 |
{
|
|
531 |
__ASSERT_DEBUG(aFavouritesView, Util::Panic( Util::EUninitializedData ));
|
|
532 |
TRAP_IGNORE(
|
|
533 |
((CBrowserFavouritesView*)aFavouritesView)->RefreshL();
|
|
534 |
);
|
|
535 |
return KErrNone;
|
|
536 |
}
|
|
537 |
|
|
538 |
// ----------------------------------------------------------------------------
|
|
539 |
// CBrowserFavouritesView::ResetStateInDeActivation
|
|
540 |
// ----------------------------------------------------------------------------
|
|
541 |
//
|
|
542 |
void CBrowserFavouritesView::ResetStateInDeActivation()
|
|
543 |
{
|
|
544 |
//Set iLastSelection to zero if there will be a folder change
|
|
545 |
if ( iCurrentFolder != iInitialFolder )
|
|
546 |
{
|
|
547 |
iLastSelection = 0;
|
|
548 |
}
|
|
549 |
}
|
|
550 |
|
|
551 |
// ---------------------------------------------------------
|
|
552 |
// CBrowserFavouritesView::DoDeactivate
|
|
553 |
// ---------------------------------------------------------
|
|
554 |
//
|
|
555 |
void CBrowserFavouritesView::DoDeactivate()
|
|
556 |
{
|
|
557 |
iIsActivated = EFalse;
|
|
558 |
TRAP_IGNORE(ApiProvider().StopProgressAnimationL());
|
|
559 |
|
|
560 |
if(iFavViewRefresh)
|
|
561 |
{
|
|
562 |
iFavViewRefresh->Cancel();
|
|
563 |
}
|
|
564 |
|
|
565 |
if ( iContainer )
|
|
566 |
{
|
|
567 |
iLastSelection = iContainer->Listbox()->CurrentItemIndex();
|
|
568 |
}
|
|
569 |
|
|
570 |
if ( !iSaveStateOnDeactivate )
|
|
571 |
{
|
|
572 |
ResetStateInDeActivation(); // entering root directory
|
|
573 |
iSaveStateOnDeactivate = EFalse;
|
|
574 |
}
|
|
575 |
else
|
|
576 |
{
|
|
577 |
CBrowserFavouritesListboxState *temp = NULL;
|
|
578 |
TInt err( KErrNone );
|
|
579 |
TInt tempUid( KFavouritesNullUid );
|
|
580 |
|
|
581 |
temp = new CBrowserFavouritesListboxState;
|
|
582 |
if ( iContainer && temp!=NULL )
|
|
583 |
{
|
|
584 |
delete iSavedListboxState;
|
|
585 |
iSavedListboxState = temp;
|
|
586 |
// folder might be empty, no CurrentItem at all
|
|
587 |
if ( iContainer->Listbox()->CurrentItem() )
|
|
588 |
{
|
|
589 |
tempUid = iContainer->Listbox()->CurrentItem()->Uid();
|
|
590 |
}
|
|
591 |
iSavedListboxState->iHighlightUid = tempUid;
|
|
592 |
TRAP( err, {
|
|
593 |
iSavedListboxState->iMarkUids = iContainer->Listbox()->MarkedUidsLC();
|
|
594 |
CleanupStack::Pop(); // Uid list; ownership is now in the state.
|
|
595 |
} )
|
|
596 |
}
|
|
597 |
if ( !err )
|
|
598 |
{
|
|
599 |
iSavedListboxState->iTopItemUid = tempUid;
|
|
600 |
}
|
|
601 |
else
|
|
602 |
{
|
|
603 |
delete iSavedListboxState;
|
|
604 |
}
|
|
605 |
}
|
|
606 |
|
|
607 |
if ( !ApiProvider().ExitInProgress() )
|
|
608 |
{
|
|
609 |
ApiProvider().CommsModel().RemoveObserver( *this );
|
|
610 |
}
|
|
611 |
iModel->RemoveObserver( *this );
|
|
612 |
|
|
613 |
if ( iContainer )
|
|
614 |
{
|
|
615 |
AppUi()->RemoveFromViewStack( *this, iContainer );
|
|
616 |
delete iContainer;
|
|
617 |
iContainer = NULL;
|
|
618 |
}
|
|
619 |
iModel->CloseDb();
|
|
620 |
}
|
|
621 |
|
|
622 |
// ---------------------------------------------------------
|
|
623 |
// CBrowserFavouritesView::HandleClientRectChange
|
|
624 |
// ---------------------------------------------------------
|
|
625 |
//
|
|
626 |
void CBrowserFavouritesView::HandleClientRectChange()
|
|
627 |
{
|
|
628 |
if ( iContainer )
|
|
629 |
{
|
|
630 |
iContainer->SetRect( ClientRect() );
|
|
631 |
}
|
|
632 |
}
|
|
633 |
|
|
634 |
// ---------------------------------------------------------
|
|
635 |
// CBrowserFavouritesView::DynInitMenuPaneL
|
|
636 |
// ---------------------------------------------------------
|
|
637 |
//
|
|
638 |
void CBrowserFavouritesView::DynInitMenuPaneL
|
|
639 |
( TInt aResourceId, CEikMenuPane* aMenuPane )
|
|
640 |
{
|
|
641 |
if ( iContainer && iContainer->Listbox() )
|
|
642 |
{
|
|
643 |
TBrowserFavouritesSelectionState state =
|
|
644 |
iContainer->Listbox()->SelectionStateL();
|
|
645 |
TCommandVisibility::TIndex index =
|
|
646 |
TCommandVisibility::Index( state, iShowOkOptions );
|
|
647 |
DynInitMenuPaneL( aResourceId, aMenuPane, index, state );
|
|
648 |
}
|
|
649 |
}
|
|
650 |
|
|
651 |
// ---------------------------------------------------------
|
|
652 |
// CBrowserFavouritesView::HandleForegroundEventL
|
|
653 |
// ---------------------------------------------------------
|
|
654 |
//
|
|
655 |
void CBrowserFavouritesView::HandleForegroundEventL( TBool aForeground )
|
|
656 |
{
|
|
657 |
// If another thread made changes to database, sometimes we could not
|
|
658 |
// refresh when the notifcation comes in (most likely the other thread
|
|
659 |
// closes the database and that performs an automatic compact(?)).
|
|
660 |
// When coming foreground, check for missed updates.
|
|
661 |
// Also, when coming to foreground Refresh if Skin has changed
|
|
662 |
if ( aForeground && (iUpdatePending || iContainer->Listbox()->IsSkinUpdated()))
|
|
663 |
{
|
|
664 |
RefreshL();
|
|
665 |
if (iContainer->Listbox()->IsSkinUpdated())
|
|
666 |
{
|
|
667 |
iContainer->Listbox()->SetSkinUpdated(EFalse);
|
|
668 |
}
|
|
669 |
}
|
|
670 |
}
|
|
671 |
|
|
672 |
// ---------------------------------------------------------
|
|
673 |
// CBrowserFavouritesView::HandleListBoxEventL
|
|
674 |
// ---------------------------------------------------------
|
|
675 |
//
|
|
676 |
void CBrowserFavouritesView::HandleListBoxEventL
|
|
677 |
( CEikListBox* aListBox, MEikListBoxObserver::TListBoxEvent aEventType )
|
|
678 |
{
|
|
679 |
if ( aListBox == iContainer->Listbox() )
|
|
680 |
{
|
|
681 |
switch ( aEventType )
|
|
682 |
{
|
|
683 |
case MEikListBoxObserver::EEventEnterKeyPressed:
|
|
684 |
case MEikListBoxObserver::EEventItemDoubleClicked:
|
|
685 |
#ifdef BRDO_SINGLE_CLICK_ENABLED_FF
|
|
686 |
case MEikListBoxObserver::EEventItemSingleClicked:
|
|
687 |
#endif
|
|
688 |
{
|
|
689 |
if ( iContainer->Listbox()->CurrentItem() )
|
|
690 |
{
|
|
691 |
if ( iContainer->Listbox()->CurrentItem()->IsFolder() )
|
|
692 |
{
|
|
693 |
OpenCurrentFolderL();
|
|
694 |
}
|
|
695 |
}
|
|
696 |
break;
|
|
697 |
}
|
|
698 |
|
|
699 |
default:
|
|
700 |
{
|
|
701 |
break;
|
|
702 |
}
|
|
703 |
}
|
|
704 |
}
|
|
705 |
}
|
|
706 |
|
|
707 |
// ---------------------------------------------------------
|
|
708 |
// CBrowserFavouritesView::CloseCurrentFolderL
|
|
709 |
// ---------------------------------------------------------
|
|
710 |
//
|
|
711 |
void CBrowserFavouritesView::CloseCurrentFolderL()
|
|
712 |
{
|
|
713 |
if ( iCurrentFolder != KFavouritesRootUid )
|
|
714 |
{
|
|
715 |
// Folders are one level deep. Closing any folder takes us to root.
|
|
716 |
if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
|
|
717 |
== KErrNone )
|
|
718 |
{
|
|
719 |
if ( iContainer && iContainer->Listbox() )
|
|
720 |
{
|
|
721 |
// After closing, the highlight should be
|
|
722 |
// on the folder just being closed.
|
|
723 |
iPreferredHighlightUid = iCurrentFolder;
|
|
724 |
OpenFolderL( KFavouritesRootUid );
|
|
725 |
}
|
|
726 |
iModel->CommitL();
|
|
727 |
}
|
|
728 |
}
|
|
729 |
}
|
|
730 |
|
|
731 |
// ---------------------------------------------------------
|
|
732 |
// CBrowserFavouritesView::OpenCurrentFolderL
|
|
733 |
// ---------------------------------------------------------
|
|
734 |
//
|
|
735 |
void CBrowserFavouritesView::OpenCurrentFolderL()
|
|
736 |
{
|
|
737 |
if ( iContainer && iContainer->Listbox() )
|
|
738 |
{
|
|
739 |
const CFavouritesItem* folder =
|
|
740 |
iContainer->Listbox()->CurrentItem();
|
|
741 |
if ( folder && folder->IsFolder() )
|
|
742 |
{
|
|
743 |
if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
|
|
744 |
== KErrNone )
|
|
745 |
{
|
|
746 |
OpenFolderL( folder->Uid() );
|
|
747 |
iModel->CommitL();
|
|
748 |
}
|
|
749 |
}
|
|
750 |
}
|
|
751 |
}
|
|
752 |
|
|
753 |
// ---------------------------------------------------------
|
|
754 |
// CBrowserFavouritesView::OpenMarkedFolderL
|
|
755 |
// ---------------------------------------------------------
|
|
756 |
//
|
|
757 |
void CBrowserFavouritesView::OpenMarkedFolderL()
|
|
758 |
{
|
|
759 |
if ( iContainer && iContainer->Listbox() )
|
|
760 |
{
|
|
761 |
const CFavouritesItem* folder =
|
|
762 |
iContainer->Listbox()->MarkedItemL();
|
|
763 |
if ( folder && folder->IsFolder() )
|
|
764 |
{
|
|
765 |
if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
|
|
766 |
== KErrNone )
|
|
767 |
{
|
|
768 |
OpenFolderL( folder->Uid() );
|
|
769 |
iModel->CommitL();
|
|
770 |
}
|
|
771 |
}
|
|
772 |
}
|
|
773 |
}
|
|
774 |
|
|
775 |
// ---------------------------------------------------------
|
|
776 |
// CBrowserFavouritesView::DeleteMarkedItemsL
|
|
777 |
// ---------------------------------------------------------
|
|
778 |
//
|
|
779 |
void CBrowserFavouritesView::DeleteMarkedItemsL()
|
|
780 |
{
|
|
781 |
CArrayPtr<const CFavouritesItem>* items =
|
|
782 |
iContainer->Listbox()->SelectedItemsLC();
|
|
783 |
// Permormance optimization: keep a separate list for folders.
|
|
784 |
// (Make the "non-empty folder" check only for folders; this speeds up
|
|
785 |
// things considerably when many items are selected.)
|
|
786 |
CArrayFix<TInt>* uids = NewUidListLC();
|
|
787 |
CArrayFix<TInt>* folderUids = NewUidListLC();
|
|
788 |
TInt i;
|
|
789 |
TInt count = items->Count();
|
|
790 |
const CFavouritesItem* item = NULL;
|
|
791 |
|
|
792 |
for ( i = 0; i < count; i++ )
|
|
793 |
{
|
|
794 |
item = items->At( i );
|
|
795 |
uids->AppendL( item->Uid() );
|
|
796 |
if ( item->IsFolder() )
|
|
797 |
{
|
|
798 |
folderUids->AppendL( item->Uid() );
|
|
799 |
}
|
|
800 |
}
|
|
801 |
// Cannot delete the "items" pointer list, as other objects were pushed
|
|
802 |
// after it. But DO NOT USE it after this point! The call to ConfirmDeleteL
|
|
803 |
// allows other active objects to run, and the listbox may be updated.
|
|
804 |
// If listbox is updated, all pointers in "items" point to deleted objects.
|
|
805 |
|
|
806 |
if ( ConfirmDeleteL( *uids, *folderUids ) )
|
|
807 |
{
|
|
808 |
|
|
809 |
if (count ==1)
|
|
810 |
{
|
|
811 |
CFavouritesItemList* allItems = GetItemsLC( KFavouritesRootUid );
|
|
812 |
item = items->At(0);
|
|
813 |
iPreferredHighlightUid = item->Uid();
|
|
814 |
TInt index = allItems->UidToIndex(iPreferredHighlightUid);
|
|
815 |
index++;
|
|
816 |
if (allItems->IndexToUid(index) != NULL)
|
|
817 |
{
|
|
818 |
iPreferredHighlightUid = allItems->IndexToUid(index);
|
|
819 |
}
|
|
820 |
else
|
|
821 |
{
|
|
822 |
iPreferredHighlightUid = allItems->IndexToUid(index-2);
|
|
823 |
}
|
|
824 |
CleanupStack::PopAndDestroy(); //allItems
|
|
825 |
}
|
|
826 |
|
|
827 |
|
|
828 |
CArrayFix<TInt>* notDeletedUids = NewUidListLC();
|
|
829 |
|
|
830 |
// OOD handling. If disk space is low, we try to get some spare.
|
|
831 |
|
|
832 |
CRepository* repository = CRepository::NewL( KCRUidBrowser );
|
|
833 |
|
|
834 |
TBool diskLow = Util::FFSSpaceBelowCriticalLevelL
|
|
835 |
( /*aShowErrorNote=*/EFalse, KEstimatedDeleteFfsOverhead );
|
|
836 |
if ( diskLow )
|
|
837 |
{
|
|
838 |
// Using disk space requests is not supported by CenRep.
|
|
839 |
delete repository;
|
|
840 |
}
|
|
841 |
|
|
842 |
if ( !iModel->BeginL
|
|
843 |
(
|
|
844 |
/*aWrite=*/ETrue,
|
|
845 |
/*aDbErrorNote=*/ETrue,
|
|
846 |
/*aLffsCheck=*/EFalse
|
|
847 |
)
|
|
848 |
)
|
|
849 |
{
|
|
850 |
__ASSERT_DEBUG( !iIncrementalOp, Util::Panic
|
|
851 |
( Util::EIncrementalOperationAlreadyRunning ) );
|
|
852 |
// Seems we have to give lower priority to the delete operation,
|
|
853 |
// or else the wait note does not show up.
|
|
854 |
iIncrementalOp = CBrowserFavouritesIncrementalDelete::NewL
|
|
855 |
(
|
|
856 |
*iModel,
|
|
857 |
*uids,
|
|
858 |
*notDeletedUids,
|
|
859 |
CActive::EPriorityStandard - 1
|
|
860 |
);
|
|
861 |
iIncrementalOp->ExecuteL();
|
|
862 |
delete iIncrementalOp;
|
|
863 |
iIncrementalOp = NULL;
|
|
864 |
iModel->CommitL();
|
|
865 |
|
|
866 |
if ( diskLow )
|
|
867 |
{
|
|
868 |
// Compact database now.
|
|
869 |
iModel->Database().Compact();
|
|
870 |
// Make a manual refresh. When we get notification about the
|
|
871 |
// commit, database is most likely busy with compact, and
|
|
872 |
// the refresh is missed.
|
|
873 |
RefreshL();
|
|
874 |
}
|
|
875 |
|
|
876 |
// Everything that can be deleted, is deleted by now.
|
|
877 |
// Let the user know the outcome.
|
|
878 |
DisplayResultOfDeleteL( *uids, *notDeletedUids );
|
|
879 |
// Refresh the view only in embedded mode because in standalone mode Refresh is called by
|
|
880 |
// HandleFavouritesModelChangeL causing the view to refresh twice and lose the cursor position
|
|
881 |
if ( ApiProvider().IsEmbeddedModeOn() )
|
|
882 |
{
|
|
883 |
RefreshL();
|
|
884 |
}
|
|
885 |
}
|
|
886 |
|
|
887 |
for ( TInt ii = 0; ii< uids->Count(); ii++ )
|
|
888 |
{
|
|
889 |
TInt prefUid;
|
|
890 |
iModel->Database().PreferredUid( iCurrentFolder, prefUid );
|
|
891 |
if ( prefUid == uids->At( ii ) )
|
|
892 |
{
|
|
893 |
iModel->Database().SetPreferredUid( iCurrentFolder,NULL );
|
|
894 |
break;
|
|
895 |
}
|
|
896 |
}
|
|
897 |
|
|
898 |
CleanupStack::PopAndDestroy(); // notDeletedUids
|
|
899 |
}
|
|
900 |
CleanupStack::PopAndDestroy( 3 ); // folderUids, uids, items
|
|
901 |
}
|
|
902 |
|
|
903 |
// ---------------------------------------------------------
|
|
904 |
// CBrowserFavouritesView::AddNewFolderL
|
|
905 |
// ---------------------------------------------------------
|
|
906 |
//
|
|
907 |
TInt CBrowserFavouritesView::AddNewFolderL()
|
|
908 |
{
|
|
909 |
TInt uid = KFavouritesNullUid;
|
|
910 |
// Make an item and fill it with default values.
|
|
911 |
CFavouritesItem* folder = CFavouritesItem::NewLC();
|
|
912 |
folder->SetType( CFavouritesItem::EFolder );
|
|
913 |
folder->SetParentFolder( KFavouritesRootUid );
|
|
914 |
iModel->SetNameToDefaultL( *folder );
|
|
915 |
TInt err = iModel->MakeUniqueNameL( *folder );
|
|
916 |
if ( !err )
|
|
917 |
{
|
|
918 |
// We have the folder with a default unique name.
|
|
919 |
// Let the user rename it.
|
|
920 |
if ( iModel->RenameQueryL( *folder, ETrue ))
|
|
921 |
{
|
|
922 |
// Rename accepted.
|
|
923 |
err = iModel->AddL( *folder, /*aDbErrorNote=*/ETrue,
|
|
924 |
CBrowserFavouritesModel::EAskIfRename );
|
|
925 |
if ( !err )
|
|
926 |
{
|
|
927 |
// Succesfully created. Set highlight to new folder (by setting
|
|
928 |
// preferred highlight uid - we have not see the new folder
|
|
929 |
// yet, until db notification kicks in.
|
|
930 |
uid = iPreferredHighlightUid = folder->Uid();
|
|
931 |
}
|
|
932 |
}
|
|
933 |
}
|
|
934 |
CleanupStack::PopAndDestroy(); // folder
|
|
935 |
return uid;
|
|
936 |
}
|
|
937 |
|
|
938 |
// ---------------------------------------------------------
|
|
939 |
// CBrowserFavouritesView::MoveMarkedItemsL
|
|
940 |
// ---------------------------------------------------------
|
|
941 |
//
|
|
942 |
void CBrowserFavouritesView::MoveMarkedItemsL()
|
|
943 |
{
|
|
944 |
TInt targetFolder = SelectTargetFolderL( iCurrentFolder );
|
|
945 |
|
|
946 |
// If we have the target folder, do the move.
|
|
947 |
if ( targetFolder != KFavouritesNullUid )
|
|
948 |
{
|
|
949 |
CArrayFix<TInt>* uids = iContainer->Listbox()->SelectedUidsLC();
|
|
950 |
CArrayFix<TInt>* unmovableUids = NewUidListLC();
|
|
951 |
CArrayFix<TInt>* conflictingNameUids = NewUidListLC();
|
|
952 |
if ( !iModel->BeginL( /*aWrite=*/ETrue, /*aDbErrorNote=*/ETrue ) )
|
|
953 |
{
|
|
954 |
__ASSERT_DEBUG( !iIncrementalOp, Util::Panic
|
|
955 |
( Util::EIncrementalOperationAlreadyRunning ) );
|
|
956 |
// Seems we have to give lower priority to the move operation,
|
|
957 |
// or else the wait note does not show up.
|
|
958 |
iIncrementalOp = CBrowserFavouritesIncrementalMove::NewL
|
|
959 |
(
|
|
960 |
*iModel,
|
|
961 |
*uids,
|
|
962 |
*unmovableUids,
|
|
963 |
*conflictingNameUids,
|
|
964 |
targetFolder,
|
|
965 |
CActive::EPriorityStandard - 1
|
|
966 |
);
|
|
967 |
iIncrementalOp->ExecuteL();
|
|
968 |
delete iIncrementalOp;
|
|
969 |
iIncrementalOp = NULL;
|
|
970 |
iModel->CommitL();
|
|
971 |
// Everything that can be moved, is moved by now.
|
|
972 |
// If some items could not be moved, see why.
|
|
973 |
HandleMoveResultL
|
|
974 |
( targetFolder, *uids, *unmovableUids, *conflictingNameUids );
|
|
975 |
|
|
976 |
for ( TInt ii = 0; ii< uids->Count(); ii++ )
|
|
977 |
{
|
|
978 |
TInt prefUid;
|
|
979 |
iModel->Database().PreferredUid( iCurrentFolder, prefUid );
|
|
980 |
if ( prefUid == uids->At( ii ) )
|
|
981 |
{
|
|
982 |
iModel->Database().SetPreferredUid( iCurrentFolder,NULL );
|
|
983 |
break;
|
|
984 |
}
|
|
985 |
}
|
|
986 |
|
|
987 |
CBrowserBookmarksOrder* bmOrder = CBrowserBookmarksOrder::NewLC();
|
|
988 |
CArrayFixFlat<TInt>* orderArray = new (ELeave) CArrayFixFlat<TInt>(KGranularityHigh);
|
|
989 |
CleanupStack::PushL( orderArray );
|
|
990 |
if ( Model().Database().GetData( CurrentFolder() ,*bmOrder ) == KErrNone)
|
|
991 |
{
|
|
992 |
if ( bmOrder->GetBookMarksOrder().Count() )
|
|
993 |
{
|
|
994 |
orderArray->AppendL( &( bmOrder->GetBookMarksOrder()[0] ), bmOrder->GetBookMarksOrder().Count());
|
|
995 |
TInt swapTo = 0;
|
|
996 |
TInt swappedItem;
|
|
997 |
for ( TInt i=0; i<orderArray->Count();i++ )
|
|
998 |
{
|
|
999 |
TInt swapFrom=0;
|
|
1000 |
while (swapFrom<uids->Count() && ( (*uids)[swapFrom] != ( *orderArray )[i]) )
|
|
1001 |
{
|
|
1002 |
swapFrom++;
|
|
1003 |
}
|
|
1004 |
if (swapFrom<uids->Count())
|
|
1005 |
{
|
|
1006 |
if ((swapFrom != swapTo) && (swapTo < uids->Count() ) )
|
|
1007 |
{
|
|
1008 |
swappedItem = ( *uids )[swapFrom];
|
|
1009 |
( *uids )[swapFrom] = ( *uids )[swapTo];
|
|
1010 |
( *uids )[swapTo] = swappedItem;
|
|
1011 |
}
|
|
1012 |
swapTo++;
|
|
1013 |
}
|
|
1014 |
}
|
|
1015 |
}
|
|
1016 |
}
|
|
1017 |
|
|
1018 |
orderArray->Reset();
|
|
1019 |
if ( Model().Database().GetData( targetFolder ,*bmOrder ) == KErrNone)
|
|
1020 |
{
|
|
1021 |
if ( bmOrder->GetBookMarksOrder().Count() )
|
|
1022 |
{
|
|
1023 |
orderArray->AppendL( &( bmOrder->GetBookMarksOrder()[0] ), bmOrder->GetBookMarksOrder().Count());
|
|
1024 |
if ( orderArray->Count() )
|
|
1025 |
{
|
|
1026 |
for ( TInt i = 0; i < uids->Count(); i++ )
|
|
1027 |
{
|
|
1028 |
for (TInt j = 0; j < orderArray->Count(); j++ )
|
|
1029 |
{
|
|
1030 |
if ( orderArray->At( j ) == uids->At( i ))
|
|
1031 |
{
|
|
1032 |
orderArray->Delete( j );
|
|
1033 |
}
|
|
1034 |
}
|
|
1035 |
Model().AddUidToLastPlaceL(uids->At( i ), orderArray, bmOrder);
|
|
1036 |
}
|
|
1037 |
bmOrder->SetBookMarksOrderL( *orderArray );
|
|
1038 |
Model().Database().SetData( targetFolder , *bmOrder );
|
|
1039 |
}
|
|
1040 |
}
|
|
1041 |
}
|
|
1042 |
|
|
1043 |
CleanupStack::PopAndDestroy( ); //orderArray
|
|
1044 |
CleanupStack::PopAndDestroy( ); //bmOrder
|
|
1045 |
}
|
|
1046 |
CleanupStack::PopAndDestroy( 3 ); // conflictingNameUids,
|
|
1047 |
// unmovableUids, uids
|
|
1048 |
}
|
|
1049 |
}
|
|
1050 |
|
|
1051 |
// ---------------------------------------------------------
|
|
1052 |
// CBrowserFavouritesView::RenameCurrentItemL
|
|
1053 |
// ---------------------------------------------------------
|
|
1054 |
//
|
|
1055 |
void CBrowserFavouritesView::RenameCurrentItemL()
|
|
1056 |
{
|
|
1057 |
if ( iContainer && iContainer->Listbox() )
|
|
1058 |
{
|
|
1059 |
const CFavouritesItem* listboxItem =
|
|
1060 |
iContainer->Listbox()->CurrentItem();
|
|
1061 |
if ( listboxItem )
|
|
1062 |
{
|
|
1063 |
CFavouritesItem* item = CFavouritesItem::NewLC();
|
|
1064 |
*item = *listboxItem;
|
|
1065 |
if ( iModel->RenameQueryL( *item, EFalse ) )
|
|
1066 |
{
|
|
1067 |
iModel->UpdateL
|
|
1068 |
(
|
|
1069 |
*item,
|
|
1070 |
listboxItem->Uid(),
|
|
1071 |
/*aDbErrorNote=*/ETrue,
|
|
1072 |
CBrowserFavouritesModel::EAskIfRename
|
|
1073 |
);
|
|
1074 |
|
|
1075 |
iPreferredHighlightUid = item->Uid();
|
|
1076 |
|
|
1077 |
// Show infonote "Unable to rename" if read-only item
|
|
1078 |
if ( listboxItem->IsReadOnly() )
|
|
1079 |
{
|
|
1080 |
TBrowserDialogs::InfoNoteL
|
|
1081 |
(
|
|
1082 |
R_BROWSER_INFO_NOTE,
|
|
1083 |
_R(TEXT_PRMPT_CANT_RENAME),
|
|
1084 |
listboxItem->Name()
|
|
1085 |
);
|
|
1086 |
}
|
|
1087 |
}
|
|
1088 |
CleanupStack::PopAndDestroy(); // item
|
|
1089 |
}
|
|
1090 |
}
|
|
1091 |
}
|
|
1092 |
|
|
1093 |
// ---------------------------------------------------------
|
|
1094 |
// CBrowserFavouritesView::SetRootFolderForAdaptiveBookmarks
|
|
1095 |
// ---------------------------------------------------------
|
|
1096 |
//
|
|
1097 |
void CBrowserFavouritesView::SetRootFolderForAdaptiveBookmarks()
|
|
1098 |
{
|
|
1099 |
iCurrentFolder = KFavouritesRootUid;
|
|
1100 |
}
|
|
1101 |
|
|
1102 |
// ---------------------------------------------------------
|
|
1103 |
// CBrowserFavouritesView::OpenFolderL
|
|
1104 |
// ---------------------------------------------------------
|
|
1105 |
//
|
|
1106 |
void CBrowserFavouritesView::OpenFolderL( TInt aFolder )
|
|
1107 |
{
|
|
1108 |
|
|
1109 |
CFavouritesItem* folder = CFavouritesItem::NewLC();
|
|
1110 |
if ( iModel->Database().Get( aFolder, *folder ) == KErrNone )
|
|
1111 |
{
|
|
1112 |
iContainer->Listbox()->GetDefaultData().iPreferedId = NULL;
|
|
1113 |
iContainer->Listbox()->GetDefaultData().iInSeamlessFolder = EFalse;
|
|
1114 |
// Set title.
|
|
1115 |
if ( aFolder == KFavouritesRootUid )
|
|
1116 |
{
|
|
1117 |
UpdateNaviPaneL(); // remove NaviPane before setting title - SetTitleL redraws
|
|
1118 |
if(ApiProvider().StartedUp())
|
|
1119 |
ApiProvider().Display().SetTitleL( RootTitleResourceId() );
|
|
1120 |
else
|
|
1121 |
{
|
|
1122 |
// Set title to be page title
|
|
1123 |
CEikStatusPane* sp = STATIC_CAST( CAknAppUi*, CEikonEnv::Static()->EikAppUi() )->StatusPane();
|
|
1124 |
CAknTitlePane* title = STATIC_CAST( CAknTitlePane*, sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
1125 |
HBufC* name = CEikonEnv::Static()->AllocReadResourceLC( R_BROWSER_OPTION_BOOKMARKS );
|
|
1126 |
title->SetTextL( *name );
|
|
1127 |
CleanupStack::PopAndDestroy(); // name
|
|
1128 |
}
|
|
1129 |
}
|
|
1130 |
else
|
|
1131 |
{
|
|
1132 |
// Next get localized title text if the folder is a seamless link folder.
|
|
1133 |
TInt resId = CBrowserFavouritesView::GetSeamlessFolderTitleResourceID(
|
|
1134 |
folder->ContextId() );
|
|
1135 |
HBufC* name;
|
|
1136 |
|
|
1137 |
if (resId)
|
|
1138 |
{
|
|
1139 |
iContainer->Listbox()->GetDefaultData().iInSeamlessFolder = ETrue;
|
|
1140 |
TInt prefUid;
|
|
1141 |
iModel->Database().PreferredUid( aFolder, prefUid );
|
|
1142 |
iContainer->Listbox()->GetDefaultData().iPreferedId = prefUid;
|
|
1143 |
name = iCoeEnv->AllocReadResourceLC( resId );
|
|
1144 |
folder->SetNameL(name->Des()); // set the localized name
|
|
1145 |
CleanupStack::PopAndDestroy(); // name
|
|
1146 |
}
|
|
1147 |
|
|
1148 |
ApiProvider().Display().SetTitleL( folder->Name() );
|
|
1149 |
}
|
|
1150 |
|
|
1151 |
iCurrentFolder = aFolder;
|
|
1152 |
FillListboxL( aFolder, /*aKeepState=*/EFalse );
|
|
1153 |
|
|
1154 |
if(ApiProvider().StartedUp())
|
|
1155 |
{
|
|
1156 |
Container()->Listbox()->ClearSelection();
|
|
1157 |
UpdateCbaL();
|
|
1158 |
}
|
|
1159 |
|
|
1160 |
UpdateNaviPaneL();
|
|
1161 |
}
|
|
1162 |
CleanupStack::PopAndDestroy(); // folder
|
|
1163 |
}
|
|
1164 |
|
|
1165 |
// ---------------------------------------------------------
|
|
1166 |
// CBrowserFavouritesView::OpenNextFolderL
|
|
1167 |
// ---------------------------------------------------------
|
|
1168 |
//
|
|
1169 |
void CBrowserFavouritesView::OpenNextFolderL( TBool aForward )
|
|
1170 |
{
|
|
1171 |
__ASSERT_DEBUG( iCurrentFolder != KFavouritesRootUid,
|
|
1172 |
Util::Panic( Util::ERootLevel ) );
|
|
1173 |
|
|
1174 |
if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
|
|
1175 |
== KErrNone )
|
|
1176 |
{
|
|
1177 |
TInt nextFolder = iModel->NextFolderL( iCurrentFolder, aForward );
|
|
1178 |
if ( nextFolder != KFavouritesNullUid )
|
|
1179 |
{
|
|
1180 |
OpenFolderL( nextFolder );
|
|
1181 |
}
|
|
1182 |
iModel->CommitL();
|
|
1183 |
}
|
|
1184 |
}
|
|
1185 |
|
|
1186 |
// ---------------------------------------------------------
|
|
1187 |
// CBrowserFavouritesView::FillListboxL
|
|
1188 |
// ---------------------------------------------------------
|
|
1189 |
//
|
|
1190 |
void CBrowserFavouritesView::FillListboxL( TInt aFolder, TBool aKeepState )
|
|
1191 |
{
|
|
1192 |
// During an incremental operation we should never update the listbox
|
|
1193 |
// because some of them holds pointers to listbox items.
|
|
1194 |
//
|
|
1195 |
// If we have an incremental operation, we should never get here:
|
|
1196 |
// 1) Any change notification (faves db, ap db, preferences) handling is
|
|
1197 |
// skipped in RefreshL, where all change handling comes
|
|
1198 |
// together.
|
|
1199 |
// 2) All incremental operations have an empty CBA, so we cannot get here
|
|
1200 |
// by user input either.
|
|
1201 |
// But to make this safe from potential errors (e.g. user activity due to
|
|
1202 |
// some error in wait notes, CBA, key handling etc., and also from bugs in
|
|
1203 |
// this code), we double-check here.
|
|
1204 |
// In release build do nothing (avoid the crash), in debug build panic.
|
|
1205 |
if ( iIncrementalOp )
|
|
1206 |
{
|
|
1207 |
#ifdef _DEBUG
|
|
1208 |
Util::Panic( Util::ECannotUpdateDataInUse );
|
|
1209 |
#else
|
|
1210 |
return;
|
|
1211 |
#endif
|
|
1212 |
}
|
|
1213 |
|
|
1214 |
CBrowserFavouritesListbox* listbox = iContainer->Listbox();
|
|
1215 |
|
|
1216 |
// Disable redraw to avoid flickering.
|
|
1217 |
TBool redrawDisabled = listbox->View()->RedrawDisabled();
|
|
1218 |
listbox->View()->SetDisableRedraw( ETrue );
|
|
1219 |
|
|
1220 |
// Change the data.
|
|
1221 |
CFavouritesItemList* items = GetItemsLC( aFolder );
|
|
1222 |
|
|
1223 |
// Next take localized item names for seamless links.
|
|
1224 |
TInt contextId;
|
|
1225 |
TInt resId = 0;
|
|
1226 |
HBufC* name;
|
|
1227 |
|
|
1228 |
TBool browserService = ApiProvider().Preferences().ServiceFeature();
|
|
1229 |
TBool firstBoot = ApiProvider().Preferences().GetIntValue( KBrowserFirstBoot );
|
|
1230 |
TInt serviceUid = KErrNotFound;
|
|
1231 |
|
|
1232 |
for(int i=0; i<items->Count(); i++)
|
|
1233 |
{
|
|
1234 |
if (!items->At(i)->IsHidden())
|
|
1235 |
{
|
|
1236 |
contextId = items->At(i)->ContextId();
|
|
1237 |
|
|
1238 |
if ( firstBoot && browserService )
|
|
1239 |
{
|
|
1240 |
//This is the first boot and we need to move Service top of the bookmarks.
|
|
1241 |
//Here we save uid for Service item.
|
|
1242 |
if ( contextId == KFavouritesServiceContextId )
|
|
1243 |
{
|
|
1244 |
serviceUid = items->IndexToUid( i );
|
|
1245 |
}
|
|
1246 |
}
|
|
1247 |
|
|
1248 |
resId = CBrowserFavouritesView::GetSeamlessFolderResourceID(
|
|
1249 |
contextId );
|
|
1250 |
if(resId)
|
|
1251 |
{
|
|
1252 |
name = iCoeEnv->AllocReadResourceLC( resId );
|
|
1253 |
items->At(i)->SetNameL(name->Des());
|
|
1254 |
CleanupStack::PopAndDestroy(); // name
|
|
1255 |
}
|
|
1256 |
}
|
|
1257 |
else
|
|
1258 |
{
|
|
1259 |
items->Delete(i);
|
|
1260 |
i--;
|
|
1261 |
}
|
|
1262 |
}
|
|
1263 |
|
|
1264 |
if ( firstBoot && browserService && serviceUid != KErrNotFound )
|
|
1265 |
{
|
|
1266 |
//get current order array
|
|
1267 |
CBrowserBookmarksOrder* currentOrder = CBrowserBookmarksOrder::NewLC();
|
|
1268 |
CArrayFixFlat<TInt>* orderArray = new (ELeave) CArrayFixFlat<TInt>( KGranularityHigh );
|
|
1269 |
CleanupStack::PushL( orderArray );
|
|
1270 |
|
|
1271 |
iModel->Database().GetData( KFavouritesRootUid, *currentOrder );
|
|
1272 |
orderArray->AppendL( &( currentOrder->GetBookMarksOrder()[0] ), currentOrder->GetBookMarksOrder().Count());
|
|
1273 |
|
|
1274 |
//First sort UI. Move Service
|
|
1275 |
CFavouritesItem* serviceCopy = CFavouritesItem::NewLC();
|
|
1276 |
const CFavouritesItem* serviceItem = items->ItemByUid( serviceUid );
|
|
1277 |
if ( serviceItem )
|
|
1278 |
{
|
|
1279 |
*serviceCopy = *serviceItem;
|
|
1280 |
items->Delete( serviceUid );
|
|
1281 |
items->InsertL( 0, serviceCopy ); //ownership transfered
|
|
1282 |
CleanupStack::Pop( serviceCopy );
|
|
1283 |
}
|
|
1284 |
else
|
|
1285 |
{
|
|
1286 |
User::Leave( KErrNotFound );
|
|
1287 |
}
|
|
1288 |
|
|
1289 |
//Next change order in db. Move Service
|
|
1290 |
orderArray->InsertL( 0, orderArray->At( serviceUid ) );
|
|
1291 |
orderArray->Delete( serviceUid+1 );
|
|
1292 |
|
|
1293 |
//save changes to db
|
|
1294 |
currentOrder->SetBookMarksOrderL( *orderArray );
|
|
1295 |
iModel->Database().SetData( KFavouritesRootUid, *currentOrder );
|
|
1296 |
|
|
1297 |
CleanupStack::PopAndDestroy( 2 ); //orderArray, currentOrder
|
|
1298 |
//service moved to top of the bookmark list. We can set firstboot value to false
|
|
1299 |
// so now we can set firstboot value to false.
|
|
1300 |
CRepository* repository = CRepository::NewLC( KCRUidBrowser );
|
|
1301 |
User::LeaveIfError( repository->Set(KBrowserFirstBoot, EFalse) );
|
|
1302 |
CleanupStack::PopAndDestroy( repository );
|
|
1303 |
|
|
1304 |
// Set Search item to italics font
|
|
1305 |
iContainer->Listbox()->ItalicizeRowItemL(0);
|
|
1306 |
}
|
|
1307 |
CleanupStack::Pop(); // items: passing ownership to listbox.
|
|
1308 |
iContainer->Listbox()->SetDataL
|
|
1309 |
( items, /*ApiProvider().CommsModel(),*/ aKeepState );
|
|
1310 |
CAknColumnListBoxView *aknview = STATIC_CAST(CAknColumnListBoxView*, iContainer->Listbox()->View() );
|
|
1311 |
|
|
1312 |
if ( !items->Count() )
|
|
1313 |
{
|
|
1314 |
iContainer->Listbox()->UpdateFilterL(); // ...and tell to listbox.
|
|
1315 |
aknview->SetFindEmptyListState(EFalse);
|
|
1316 |
}
|
|
1317 |
else
|
|
1318 |
{
|
|
1319 |
aknview->SetFindEmptyListState(ETrue);
|
|
1320 |
}
|
|
1321 |
|
|
1322 |
if(ApiProvider().StartedUp())
|
|
1323 |
iContainer->SizeChanged(); // Needed to show/hide Find Pane!
|
|
1324 |
iCurrentFolder = aFolder;
|
|
1325 |
|
|
1326 |
HighlightPreferredL();
|
|
1327 |
iContainer->HandleCursorChangedL( listbox );
|
|
1328 |
listbox->View()->SetDisableRedraw( redrawDisabled );
|
|
1329 |
|
|
1330 |
if(ApiProvider().StartedUp())
|
|
1331 |
{
|
|
1332 |
listbox->DrawDeferred();
|
|
1333 |
UpdateCbaL();
|
|
1334 |
UpdateNaviPaneL();
|
|
1335 |
}
|
|
1336 |
}
|
|
1337 |
|
|
1338 |
// ----------------------------------------------------------------------------
|
|
1339 |
// CBrowserFavouritesView::ConfirmDeleteL
|
|
1340 |
// ----------------------------------------------------------------------------
|
|
1341 |
//
|
|
1342 |
TBool CBrowserFavouritesView::ConfirmDeleteL
|
|
1343 |
( CArrayFix<TInt>& aUids, CArrayFix<TInt>& aFolderUids )
|
|
1344 |
{
|
|
1345 |
CBrowserFavouritesModel::TDbQuery anyNonEmptyFolders;
|
|
1346 |
TInt ret = EFalse;
|
|
1347 |
|
|
1348 |
anyNonEmptyFolders = iModel->AnyNonEmptyFoldersL( aFolderUids );
|
|
1349 |
switch ( anyNonEmptyFolders )
|
|
1350 |
{
|
|
1351 |
case CBrowserFavouritesModel::EYes:
|
|
1352 |
{
|
|
1353 |
// At least one non-empty folder is selected.
|
|
1354 |
ret = TBrowserDialogs::ConfirmQueryYesNoL(
|
|
1355 |
_R(TEXT_DEL_FULL_FLDRS_QUERY) );
|
|
1356 |
break;
|
|
1357 |
}
|
|
1358 |
|
|
1359 |
case CBrowserFavouritesModel::ENo:
|
|
1360 |
{
|
|
1361 |
// No non-empty folders are selected.
|
|
1362 |
TInt count = aUids.Count();
|
|
1363 |
switch ( count )
|
|
1364 |
{
|
|
1365 |
case 0:
|
|
1366 |
{
|
|
1367 |
// Empty selection (???);
|
|
1368 |
ret = EFalse;
|
|
1369 |
break;
|
|
1370 |
}
|
|
1371 |
|
|
1372 |
case 1:
|
|
1373 |
{
|
|
1374 |
// One item is selected (item or empty folder).
|
|
1375 |
// Get its name.
|
|
1376 |
const CFavouritesItem* item = iContainer->Listbox()->
|
|
1377 |
ItemByUid( aUids.At( 0 ) );
|
|
1378 |
if ( item )
|
|
1379 |
{
|
|
1380 |
ret = TBrowserDialogs::ConfirmQueryYesNoL(
|
|
1381 |
_R(TEXT_QUERY_COMMON_CONF_DELETE), item->Name() );
|
|
1382 |
}
|
|
1383 |
else
|
|
1384 |
{
|
|
1385 |
// Could not get item (maybe listbox has been updated).
|
|
1386 |
ret = EFalse;
|
|
1387 |
}
|
|
1388 |
break;
|
|
1389 |
}
|
|
1390 |
|
|
1391 |
default:
|
|
1392 |
{
|
|
1393 |
// More items are selected (items or/and empty folders).
|
|
1394 |
ret = TBrowserDialogs::ConfirmQueryYesNoL(
|
|
1395 |
_R(TEXT_DEL_ITEMS_QUERY), count );
|
|
1396 |
break;
|
|
1397 |
}
|
|
1398 |
|
|
1399 |
}
|
|
1400 |
break;
|
|
1401 |
}
|
|
1402 |
|
|
1403 |
case CBrowserFavouritesModel::EError:
|
|
1404 |
default:
|
|
1405 |
{
|
|
1406 |
// Could not access database.
|
|
1407 |
ret = EFalse;
|
|
1408 |
break;
|
|
1409 |
}
|
|
1410 |
}
|
|
1411 |
|
|
1412 |
return ret;
|
|
1413 |
}
|
|
1414 |
|
|
1415 |
// ---------------------------------------------------------
|
|
1416 |
// CBrowserFavouritesView::DisplayResultOfDeleteL
|
|
1417 |
// ---------------------------------------------------------
|
|
1418 |
//
|
|
1419 |
void CBrowserFavouritesView::DisplayResultOfDeleteL
|
|
1420 |
( const CArrayFix<TInt>& /*aUids*/, const CArrayFix<TInt>& aNotDeletedUids )
|
|
1421 |
{
|
|
1422 |
switch ( aNotDeletedUids.Count() )
|
|
1423 |
{
|
|
1424 |
case 0:
|
|
1425 |
{
|
|
1426 |
// All items deleted successfully.
|
|
1427 |
// Display nothing.
|
|
1428 |
break;
|
|
1429 |
}
|
|
1430 |
case 1:
|
|
1431 |
{
|
|
1432 |
// One item is not deleted.
|
|
1433 |
const CFavouritesItem* item = iContainer->Listbox()->
|
|
1434 |
ItemByUid( aNotDeletedUids.At( 0 ) );
|
|
1435 |
if ( item )
|
|
1436 |
{
|
|
1437 |
TBrowserDialogs::InfoNoteL
|
|
1438 |
(
|
|
1439 |
R_BROWSER_INFO_NOTE,
|
|
1440 |
_R(TEXT_CANT_DELETE_ITEM),
|
|
1441 |
item->Name()
|
|
1442 |
);
|
|
1443 |
}
|
|
1444 |
// else
|
|
1445 |
// this item is not found in the listbox (so it does not exist,
|
|
1446 |
// most likely got deleted somehow) - keep quiet.
|
|
1447 |
break;
|
|
1448 |
}
|
|
1449 |
default:
|
|
1450 |
{
|
|
1451 |
// More items are not deleted.
|
|
1452 |
TBrowserDialogs::InfoNoteL
|
|
1453 |
(
|
|
1454 |
R_BROWSER_INFO_NOTE,
|
|
1455 |
_R(TEXT_CANT_DELETE_ITEMS),
|
|
1456 |
aNotDeletedUids.Count()
|
|
1457 |
);
|
|
1458 |
break;
|
|
1459 |
}
|
|
1460 |
}
|
|
1461 |
}
|
|
1462 |
|
|
1463 |
// ---------------------------------------------------------
|
|
1464 |
// CBrowserFavouritesView::SelectTargetFolderL
|
|
1465 |
// ---------------------------------------------------------
|
|
1466 |
//
|
|
1467 |
TInt CBrowserFavouritesView::SelectTargetFolderL( TInt aExcludeFolder )
|
|
1468 |
{
|
|
1469 |
TInt targetFolder = KFavouritesNullUid;
|
|
1470 |
|
|
1471 |
switch ( iModel->AnyFoldersL() )
|
|
1472 |
{
|
|
1473 |
case CBrowserFavouritesModel::EYes:
|
|
1474 |
{
|
|
1475 |
// Select from existing folders.
|
|
1476 |
CBrowserFavouritesFolderSelector* selector =
|
|
1477 |
CBrowserFavouritesFolderSelector::NewL
|
|
1478 |
( *iModel, ApiProvider(), aExcludeFolder );
|
|
1479 |
targetFolder = selector->ExecuteLD();
|
|
1480 |
break;
|
|
1481 |
}
|
|
1482 |
case CBrowserFavouritesModel::ENo:
|
|
1483 |
{
|
|
1484 |
break;
|
|
1485 |
}
|
|
1486 |
case CBrowserFavouritesModel::EError:
|
|
1487 |
default:
|
|
1488 |
{
|
|
1489 |
// Some error; quit.
|
|
1490 |
break;
|
|
1491 |
}
|
|
1492 |
}
|
|
1493 |
return targetFolder;
|
|
1494 |
}
|
|
1495 |
|
|
1496 |
// ---------------------------------------------------------
|
|
1497 |
// CBrowserFavouritesView::HandleMoveResultL
|
|
1498 |
// ---------------------------------------------------------
|
|
1499 |
//
|
|
1500 |
void CBrowserFavouritesView::HandleMoveResultL
|
|
1501 |
(
|
|
1502 |
TInt aFolder,
|
|
1503 |
const CArrayFix<TInt>& /*aUids*/,
|
|
1504 |
const CArrayFix<TInt>& aUnmovableUids,
|
|
1505 |
const CArrayFix<TInt>& aConflictingNameUids
|
|
1506 |
)
|
|
1507 |
{
|
|
1508 |
// See if some items has to be renamed to do the move.
|
|
1509 |
if ( aConflictingNameUids.Count() )
|
|
1510 |
{
|
|
1511 |
if ( aConflictingNameUids.Count() == 1 )
|
|
1512 |
{
|
|
1513 |
// One item needs to be renamed if the user wants to move them.
|
|
1514 |
// Let the user know and ask if replace.
|
|
1515 |
const CFavouritesItem* item = iContainer->Listbox()->
|
|
1516 |
ItemByUid( aConflictingNameUids.At( 0 ) );
|
|
1517 |
if ( item )
|
|
1518 |
{
|
|
1519 |
TBrowserDialogs::InfoNoteL
|
|
1520 |
(
|
|
1521 |
R_BROWSER_INFO_NOTE,
|
|
1522 |
_R(TEXT_FLDR_NAME_ALREADY_USED),
|
|
1523 |
item->Name()
|
|
1524 |
);
|
|
1525 |
RenameAndMoveItemsL( aConflictingNameUids, aFolder );
|
|
1526 |
}
|
|
1527 |
}
|
|
1528 |
else
|
|
1529 |
{
|
|
1530 |
// Some items needs to be renamed if the user wants to move them.
|
|
1531 |
// Let the user know and ask for each if replace.
|
|
1532 |
TBrowserDialogs::InfoNoteL( R_BROWSER_INFO_NOTE,
|
|
1533 |
_R(TEXT_FLDR_NAMES_IN_USE_RENAME) );
|
|
1534 |
RenameAndMoveItemsL( aConflictingNameUids, aFolder );
|
|
1535 |
}
|
|
1536 |
}
|
|
1537 |
|
|
1538 |
// Check unmovable items.
|
|
1539 |
if ( aUnmovableUids.Count() )
|
|
1540 |
{
|
|
1541 |
if ( aUnmovableUids.Count() == 1 )
|
|
1542 |
{
|
|
1543 |
// One item is not moved.
|
|
1544 |
const CFavouritesItem* item = iContainer->Listbox()->
|
|
1545 |
ItemByUid( aUnmovableUids.At( 0 ) );
|
|
1546 |
if ( item )
|
|
1547 |
{
|
|
1548 |
TBrowserDialogs::InfoNoteL
|
|
1549 |
(
|
|
1550 |
R_BROWSER_INFO_NOTE,
|
|
1551 |
_R(TEXT_ITEM_CANNOT_BE_MOVED),
|
|
1552 |
item->Name()
|
|
1553 |
);
|
|
1554 |
}
|
|
1555 |
}
|
|
1556 |
else
|
|
1557 |
{
|
|
1558 |
// More items could not be moved.
|
|
1559 |
TBrowserDialogs::InfoNoteL
|
|
1560 |
(
|
|
1561 |
R_BROWSER_INFO_NOTE,
|
|
1562 |
_R(TEXT_SOME_ITEMS_CANT_MOVE),
|
|
1563 |
aUnmovableUids.Count()
|
|
1564 |
);
|
|
1565 |
}
|
|
1566 |
}
|
|
1567 |
// else
|
|
1568 |
// All is well: all moved succesfully. Display nothing.
|
|
1569 |
}
|
|
1570 |
|
|
1571 |
// ---------------------------------------------------------
|
|
1572 |
// CBrowserFavouritesView::RenameAndMoveItemsL
|
|
1573 |
// ---------------------------------------------------------
|
|
1574 |
//
|
|
1575 |
void CBrowserFavouritesView::RenameAndMoveItemsL
|
|
1576 |
( const CArrayFix<TInt>& aUids, TInt aFolder )
|
|
1577 |
{
|
|
1578 |
TInt err = KErrNone;
|
|
1579 |
TInt i;
|
|
1580 |
TInt uid;
|
|
1581 |
TInt count = aUids.Count();
|
|
1582 |
TInt itemErr;
|
|
1583 |
|
|
1584 |
CFavouritesItem* item = CFavouritesItem::NewLC();
|
|
1585 |
|
|
1586 |
for ( i = 0; i < count && !err; i++ )
|
|
1587 |
{
|
|
1588 |
// Get each item in turn from db (ignore if any of them is not found).
|
|
1589 |
// Let the user rename each. Quit on the first Cancel from the user.
|
|
1590 |
// All database manipulating methods, which are called here, retry on
|
|
1591 |
// failure, so if we ever get an error value, that means that the user
|
|
1592 |
// cancelled something.
|
|
1593 |
uid = aUids.At( i );
|
|
1594 |
err = iModel->BeginL( /*aWrite=*/ETrue, /*aDbErrorNote=*/ETrue );
|
|
1595 |
if ( !err )
|
|
1596 |
{
|
|
1597 |
// Check if we have the item.
|
|
1598 |
itemErr = iModel->Database().Get( uid, *item );
|
|
1599 |
iModel->CommitL();
|
|
1600 |
if ( !itemErr )
|
|
1601 |
{
|
|
1602 |
// We have this item. Ask the user to rename it.
|
|
1603 |
if ( iModel->RenameQueryL( *item, EFalse) )
|
|
1604 |
{
|
|
1605 |
// The user renamed the item: try to update and go on.
|
|
1606 |
item->SetParentFolder( aFolder );
|
|
1607 |
err = iModel->UpdateL( *item, uid, /*aDbErrorNote=*/ETrue,
|
|
1608 |
CBrowserFavouritesModel::EAskIfRename );
|
|
1609 |
}
|
|
1610 |
else
|
|
1611 |
{
|
|
1612 |
// Cancelled. Quit.
|
|
1613 |
err = KErrCancel;
|
|
1614 |
}
|
|
1615 |
}
|
|
1616 |
}
|
|
1617 |
}
|
|
1618 |
CleanupStack::PopAndDestroy(); // item
|
|
1619 |
}
|
|
1620 |
|
|
1621 |
// ---------------------------------------------------------
|
|
1622 |
// CBrowserFavouritesView::UpdateNaviPaneL
|
|
1623 |
// ---------------------------------------------------------
|
|
1624 |
//
|
|
1625 |
void CBrowserFavouritesView::UpdateNaviPaneL()
|
|
1626 |
{
|
|
1627 |
if ( iCurrentFolder == KFavouritesRootUid )
|
|
1628 |
{
|
|
1629 |
// In root folder show the tabs.
|
|
1630 |
iContainer->ShowRootNaviPane();
|
|
1631 |
}
|
|
1632 |
else
|
|
1633 |
{
|
|
1634 |
// In other folder, show "1/4" style text.
|
|
1635 |
TInt folderIndex;
|
|
1636 |
TInt folderCount;
|
|
1637 |
TInt err;
|
|
1638 |
err = iModel->FolderInfoL( iCurrentFolder, folderCount, folderIndex );
|
|
1639 |
if ( !err )
|
|
1640 |
{
|
|
1641 |
iContainer->ShowFolderNaviPaneL( folderIndex, folderCount );
|
|
1642 |
}
|
|
1643 |
}
|
|
1644 |
}
|
|
1645 |
|
|
1646 |
// ---------------------------------------------------------
|
|
1647 |
// CBrowserFavouritesView::OfferKeyEventL
|
|
1648 |
// ---------------------------------------------------------
|
|
1649 |
//
|
|
1650 |
TKeyResponse CBrowserFavouritesView::OfferKeyEventL
|
|
1651 |
( const TKeyEvent& aKeyEvent, TEventCode /*aType*/ )
|
|
1652 |
{
|
|
1653 |
// This method is called back from the container, to process the keypresses
|
|
1654 |
// that cannot be handled by the container. Those are (currently) the
|
|
1655 |
// left/right arrow keypresses, since the container does not know anything
|
|
1656 |
// about what folder is open, which knowledge is required to process
|
|
1657 |
// arrow presses. So we do that here.
|
|
1658 |
// Any other key processing is still in the container.
|
|
1659 |
TKeyResponse result = EKeyWasNotConsumed;
|
|
1660 |
switch ( aKeyEvent.iCode )
|
|
1661 |
{
|
|
1662 |
|
|
1663 |
case EKeyLeftArrow: // West
|
|
1664 |
{
|
|
1665 |
if ( iCurrentFolder != KFavouritesRootUid )
|
|
1666 |
{
|
|
1667 |
// We are in some folder. Move between subfolders in the
|
|
1668 |
// leftward direction.
|
|
1669 |
if ( !ApiProvider().IsEmbeddedModeOn() )
|
|
1670 |
{
|
|
1671 |
OpenNextFolderL( /*aForward=*/EFalse );
|
|
1672 |
}
|
|
1673 |
//return EKeyWasConsumed anyway, since in embedded mode user can access only the launch folder
|
|
1674 |
result = EKeyWasConsumed;
|
|
1675 |
}
|
|
1676 |
break;
|
|
1677 |
}
|
|
1678 |
|
|
1679 |
case EKeyRightArrow: // East
|
|
1680 |
{
|
|
1681 |
if ( iCurrentFolder != KFavouritesRootUid )
|
|
1682 |
{
|
|
1683 |
// We are in some folder. Move between subfolders in the
|
|
1684 |
// rightward direction.
|
|
1685 |
if ( !ApiProvider().IsEmbeddedModeOn() )
|
|
1686 |
{
|
|
1687 |
OpenNextFolderL( /*aForward=*/ETrue );
|
|
1688 |
}
|
|
1689 |
//return EKeyWasConsumed anyway, since in embedded mode user can access only the launch folder
|
|
1690 |
result = EKeyWasConsumed;
|
|
1691 |
}
|
|
1692 |
break;
|
|
1693 |
}
|
|
1694 |
|
|
1695 |
case EKeyRightUpArrow: // Northeast
|
|
1696 |
case EStdKeyDevice11: // : Extra KeyEvent supports diagonal event simulator wedge
|
|
1697 |
case EKeyRightDownArrow: // Southeast
|
|
1698 |
case EStdKeyDevice12: // : Extra KeyEvent supports diagonal event simulator wedge
|
|
1699 |
case EKeyLeftDownArrow: // Southwest
|
|
1700 |
case EStdKeyDevice13: // : Extra KeyEvent supports diagonal event simulator wedge
|
|
1701 |
case EKeyLeftUpArrow: // Northwest
|
|
1702 |
case EStdKeyDevice10: // : Extra KeyEvent supports diagonal event simulator wedge
|
|
1703 |
{ // Here, "eat" all of the diagonals so they have no effect
|
|
1704 |
result = EKeyWasConsumed;
|
|
1705 |
break;
|
|
1706 |
}
|
|
1707 |
|
|
1708 |
|
|
1709 |
case EKeyBackspace:
|
|
1710 |
case EKeyDelete:
|
|
1711 |
{
|
|
1712 |
TBrowserFavouritesSelectionState state =
|
|
1713 |
iContainer->Listbox()->SelectionStateL();
|
|
1714 |
if ( state.AnyDeletable() )
|
|
1715 |
{
|
|
1716 |
// We don't editing (not in Goto Pane),
|
|
1717 |
// and have something to delete. In this case, Clear key
|
|
1718 |
// deletes the selection (or highlighted items).
|
|
1719 |
if ( ((iContainer->Listbox()->CurrentItem()->ContextId() == NULL ) &&
|
|
1720 |
(iContainer->Listbox()->CurrentItem()->Uid() != KFavouritesAdaptiveItemsFolderUid) ||
|
|
1721 |
state.AnyMarked() )
|
|
1722 |
)
|
|
1723 |
{
|
|
1724 |
DeleteMarkedItemsL();
|
|
1725 |
}
|
|
1726 |
result = EKeyWasConsumed;
|
|
1727 |
}
|
|
1728 |
break;
|
|
1729 |
}
|
|
1730 |
|
|
1731 |
case EKeyOK:
|
|
1732 |
// OK key is handled through MSK handling
|
|
1733 |
result = EKeyWasConsumed;
|
|
1734 |
break;
|
|
1735 |
|
|
1736 |
case EKeyEnter:
|
|
1737 |
{
|
|
1738 |
if ( !(aKeyEvent.iModifiers & EModifierShift) )
|
|
1739 |
{
|
|
1740 |
TBrowserFavouritesSelectionState state =
|
|
1741 |
iContainer->Listbox()->SelectionStateL();
|
|
1742 |
if ( state.IsEmpty() || state.AnyMarked() )
|
|
1743 |
{
|
|
1744 |
// Selection key (alone) pressed when there are marked
|
|
1745 |
// items or the list is empty. Bring up context sensitive
|
|
1746 |
// (OK-Options) menu.
|
|
1747 |
MenuBar( )->
|
|
1748 |
SetMenuTitleResourceId( OkOptionsMenuResourceId() );
|
|
1749 |
iShowOkOptions = ETrue;
|
|
1750 |
// Call to menu activation is trapped - to make sure that
|
|
1751 |
// iShowOkOptions and bad menu doesn't stick in.
|
|
1752 |
TRAP_IGNORE( ProcessCommandL( EAknSoftkeyOptions ) );
|
|
1753 |
iShowOkOptions = EFalse;
|
|
1754 |
MenuBar( )->
|
|
1755 |
SetMenuTitleResourceId( OptionsMenuResourceId() );
|
|
1756 |
|
|
1757 |
// Update CBA to include context menu MSK icon
|
|
1758 |
UpdateCbaL();
|
|
1759 |
|
|
1760 |
result = EKeyWasConsumed;
|
|
1761 |
}
|
|
1762 |
}
|
|
1763 |
break;
|
|
1764 |
}
|
|
1765 |
|
|
1766 |
default:
|
|
1767 |
{
|
|
1768 |
break;
|
|
1769 |
}
|
|
1770 |
}
|
|
1771 |
|
|
1772 |
return result;
|
|
1773 |
}
|
|
1774 |
|
|
1775 |
// ---------------------------------------------------------
|
|
1776 |
// CBrowserFavouritesView::HandleFavouritesModelChangeL
|
|
1777 |
// ---------------------------------------------------------
|
|
1778 |
//
|
|
1779 |
void CBrowserFavouritesView::HandleFavouritesModelChangeL()
|
|
1780 |
{
|
|
1781 |
// Change in favourites database.
|
|
1782 |
if ( iRefresh )
|
|
1783 |
{
|
|
1784 |
RefreshL();
|
|
1785 |
}
|
|
1786 |
iRefresh = ETrue;
|
|
1787 |
}
|
|
1788 |
|
|
1789 |
// ---------------------------------------------------------
|
|
1790 |
// CBrowserFavouritesView::HandleCommsModelChangeL
|
|
1791 |
// ---------------------------------------------------------
|
|
1792 |
//
|
|
1793 |
void CBrowserFavouritesView::HandleCommsModelChangeL()
|
|
1794 |
{
|
|
1795 |
// Change in AP-s (CommsDb).
|
|
1796 |
RefreshL( /*aDbErrorNote=*/EFalse );
|
|
1797 |
}
|
|
1798 |
|
|
1799 |
void CBrowserFavouritesView::OpenFixedFolderL(TInt aUid)
|
|
1800 |
{
|
|
1801 |
OpenFolderL(aUid);
|
|
1802 |
}
|
|
1803 |
|
|
1804 |
// ---------------------------------------------------------
|
|
1805 |
// CBrowserFavouritesView::SetPreferedCurrentItemL
|
|
1806 |
// ---------------------------------------------------------
|
|
1807 |
//
|
|
1808 |
void CBrowserFavouritesView::SetPreferedCurrentItemL()
|
|
1809 |
{
|
|
1810 |
// check the current item is exist
|
|
1811 |
if ( iContainer->Listbox()->CurrentItem() )
|
|
1812 |
{
|
|
1813 |
iContainer->Listbox()->GetDefaultData().iPreferedId =
|
|
1814 |
iContainer->Listbox()->CurrentItem()->Uid();
|
|
1815 |
iModel->Database().SetPreferredUid(
|
|
1816 |
iCurrentFolder,iContainer->Listbox()->CurrentItem()->Uid() );
|
|
1817 |
iRefresh = ETrue;
|
|
1818 |
}
|
|
1819 |
}
|
|
1820 |
|
|
1821 |
// ---------------------------------------------------------
|
|
1822 |
// CBrowserFavouritesView::SetUnPreferedCurrentItemL
|
|
1823 |
// ---------------------------------------------------------
|
|
1824 |
//
|
|
1825 |
void CBrowserFavouritesView::SetUnPreferedCurrentItemL()
|
|
1826 |
{
|
|
1827 |
// check the current item is exist
|
|
1828 |
if ( iContainer->Listbox()->CurrentItem() )
|
|
1829 |
{
|
|
1830 |
iContainer->Listbox()->GetDefaultData().iPreferedId = NULL;
|
|
1831 |
iModel->Database().SetPreferredUid( iCurrentFolder,NULL );
|
|
1832 |
iRefresh = ETrue;
|
|
1833 |
}
|
|
1834 |
}
|
|
1835 |
|
|
1836 |
// ---------------------------------------------------------
|
|
1837 |
// CBrowserFavouritesView::ConfigContextMenu
|
|
1838 |
// ---------------------------------------------------------
|
|
1839 |
//
|
|
1840 |
void CBrowserFavouritesView::ConfigContextMenu()
|
|
1841 |
{
|
|
1842 |
// Config Context Sensitive Menu Resource and Type when items are marked
|
|
1843 |
|
|
1844 |
MenuBar()->SetContextMenuTitleResourceId( OkOptionsMenuResourceId());
|
|
1845 |
MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
|
|
1846 |
MenuBar()->SetMenuTitleResourceId( OptionsMenuResourceId());
|
|
1847 |
MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions); // adds task swapper menu item first
|
|
1848 |
}
|
|
1849 |
|
|
1850 |
void CBrowserFavouritesView::UpdateToolbarButtonsState()
|
|
1851 |
{
|
|
1852 |
LOG_ENTERFN("CBrowserFavouritesView::UpdateToolbarButtonsState");
|
|
1853 |
BROWSER_LOG( ( _L("Implementation is not required here") ) );
|
|
1854 |
}
|
|
1855 |
|
|
1856 |
// End of File
|