|
1 /* |
|
2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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: View for folder |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <StringLoader.h> |
|
22 #include <akntitle.h> |
|
23 #include <aknnavi.h> |
|
24 #include <aknnavide.h> |
|
25 #include <barsread.h> |
|
26 #include <aknlists.h> |
|
27 #include <AknsConstants.h> |
|
28 #include <AknInfoPopupNoteController.h> |
|
29 #include <csxhelp/fmgr.hlp.hrh> |
|
30 #include <CFileManagerEngine.h> |
|
31 #include <FileManager.rsg> |
|
32 #include <FileManagerView.rsg> |
|
33 #include <TFileManagerDriveInfo.h> |
|
34 #include <CFileManagerCommonDefinitions.h> |
|
35 #include <FileManagerDebug.h> |
|
36 #include "CFileManagerFoldersView.h" |
|
37 #include "CFileManagerFileListContainer.h" |
|
38 #include "CFileManagerAppUi.h" |
|
39 #include "CFileManagerDocument.h" |
|
40 #include "Cfilemanagerfoldernavigationpane.h" |
|
41 #include "FileManager.hrh" |
|
42 #include "FileManagerUID.h" |
|
43 |
|
44 // CONSTANTS |
|
45 const TUid CFileManagerFoldersView::KOpenFromSearchResultsView = |
|
46 { EOpenFromSearchResultsView }; |
|
47 |
|
48 |
|
49 // ============================ MEMBER FUNCTIONS =============================== |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CFileManagerFoldersView::CFileManagerFoldersView |
|
53 // C++ default constructor can NOT contain any code, that |
|
54 // might leave. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CFileManagerFoldersView::CFileManagerFoldersView() |
|
58 { |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CFileManagerFoldersView::ConstructL |
|
63 // Symbian 2nd phase constructor can leave. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CFileManagerFoldersView::ConstructL() |
|
67 { |
|
68 CFileManagerViewBase::ConstructL( R_FILEMANAGER_FOLDERS_VIEW ); |
|
69 |
|
70 CEikStatusPane* sp = StatusPane(); |
|
71 |
|
72 iNaviPane = static_cast< CAknNavigationControlContainer* > |
|
73 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
74 |
|
75 iPopupController = CAknInfoPopupNoteController::NewL(); |
|
76 iPopupController->SetTimeDelayBeforeShow( 0 ); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CFileManagerFoldersView::NewLC |
|
81 // Two-phased constructor. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 CFileManagerFoldersView* CFileManagerFoldersView::NewLC() |
|
85 { |
|
86 CFileManagerFoldersView* self = new( ELeave ) CFileManagerFoldersView; |
|
87 |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(); |
|
90 |
|
91 return self; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CFileManagerFoldersView::~CFileManagerFoldersView |
|
96 // Destructor |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CFileManagerFoldersView::~CFileManagerFoldersView() |
|
100 { |
|
101 delete iPopupController; |
|
102 delete iNaviDecorator; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CFileManagerFoldersView::Id |
|
107 // |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 TUid CFileManagerFoldersView::Id() const |
|
111 { |
|
112 return CFileManagerAppUi::KFileManagerFoldersViewId; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CFileManagerFoldersView::CreateContainerL |
|
117 // |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 CFileManagerContainerBase* CFileManagerFoldersView::CreateContainerL() |
|
121 { |
|
122 return CFileManagerFileListContainer::NewL( |
|
123 ClientRect(), |
|
124 iIndex, |
|
125 CFileManagerFileListContainer::EListFolder, |
|
126 R_QTN_SELEC_EMPTY_LIST, |
|
127 KFMGR_HLP_MEM_STORE_VIEW ); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CFileManagerFoldersView::DoActivateL |
|
132 // |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CFileManagerFoldersView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
136 TUid aCustomMessageId, |
|
137 const TDesC8& aCustomMessage ) |
|
138 { |
|
139 FUNC_LOG |
|
140 |
|
141 if ( aCustomMessageId == KOpenFromSearchResultsView ) |
|
142 { |
|
143 iInitialFolderDepth = iEngine.FolderLevel(); |
|
144 } |
|
145 else |
|
146 { |
|
147 // Check embedded app exit |
|
148 CFileManagerAppUi* appUi = |
|
149 static_cast< CFileManagerAppUi* >( AppUi() ); |
|
150 appUi->ExitEmbeddedAppIfNeededL(); |
|
151 |
|
152 iInitialFolderDepth = 1; // First folder view level |
|
153 } |
|
154 |
|
155 CFileManagerViewBase::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage ); |
|
156 |
|
157 TResourceReader reader; |
|
158 iCoeEnv->CreateResourceReaderLC( reader, R_FILEMANAGER_FOLDER_NAVIGATION_PANE ); |
|
159 iNaviControl = CFileManagerFolderNavigationPane::NewL( iEngine.Memory(), 0, reader ); |
|
160 CleanupStack::PopAndDestroy(); // reader |
|
161 |
|
162 iNaviControl->SetObserver( this ); |
|
163 |
|
164 iNaviDecorator = CAknNavigationDecorator::NewL( iNaviPane, iNaviControl ); |
|
165 iNaviDecorator->SetContainerWindowL( *iNaviPane ); |
|
166 iNaviPane->PushL( *iNaviDecorator ); |
|
167 |
|
168 RefreshTitleL(); |
|
169 iEngine.SetState( CFileManagerEngine::ENavigation ); |
|
170 iEngine.SetObserver( this ); |
|
171 iEngine.RefreshDirectory(); |
|
172 } |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CFileManagerFoldersView::DoDeactivate |
|
175 // |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CFileManagerFoldersView::DoDeactivate() |
|
179 { |
|
180 FUNC_LOG |
|
181 |
|
182 CFileManagerViewBase::DoDeactivate(); |
|
183 |
|
184 iNaviPane->Pop( iNaviDecorator ); |
|
185 delete iNaviDecorator; |
|
186 iNaviDecorator = NULL; |
|
187 iNaviControl = NULL; // Not owned and deleted by decorator |
|
188 |
|
189 iPopupController->HideInfoPopupNote(); |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CFileManagerFoldersView::RefreshTitleL |
|
194 // |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CFileManagerFoldersView::RefreshTitleL() |
|
198 { |
|
199 static_cast< CFileManagerAppUi* >( AppUi() )->SetTitleL( |
|
200 iEngine.LocalizedNameOfCurrentDirectory() ); |
|
201 |
|
202 if ( iNaviControl ) // May be deleted by view deactivation |
|
203 { |
|
204 iNaviControl->ChangeRootL( iEngine.Memory() ); |
|
205 iNaviControl->SetFolderDepth( iEngine.FolderLevel() ); |
|
206 } |
|
207 |
|
208 iNaviPane->DrawDeferred(); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CFileManagerFoldersView::HandleCommandL |
|
213 // |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void CFileManagerFoldersView::HandleCommandL( TInt aCommand ) |
|
217 { |
|
218 switch( aCommand ) |
|
219 { |
|
220 case EAknSoftkeyBack: |
|
221 { |
|
222 BackstepL(); |
|
223 break; |
|
224 } |
|
225 case EFileManagerOpen: |
|
226 { |
|
227 iPopupController->HideInfoPopupNote(); |
|
228 CFileManagerViewBase::CmdOpenL(); |
|
229 break; |
|
230 } |
|
231 default: |
|
232 { |
|
233 CFileManagerViewBase::HandleCommandL( aCommand ); |
|
234 break; |
|
235 } |
|
236 } |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CFileManagerFoldersView::DirectoryChangedL |
|
241 // |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CFileManagerFoldersView::DirectoryChangedL() |
|
245 { |
|
246 FUNC_LOG |
|
247 |
|
248 CFileManagerAppUi* appUi = static_cast< CFileManagerAppUi* >( AppUi() ); |
|
249 |
|
250 if ( iEngine.FolderLevel() < iInitialFolderDepth || !iContainer ) |
|
251 { |
|
252 appUi->CloseFoldersViewL(); |
|
253 } |
|
254 else |
|
255 { |
|
256 if ( !appUi->IsSearchViewOpen() ) |
|
257 { |
|
258 appUi->ExitEmbeddedAppIfNeededL(); |
|
259 } |
|
260 TInt usb_err(KErrNone); |
|
261 TRAP( usb_err,RefreshDriveInfoL() ); |
|
262 if (usb_err != KErrNone) |
|
263 { |
|
264 usbWrongRemoved = ETrue; |
|
265 HBufC* error = StringLoader::LoadLC(R_QTN_SELEC_EMPTY_LIST); |
|
266 |
|
267 if (iContainer) |
|
268 { |
|
269 iContainer->ListBoxSetTextL(*error); |
|
270 } |
|
271 CleanupStack::PopAndDestroy(error); |
|
272 } |
|
273 else |
|
274 { |
|
275 TFileManagerDriveInfo& drvInfo( DriveInfo() ); |
|
276 if ( !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) ) |
|
277 { |
|
278 //User::Leave(KErrPathNotFound); |
|
279 HBufC* error = StringLoader::LoadLC(R_QTN_SELEC_EMPTY_LIST); |
|
280 |
|
281 if (iContainer) |
|
282 { |
|
283 iContainer->ListBoxSetTextL(*error); |
|
284 } |
|
285 CleanupStack::PopAndDestroy(error); |
|
286 } |
|
287 else |
|
288 { |
|
289 usbWrongRemoved = EFalse; |
|
290 TInt index( iEngine.CurrentIndex() ); |
|
291 if ( index != KErrNotFound ) |
|
292 { |
|
293 iContainer->RefreshListL( index ); |
|
294 } |
|
295 else |
|
296 { |
|
297 iContainer->RefreshListL( iIndex ); |
|
298 } |
|
299 |
|
300 } |
|
301 } |
|
302 RefreshTitleL(); |
|
303 iFolderDepth = iEngine.FolderLevel(); |
|
304 } |
|
305 } |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // CFileManagerFoldersView::HandleResourceChangeL |
|
309 // (other items were commented in a header). |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 void CFileManagerFoldersView::HandleResourceChangeL( TInt aType ) |
|
313 { |
|
314 if ( iNaviControl ) // May be deleted by view deactivation |
|
315 { |
|
316 iNaviControl->HandleResourceChangeL( aType ); |
|
317 } |
|
318 } |
|
319 |
|
320 // ------------------------------------------------------------------------------ |
|
321 // CFileManagerFoldersView::UpdateCbaL |
|
322 // |
|
323 // ------------------------------------------------------------------------------ |
|
324 // |
|
325 void CFileManagerFoldersView::UpdateCbaL() |
|
326 { |
|
327 UpdateCommonCbaL(); |
|
328 } |
|
329 |
|
330 // ------------------------------------------------------------------------------ |
|
331 // CFileManagerFoldersView::BackstepL |
|
332 // |
|
333 // ------------------------------------------------------------------------------ |
|
334 // |
|
335 void CFileManagerFoldersView::BackstepL( |
|
336 TInt aBacksteps ) |
|
337 { |
|
338 |
|
339 |
|
340 |
|
341 if ( usbWrongRemoved ) |
|
342 { |
|
343 CFileManagerAppUi* appUi = static_cast<CFileManagerAppUi*> (AppUi()); |
|
344 usbWrongRemoved = EFalse; |
|
345 iFolderDepth = 0; |
|
346 iIndex = 0; |
|
347 appUi->CloseFoldersViewL(); |
|
348 } |
|
349 else |
|
350 { |
|
351 if (iActiveProcess != ENoProcess) |
|
352 { |
|
353 return; // Ignore to avoid container mess up |
|
354 } |
|
355 |
|
356 iPopupController->HideInfoPopupNote(); |
|
357 CFileManagerAppUi* appUi = static_cast<CFileManagerAppUi*> (AppUi()); |
|
358 TInt level(iEngine.FolderLevel()); |
|
359 |
|
360 while ( aBacksteps > 0 ) |
|
361 { |
|
362 if ( level < iInitialFolderDepth ) |
|
363 { |
|
364 break; |
|
365 } |
|
366 TRAP_IGNORE( iEngine.BackstepL() ); |
|
367 --level; |
|
368 --aBacksteps; |
|
369 } |
|
370 |
|
371 if ( !appUi->IsSearchViewOpen() ) |
|
372 { |
|
373 appUi->ExitEmbeddedAppIfNeededL(); |
|
374 } |
|
375 |
|
376 if (level < iInitialFolderDepth) |
|
377 { |
|
378 iFolderDepth = 0; |
|
379 iIndex = 0; |
|
380 appUi->CloseFoldersViewL(); |
|
381 } |
|
382 else |
|
383 { |
|
384 iEngine.SetObserver(this); |
|
385 iEngine.RefreshDirectory(); |
|
386 } |
|
387 } |
|
388 } |
|
389 |
|
390 // ------------------------------------------------------------------------------ |
|
391 // CFileManagerFoldersView::FolderName |
|
392 // |
|
393 // ------------------------------------------------------------------------------ |
|
394 // |
|
395 TPtrC CFileManagerFoldersView::FolderName( const TInt aLevel ) |
|
396 { |
|
397 if ( !aLevel ) |
|
398 { |
|
399 // Get memory store name |
|
400 return iEngine.CurrentDriveName(); |
|
401 } |
|
402 |
|
403 // Get folder name |
|
404 TPtrC dir( iEngine.CurrentDirectory() ); |
|
405 TInt drive = TDriveUnit( dir ); |
|
406 TPtrC root( iEngine.DriveRootDirectory( drive ) ); |
|
407 TInt count( dir.Length() ); |
|
408 TInt bsCount( 0 ); |
|
409 |
|
410 for ( TInt i( root.Length() ); i < count; ) |
|
411 { |
|
412 TPtrC ptr( dir.Mid( i ) ); |
|
413 TInt j( ptr.Locate( KFmgrBackslash()[ 0 ] ) ); |
|
414 if ( j != KErrNotFound ) |
|
415 { |
|
416 ++bsCount; |
|
417 if ( bsCount == aLevel ) |
|
418 { |
|
419 // Use localised folder name if it exists |
|
420 TPtrC locName( iEngine.LocalizedName( dir.Left( |
|
421 i + j + 1 ) ) ); |
|
422 if ( locName.Length() ) |
|
423 { |
|
424 return locName; |
|
425 } |
|
426 return TPtrC( ptr.Left( j ) ); |
|
427 } |
|
428 } |
|
429 else |
|
430 { |
|
431 break; |
|
432 } |
|
433 i += j + 1; |
|
434 } |
|
435 return TPtrC( KNullDesC ); |
|
436 } |
|
437 |
|
438 // ------------------------------------------------------------------------------ |
|
439 // CFileManagerFoldersView::HandleFolderNaviEventL |
|
440 // |
|
441 // ------------------------------------------------------------------------------ |
|
442 // |
|
443 void CFileManagerFoldersView::HandleFolderNaviEventL( |
|
444 TNaviEvent aEvent, TInt aValue ) |
|
445 { |
|
446 switch ( aEvent ) |
|
447 { |
|
448 case ENaviTapDown: |
|
449 { |
|
450 iPopupController->HideInfoPopupNote(); |
|
451 break; |
|
452 } |
|
453 case ENaviTapUp: |
|
454 { |
|
455 if ( aValue != KErrNotFound ) |
|
456 { |
|
457 TInt level( iEngine.FolderLevel() ); |
|
458 if ( level > aValue ) |
|
459 { |
|
460 BackstepL( level - aValue ); |
|
461 } |
|
462 } |
|
463 break; |
|
464 } |
|
465 case ENaviLongTap: |
|
466 { |
|
467 if ( aValue != KErrNotFound ) |
|
468 { |
|
469 TPtrC folder( FolderName( aValue ) ); |
|
470 if ( folder.Length() ) |
|
471 { |
|
472 iPopupController->SetTextL( folder ); |
|
473 iPopupController->ShowInfoPopupNote(); |
|
474 } |
|
475 } |
|
476 break; |
|
477 } |
|
478 default: |
|
479 { |
|
480 break; |
|
481 } |
|
482 } |
|
483 } |
|
484 |
|
485 // End of File |