filebrowser/ui/src/filebrowserview.cpp
changeset 35 98924d2efce9
parent 34 e0ec97ec3cc4
child 37 c20154ccf3c0
child 41 6c7007136f84
equal deleted inserted replaced
34:e0ec97ec3cc4 35:98924d2efce9
     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 "filebrowserview.h"
       
    19 #include "filebrowsermainwindow.h"
       
    20 #include "settingsview.h"
       
    21 #include "editorview.h"
       
    22 #include "searchview.h"
       
    23 #include "enginewrapper.h"
       
    24 #include "notifications.h"
       
    25 
       
    26 #include "filebrowsermodel.h"
       
    27 
       
    28 #include <HbMainWindow>
       
    29 #include <HbMenu>
       
    30 #include <HbPopup>
       
    31 #include <HbView>
       
    32 #include <HbMessageBox>
       
    33 #include <HbAction>
       
    34 #include <HbLabel>
       
    35 #include <HbListView>
       
    36 #include <HbListViewItem>
       
    37 #include <HbListWidget>
       
    38 #include <HbLineEdit>
       
    39 #include <HbAbstractViewItem>
       
    40 #include <HbSelectionDialog>
       
    41 #include <HbValidator>
       
    42 #include <HbInputDialog>
       
    43 #include <HbToolBar>
       
    44 
       
    45 #include <QString>
       
    46 #include <QGraphicsLinearLayout>
       
    47 #include <QItemSelection>
       
    48 #include <QDebug>
       
    49 //TODO check if needed to do this way
       
    50 #include <FB.hrh>
       
    51 
       
    52 //const int DRIVEPATHLENGTH = 4;
       
    53 const QString okActionText("OK");
       
    54 const QString cancelActionText("Cancel");
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 
       
    58 FileBrowserView::FileBrowserView(FileBrowserMainWindow &mainWindow)
       
    59     : mMainWindow(mainWindow),
       
    60     mEngineWrapper(0),
       
    61     mListView(0),
       
    62     mToolBar(0),
       
    63     mNaviPane(0),
       
    64     mMainLayout(0),
       
    65     mFileBrowserModel(0),
       
    66     mOptionMenuActions(),
       
    67     mContextMenuActions(),
       
    68     mContextMenu(0),
       
    69     mToolbarBackAction(0),
       
    70     mItemHighlighted(false),
       
    71     mLocationChanged(false),
       
    72     mRemoveFileAfterCopied(false),
       
    73 //    mClipBoardInUse(false),
       
    74     mFolderContentChanged(false),
       
    75     mCurrentIndex(),
       
    76     mOldPassword(),
       
    77     mPanicCategory(),
       
    78     mAbsoluteFilePath(),
       
    79     mOverwriteOptions(),
       
    80     mModelIndex(),
       
    81     mNewFileName(),
       
    82     mProceed(false),
       
    83     mEraseMBR(false)
       
    84 {
       
    85     setTitle("File Browser");
       
    86 
       
    87     createMenu();
       
    88     createContextMenu();
       
    89     createToolBar();
       
    90 }
       
    91 
       
    92 // ---------------------------------------------------------------------------	
       
    93 
       
    94 void FileBrowserView::init(EngineWrapper *engineWrapper)
       
    95 {
       
    96     mEngineWrapper = engineWrapper;
       
    97 
       
    98     mListView = new HbListView(this);
       
    99     mFileBrowserModel = new FileBrowserModel(mEngineWrapper);
       
   100     if (!mListView->model()) {
       
   101         mListView->setModel(mFileBrowserModel);
       
   102         mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape);
       
   103         mEngineWrapper->refreshView();
       
   104         mToolbarBackAction->setEnabled(!mEngineWrapper->isDriveListViewActive());
       
   105     }
       
   106 
       
   107     //mListView->setRootIndex(mFileSystemModel->index(startPath));
       
   108     //mListView->setRootIndex(model->index());
       
   109 
       
   110     mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
       
   111 
       
   112     connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
       
   113     connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)),
       
   114             this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF)));
       
   115 
       
   116     mNaviPane = new HbLabel(this);
       
   117     mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default
       
   118     //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
       
   119     HbFontSpec fontSpec(HbFontSpec::PrimarySmall);
       
   120     mNaviPane->setFontSpec(fontSpec);
       
   121 
       
   122     // Create layout and add list view and toolbar into layout:
       
   123     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
   124     mMainLayout->addItem(mNaviPane);
       
   125     mMainLayout->addItem(mListView);
       
   126     //mMainLayout->addItem(mToolBar);
       
   127     setLayout(mMainLayout);
       
   128 }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 
       
   132 FileBrowserView::~FileBrowserView()
       
   133 {  
       
   134 //    if (mEngineWrapper) {
       
   135 //        delete mEngineWrapper;
       
   136 //    }
       
   137     if (mContextMenu) {
       
   138         mContextMenu->deleteLater();
       
   139     }
       
   140 
       
   141     delete mFileBrowserModel;
       
   142     delete mListView;
       
   143     delete mToolBar;
       
   144 }
       
   145 
       
   146 /**
       
   147   Initial setup for options menu.
       
   148   Dynamic menu update during the runtime is performed by updateOptionMenu() which
       
   149   to menu's aboutToShow() signal.
       
   150   */
       
   151 void FileBrowserView::createMenu()
       
   152 {
       
   153     createFileMenu();
       
   154     createEditMenu();
       
   155     createViewMenu();
       
   156     createToolsMenu();
       
   157 
       
   158     createSelectionMenuItem();
       
   159     createSettingsMenuItem();
       
   160     createAboutMenuItem();
       
   161     createExitMenuItem();
       
   162 
       
   163     // menu dynamic update
       
   164     connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu()));
       
   165 }
       
   166 
       
   167 /**
       
   168   Initial setup for File submenu
       
   169   */
       
   170 void FileBrowserView::createFileMenu()
       
   171 {
       
   172     mOptionMenuActions.mFileMenu = menu()->addMenu("File");
       
   173 
       
   174     mOptionMenuActions.mFileBackMoveUp = mOptionMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp()));
       
   175     mOptionMenuActions.mFileOpenDrive = mOptionMenuActions.mFileMenu->addAction("Open drive (->)", this, SLOT(fileOpenDrive()));
       
   176     mOptionMenuActions.mFileOpenDirectory = mOptionMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory()));
       
   177     mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
       
   178     //mOptionMenuActions.mFileSearch->setVisible(false);
       
   179 
       
   180     mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New");
       
   181     mOptionMenuActions.mFileNewFile = mOptionMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile()));
       
   182     mOptionMenuActions.mFileNewDirectory = mOptionMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory()));
       
   183 
       
   184     mOptionMenuActions.mFileDelete = mOptionMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
       
   185     mOptionMenuActions.mFileRename = mOptionMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
       
   186     mOptionMenuActions.mFileTouch = mOptionMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
       
   187     mOptionMenuActions.mFileProperties = mOptionMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties()));
       
   188 
       
   189 //    mOptionMenuActions.mFileChecksumsMenu = mOptionMenuActions.mFileMenu->addMenu("Checksums");
       
   190 //    mOptionMenuActions.mFileChecksumsMD5 = mOptionMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5()));
       
   191 //    mOptionMenuActions.mFileChecksumsMD2 = mOptionMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2()));
       
   192 //    mOptionMenuActions.mFileChecksumsSHA1 = mOptionMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1()));
       
   193 
       
   194     mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
       
   195     mOptionMenuActions.mFileSetAttributes->setVisible(false);
       
   196 }
       
   197 
       
   198 /**
       
   199   Initial setup for Edit submenu
       
   200   */
       
   201 void FileBrowserView::createEditMenu()
       
   202 {
       
   203     mOptionMenuActions.mEditMenu = menu()->addMenu("Edit");
       
   204 
       
   205     mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE()));
       
   206     mOptionMenuActions.mEditSnapShotToE->setVisible(false);
       
   207     mOptionMenuActions.mEditCut = mOptionMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut()));
       
   208     mOptionMenuActions.mEditCopy = mOptionMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy()));
       
   209     mOptionMenuActions.mEditPaste = mOptionMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste()));
       
   210 
       
   211     mOptionMenuActions.mEditCopyToFolder = mOptionMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder()));
       
   212     mOptionMenuActions.mEditMoveToFolder = mOptionMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder()));
       
   213 
       
   214     mOptionMenuActions.mEditSelect = mOptionMenuActions.mEditMenu->addAction("Select", this, SLOT(editSelect()));
       
   215     mOptionMenuActions.mEditUnselect = mOptionMenuActions.mEditMenu->addAction("Unselect", this, SLOT(editUnselect()));
       
   216     mOptionMenuActions.mEditSelectAll = mOptionMenuActions.mEditMenu->addAction("Select all", this, SLOT(editSelectAll()));
       
   217     mOptionMenuActions.mEditUnselectAll = mOptionMenuActions.mEditMenu->addAction("Unselect all", this, SLOT(editUnselectAll()));
       
   218 }
       
   219 
       
   220 /**
       
   221   Initial setup for View submenu
       
   222   */
       
   223 void FileBrowserView::createViewMenu()
       
   224 {
       
   225     mOptionMenuActions.mViewMenu = menu()->addMenu("View");
       
   226     mOptionMenuActions.mViewMenu->menuAction()->setVisible(false);
       
   227 
       
   228     mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries()));
       
   229     mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh()));
       
   230 }
       
   231 
       
   232 /**
       
   233   Initial setup for Tools submenu
       
   234   */
       
   235 void FileBrowserView::createToolsMenu()
       
   236 {
       
   237     mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools");
       
   238 
       
   239     mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile()));
       
   240     mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false);
       
   241     mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile()));
       
   242     //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false);
       
   243 
       
   244     mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache");
       
   245     mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false);
       
   246     mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable()));
       
   247     mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable()));
       
   248 
       
   249     mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors()));
       
   250     mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk()));
       
   251     mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false);
       
   252     mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes()));
       
   253     mOptionMenuActions.mToolsEditDataTypes->setVisible(false);
       
   254     mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors()));
       
   255 
       
   256     mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate");
       
   257     mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave()));
       
   258     mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic()));
       
   259     mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false);
       
   260     mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException()));
       
   261 
       
   262 //    mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity");
       
   263 //    mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared()));
       
   264 //    mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI()));
       
   265 //    mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI()));
       
   266 
       
   267     mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments");
       
   268     mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false);
       
   269     mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox()));
       
   270     mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts()));
       
   271     mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems()));
       
   272     mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox()));
       
   273 
       
   274     mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo()));
       
   275     mOptionMenuActions.mToolsMemoryInfo->setVisible(false);
       
   276 
       
   277     mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup");
       
   278     mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false);
       
   279     mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart()));
       
   280     mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore()));
       
   281     mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop()));
       
   282 
       
   283     mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion()));
       
   284     mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere()));
       
   285     mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false);
       
   286 }
       
   287 
       
   288 /**
       
   289   Creates Selection mode menu item in option menu
       
   290   */
       
   291 void FileBrowserView::createSelectionMenuItem()
       
   292 {
       
   293     if (!mOptionMenuActions.mSelection) {
       
   294         mOptionMenuActions.mSelection = menu()->addAction("Selection mode");
       
   295         mOptionMenuActions.mSelection->setToolTip("Selection mode");
       
   296         mOptionMenuActions.mSelection->setCheckable(true);
       
   297         connect(mOptionMenuActions.mSelection, SIGNAL(triggered()), this, SLOT(selectionModeChanged()));
       
   298     }
       
   299 }
       
   300 
       
   301 /**
       
   302   Creates Setting menu item in option menu
       
   303   */
       
   304 void FileBrowserView::createSettingsMenuItem()
       
   305 {
       
   306     mOptionMenuActions.mSetting = menu()->addAction("Settings...");
       
   307     connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView()));
       
   308 }
       
   309 
       
   310 
       
   311 /**
       
   312   Creates About menu item in option menu
       
   313   */
       
   314 void FileBrowserView::createAboutMenuItem()
       
   315 {
       
   316     // about note
       
   317     mOptionMenuActions.mAbout = menu()->addAction("About");
       
   318     connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about()));
       
   319 }
       
   320 
       
   321 /**
       
   322   Creates Exit menu item in option menu
       
   323   */
       
   324 void FileBrowserView::createExitMenuItem()
       
   325 {
       
   326     // application exit
       
   327     mOptionMenuActions.mExit = menu()->addAction("Exit");
       
   328     connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit()));
       
   329 }
       
   330 
       
   331 /**
       
   332   update menu: disk admin available only in device root view. edit available only in folder view
       
   333   when file or folder content exist in current folder, or clipboard has copied item.
       
   334   file and view menus updated every time regarding the folder content.
       
   335   tools, settings, about, exit always available.
       
   336   If there's remove and add operations at same time, always remove first
       
   337   to keep to the correct menu items order.
       
   338   */
       
   339 void FileBrowserView::updateOptionMenu()
       
   340 {
       
   341     bool isFileItemListEmpty = mFileBrowserModel->rowCount() == 0;
       
   342     bool isDriveListActive = mEngineWrapper->isDriveListViewActive();
       
   343     bool isNormalModeActive = true;       //iModel->FileUtils()->IsNormalModeActive();
       
   344     bool currentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly();   //iModel->FileUtils()->IsCurrentDriveReadOnly();
       
   345     bool currentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir();
       
   346     bool listBoxSelections = mListView->selectionModel()->selection().count() == 0;
       
   347     bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
       
   348     bool emptyClipBoard = !mEngineWrapper->isClipBoardListInUse();
       
   349     bool showSnapShot = false;           //iModel->FileUtils()->DriveSnapShotPossible();
       
   350 
       
   351     bool showEditMenu(true);
       
   352     if (isDriveListActive) {
       
   353         if (!showSnapShot || isFileItemListEmpty && emptyClipBoard)
       
   354             showEditMenu = false;
       
   355         else
       
   356             showEditMenu = true;
       
   357     } else {
       
   358         if (isFileItemListEmpty && emptyClipBoard)
       
   359             showEditMenu = false;
       
   360         else
       
   361             showEditMenu = true;
       
   362     }
       
   363 
       
   364     mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu);
       
   365     // TODO mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(isDriveListActive);
       
   366 
       
   367     mOptionMenuActions.mFileBackMoveUp->setVisible( !isDriveListActive);
       
   368 
       
   369     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpen, isFileItemListEmpty || isDriveListActive || currentItemDirectory);
       
   370     mOptionMenuActions.mFileOpenDrive->setVisible( !(isFileItemListEmpty || !isDriveListActive));
       
   371     mOptionMenuActions.mFileOpenDirectory->setVisible( !(isFileItemListEmpty || isDriveListActive || !currentItemDirectory));
       
   372 
       
   373     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive);
       
   374     //aMenuPane->SetItemDimmed(EFileBrowserCmd FileEdit, isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive);
       
   375     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || currentItemDirectory);
       
   376 
       
   377     mOptionMenuActions.mFileNewMenu->menuAction()->setVisible(!(isDriveListActive || currentDriveReadOnly));
       
   378     mOptionMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly && isSelectionMode);
       
   379     mOptionMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly && !listBoxSelections && isSelectionMode);
       
   380     mOptionMenuActions.mFileTouch->setVisible(!(isFileItemListEmpty || isDriveListActive || currentDriveReadOnly));
       
   381     mOptionMenuActions.mFileProperties->setVisible(!(isFileItemListEmpty || listBoxSelections));
       
   382     // TODO mOptionMenuActions.mFileChecksumsMenu->setVisible(!(isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive));
       
   383     // TODO mOptionMenuActions.mFileSetAttributes->setVisible(!(isFileItemListEmpty || isDriveListActive || currentDriveReadOnly));
       
   384     // TODO mOptionMenuActions.mFileCompress->setVisible(!(currentDriveReadOnly || isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive));
       
   385     // TODO mOptionMenuActions.mFileDecompress->setVisible(!(currentDriveReadOnly || isFileItemListEmpty || listBoxSelections || currentItemDirectory || isDriveListActive));
       
   386 
       
   387 //    bool currentSelected = true;    //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex());
       
   388     bool allSelected = mListView->selectionModel()->selection().count() == mFileBrowserModel->rowCount();
       
   389     bool noneSelected = mListView->selectionModel()->selection().count() != 0;
       
   390 
       
   391     //mOptionMenuActions.mEditSnapShotToE->setVisible(isDriveListActive); // TODO
       
   392     mOptionMenuActions.mEditCut->setVisible(!isDriveListActive && !currentDriveReadOnly && !isFileItemListEmpty && !isSelectionMode);
       
   393     mOptionMenuActions.mEditCopy->setVisible(!isDriveListActive && !isFileItemListEmpty);
       
   394     mOptionMenuActions.mEditPaste->setVisible(!(isDriveListActive || emptyClipBoard || currentDriveReadOnly));
       
   395     mOptionMenuActions.mEditCopyToFolder->setVisible(!(isDriveListActive || isFileItemListEmpty));
       
   396     mOptionMenuActions.mEditMoveToFolder->setVisible(!(isDriveListActive || currentDriveReadOnly || isFileItemListEmpty));
       
   397 
       
   398     mOptionMenuActions.mEditSelect->setVisible(false/*!isDriveListActive && !currentSelected && !isFileItemListEmpty*/);
       
   399     mOptionMenuActions.mEditUnselect->setVisible(false/*!isDriveListActive && currentSelected && !isFileItemListEmpty*/);
       
   400     mOptionMenuActions.mEditSelectAll->setVisible(!isDriveListActive && !allSelected && !isFileItemListEmpty);
       
   401     mOptionMenuActions.mEditUnselectAll->setVisible(!isDriveListActive && !noneSelected && !isFileItemListEmpty);
       
   402 
       
   403     // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isDriveListActive || isFileItemListEmpty));
       
   404     // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isDriveListActive || isFileItemListEmpty));
       
   405     mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive);
       
   406     mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty);
       
   407 
       
   408     // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU
       
   409     // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn);
       
   410 
       
   411     // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU
       
   412     // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn);
       
   413 
       
   414     // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU
       
   415     bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists();
       
   416     mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed);
       
   417     mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed);
       
   418 
       
   419 //    bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath);
       
   420 //    bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath);
       
   421 //    bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath);
       
   422 //
       
   423 //    bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed;
       
   424 //    mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon);
       
   425 //
       
   426 //    mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed);
       
   427 //    mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed);
       
   428 //    mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed);
       
   429 }
       
   430 
       
   431 void FileBrowserView::createContextMenu()
       
   432 {
       
   433     mContextMenu = new HbMenu();
       
   434     connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu()));
       
   435 
       
   436     createFileContextMenu();
       
   437     createEditContextMenu();
       
   438     createViewContextMenu();
       
   439     createDiskAdminContextMenu();
       
   440 }
       
   441 
       
   442 
       
   443 void FileBrowserView::createFileContextMenu()
       
   444 {
       
   445     mContextMenuActions.mFileMenu = mContextMenu->addMenu("File");
       
   446 
       
   447     mContextMenuActions.mFileBackMoveUp = mContextMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp()));
       
   448     mContextMenuActions.mFileOpenDrive = mContextMenuActions.mFileMenu->addAction("Open drive (->)", this, SLOT(fileOpenDrive()));
       
   449     mContextMenuActions.mFileOpenDirectory = mContextMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory()));
       
   450 //    mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
       
   451     //mContextMenuActions.mFileSearch->setVisible(false);
       
   452 
       
   453 //    mContextMenuActions.mFileNewMenu = mContextMenuActions.mFileMenu->addMenu("New");
       
   454 //    mContextMenuActions.mFileNewFile = mContextMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile()));
       
   455 //    mContextMenuActions.mFileNewDirectory = mContextMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory()));
       
   456 
       
   457     mContextMenuActions.mFileDelete = mContextMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
       
   458     mContextMenuActions.mFileRename = mContextMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
       
   459     mContextMenuActions.mFileTouch = mContextMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
       
   460     mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties()));
       
   461 
       
   462     mContextMenuActions.mFileChecksumsMenu = mContextMenuActions.mFileMenu->addMenu("Checksums");
       
   463     mContextMenuActions.mFileChecksumsMD5 = mContextMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5()));
       
   464     mContextMenuActions.mFileChecksumsMD2 = mContextMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2()));
       
   465     mContextMenuActions.mFileChecksumsSHA1 = mContextMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1()));
       
   466 
       
   467 //    mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
       
   468 //    mContextMenuActions.mFileSetAttributes->setVisible(false);
       
   469 }
       
   470 
       
   471 void FileBrowserView::createEditContextMenu()
       
   472 {
       
   473     mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit");
       
   474 
       
   475     //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE()));
       
   476 //    mContextMenuActions.mEditSnapShotToE->setVisible(false);
       
   477     mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut()));
       
   478     mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy()));
       
   479     mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste()));
       
   480 
       
   481     mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder()));
       
   482     mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder()));
       
   483 }
       
   484 
       
   485 void FileBrowserView::createViewContextMenu()
       
   486 {
       
   487 
       
   488 }
       
   489 
       
   490 /**
       
   491   Initial setup for Disk Admin submenu
       
   492   */
       
   493 void FileBrowserView::createDiskAdminContextMenu()
       
   494 {
       
   495     mContextMenuActions.mDiskAdminMenu = mContextMenu->addMenu("Disk admin");
       
   496     //mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(false);
       
   497 
       
   498     mContextMenuActions.mDiskAdminSetDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Set drive password", this, SLOT(diskAdminSetDrivePassword()));
       
   499     mContextMenuActions.mDiskAdminUnlockDrive = mContextMenuActions.mDiskAdminMenu->addAction("Unlock drive", this, SLOT(diskAdminUnlockDrive()));
       
   500     mContextMenuActions.mDiskAdminClearDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Clear drive password", this, SLOT(diskAdminClearDrivePassword()));
       
   501     mContextMenuActions.mDiskAdminEraseDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Erase drive password", this, SLOT(diskAdminEraseDrivePassword()));
       
   502 
       
   503     mContextMenuActions.mDiskAdminFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Format drive", this, SLOT(diskAdminFormatDrive()));
       
   504     mContextMenuActions.mDiskAdminFormatDrive->setVisible(false);
       
   505     mContextMenuActions.mDiskAdminQuickFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Quick format drive", this, SLOT(diskAdminQuickFormatDrive()));
       
   506     mContextMenuActions.mDiskAdminQuickFormatDrive->setVisible(false);
       
   507 
       
   508     mContextMenuActions.mDiskAdminCheckDisk = mContextMenuActions.mDiskAdminMenu->addAction("Check disk", this, SLOT(diskAdminCheckDisk()));
       
   509     mContextMenuActions.mDiskAdminScanDrive = mContextMenuActions.mDiskAdminMenu->addAction("Scan drive", this, SLOT(diskAdminScanDrive()));
       
   510     mContextMenuActions.mDiskAdminSetDriveName = mContextMenuActions.mDiskAdminMenu->addAction("Set drive name", this, SLOT(diskAdminSetDriveName()));
       
   511     mContextMenuActions.mDiskAdminSetDriveVolumeLabel = mContextMenuActions.mDiskAdminMenu->addAction("Set drive volume label", this, SLOT(diskAdminSetDriveVolumeLabel()));
       
   512     mContextMenuActions.mDiskAdminEjectDrive = mContextMenuActions.mDiskAdminMenu->addAction("Eject drive", this, SLOT(diskAdminEjectDrive()));
       
   513     mContextMenuActions.mDiskAdminDismountDrive = mContextMenuActions.mDiskAdminMenu->addAction("Dismount drive", this, SLOT(diskAdminDismountDrive()));
       
   514     mContextMenuActions.mDiskAdminEraseMBR = mContextMenuActions.mDiskAdminMenu->addAction("Erase MBR", this, SLOT(diskAdminEraseMBR()));
       
   515     mContextMenuActions.mDiskAdminPartitionDrive = mContextMenuActions.mDiskAdminMenu->addAction("Partition drive", this, SLOT(diskAdminPartitionDrive()));
       
   516 }
       
   517 
       
   518 void FileBrowserView::updateContextMenu()
       
   519 {
       
   520     bool isFileItemListEmpty = mFileBrowserModel->rowCount() == 0;
       
   521     bool isDriveListActive = mEngineWrapper->isDriveListViewActive();
       
   522 //    bool isNormalModeActive = true;       //iModel->FileUtils()->IsNormalModeActive();
       
   523     bool currentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly();
       
   524     bool currentItemDirectory = mEngineWrapper->getFileEntry(mCurrentIndex /*currentItemIndex()*/).isDir();
       
   525     bool listBoxSelections = mListView->selectionModel()->selection().count() == 0;
       
   526     bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
       
   527     bool emptyClipBoard = !mEngineWrapper->isClipBoardListInUse();
       
   528 //    bool showSnapShot = false;           //iModel->FileUtils()->DriveSnapShotPossible();
       
   529 
       
   530 //    bool showEditMenu(true);
       
   531 //    if (isDriveListActive) {
       
   532 //        if (!showSnapShot || isFileItemListEmpty && emptyClipBoard)
       
   533 //            showEditMenu = false;
       
   534 //        else
       
   535 //            showEditMenu = true;
       
   536 //    } else {
       
   537 //        if (isFileItemListEmpty && emptyClipBoard)
       
   538 //            showEditMenu = false;
       
   539 //        else
       
   540 //            showEditMenu = true;
       
   541 //    }
       
   542 
       
   543     // File submenu
       
   544     mContextMenuActions.mFileBackMoveUp->setVisible( !isDriveListActive);
       
   545     mContextMenuActions.mFileOpenDrive->setVisible( !isFileItemListEmpty && isDriveListActive);
       
   546     mContextMenuActions.mFileOpenDirectory->setVisible( !isFileItemListEmpty && !isDriveListActive && currentItemDirectory);
       
   547 
       
   548 //    mContextMenuActions.mFileNewMenu->menuAction()->setVisible(!(isDriveListActive || currentDriveReadOnly));
       
   549     mContextMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly);
       
   550     mContextMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly && !listBoxSelections);
       
   551     mContextMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isDriveListActive && !currentDriveReadOnly);
       
   552     mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty && !listBoxSelections && !isSelectionMode);
       
   553 
       
   554     mContextMenuActions.mFileChecksumsMenu->menuAction()->setVisible(!(isFileItemListEmpty || isSelectionMode /*|| listBoxSelections*/ || currentItemDirectory || isDriveListActive));
       
   555     // Edit submenu
       
   556     mContextMenuActions.mEditMenu->menuAction()->setVisible(!isDriveListActive);
       
   557     mContextMenuActions.mEditCut->setVisible(!(isDriveListActive || currentDriveReadOnly || isFileItemListEmpty));
       
   558     mContextMenuActions.mEditCopy->setVisible(!(isDriveListActive || isFileItemListEmpty));
       
   559     mContextMenuActions.mEditPaste->setVisible(!isDriveListActive && !emptyClipBoard && !currentDriveReadOnly);
       
   560     mContextMenuActions.mEditCopyToFolder->setVisible(!(isDriveListActive || isFileItemListEmpty));
       
   561     mContextMenuActions.mEditMoveToFolder->setVisible(!(isDriveListActive || currentDriveReadOnly || isFileItemListEmpty));
       
   562     //DiskAdmin submenu
       
   563     mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(isDriveListActive);
       
   564 }
       
   565 
       
   566 // ---------------------------------------------------------------------------
       
   567 
       
   568 void FileBrowserView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords)
       
   569 {
       
   570     //Q_UNUSED(listViewItem);
       
   571 
       
   572 //    QItemSelectionModel *selectionIndexes = mListView->selectionModel();
       
   573 
       
   574     // by default use selected items
       
   575 //    if (selectionIndexes && selectionIndexes->hasSelection()) {
       
   576 //        mSelectionIndexes = mListView->selectionModel()->selectedIndexes();
       
   577 //    } else {
       
   578         mCurrentIndex = listViewItem->modelIndex();
       
   579 //        mSelectionIndexes.clear();
       
   580 //        mSelectionIndexes.append(mModelIndex);
       
   581 //    }
       
   582     mContextMenu->setPreferredPos(coords);
       
   583     mContextMenu->show();
       
   584 }
       
   585 
       
   586 
       
   587 /**
       
   588   Create a file browser tool bar
       
   589   */
       
   590 void FileBrowserView::createToolBar()
       
   591 {
       
   592     mToolBar = new HbToolBar(this);
       
   593 
       
   594     mToolbarBackAction = new HbAction(/*"Back"*/);
       
   595     mToolbarBackAction->setToolTip("Back");
       
   596     mToolbarBackAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_folder_parent.svg")));
       
   597     connect(mToolbarBackAction, SIGNAL(triggered()), this, SLOT(fileBackMoveUp()));
       
   598     mToolBar->addAction(mToolbarBackAction);
       
   599 
       
   600     if (mOptionMenuActions.mSelection) {
       
   601         mToolBar->addAction(mOptionMenuActions.mSelection);
       
   602     }
       
   603 
       
   604     setToolBar(mToolBar);
       
   605 }
       
   606 
       
   607 /**
       
   608   Refresh FileBrowser view
       
   609   */
       
   610 void FileBrowserView::refreshList()
       
   611 {
       
   612     mEngineWrapper->refreshView();
       
   613 //    mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
       
   614     mListView->reset();
       
   615     mListView->setModel(mFileBrowserModel);
       
   616     mToolbarBackAction->setEnabled(!mEngineWrapper->isDriveListViewActive());
       
   617 
       
   618     TListingMode listingMode = mEngineWrapper->listingMode();
       
   619     if (listingMode == ENormalEntries)
       
   620         mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
       
   621     else if (listingMode == ESearchResults)
       
   622         mNaviPane->setPlainText(QString(tr("Search results")));
       
   623     else if (listingMode == EOpenFiles)
       
   624         mNaviPane->setPlainText(QString(tr("Open files")));
       
   625     else if (listingMode == EMsgAttachmentsInbox)
       
   626         mNaviPane->setPlainText(QString(tr("Attachments in Inbox")));
       
   627     else if (listingMode == EMsgAttachmentsDrafts)
       
   628         mNaviPane->setPlainText(QString(tr("Attachments in Drafts")));
       
   629     else if (listingMode == EMsgAttachmentsSentItems)
       
   630         mNaviPane->setPlainText(QString(tr("Attachments in Sent Items")));
       
   631     else if (listingMode == EMsgAttachmentsOutbox)
       
   632         mNaviPane->setPlainText(QString(tr("Attachments in Outbox")));
       
   633 }
       
   634 
       
   635 /**
       
   636   Populate changed folder content, i.e. in practice navigation list items
       
   637   */
       
   638 void FileBrowserView::populateFolderContent()
       
   639 {
       
   640     // update the file browser by setting up the model with current directory as root path
       
   641     if(mListView->model() == 0)  {
       
   642         mFileBrowserModel = new FileBrowserModel(mEngineWrapper);
       
   643         mListView->setModel(mFileBrowserModel);
       
   644     }
       
   645 
       
   646     refreshList();
       
   647     //mFileSystemModel->setFilter(mFileSystemModel->filter() | QDir::System | QDir::Hidden);
       
   648     //mFileSystemModel->setRootPath(directory);
       
   649     //mListView->setRootIndex(mFileSystemModel->index(directory));
       
   650 }
       
   651 
       
   652 // ---------------------------------------------------------------------------	
       
   653 
       
   654 void FileBrowserView::fileOpen(HbAction *action)
       
   655 {
       
   656 //    Q_UNUSED(action);
       
   657     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
       
   658     if(!action && dlg && dlg->selectedItems().count()){
       
   659         int selectionIndex = dlg->selectedItems().at(0).toInt();
       
   660 
       
   661         if (selectionIndex == 0) {
       
   662             // open editor view
       
   663             emit aboutToShowEditorView(mAbsoluteFilePath, true);
       
   664         } else if (selectionIndex == 1) {
       
   665             // AppArc
       
   666             mEngineWrapper->openAppArc(mAbsoluteFilePath);
       
   667         } else {
       
   668             // DocHandler
       
   669             mEngineWrapper->openDocHandler(mAbsoluteFilePath, true);
       
   670         }
       
   671     }
       
   672 }
       
   673 
       
   674 /**
       
   675   Open overwrite dialog
       
   676   */
       
   677 void FileBrowserView::fileOverwriteDialog()
       
   678 {
       
   679     mOverwriteOptions = OverwriteOptions();
       
   680     // open user-dialog to select: view as text/hex,  open w/AppArc or open w/DocH. embed
       
   681     QStringList list;
       
   682     list << QString("Overwrite all")
       
   683             << QString("Skip all existing")
       
   684             << QString("Gen. unique filenames")
       
   685             << QString("Query postfix");
       
   686     openListDialog(list, QString("Overwrite?"), this, SLOT(fileOverwrite(HbAction *)));
       
   687 }
       
   688 
       
   689 /**
       
   690   File overwrite
       
   691   */
       
   692 void FileBrowserView::fileOverwrite(HbAction *action)
       
   693 {
       
   694 //    Q_UNUSED(action);
       
   695     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
       
   696     if(!action && dlg && dlg->selectedItems().count()) {
       
   697         mOverwriteOptions.queryIndex = dlg->selectedItems().at(0).toInt();
       
   698         if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) {
       
   699             QString heading = QString("Postfix");
       
   700             HbInputDialog::getText(heading, this, SLOT(fileOverwritePostfix(HbAction *)), QString(), scene());
       
   701         } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) {
       
   702             mOverwriteOptions.overWriteFlags = 0;
       
   703         }
       
   704     } else {
       
   705         mOverwriteOptions.doFileOperations = false;
       
   706     }
       
   707 }
       
   708 
       
   709 /**
       
   710   File overwrite postfix query dialog
       
   711   */
       
   712 void FileBrowserView::fileOverwritePostfix(HbAction *action)
       
   713 {
       
   714     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   715     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   716         mOverwriteOptions.postFix = dlg->value().toString();
       
   717     } else {
       
   718         mOverwriteOptions.doFileOperations = false;
       
   719     }
       
   720 }
       
   721 
       
   722 // ---------------------------------------------------------------------------
       
   723 /**
       
   724   Show a list dialog
       
   725   \param List aList of item to select item from.
       
   726   \param Title text titleText of a dialog heading widget
       
   727   \return None
       
   728   */
       
   729 void FileBrowserView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member)
       
   730 {
       
   731 //    Q_UNUSED(items);
       
   732 //    Q_UNUSED(titleText);
       
   733 //    Q_UNUSED(receiver);
       
   734 //    Q_UNUSED(member);
       
   735     // Create a list and some simple content for it
       
   736     HbSelectionDialog *dlg = new HbSelectionDialog();
       
   737     dlg->setAttribute(Qt::WA_DeleteOnClose);
       
   738     // Set items to be popup's content
       
   739     dlg->setStringItems(items);
       
   740     dlg->setSelectionMode(HbAbstractItemView::SingleSelection);
       
   741     //dlg->setDismissPolicy(HbPopup::TapOutside);
       
   742 
       
   743     HbLabel *title = new HbLabel(dlg);
       
   744     title->setPlainText(titleText);
       
   745     dlg->setHeadingWidget(title);
       
   746 
       
   747     // Launch popup and handle the user response:
       
   748     dlg->open(receiver, member);
       
   749 }
       
   750 
       
   751 // ---------------------------------------------------------------------------
       
   752 
       
   753 void FileBrowserView::openPropertyDialog(const QStringList& propertyList, const QString& title)
       
   754 {
       
   755     HbDialog *dialog = new HbDialog();
       
   756     dialog->setDismissPolicy(HbPopup::TapOutside);
       
   757     dialog->setTimeout(HbPopup::NoTimeout);
       
   758 
       
   759     HbLabel *titleWidget = new HbLabel();
       
   760     titleWidget->setPlainText(title);
       
   761     dialog->setHeadingWidget(titleWidget);
       
   762 
       
   763     // Create a list and some simple content for it
       
   764     HbListWidget *list = new HbListWidget();
       
   765     QString str;
       
   766     foreach (str, propertyList) {
       
   767         list->addItem(str);
       
   768     }
       
   769 
       
   770     // Connect list item activation signal to close the popup
       
   771     connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close()));
       
   772 
       
   773     HbAction *cancelAction = new HbAction("Close");
       
   774     dialog->setPrimaryAction(cancelAction);
       
   775 
       
   776     // Set listwidget to be popup's content
       
   777     dialog->setContentWidget(list);
       
   778     // Launch popup and handle the user response:
       
   779     dialog->open();
       
   780 }
       
   781 
       
   782 void FileBrowserView::storeSelectedItemsOrCurrentItem()
       
   783 {
       
   784     QItemSelectionModel *selectionIndexes = mListView->selectionModel();
       
   785 
       
   786     // by default use selected items
       
   787     if (selectionIndexes) {
       
   788         if (selectionIndexes->hasSelection()) {
       
   789             mSelectionIndexes = mListView->selectionModel()->selectedIndexes();
       
   790         } else { // or if none selected, use the current item index
       
   791             mSelectionIndexes.clear();
       
   792             mSelectionIndexes.append(mCurrentIndex);
       
   793 //            QModelIndex currentIndex = currentItemIndex();
       
   794 //            if (mFileBrowserModel->rowCount(currentItemIndex) > currentItemIndex && currentItemIndex >= 0)
       
   795 //            {
       
   796 //                modelIndexList.append(currentIndex);
       
   797 //            }
       
   798         }
       
   799     }
       
   800 //    mClipBoardInUse = true;
       
   801 }
       
   802 
       
   803 // ---------------------------------------------------------------------------
       
   804 
       
   805 QModelIndex FileBrowserView::currentItemIndex()
       
   806 {
       
   807     return mCurrentIndex;//mListView->selectionModel()->currentIndex();
       
   808 }
       
   809 
       
   810 // ---------------------------------------------------------------------------
       
   811 // operations in File Menu
       
   812 // ---------------------------------------------------------------------------
       
   813 
       
   814 /**
       
   815   Move back/up in folder browsing history
       
   816   */
       
   817 void FileBrowserView::fileBackMoveUp()
       
   818 {
       
   819     mLocationChanged = true;
       
   820 //    if(mDirectory.length() < DRIVEPATHLENGTH) {
       
   821 //        // location in the root of any drive -> move back/up to root of device
       
   822 //        QModelIndex index = currentItemIndex();
       
   823 //        const QString filePath = mFileSystemModel->filePath(index);
       
   824 //        qDebug() << "handleBackButton filePath" << filePath;
       
   825 //        mDirectory = mInitDirPath.path();
       
   826 //        populateFolderContent(mDirectory);
       
   827 //    }
       
   828 //    else if(mDirectory != mInitDirPath.path()) {
       
   829 //        // location in any folder in any drive -> move back/up
       
   830 //        QDir dir(mDirectory);
       
   831 //        dir.cdUp();
       
   832 //        const QString currentPath = dir.absolutePath();
       
   833 //        mDirectory = currentPath;
       
   834 //        populateFolderContent(currentPath);
       
   835 //        mSelectedFilePath = "";
       
   836 //    } else {
       
   837 //        // location already in the device root, no way up.
       
   838 //        // do nothing.
       
   839 //    }
       
   840     mEngineWrapper->moveUpOneLevel();
       
   841     populateFolderContent();
       
   842 }
       
   843 
       
   844 void FileBrowserView::fileOpenDrive()
       
   845 {
       
   846     // TODO make a separate function to be called from here and fileOpenDirectory()
       
   847     mLocationChanged = true;
       
   848     // get selected drive or directory from list view model and open it:
       
   849     //if (mListView->selectionModel()->hasSelection()) {
       
   850 //    if (mListView->selectionModel()->selection().count() != 0) {
       
   851 //        QModelIndex currentIndex = currentItemIndex();
       
   852         mEngineWrapper->moveDownToDirectory(mCurrentIndex);
       
   853         populateFolderContent();
       
   854 //    } else {
       
   855 //        Notifications::showErrorNote("not selected item!");
       
   856 //    }
       
   857 }
       
   858 
       
   859 void FileBrowserView::fileOpenDirectory()
       
   860 {
       
   861     mLocationChanged = true;
       
   862     // get selected drive or directory from list view model and open it:
       
   863     //if (mListView->selectionModel()->hasSelection()) {
       
   864 //    if (mListView->selectionModel()->selection().count() != 0) {
       
   865 //        QModelIndex currentIndex = currentItemIndex();
       
   866         mEngineWrapper->moveDownToDirectory(mCurrentIndex);
       
   867         populateFolderContent();
       
   868 //    } else {
       
   869 //        Notifications::showErrorNote("not selected item!");
       
   870 //    }
       
   871 }
       
   872 
       
   873 void FileBrowserView::fileSearch()
       
   874 {
       
   875     QString searchPath;
       
   876 //    if (mEngineWrapper->currentPath() != mInitDirPath.path()) {
       
   877 //        searchPath = mDirectory;
       
   878 //        searchPath.replace("/", "\\");
       
   879 //        searchPath+="\\";
       
   880 //    }
       
   881     searchPath = mEngineWrapper->currentPath();
       
   882 //    mSearch->open(searchPath);
       
   883     emit aboutToShowSearchView(searchPath);
       
   884 }
       
   885 
       
   886 /**
       
   887   Open new file dialog
       
   888   */
       
   889 void FileBrowserView::fileNewFile()
       
   890 {
       
   891     QString heading = QString("Enter filename");
       
   892     HbInputDialog::getText(heading, this, SLOT(doFileNewFile(HbAction*)), QString(), scene());
       
   893 }
       
   894 
       
   895 /**
       
   896   Create a new file in current directory with a name queried from user
       
   897   */
       
   898 void FileBrowserView::doFileNewFile(HbAction *action)
       
   899 {
       
   900     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   901     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   902         QString newFileName = dlg->value().toString();
       
   903         mEngineWrapper->createNewFile(newFileName);
       
   904         refreshList();
       
   905     }
       
   906 }
       
   907 
       
   908 /**
       
   909   Open new directory dialog
       
   910   */
       
   911 void FileBrowserView::fileNewDirectory()
       
   912 {
       
   913     QString heading = QString("Enter directory name");
       
   914     HbInputDialog::getText(heading, this, SLOT(doFileNewDirectory(HbAction*)), QString(), scene());
       
   915 }
       
   916 
       
   917 /**
       
   918   Create a new directory in current directory with a name queried from user
       
   919   */
       
   920 void FileBrowserView::doFileNewDirectory(HbAction *action)
       
   921 {
       
   922     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   923     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   924         QString newDirectoryName = dlg->value().toString();
       
   925         mEngineWrapper->createNewDirectory(newDirectoryName);
       
   926         refreshList();
       
   927     }
       
   928 }
       
   929 
       
   930 /**
       
   931   Question for Delete actually selected files
       
   932   */
       
   933 void FileBrowserView::fileDelete()
       
   934 {
       
   935     storeSelectedItemsOrCurrentItem();
       
   936     const QString messageFormat = "Delete %1 entries?";
       
   937     QString message = messageFormat.arg(mSelectionIndexes.count());
       
   938     HbMessageBox::question(message, this, SLOT(doFileDelete(HbAction*)));
       
   939 }
       
   940 
       
   941 /**
       
   942   Delete actually selected files
       
   943   */
       
   944 void FileBrowserView::doFileDelete(HbAction* action)
       
   945 {
       
   946     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
   947         //storeSelectedItemsOrCurrentItem();
       
   948         mEngineWrapper->deleteItems(mSelectionIndexes);
       
   949         refreshList();
       
   950     }
       
   951 }
       
   952 
       
   953 /**
       
   954   Open rename dialog for actually selected files
       
   955   */
       
   956 void FileBrowserView::fileRename()
       
   957 {
       
   958     storeSelectedItemsOrCurrentItem();
       
   959     mEngineWrapper->setCurrentSelection(mSelectionIndexes);
       
   960 
       
   961     for (int i(0), ie(mSelectionIndexes.count()); i < ie; ++i ) {
       
   962         mProceed = (i == ie-1); // if the last item
       
   963         mModelIndex = mSelectionIndexes.at(i);
       
   964         FileEntry entry = mEngineWrapper->getFileEntry(mModelIndex);
       
   965 
       
   966         QString heading = QString("Enter new name");
       
   967         HbInputDialog::getText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene());
       
   968     }
       
   969 }
       
   970 
       
   971 /**
       
   972   Rename actually selected files
       
   973   */
       
   974 void FileBrowserView::doFileRename(HbAction *action)
       
   975 {
       
   976     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   977     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   978         mNewFileName = dlg->value().toString();
       
   979 
       
   980         if (mEngineWrapper->targetExists(mModelIndex, mNewFileName)) {
       
   981             const QString messageTemplate = QString("%1 already exists, overwrite?");
       
   982             QString message = messageTemplate.arg(mNewFileName);
       
   983             HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(HbAction *)));
       
   984         } else {
       
   985             mEngineWrapper->rename(mModelIndex, mNewFileName);
       
   986             if (mProceed) {
       
   987                 mEngineWrapper->startExecutingCommands(QString("Renaming"));
       
   988                 refreshList();
       
   989             }
       
   990         }
       
   991     }
       
   992 }
       
   993 
       
   994 /**
       
   995   Rename actually selected files
       
   996   */
       
   997 void FileBrowserView::doFileRenameFileExist(HbAction *action)
       
   998 {
       
   999     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1000         mEngineWrapper->rename(mModelIndex, mNewFileName);
       
  1001         if (mProceed) {
       
  1002             mEngineWrapper->startExecutingCommands(QString("Renaming"));
       
  1003             refreshList();
       
  1004         }
       
  1005     }
       
  1006 }
       
  1007 
       
  1008 /**
       
  1009   Touch actually selected files
       
  1010   */
       
  1011 void FileBrowserView::fileTouch()
       
  1012 {
       
  1013     storeSelectedItemsOrCurrentItem();
       
  1014     mEngineWrapper->setCurrentSelection(mSelectionIndexes);
       
  1015 
       
  1016     if (mEngineWrapper->selectionHasDirs()) {
       
  1017         const QString message = "Recurse touch for all selected dirs?";
       
  1018         HbMessageBox::question(message, this, SLOT(doFileTouch(HbAction*)));
       
  1019     }
       
  1020     else{
       
  1021         mEngineWrapper->touch(false);
       
  1022         refreshList();
       
  1023     }
       
  1024 }
       
  1025 
       
  1026 /**
       
  1027   Touch actually selected files
       
  1028   */
       
  1029 void FileBrowserView::doFileTouch(HbAction* action)
       
  1030 {
       
  1031     bool recurse = false;
       
  1032     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1033         recurse = true;
       
  1034         }
       
  1035     mEngineWrapper->touch(recurse);
       
  1036     refreshList();
       
  1037 }
       
  1038 
       
  1039 void FileBrowserView::fileChecksumsMD5()
       
  1040 {
       
  1041     fileChecksums(EFileChecksumsMD5);
       
  1042 }
       
  1043 
       
  1044 void FileBrowserView::fileChecksumsMD2()
       
  1045 {
       
  1046     fileChecksums(EFileChecksumsMD2);
       
  1047 }
       
  1048 
       
  1049 void FileBrowserView::fileChecksumsSHA1()
       
  1050 {
       
  1051     fileChecksums(EFileChecksumsSHA1);
       
  1052 }
       
  1053 
       
  1054 void FileBrowserView::fileChecksums(TFileBrowserCmdFileChecksums checksumType)
       
  1055 {
       
  1056 //    QModelIndex currentIndex = currentItemIndex();
       
  1057     mEngineWrapper->showFileCheckSums(mCurrentIndex, checksumType);
       
  1058 }
       
  1059 
       
  1060 /**
       
  1061   Show file properties
       
  1062   */
       
  1063 void FileBrowserView::fileProperties()
       
  1064 {
       
  1065     QModelIndex currentIndex = currentItemIndex();
       
  1066     QStringList propertyList;
       
  1067     QString titleText;
       
  1068     mEngineWrapper->properties(currentIndex, propertyList, titleText);
       
  1069     openPropertyDialog(propertyList, titleText);
       
  1070 }
       
  1071 
       
  1072 void FileBrowserView::fileSetAttributes()
       
  1073 {
       
  1074 
       
  1075 }
       
  1076 
       
  1077 // edit menu
       
  1078 void FileBrowserView::editSnapShotToE()
       
  1079 {
       
  1080 
       
  1081 }
       
  1082 
       
  1083 /**
       
  1084   Set selected files into clipboard.
       
  1085   Selected item will be removed after paste operation.
       
  1086   */
       
  1087 void FileBrowserView::editCut()
       
  1088 {
       
  1089     storeSelectedItemsOrCurrentItem();
       
  1090     mClipboardIndexes = mSelectionIndexes;
       
  1091 
       
  1092     mEngineWrapper->clipboardCut(mClipboardIndexes);
       
  1093 
       
  1094     int operations = mClipboardIndexes.count();
       
  1095     const QString message = QString ("%1 entries cut to clipboard");
       
  1096     QString noteMsg = message.arg(operations);
       
  1097 
       
  1098     Notifications::showInformationNote(noteMsg);
       
  1099 }
       
  1100 
       
  1101 /**
       
  1102   Set selected files into clipboard.
       
  1103   Selected item will not be removed after paste operation.
       
  1104   */
       
  1105 void FileBrowserView::editCopy()
       
  1106 {
       
  1107     storeSelectedItemsOrCurrentItem();
       
  1108     mClipboardIndexes = mSelectionIndexes;
       
  1109 
       
  1110     mEngineWrapper->clipboardCopy(mClipboardIndexes);
       
  1111 
       
  1112     int operations = mClipboardIndexes.count();
       
  1113 
       
  1114     const QString message = QString ("%1 entries copied to clipboard");
       
  1115     QString noteMsg = message.arg(operations);
       
  1116 
       
  1117     Notifications::showInformationNote(noteMsg);
       
  1118 }
       
  1119 
       
  1120 /**
       
  1121   Moves or copies file selection stored in clipboard to a actual directory.
       
  1122   Removing files depend on previous operation, i.e. Cut or Copy
       
  1123   */
       
  1124 void FileBrowserView::editPaste()
       
  1125 {
       
  1126     bool someEntryExists(false);
       
  1127 
       
  1128     // TODO Set entry items here
       
  1129 
       
  1130     someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndexes, mEngineWrapper->currentPath());
       
  1131     if (someEntryExists) {
       
  1132         fileOverwriteDialog();
       
  1133     }
       
  1134     mEngineWrapper->clipboardPaste(mOverwriteOptions);
       
  1135 }
       
  1136 
       
  1137 /**
       
  1138   Open copy to folder new filename dialog
       
  1139   */
       
  1140 void FileBrowserView::editCopyToFolder()
       
  1141 {
       
  1142     QString heading = QString("Enter new name");
       
  1143     HbInputDialog::getText(heading, this, SLOT(doEditCopyToFolder(HbAction*)), mEngineWrapper->currentPath(), scene());
       
  1144 }
       
  1145 
       
  1146 /**
       
  1147   Copies current file selection to a queried directory.
       
  1148   */
       
  1149 void FileBrowserView::doEditCopyToFolder(HbAction *action)
       
  1150 {
       
  1151     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1152     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1153         QString targetDir = dlg->value().toString();
       
  1154         bool someEntryExists(false);
       
  1155 
       
  1156         // TODO Set entry items here
       
  1157         storeSelectedItemsOrCurrentItem();
       
  1158         mEngineWrapper->setCurrentSelection(mSelectionIndexes);
       
  1159 
       
  1160         someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir);
       
  1161         if (someEntryExists) {
       
  1162             fileOverwriteDialog();
       
  1163         }
       
  1164         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, false);
       
  1165         refreshList();
       
  1166     }
       
  1167 }
       
  1168 
       
  1169 /**
       
  1170   Open move to folder new filename dialog.
       
  1171   */
       
  1172 void FileBrowserView::editMoveToFolder()
       
  1173 {
       
  1174     QString heading = QString("Enter new name");
       
  1175     HbInputDialog::getText(heading, this, SLOT(doEditCopyToFolder(HbAction*)), mEngineWrapper->currentPath(), scene());
       
  1176 }
       
  1177 
       
  1178 /**
       
  1179   Moves current file selection to a queried directory.
       
  1180   */
       
  1181 void FileBrowserView::doEditMoveToFolder(HbAction *action)
       
  1182 {
       
  1183     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1184     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1185         QString targetDir = dlg->value().toString();
       
  1186         bool someEntryExists(false);
       
  1187 
       
  1188         // TODO Set entry items here
       
  1189         storeSelectedItemsOrCurrentItem();
       
  1190         mEngineWrapper->setCurrentSelection(mSelectionIndexes);
       
  1191 
       
  1192         someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir);
       
  1193         if (someEntryExists) {
       
  1194             fileOverwriteDialog();
       
  1195         }
       
  1196         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, true);
       
  1197         refreshList();
       
  1198     }
       
  1199 }
       
  1200 
       
  1201 /**
       
  1202   Select current file
       
  1203   */
       
  1204 void FileBrowserView::editSelect()
       
  1205 {
       
  1206     QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1207     if (selectionModel) {
       
  1208         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::SelectCurrent);
       
  1209         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Select);
       
  1210         itemHighlighted(selectionModel->currentIndex());
       
  1211         refreshList();
       
  1212     }
       
  1213 }
       
  1214 
       
  1215 /**
       
  1216   Unselect current file
       
  1217   */
       
  1218 void FileBrowserView::editUnselect()
       
  1219 {
       
  1220     QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1221     if (selectionModel) {
       
  1222         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Deselect);
       
  1223         itemHighlighted(selectionModel->currentIndex());
       
  1224     }
       
  1225 }
       
  1226 
       
  1227 /**
       
  1228   Select all files
       
  1229   */
       
  1230 void FileBrowserView::editSelectAll()
       
  1231 {
       
  1232     QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1233     if (selectionModel) {
       
  1234 
       
  1235         if (mFileBrowserModel->rowCount() > 0) {
       
  1236             QModelIndex firstIndex = mFileBrowserModel->index(0, 0);
       
  1237             QModelIndex lastIndex = mFileBrowserModel->index( (mFileBrowserModel->rowCount() - 1), 0);
       
  1238 
       
  1239             QItemSelection itemSelection(firstIndex, lastIndex);
       
  1240             //selectionModel->select(itemSelection, QItemSelectionModel::SelectCurrent);
       
  1241             selectionModel->select(itemSelection, QItemSelectionModel::Select);
       
  1242         }
       
  1243     }
       
  1244 }
       
  1245 
       
  1246 /**
       
  1247   Unselect all files
       
  1248   */
       
  1249 void FileBrowserView::editUnselectAll()
       
  1250 {
       
  1251     QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1252     if (selectionModel) {
       
  1253         selectionModel->clearSelection();
       
  1254     }
       
  1255 }
       
  1256 
       
  1257 // ---------------------------------------------------------------------------
       
  1258 // view menu
       
  1259 // ---------------------------------------------------------------------------
       
  1260 void FileBrowserView::viewFilterEntries()
       
  1261 {
       
  1262 
       
  1263 }
       
  1264 void FileBrowserView::viewRefresh()
       
  1265 {
       
  1266     refreshList();
       
  1267 }
       
  1268 
       
  1269 // ---------------------------------------------------------------------------
       
  1270 // disk admin menu
       
  1271 // ---------------------------------------------------------------------------
       
  1272 
       
  1273 /**
       
  1274   Open old password for the selected drive dialog.
       
  1275   */
       
  1276 void FileBrowserView::diskAdminSetDrivePassword()
       
  1277 {
       
  1278     QModelIndex currentIndex = currentItemIndex();
       
  1279     // check if the drive has a password
       
  1280     if (mEngineWrapper->hasDrivePassword(currentIndex)) {
       
  1281         QString heading = QString("Existing password");
       
  1282         HbInputDialog::getText(heading, this, SLOT(diskAdminSetDrivePasswordNew(HbAction*)), QString(), scene());
       
  1283     }
       
  1284 }
       
  1285 
       
  1286 /**
       
  1287    Open new password for the selected drive dialog.
       
  1288   */
       
  1289 void FileBrowserView::diskAdminSetDrivePasswordNew(HbAction *action)
       
  1290 {
       
  1291     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1292     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1293         mOldPassword = dlg->value().toString();
       
  1294     }
       
  1295 
       
  1296     QString heading = QString("New password");
       
  1297     HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene());
       
  1298 }
       
  1299 
       
  1300 /**
       
  1301    Set password for the selected drive.
       
  1302   */
       
  1303 void FileBrowserView::doDiskAdminSetDrivePassword(HbAction *action)
       
  1304 {
       
  1305     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1306     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1307         QString newPassword = dlg->value().toString();
       
  1308         QModelIndex currentIndex = currentItemIndex();
       
  1309         mEngineWrapper->DiskAdminSetDrivePassword(currentIndex, mOldPassword, newPassword);
       
  1310         refreshList();
       
  1311     }
       
  1312 }
       
  1313 
       
  1314 /**
       
  1315   Open Unlock the selected drive dialog.
       
  1316   */
       
  1317 void FileBrowserView::diskAdminUnlockDrive()
       
  1318 {
       
  1319     QModelIndex currentIndex = currentItemIndex();
       
  1320     // check if the drive is locked
       
  1321     if (mEngineWrapper->isDriveLocked(currentIndex)) {
       
  1322         QString heading = QString("Existing password");
       
  1323         HbInputDialog::getText(heading, this, SLOT(doDiskAdminUnlockDrive(HbAction*)), QString(), scene());
       
  1324     } else {
       
  1325         Notifications::showInformationNote(QString("This drive is not locked"));
       
  1326     }
       
  1327 }
       
  1328 
       
  1329 /**
       
  1330   Unlock the selected drive.
       
  1331   */
       
  1332 void FileBrowserView::doDiskAdminUnlockDrive(HbAction *action)
       
  1333 {
       
  1334     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1335     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1336         QString oldPassword = dlg->value().toString();
       
  1337         QModelIndex currentIndex = currentItemIndex();
       
  1338         mEngineWrapper->DiskAdminUnlockDrive(currentIndex, oldPassword);
       
  1339         refreshList();
       
  1340     }
       
  1341 }
       
  1342 
       
  1343 /**
       
  1344   Open clear password of the selected drive dialog.
       
  1345   */
       
  1346 void FileBrowserView::diskAdminClearDrivePassword()
       
  1347 {
       
  1348     QModelIndex currentIndex = currentItemIndex();
       
  1349     // check if the drive has a password
       
  1350     if (mEngineWrapper->hasDrivePassword(currentIndex)) {
       
  1351         QString heading = QString("Existing password");
       
  1352         HbInputDialog::getText(heading, this, SLOT(doDiskAdminClearDrivePassword(HbAction*)), QString(), scene());
       
  1353     } else {
       
  1354         Notifications::showInformationNote(QString("This drive has no password"));
       
  1355     }
       
  1356 }
       
  1357 
       
  1358 /**
       
  1359   Clear password of the selected drive.
       
  1360   */
       
  1361 void FileBrowserView::doDiskAdminClearDrivePassword(HbAction *action)
       
  1362 {
       
  1363     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1364     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1365         QString oldPassword = dlg->value().toString();
       
  1366         QModelIndex currentIndex = currentItemIndex();
       
  1367         mEngineWrapper->DiskAdminClearDrivePassword(currentIndex, oldPassword);
       
  1368         refreshList();
       
  1369     }
       
  1370 }
       
  1371 
       
  1372 
       
  1373 /**
       
  1374   Question for erase password of the selected drive
       
  1375   */
       
  1376 void FileBrowserView::diskAdminEraseDrivePassword()
       
  1377 {
       
  1378     // check if the drive has a password
       
  1379     QModelIndex currentIndex = currentItemIndex();
       
  1380     if (mEngineWrapper->hasDrivePassword(currentIndex)) {
       
  1381         HbMessageBox::question(QString("Are you sure? All data can be lost!"), this, SLOT(doDiskAdminEraseDrivePassword(HbAction*)));
       
  1382     } else {
       
  1383         Notifications::showInformationNote(QString("This drive has no password"));
       
  1384     }
       
  1385 }
       
  1386 
       
  1387 /**
       
  1388   Erase password of the selected drive
       
  1389   */
       
  1390 void FileBrowserView::doDiskAdminEraseDrivePassword(HbAction* action)
       
  1391 {
       
  1392     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1393         QModelIndex currentIndex = currentItemIndex();
       
  1394         mEngineWrapper->DiskAdminEraseDrivePassword(currentIndex);
       
  1395         refreshList();
       
  1396     }
       
  1397 }
       
  1398 
       
  1399 /**
       
  1400   Performs format on the selected drive
       
  1401   */
       
  1402 void FileBrowserView::diskAdminFormatDrive()
       
  1403 {
       
  1404     HbMessageBox::question(QString("Are you sure? All data will be lost!"), this, SLOT(doDiskAdminFormatDrive(HbAction*)));
       
  1405 }
       
  1406 
       
  1407 /**
       
  1408   Performs format on the selected drive
       
  1409   */
       
  1410 void FileBrowserView::doDiskAdminFormatDrive(HbAction* action)
       
  1411 {
       
  1412     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1413         QModelIndex currentIndex = currentItemIndex();
       
  1414         mEngineWrapper->DiskAdminFormatDrive(currentIndex, false);
       
  1415     }
       
  1416 }
       
  1417 
       
  1418 /**
       
  1419   Performs quick format on the selected drive
       
  1420   */
       
  1421 void FileBrowserView::diskAdminQuickFormatDrive()
       
  1422 {
       
  1423     HbMessageBox::question(QString("Are you sure? All data will be lost!"), this, SLOT(doDiskAdminQuickFormatDrive(HbAction*)));
       
  1424 }
       
  1425 
       
  1426 /**
       
  1427   Performs quick format on the selected drive
       
  1428   */
       
  1429 void FileBrowserView::doDiskAdminQuickFormatDrive(HbAction* action)
       
  1430 {
       
  1431     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1432         QModelIndex currentIndex = currentItemIndex();
       
  1433         mEngineWrapper->DiskAdminFormatDrive(currentIndex, true);
       
  1434     }
       
  1435 }
       
  1436 
       
  1437 /**
       
  1438     Checks the disk integrity on the selected drive
       
  1439   */
       
  1440 void FileBrowserView::diskAdminCheckDisk()
       
  1441 {
       
  1442     QModelIndex currentIndex = currentItemIndex();
       
  1443     mEngineWrapper->DiskAdminCheckDisk(currentIndex);
       
  1444 }
       
  1445 
       
  1446 /**
       
  1447   Checks the selected drive for errors and corrects them
       
  1448   */
       
  1449 void FileBrowserView::diskAdminScanDrive()
       
  1450 {
       
  1451     HbMessageBox::question(QString("This finds errors on disk and corrects them. Proceed?"), this, SLOT(doDiskAdminScanDrive(HbAction*)));
       
  1452 }
       
  1453 
       
  1454 /**
       
  1455   Checks the selected drive for errors and corrects them
       
  1456   */
       
  1457 void FileBrowserView::doDiskAdminScanDrive(HbAction* action)
       
  1458 {
       
  1459     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1460         QModelIndex currentIndex = currentItemIndex();
       
  1461         mEngineWrapper->DiskAdminScanDrive(currentIndex);
       
  1462         refreshList();
       
  1463     }
       
  1464 }
       
  1465 
       
  1466 /**
       
  1467   Open drive name dialog
       
  1468   */
       
  1469 void FileBrowserView::diskAdminSetDriveName()
       
  1470 {
       
  1471     QString driveName;
       
  1472 
       
  1473     // get existing drive name
       
  1474     QModelIndex currentIndex = currentItemIndex();
       
  1475     mEngineWrapper->GetDriveName(currentIndex, driveName);
       
  1476 
       
  1477     QString heading = QString("New name");
       
  1478     HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDriveName(HbAction*)), driveName, scene());
       
  1479 }
       
  1480 
       
  1481 /**
       
  1482   Set drive name.
       
  1483   */
       
  1484 void FileBrowserView::doDiskAdminSetDriveName(HbAction *action)
       
  1485 {
       
  1486     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1487     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1488         QString driveName = dlg->value().toString();
       
  1489 
       
  1490         QModelIndex currentIndex = currentItemIndex();
       
  1491         mEngineWrapper->DiskAdminSetDriveName(currentIndex, driveName);
       
  1492 
       
  1493         refreshList();
       
  1494     }
       
  1495 }
       
  1496 
       
  1497 /**
       
  1498   Open drive volume label dialog
       
  1499   */
       
  1500 void FileBrowserView::diskAdminSetDriveVolumeLabel()
       
  1501 {
       
  1502     QString volumeLabel;
       
  1503 
       
  1504     // get existing drive name
       
  1505     QModelIndex currentIndex = currentItemIndex();
       
  1506     mEngineWrapper->GetDriveVolumeLabel(currentIndex, volumeLabel);
       
  1507 
       
  1508     QString heading = QString("New volume label");
       
  1509     HbInputDialog::getText(heading, this, SLOT(doDiskAdminSetDriveVolumeLabel(HbAction*)), volumeLabel, scene());
       
  1510 }
       
  1511 
       
  1512 /**
       
  1513   Set drive volume label.
       
  1514   */
       
  1515 void FileBrowserView::doDiskAdminSetDriveVolumeLabel(HbAction *action)
       
  1516 {
       
  1517     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1518     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1519         QString volumeLabel = dlg->value().toString();
       
  1520 
       
  1521         QModelIndex currentIndex = currentItemIndex();
       
  1522         mEngineWrapper->DiskAdminSetDriveVolumeLabel(currentIndex, volumeLabel);
       
  1523 
       
  1524         refreshList();
       
  1525     }
       
  1526 }
       
  1527 
       
  1528 /**
       
  1529   Eject the selected drive
       
  1530   */
       
  1531 void FileBrowserView::diskAdminEjectDrive()
       
  1532 {
       
  1533     QModelIndex currentIndex = currentItemIndex();
       
  1534     mEngineWrapper->DiskAdminEjectDrive(currentIndex);
       
  1535     refreshList();
       
  1536 }
       
  1537 
       
  1538 /**
       
  1539   Dismount the selected drive
       
  1540   */
       
  1541 void FileBrowserView::diskAdminDismountDrive()
       
  1542 {
       
  1543     HbMessageBox::question(QString("Are you sure you know what are you doing?"), this, SLOT(doDiskAdminDismountDrive(HbAction*)));
       
  1544 }
       
  1545 
       
  1546 void FileBrowserView::doDiskAdminDismountDrive(HbAction* action)
       
  1547 {
       
  1548     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1549         QModelIndex currentIndex = currentItemIndex();
       
  1550         mEngineWrapper->DiskAdminDismountDrive(currentIndex);
       
  1551         refreshList();
       
  1552     }
       
  1553 }
       
  1554 
       
  1555 /**
       
  1556   Erase Master Boot Record of the selected drive
       
  1557   */
       
  1558 void FileBrowserView::diskAdminEraseMBR()
       
  1559 {
       
  1560     // TODO What to do with FB LITE macros?
       
  1561     HbMessageBox::question(QString("Are you sure? Your media driver must support this!"), this, SLOT(doDiskAdminEraseMBR(HbAction*)));
       
  1562 }
       
  1563 
       
  1564 void FileBrowserView::doDiskAdminEraseMBR(HbAction* action)
       
  1565 {
       
  1566     // TODO What to do with FB LITE macros?
       
  1567     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1568         HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"), this, SLOT(doDiskAdminReallyEraseMBR(HbAction*)));
       
  1569     }
       
  1570 }
       
  1571 
       
  1572 void FileBrowserView::doDiskAdminReallyEraseMBR(HbAction* action)
       
  1573 {
       
  1574     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1575         QModelIndex currentIndex = currentItemIndex();
       
  1576         // warn if the selected drive is not detected as removable
       
  1577         if (mEngineWrapper->isDriveRemovable(currentIndex)) {
       
  1578             mEngineWrapper->DiskAdminEraseMBR(currentIndex);
       
  1579             refreshList();
       
  1580         } else {
       
  1581             HbMessageBox::question(QString("Selected drive is not removable, really continue?"), this, SLOT(doDiskAdminNotRemovableReallyEraseMBR(HbAction*)));
       
  1582         }
       
  1583     }
       
  1584 }
       
  1585 
       
  1586 void FileBrowserView::doDiskAdminNotRemovableReallyEraseMBR(HbAction* action)
       
  1587 {
       
  1588     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1589         QModelIndex currentIndex = currentItemIndex();
       
  1590         mEngineWrapper->DiskAdminEraseMBR(currentIndex);
       
  1591         refreshList();
       
  1592     }
       
  1593 
       
  1594 }
       
  1595 
       
  1596 /**
       
  1597   Partition the selected drive
       
  1598   */
       
  1599 void FileBrowserView::diskAdminPartitionDrive()
       
  1600 {
       
  1601     const QString message("Are you sure? Your media driver must support this!");
       
  1602     HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveProceed(HbAction *)));
       
  1603 }
       
  1604 
       
  1605 /**
       
  1606   Partition the selected drive if user is sure
       
  1607   */
       
  1608 void FileBrowserView::diskAdminPartitionDriveProceed(HbAction *action)
       
  1609 {
       
  1610     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1611         const QString message("Are you really sure you know what are you doing ?!?");
       
  1612         HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveReallyProceed(HbAction *)));
       
  1613     }
       
  1614 }
       
  1615 
       
  1616 /**
       
  1617   Partition the selected drive if user is really sure
       
  1618   */
       
  1619 void FileBrowserView::diskAdminPartitionDriveReallyProceed(HbAction *action)
       
  1620 {
       
  1621     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1622         QModelIndex currentIndex = currentItemIndex();
       
  1623         mEraseMBR = false;
       
  1624         // warn if the selected drive is not detected as removable
       
  1625         mProceed = false;
       
  1626         if (mEngineWrapper->isDriveRemovable(currentIndex)) {
       
  1627             mProceed = true;
       
  1628         } else {
       
  1629             const QString message("Selected drive is not removable, really continue?");
       
  1630             HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveIsNotRemovable(HbAction *)));
       
  1631         }
       
  1632 
       
  1633         if (mProceed) {
       
  1634             // query if erase mbr
       
  1635             mEraseMBR = false;
       
  1636 
       
  1637             QString message("Erase MBR first (normally needed)?");
       
  1638             HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveEraseMbr(HbAction *)));
       
  1639 
       
  1640             // TODO use HbListDialog
       
  1641             QStringList list;
       
  1642             list << "1" << "2" << "3" << "4";
       
  1643             openListDialog(list, QString("Partitions?"), this, SLOT(diskAdminPartitionDriveGetCount(HbAction*)));
       
  1644         }
       
  1645     }
       
  1646 }
       
  1647 
       
  1648 /**
       
  1649   Store result of user query about proceeding when drive is not removable.
       
  1650   */
       
  1651 void FileBrowserView::diskAdminPartitionDriveIsNotRemovable(HbAction *action)
       
  1652 {
       
  1653     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1654         mProceed = true;
       
  1655     } else {
       
  1656         mProceed = false;
       
  1657     }
       
  1658 }
       
  1659 
       
  1660 /**
       
  1661   Store result of user query about erase MBR
       
  1662   */
       
  1663 void FileBrowserView::diskAdminPartitionDriveEraseMbr(HbAction *action)
       
  1664 {
       
  1665     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
  1666         mEraseMBR = true;
       
  1667     }
       
  1668 }
       
  1669 
       
  1670 /**
       
  1671   Partition the selected drive
       
  1672   */
       
  1673 void FileBrowserView::diskAdminPartitionDriveGetCount(HbAction* action)
       
  1674 {
       
  1675 //    Q_UNUSED(action);
       
  1676     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
       
  1677     if(!action && dlg && dlg->selectedItems().count()){
       
  1678         int selectionIndex = dlg->selectedItems().at(0).toInt();
       
  1679         QModelIndex currentIndex = currentItemIndex();
       
  1680         int amountOfPartitions = selectionIndex + 1;
       
  1681         mEngineWrapper->DiskAdminPartitionDrive(currentIndex, mEraseMBR, amountOfPartitions);
       
  1682         refreshList();
       
  1683     }
       
  1684 }
       
  1685 
       
  1686 // ---------------------------------------------------------------------------
       
  1687 // tools menu
       
  1688 // ---------------------------------------------------------------------------
       
  1689 void FileBrowserView::toolsAllAppsToTextFile()
       
  1690 {
       
  1691 
       
  1692 }
       
  1693 
       
  1694 /**
       
  1695   Write all files to text file
       
  1696   */
       
  1697 void FileBrowserView::toolsAllFilesToTextFile()
       
  1698 {
       
  1699     mEngineWrapper->toolsWriteAllFiles();
       
  1700 }
       
  1701 
       
  1702 void FileBrowserView::toolsAvkonIconCacheEnable()
       
  1703 {
       
  1704 
       
  1705 }
       
  1706 void FileBrowserView::toolsAvkonIconCacheDisable()
       
  1707 {
       
  1708 
       
  1709 }
       
  1710 
       
  1711 /**
       
  1712   Disable extended errors
       
  1713   */
       
  1714 void FileBrowserView::toolsDisableExtendedErrors()
       
  1715 {
       
  1716     mEngineWrapper->ToolsSetErrRd(false);
       
  1717 }
       
  1718 
       
  1719 void FileBrowserView::toolsDumpMsgStoreWalk()
       
  1720 {
       
  1721 
       
  1722 }
       
  1723 void FileBrowserView::toolsEditDataTypes()
       
  1724 {
       
  1725 
       
  1726 }
       
  1727 
       
  1728 /**
       
  1729   Enable extended errors
       
  1730   */
       
  1731 void FileBrowserView::toolsEnableExtendedErrors()
       
  1732 {
       
  1733     mEngineWrapper->ToolsSetErrRd(true);
       
  1734 }
       
  1735 
       
  1736 /**
       
  1737   Open simulate leave dialog
       
  1738   */
       
  1739 void FileBrowserView::toolsErrorSimulateLeave()
       
  1740 {
       
  1741     int leaveCode = -6;
       
  1742     QString heading = QString("Leave code");
       
  1743     //HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene());
       
  1744     HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene());
       
  1745 }
       
  1746 
       
  1747 
       
  1748 /**
       
  1749   Simulate leave.
       
  1750   */
       
  1751 void FileBrowserView::doToolsErrorSimulateLeave(HbAction *action)
       
  1752 {
       
  1753     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1754     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1755         bool ok;
       
  1756         int leaveCode = dlg->value().toString().toInt(&ok);
       
  1757         if (leaveCode != 0 || ok) {
       
  1758             mEngineWrapper->ToolsErrorSimulateLeave(leaveCode);
       
  1759         }
       
  1760     }
       
  1761 }
       
  1762 
       
  1763 /**
       
  1764   Open simulate panic dialog.
       
  1765   */
       
  1766 void FileBrowserView::toolsErrorSimulatePanic()
       
  1767 {
       
  1768     mPanicCategory = QString ("Test Category");
       
  1769     QString heading = QString("Panic category");
       
  1770     HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene());
       
  1771 }
       
  1772 
       
  1773 /**
       
  1774   Simulate panic.
       
  1775   */
       
  1776 void FileBrowserView::doToolsErrorSimulatePanicCode(HbAction *action)
       
  1777 {
       
  1778     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1779     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1780         mPanicCategory = dlg->value().toString();
       
  1781         int panicCode(555);
       
  1782         QString heading = QString("Panic code");
       
  1783         HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene());
       
  1784     }
       
  1785 }
       
  1786 
       
  1787 /**
       
  1788   Simulate panic.
       
  1789   */
       
  1790 void FileBrowserView::doToolsErrorSimulatePanic(HbAction *action)
       
  1791 {
       
  1792     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1793     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1794         bool ok;
       
  1795         int panicCode = dlg->value().toInt(&ok);
       
  1796         if (panicCode != 0 || ok) {
       
  1797             mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode);
       
  1798         }
       
  1799     }
       
  1800 }
       
  1801 
       
  1802 /**
       
  1803   Open simulate exception dialog.
       
  1804   */
       
  1805 void FileBrowserView::toolsErrorSimulateException()
       
  1806 {
       
  1807     int exceptionCode = 0;
       
  1808     QString heading = QString("Exception code");
       
  1809     HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene());
       
  1810 }
       
  1811 
       
  1812 /**
       
  1813   Simulate exception.
       
  1814   */
       
  1815 void FileBrowserView::doToolsErrorSimulateException(HbAction *action)
       
  1816 {
       
  1817     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1818     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1819         bool ok;
       
  1820         int exceptionCode = dlg->value().toInt(&ok);
       
  1821         if (exceptionCode != 0 || ok) {
       
  1822             mEngineWrapper->ToolsErrorSimulateException(exceptionCode);
       
  1823         }
       
  1824     }
       
  1825 }
       
  1826 
       
  1827 //    void FileBrowserView::toolsLocalConnectivityActivateInfrared()
       
  1828 //{
       
  1829 //
       
  1830 //}
       
  1831 //    void FileBrowserView::toolsLocalConnectivityLaunchBTUI()
       
  1832 //{
       
  1833 //
       
  1834 //}
       
  1835 //    void FileBrowserView::toolsLocalConnectivityLaunchUSBUI()
       
  1836 //{
       
  1837 //
       
  1838 //}
       
  1839 void FileBrowserView::toolsMessageInbox()
       
  1840 {
       
  1841 
       
  1842 }
       
  1843 void FileBrowserView::toolsMessageDrafts()
       
  1844 {
       
  1845 
       
  1846 }
       
  1847 void FileBrowserView::toolsMessageSentItems()
       
  1848 {
       
  1849 
       
  1850 }
       
  1851 void FileBrowserView::toolsMessageOutbox()
       
  1852 {
       
  1853 
       
  1854 }
       
  1855 void FileBrowserView::toolsMemoryInfo()
       
  1856 {
       
  1857 
       
  1858 }
       
  1859 void FileBrowserView::toolsSecureBackStart()
       
  1860 {
       
  1861 
       
  1862 }
       
  1863 void FileBrowserView::toolsSecureBackRestore()
       
  1864 {
       
  1865 
       
  1866 }
       
  1867 void FileBrowserView::toolsSecureBackStop()
       
  1868 {
       
  1869 
       
  1870 }
       
  1871 
       
  1872 /**
       
  1873   Open debug mask dialog
       
  1874   */
       
  1875 void FileBrowserView::toolsSetDebugMaskQuestion()
       
  1876 {
       
  1877     quint32 dbgMask = mEngineWrapper->getDebugMask();
       
  1878     QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16));
       
  1879     QString heading = QString("Kernel debug mask in hex format");
       
  1880     HbInputDialog::getText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene());
       
  1881 }
       
  1882 
       
  1883 /**
       
  1884   Set debug mask
       
  1885   */
       
  1886 void FileBrowserView::toolsSetDebugMask(HbAction *action)
       
  1887 {
       
  1888     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1889     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1890         QString dbgMaskText = dlg->value().toString();
       
  1891         if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') {
       
  1892             bool ok;
       
  1893             quint32 dbgMask = dbgMaskText.toUInt(&ok, 16);
       
  1894             if (dbgMask != 0 || ok) {
       
  1895                 mEngineWrapper->toolsSetDebugMask(dbgMask);
       
  1896                 Notifications::showConfirmationNote(QString("Changed"));
       
  1897             } else {
       
  1898                 Notifications::showErrorNote(QString("Cannot convert value"));
       
  1899             }
       
  1900         } else {
       
  1901             Notifications::showErrorNote(QString("Not in hex format"));
       
  1902         }
       
  1903     }
       
  1904 }
       
  1905 
       
  1906 void FileBrowserView::toolsShowOpenFilesHere()
       
  1907 {
       
  1908 
       
  1909 }
       
  1910 
       
  1911 // ---------------------------------------------------------------------------
       
  1912 // main menu items
       
  1913 // ---------------------------------------------------------------------------
       
  1914 void FileBrowserView::selectionModeChanged()
       
  1915 {
       
  1916     if (mOptionMenuActions.mSelection->isChecked()) {
       
  1917          activateSelectionMode();
       
  1918      } else {
       
  1919          deActivateSelectionMode();
       
  1920      }
       
  1921 }
       
  1922 
       
  1923 /**
       
  1924   Show about note
       
  1925   */
       
  1926 void FileBrowserView::about()
       
  1927 {
       
  1928     Notifications::showAboutNote();
       
  1929 }
       
  1930 
       
  1931 // ---------------------------------------------------------------------------
       
  1932 // End of operations
       
  1933 // ---------------------------------------------------------------------------
       
  1934 
       
  1935 // ---------------------------------------------------------------------------
       
  1936 
       
  1937 /**
       
  1938   Item is selected from list when selection mode is activated from menu
       
  1939   */
       
  1940 void FileBrowserView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
       
  1941 {
       
  1942     //QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1943     //itemHighlighted(selectionModel->currentIndex());
       
  1944 }
       
  1945 
       
  1946 /**
       
  1947   An item is highlighted = single-clicked from file/folder list.
       
  1948   */
       
  1949 void FileBrowserView::itemHighlighted(const QModelIndex& index)
       
  1950 {
       
  1951     Q_UNUSED(index)
       
  1952 //    mItemHighlighted = true;
       
  1953 //    mFileInfo = mFileSystemModel->fileInfo(index);
       
  1954 }
       
  1955 
       
  1956 
       
  1957 /**
       
  1958   An item is clicked from navigation item list. Navigation item list contains
       
  1959   drive-, folder- or file items. Opens selected drive, folder or file popup menu
       
  1960   */
       
  1961 void FileBrowserView::activated(const QModelIndex& index)
       
  1962 {
       
  1963     if (mFileBrowserModel) {
       
  1964         if (mEngineWrapper->isDriveListViewActive()) {
       
  1965             mEngineWrapper->moveDownToDirectory(index);
       
  1966             populateFolderContent();
       
  1967         } else if (mEngineWrapper->getFileEntry(index).isDir()) {
       
  1968             // populate new content of changed navigation view.
       
  1969             // mLocationChanged = true;
       
  1970             // mDirectory = filePath;
       
  1971             mEngineWrapper->moveDownToDirectory(index);
       
  1972             populateFolderContent();
       
  1973         } else {  // file item
       
  1974             // mSelectedFilePath = filePath;
       
  1975             FileEntry fileEntry = mEngineWrapper->getFileEntry(index);
       
  1976             mAbsoluteFilePath = fileEntry.path() + fileEntry.name();
       
  1977 
       
  1978             // open user-dialog to select: view as text/hex,  open w/AppArc or open w/DocH. embed
       
  1979             QStringList list;
       
  1980             list << QString("View as text/hex") << QString("Open w/ AppArc") << QString("Open w/ DocH. embed");
       
  1981             openListDialog(list, QString("Open file"), this, SLOT(fileOpen(HbAction *)));
       
  1982         }
       
  1983     }
       
  1984 }
       
  1985 
       
  1986 // ---------------------------------------------------------------------------
       
  1987 
       
  1988 void FileBrowserView::activateSelectionMode()
       
  1989 {
       
  1990     QString path;
       
  1991     disconnect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
       
  1992     mListView->setSelectionMode(HbListView::MultiSelection);
       
  1993 
       
  1994 //    if (mDirectory != mInitDirPath.path()) {
       
  1995 //        QDir dir(mDirectory);
       
  1996 //        path = mDirectory;
       
  1997 //        QStringList dirs = dir.entryList(QDir::AllDirs | QDir::System | QDir::Hidden);
       
  1998 //        if (dirs.count() > 0) {
       
  1999 //            path.append("\\" + dirs.at(0) + "\\");
       
  2000 //        }
       
  2001 //    } else {
       
  2002 //        path = ("C:\\");
       
  2003 //    }
       
  2004 //    QModelIndex index = mFileSystemModel->index(path,0);
       
  2005 //    mListView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent);
       
  2006 //    mListView->selectionModel()->select(index, QItemSelectionModel::Select);
       
  2007 //    //mListView->setHighlightMode(HbItemHighlight::HighlightAlwaysVisible);
       
  2008 //    mListView->setFocus();    // TODO use focus in
       
  2009     if (mListView->selectionModel()) {
       
  2010         connect(mListView->selectionModel(),
       
  2011                 SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
       
  2012                 this,
       
  2013                 SLOT(selectionChanged(QItemSelection, QItemSelection)));
       
  2014 //        // flag to indicate that selection mode changed, "edit" sub-menu update needed
       
  2015 //        mFolderContentChanged = true;
       
  2016     }
       
  2017 }
       
  2018 
       
  2019 // ---------------------------------------------------------------------------
       
  2020 
       
  2021 void FileBrowserView::deActivateSelectionMode()
       
  2022 {
       
  2023     disconnect(mListView->selectionModel(),
       
  2024                SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
       
  2025                this,
       
  2026                SLOT(selectionChanged(QItemSelection, QItemSelection)));
       
  2027     mListView->setSelectionMode(HbListView::NoSelection);
       
  2028     connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
       
  2029     editUnselectAll();
       
  2030     // flag to indicate that selection mode changed, "edit" sub-menu update needed
       
  2031     mFolderContentChanged = true;
       
  2032 }
       
  2033 
       
  2034 // ---------------------------------------------------------------------------