diff -r 819e59dfc032 -r 2d9cac8919d3 filebrowser/engine/FBFolderSelector.cpp --- a/filebrowser/engine/FBFolderSelector.cpp Mon Oct 04 10:09:02 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,622 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#include "FBFolderSelector.h" -#include "FBFileUtils.h" -#include "FB.hrh" -#include "FBStd.h" - -#if (!defined __SERIES60_30__ && !defined __SERIES60_31__) -#include -#endif // !defined __SERIES60_30__ && !defined __SERIES60_31__ - -// ===================================== MEMBER FUNCTIONS ===================================== - -CFileBrowserFolderSelector *CFileBrowserFolderSelector::NewL( - TDes& aReturnPath, - MFolderSelectorUI *aFolderSelectorUI) - { - CFileBrowserFolderSelector* self = new(ELeave) CFileBrowserFolderSelector(aReturnPath, - aFolderSelectorUI); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -// -------------------------------------------------------------------------------------------- - -CFileBrowserFolderSelector::~CFileBrowserFolderSelector() - { - delete iFileEntryList; - delete iDriveEntryList; - - iFs.Close(); - - //iEikonEnv->InfoMsgCancel(); - } - -// -------------------------------------------------------------------------------------------- - -CFileBrowserFolderSelector::CFileBrowserFolderSelector(TDes& aReturnPath, MFolderSelectorUI *aFolderSelectorUI) : - iReturnPath(aReturnPath), - iFolderSelectorUI(aFolderSelectorUI) - { - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::ConstructL() - { - User::LeaveIfError( iFs.Connect() ); - iDriveEntryList = new(ELeave) CDriveEntryList(8); - iFileEntryList = new(ELeave) CFileEntryList(32); - iCurrentPath = KNullDesC; - - //iIsDragging = EFalse; - //EnableDragEvents(); - - // get only writeable drives - GetDriveListL(); - } - -// -------------------------------------------------------------------------------------------- - -/* -void CFileBrowserFolderSelector::HandlePointerEventL(const TPointerEvent &aPointerEvent) - { - // detect direction of dragging by comparing the start and finish points - - if (aPointerEvent.iType == TPointerEvent::EButton1Down) - { - iDragStartPoint = aPointerEvent.iPosition; - iIsDragging = EFalse; - } - else if (aPointerEvent.iType == TPointerEvent::EDrag) - { - iIsDragging = ETrue; - - return; - } - else if (aPointerEvent.iType == TPointerEvent::EButton1Up) - { - if (iIsDragging) - { - const TInt KDelta = iDragStartPoint.iX - aPointerEvent.iPosition.iX; - const TInt KThreshold = 30; - - if (KDelta < -KThreshold) // dragging to right - { - // "emulate" right key press - - TKeyEvent keyEvent; - keyEvent.iCode = EKeyRightArrow; - keyEvent.iModifiers = 0; - - TEventCode type = EEventKey; - - OfferKeyEventL(keyEvent, type); - - return; - } - else if (KDelta > KThreshold) // dragging to left - { - // "emulate" left key press - - TKeyEvent keyEvent; - keyEvent.iCode = EKeyLeftArrow; - keyEvent.iModifiers = 0; - - TEventCode type = EEventKey; - - OfferKeyEventL(keyEvent, type); - - return; - } - } - iIsDragging = EFalse; - } - else - { - iIsDragging = EFalse; - } - - CAknListQueryDialog::HandlePointerEventL(aPointerEvent); - } -*/ - -// -------------------------------------------------------------------------------------------- - -TKeyResponse CFileBrowserFolderSelector::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) - { -// if(aType != EEventKey) -// return EKeyWasNotConsumed; - -// if (aKeyEvent.iCode == EKeyLeftArrow && !IsDriveListViewActive()) -// { -// MoveUpOneLevelL(); -// return EKeyWasConsumed; -// } -// else if (aKeyEvent.iCode == EKeyRightArrow && ((ListBox()->CurrentItemIndex() > 0 && !IsDriveListViewActive()) || IsDriveListViewActive())) -// { -// MoveDownToDirectoryL(); -// return EKeyWasConsumed; -// } -// else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) -// { -// if (IsDriveListViewActive()) -// { -// MoveDownToDirectoryL(); -// return EKeyWasConsumed; -// } -// else if (ListBox()->CurrentItemIndex() == 0) -// { -// TryExitL(EAknSoftkeyOk); -// return EKeyWasConsumed; -// } -// else if (ListBox()->CurrentItemIndex() > 0) -// { -// MoveDownToDirectoryL(); -// return EKeyWasConsumed; -// } -// } -// -// TKeyResponse result = CAknDialog::OfferKeyEventL(aKeyEvent, aType); -// -// // update LSK label -// if (!IsDriveListViewActive()) -// { -// if (ListBox()->CurrentItemIndex() == 0) -// { -// ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, iLSKActionText); -// ButtonGroupContainer().DrawNow(); -// } -// else -// { -// ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Open dir")); -// ButtonGroupContainer().DrawNow(); -// } -// } -// -// return result; - return TKeyResponse(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::PreLayoutDynInitL() - { -// CAknListQueryDialog::PreLayoutDynInitL(); - -// static_cast(ListBox())->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::PostLayoutDynInitL() - { -// CAknListQueryDialog::PostLayoutDynInitL(); - - //w SetIconArrayL(static_cast*>(iIconArray)); - - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -TBool CFileBrowserFolderSelector::OkToExitL(TInt /*aButtonId*/) - { -// if (aButtonId == GetLeftCBAShortKeyPress()) -// { -// if (IsDriveListViewActive()) -// { -// MoveDownToDirectoryL(); -// return EFalse; -// } -// else if (ListBox()->CurrentItemIndex() == 0) -// { -// // close the dialog -// iReturnPath = iCurrentPath; -// return ETrue; -// } -// else if (ListBox()->CurrentItemIndex() > 0) -// { -// MoveDownToDirectoryL(); -// return EFalse; -// } -// else -// return EFalse; -// } -// else if (aButtonId == GetRightCBAShortKeyPress()) -// { -// return ETrue; -// } -// else -// { -// return EFalse; -// } - return ETrue; - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::MoveUpOneLevelL() - { - if (iCurrentPath.Length() <= 3) - { - // move to drive list view is the current path is already short enough - iCurrentPath = KNullDesC; - } - else - { - // move one directory up - TInt marker(iCurrentPath.Length()); - - // find second last dir marker - for (TInt i=iCurrentPath.Length()-2; i>=0; i--) - { - if (iCurrentPath[i] == '\\') - { - marker = i; - break; - } - - } - iCurrentPath = iCurrentPath.LeftTPtr(marker+1); - } - - // update view - RefreshViewL(); - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::MoveDownToDirectoryL(TInt index) - { - if (index >= 0) - { - if (IsDriveListViewActive()) - { - // currently in a drive list view, move to root of selected drive - if (iDriveEntryList->Count() > index) - { - TDriveEntry driveEntry = iDriveEntryList->At(index); - - iCurrentPath.Append(driveEntry.iLetter); - iCurrentPath.Append(_L(":\\")); - } - } - else - { - // this needed because we have an extra item in the listbox - index--; - - // append the new directory - if (iFileEntryList->Count() > index) - { - TFileEntry fileEntry = iFileEntryList->At(index); - - if (fileEntry.iEntry.IsDir()) - { - iCurrentPath.Append(fileEntry.iEntry.iName); - iCurrentPath.Append(_L("\\")); - } - } - } - - // update view - RefreshViewL(); - } - } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::RefreshViewL() - { - if (IsDriveListViewActive()) - { - GetDriveListL(); - } - else - { - GetFileListL(); - } - iFolderSelectorUI->InformFolderSelectionChanged(); - - // TODO -// if (iCurrentPath == KNullDesC) -// iEikonEnv->InfoMsgWithDuration(_L("<- up dir down dir ->"), TTimeIntervalMicroSeconds32(KMaxTInt)); -// else -// iEikonEnv->InfoMsgWithDuration(iCurrentPath, TTimeIntervalMicroSeconds32(KMaxTInt)); - -// SetItemTextArray(textArray); -// SetOwnershipType(ELbmOwnsItemArray); -// ListBox()->HandleItemAdditionL(); -// Layout(); -// ListBox()->SetCurrentItemIndex(0); -// DrawDeferred(); - } - -// -------------------------------------------------------------------------------------------- - -//TBool CFileBrowserFolderSelector::RunCopyDlgLD() -// { -// iLSKActionText.Copy(_L("Copy")); -// return ExecuteLD(1/*R_COPY_TO_FOLDER_SELECTION_QUERY*/); -// } - -//// -------------------------------------------------------------------------------------------- - -//TBool CFileBrowserFolderSelector::RunMoveDlgLD() -// { -// iLSKActionText.Copy(_L("Move")); -// return ExecuteLD(1/*R_MOVE_TO_FOLDER_SELECTION_QUERY*/); -// } - -//// -------------------------------------------------------------------------------------------- - -//TInt CAknQueryDialog::GetLeftCBAShortKeyPress() -// { -// return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(0))); -// } - -//// -------------------------------------------------------------------------------------------- - -//TInt CAknQueryDialog::GetRightCBAShortKeyPress() -// { -// return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(2))); -// } - -// -------------------------------------------------------------------------------------------- - -void CFileBrowserFolderSelector::GetDriveListL() - { - TDriveList driveList; - - // get drive listing depending of the support for network drives - if (true/*TODO iEngine->Settings().iSupportNetworkDrives*/) - { - #ifndef __SERIES60_30__ - #ifndef __SERIES60_31__ - User::LeaveIfError(iFs.DriveList(driveList, KDriveAttAll)); - #endif - #else - User::LeaveIfError(iFs.DriveList(driveList)); - #endif - } - else - { - User::LeaveIfError(iFs.DriveList(driveList)); - } - - iDriveEntryList->Reset(); - - //TDriveEntry driveEntry; - for (TInt i=0; iCount(); -// } - - if (driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttWriteProtected - && driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttLocked - && driveEntry.iVolumeInfo.iDrive.iDriveAtt != KDriveAbsent) - { - iDriveEntryList->AppendL(driveEntry); - } - } - } - } - -void CFileBrowserFolderSelector::GetFileListL() - { - iFileEntryList->Reset(); - - CDir* dir = NULL; - if (iFs.GetDir(iCurrentPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, dir) == KErrNone) - { - CleanupStack::PushL(dir); - - for (TInt i=0; iCount(); i++) - { - TFileEntry fileEntry; - fileEntry.iPath = iCurrentPath; - fileEntry.iEntry = (*dir)[i]; - fileEntry.iDirEntries = KErrNotFound; - fileEntry.iIconId = EFixedIconEmpty; - - // check for directory entries - if (fileEntry.iEntry.IsDir()) - { - fileEntry.iIconId = EFixedIconFolder; - - TFileName subPath = fileEntry.iPath; - subPath.Append(fileEntry.iEntry.iName); - subPath.Append(_L("\\")); - - // check if any sub directories - CDir* subDir = NULL; - if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone) - { - fileEntry.iDirEntries = subDir->Count(); - - for (TInt j=0; jCount(); j++) - { - TEntry entry = (*subDir)[j]; - - if (entry.IsDir()) - { - fileEntry.iIconId = EFixedIconFolderSub; - break; - } - } - - delete subDir; - } - iFileEntryList->AppendL(fileEntry); - } - } - - CleanupStack::PopAndDestroy(); //dir - } - } - -// -------------------------------------------------------------------------------------------- - -// End of File -