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