author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:57:31 +0300 | |
branch | RCL_3 |
changeset 22 | f5c50b8af68c |
parent 21 | 65326cf895ed |
permissions | -rw-r--r-- |
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 |
{ |
|
22
f5c50b8af68c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
263 |
// Manually deactivate marking mode if folder path |
f5c50b8af68c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
264 |
// does not exist. |
f5c50b8af68c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
265 |
if ( iContainer->IsMarkingModeActivated() ) |
f5c50b8af68c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
266 |
{ |
f5c50b8af68c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
267 |
iContainer->SetMarkingMode( EFalse ); |
f5c50b8af68c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
268 |
} |
f5c50b8af68c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
269 |
User::Leave( KErrPathNotFound ); |
21 | 270 |
} |
271 |
else |
|
272 |
{ |
|
273 |
TInt index( iEngine.CurrentIndex() ); |
|
274 |
if ( index != KErrNotFound ) |
|
275 |
{ |
|
276 |
iContainer->RefreshListL( index ); |
|
277 |
} |
|
278 |
else |
|
279 |
{ |
|
280 |
iContainer->RefreshListL( iIndex ); |
|
281 |
} |
|
282 |
RefreshTitleL(); |
|
283 |
} |
|
284 |
iFolderDepth = iEngine.FolderLevel(); |
|
285 |
} |
|
286 |
} |
|
287 |
||
288 |
// ----------------------------------------------------------------------------- |
|
289 |
// CFileManagerFoldersView::HandleResourceChangeL |
|
290 |
// (other items were commented in a header). |
|
291 |
// ----------------------------------------------------------------------------- |
|
292 |
// |
|
293 |
void CFileManagerFoldersView::HandleResourceChangeL( TInt aType ) |
|
294 |
{ |
|
295 |
if ( iNaviControl ) // May be deleted by view deactivation |
|
296 |
{ |
|
297 |
iNaviControl->HandleResourceChangeL( aType ); |
|
298 |
} |
|
299 |
} |
|
300 |
||
301 |
// ------------------------------------------------------------------------------ |
|
302 |
// CFileManagerFoldersView::UpdateCbaL |
|
303 |
// |
|
304 |
// ------------------------------------------------------------------------------ |
|
305 |
// |
|
306 |
void CFileManagerFoldersView::UpdateCbaL() |
|
307 |
{ |
|
308 |
UpdateCommonCbaL(); |
|
309 |
} |
|
310 |
||
311 |
// ------------------------------------------------------------------------------ |
|
312 |
// CFileManagerFoldersView::BackstepL |
|
313 |
// |
|
314 |
// ------------------------------------------------------------------------------ |
|
315 |
// |
|
316 |
void CFileManagerFoldersView::BackstepL( |
|
317 |
TInt aBacksteps ) |
|
318 |
{ |
|
319 |
if (iActiveProcess != ENoProcess) |
|
320 |
{ |
|
321 |
return; // Ignore to avoid container mess up |
|
322 |
} |
|
323 |
iPopupController->HideInfoPopupNote(); |
|
324 |
CFileManagerAppUi* appUi = static_cast<CFileManagerAppUi*> (AppUi()); |
|
325 |
TInt level(iEngine.FolderLevel()); |
|
326 |
while ( aBacksteps > 0 ) |
|
327 |
{ |
|
328 |
if ( level < iInitialFolderDepth ) |
|
329 |
{ |
|
330 |
break; |
|
331 |
} |
|
332 |
TRAP_IGNORE( iEngine.BackstepL() ); |
|
333 |
--level; |
|
334 |
--aBacksteps; |
|
335 |
} |
|
336 |
||
337 |
if ( !appUi->IsSearchViewOpen() ) |
|
338 |
{ |
|
339 |
appUi->ExitEmbeddedAppIfNeededL(); |
|
340 |
} |
|
341 |
||
342 |
if (level < iInitialFolderDepth) |
|
343 |
{ |
|
344 |
iFolderDepth = 0; |
|
345 |
iIndex = 0; |
|
346 |
appUi->CloseFoldersViewL(); |
|
347 |
} |
|
348 |
else |
|
349 |
{ |
|
350 |
iEngine.SetObserver(this); |
|
351 |
iEngine.RefreshDirectory(); |
|
352 |
} |
|
353 |
} |
|
354 |
||
355 |
// ------------------------------------------------------------------------------ |
|
356 |
// CFileManagerFoldersView::FolderName |
|
357 |
// |
|
358 |
// ------------------------------------------------------------------------------ |
|
359 |
// |
|
360 |
TPtrC CFileManagerFoldersView::FolderName( const TInt aLevel ) |
|
361 |
{ |
|
362 |
if ( !aLevel ) |
|
363 |
{ |
|
364 |
// Get memory store name |
|
365 |
return iEngine.CurrentDriveName(); |
|
366 |
} |
|
367 |
||
368 |
// Get folder name |
|
369 |
TPtrC dir( iEngine.CurrentDirectory() ); |
|
370 |
TInt drive = TDriveUnit( dir ); |
|
371 |
TPtrC root( iEngine.DriveRootDirectory( drive ) ); |
|
372 |
TInt count( dir.Length() ); |
|
373 |
TInt bsCount( 0 ); |
|
374 |
||
375 |
for ( TInt i( root.Length() ); i < count; ) |
|
376 |
{ |
|
377 |
TPtrC ptr( dir.Mid( i ) ); |
|
378 |
TInt j( ptr.Locate( KFmgrBackslash()[ 0 ] ) ); |
|
379 |
if ( j != KErrNotFound ) |
|
380 |
{ |
|
381 |
++bsCount; |
|
382 |
if ( bsCount == aLevel ) |
|
383 |
{ |
|
384 |
// Use localised folder name if it exists |
|
385 |
TPtrC locName( iEngine.LocalizedName( dir.Left( |
|
386 |
i + j + 1 ) ) ); |
|
387 |
if ( locName.Length() ) |
|
388 |
{ |
|
389 |
return locName; |
|
390 |
} |
|
391 |
return TPtrC( ptr.Left( j ) ); |
|
392 |
} |
|
393 |
} |
|
394 |
else |
|
395 |
{ |
|
396 |
break; |
|
397 |
} |
|
398 |
i += j + 1; |
|
399 |
} |
|
400 |
return TPtrC( KNullDesC ); |
|
401 |
} |
|
402 |
||
403 |
// ------------------------------------------------------------------------------ |
|
404 |
// CFileManagerFoldersView::HandleFolderNaviEventL |
|
405 |
// |
|
406 |
// ------------------------------------------------------------------------------ |
|
407 |
// |
|
408 |
void CFileManagerFoldersView::HandleFolderNaviEventL( |
|
409 |
TNaviEvent aEvent, TInt aValue ) |
|
410 |
{ |
|
411 |
switch ( aEvent ) |
|
412 |
{ |
|
413 |
case ENaviTapDown: |
|
414 |
{ |
|
415 |
iPopupController->HideInfoPopupNote(); |
|
416 |
break; |
|
417 |
} |
|
418 |
case ENaviTapUp: |
|
419 |
{ |
|
420 |
if ( aValue != KErrNotFound ) |
|
421 |
{ |
|
422 |
TInt level( iEngine.FolderLevel() ); |
|
423 |
if ( level > aValue ) |
|
424 |
{ |
|
425 |
BackstepL( level - aValue ); |
|
426 |
} |
|
427 |
} |
|
428 |
break; |
|
429 |
} |
|
430 |
case ENaviLongTap: |
|
431 |
{ |
|
432 |
if ( aValue != KErrNotFound ) |
|
433 |
{ |
|
434 |
TPtrC folder( FolderName( aValue ) ); |
|
435 |
if ( folder.Length() ) |
|
436 |
{ |
|
437 |
iPopupController->SetTextL( folder ); |
|
438 |
iPopupController->ShowInfoPopupNote(); |
|
439 |
} |
|
440 |
} |
|
441 |
break; |
|
442 |
} |
|
443 |
default: |
|
444 |
{ |
|
445 |
break; |
|
446 |
} |
|
447 |
} |
|
448 |
} |
|
449 |
||
450 |
// End of File |