utilityapps/filebrowser/ui/src/fbfolderselectorwrapper.cpp
changeset 55 2d9cac8919d3
parent 51 b048e15729d6
equal deleted inserted replaced
53:819e59dfc032 55:2d9cac8919d3
       
     1 /*
       
     2 * Copyright (c) 2010 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "fbfolderselectorwrapper.h"
       
    19 #include "FBFolderSelector.h"
       
    20 
       
    21 #include <QString>
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 
       
    25 /**
       
    26  * Constructor
       
    27  */
       
    28 FbFolderSelectorWrapper::FbFolderSelectorWrapper()
       
    29     : mDestinationFolderSelector(0)
       
    30 {
       
    31 }
       
    32 
       
    33 /**
       
    34  * Destructor
       
    35  */
       
    36 FbFolderSelectorWrapper::~FbFolderSelectorWrapper()
       
    37 {
       
    38     if (mDestinationFolderSelector)
       
    39         delete mDestinationFolderSelector;
       
    40 }
       
    41 
       
    42 /**
       
    43  * Initializes Engine Wrapper
       
    44  * @return true if engine was started successfully
       
    45  */
       
    46 bool FbFolderSelectorWrapper::init()
       
    47 {
       
    48     TFileName destinationFolder;
       
    49 
       
    50     TRAPD(err, mDestinationFolderSelector = CFileBrowserFolderSelector::NewL(destinationFolder, this));
       
    51     if (err != KErrNone) {
       
    52         return false;
       
    53     } else {
       
    54         //TRAP_IGNORE(mEngine->ActivateEngineL());
       
    55         //mSettings = FileBrowserSettings(&mEngine->Settings());
       
    56         return true;
       
    57     }
       
    58 }
       
    59 
       
    60 /**
       
    61   * Return current path
       
    62   */
       
    63 QString FbFolderSelectorWrapper::currentPath() const
       
    64 {
       
    65     return QString::fromUtf16(mDestinationFolderSelector->CurrentPath().Ptr(),
       
    66                               mDestinationFolderSelector->CurrentPath().Length());
       
    67 }
       
    68 
       
    69 /**
       
    70   * Return whether drive list view is active
       
    71   */
       
    72 bool FbFolderSelectorWrapper::isDriveListViewActive() const
       
    73 {
       
    74     return mDestinationFolderSelector->IsDriveListViewActive();
       
    75 }
       
    76 
       
    77 /**
       
    78   * Returns number of either drives or files depending on current view
       
    79   */
       
    80 int FbFolderSelectorWrapper::itemCount() const
       
    81 {
       
    82     if (isDriveListViewActive()) {
       
    83         return mDestinationFolderSelector->DriveEntryList()->Count();
       
    84     } else {
       
    85         return mDestinationFolderSelector->FileEntryList()->Count();
       
    86     }
       
    87 }
       
    88 
       
    89 /**
       
    90   * Returns drive entry for given \a index
       
    91   */
       
    92 FbDriveEntry FbFolderSelectorWrapper::getDriveEntry(const int index) const
       
    93 {
       
    94     TDriveEntry driveEntry;
       
    95     if (mDestinationFolderSelector->DriveEntryList()->Count() > index && index >= 0) {
       
    96         driveEntry = mDestinationFolderSelector->DriveEntryList()->At(index);
       
    97     }
       
    98     return FbDriveEntry(driveEntry);
       
    99 }
       
   100 
       
   101 /**
       
   102   * Returns file entry for given \a index
       
   103   */
       
   104 FbFileEntry FbFolderSelectorWrapper::getFileEntry(const int index) const
       
   105 {
       
   106     TFileEntry fileEntry;
       
   107     if (mDestinationFolderSelector->FileEntryList()->Count() > index && index >= 0) {
       
   108         fileEntry = mDestinationFolderSelector->FileEntryList()->At(index);
       
   109     }
       
   110     return FbFileEntry(fileEntry);
       
   111 }
       
   112 
       
   113 /**
       
   114   * Move down to selected item by \a index
       
   115   */
       
   116 void FbFolderSelectorWrapper::moveDownToDirectory(int index)
       
   117 {
       
   118     mDestinationFolderSelector->MoveDownToDirectoryL(index);
       
   119 }
       
   120 
       
   121 /**
       
   122   * Move up from folder
       
   123   */
       
   124 void FbFolderSelectorWrapper::moveUpOneLevel()
       
   125 {
       
   126     mDestinationFolderSelector->MoveUpOneLevelL();
       
   127 }
       
   128 
       
   129 void FbFolderSelectorWrapper::InformFolderSelectionChanged()
       
   130 {
       
   131     emit FolderSelectionChanged();
       
   132 }
       
   133 
       
   134 // ---------------------------------------------------------------------------