filebrowser/ui/src/fbdriveview.cpp
changeset 55 2d9cac8919d3
parent 53 819e59dfc032
child 56 392f7045e621
equal deleted inserted replaced
53:819e59dfc032 55:2d9cac8919d3
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "fbdriveview.h"
       
    19 #include "fbsettingsview.h"
       
    20 #include "fbeditorview.h"
       
    21 #include "fbsearchview.h"
       
    22 #include "enginewrapper.h"
       
    23 #include "notifications.h"
       
    24 
       
    25 #include "fbdrivemodel.h"
       
    26 #include "filebrowsersortfilterproxymodel.h"
       
    27 #include "fbdrivelistviewitem.h"
       
    28 
       
    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 
       
    44 #include <QString>
       
    45 #include <QGraphicsLinearLayout>
       
    46 #include <QItemSelection>
       
    47 #include <QDebug>
       
    48 //TODO check if needed to do this way
       
    49 #include <FB.hrh>
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 
       
    53 FbDriveView::FbDriveView() :
       
    54     mEngineWrapper(0),
       
    55     mListView(0),
       
    56     mNaviPane(0),
       
    57     mMainLayout(0),
       
    58     mFbDriveModel(0),
       
    59     mOptionMenuActions(),
       
    60     mContextMenuActions(),
       
    61     mContextMenu(0),
       
    62     mLocationChanged(false),
       
    63     mRemoveFileAfterCopied(false),
       
    64 //    mClipBoardInUse(false),
       
    65     mFolderContentChanged(false),
       
    66     mCurrentIndex(),
       
    67     mOldPassword(),
       
    68     mPanicCategory(),
       
    69     mAbsoluteFilePath(),
       
    70     mOverwriteOptions(),
       
    71     mModelIndex(),
       
    72     mNewFileName(),
       
    73     mProceed(false),
       
    74     mEraseMBR(false)
       
    75 {
       
    76     setTitle("File Browser");
       
    77 
       
    78     createMenu();
       
    79     createContextMenu();
       
    80 }
       
    81 
       
    82 // ---------------------------------------------------------------------------	
       
    83 
       
    84 void FbDriveView::init(EngineWrapper *engineWrapper)
       
    85 {
       
    86     mEngineWrapper = engineWrapper;
       
    87 
       
    88     mListView = new HbListView(this);
       
    89     mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape);
       
    90 
       
    91     mListView->setItemPrototype(new FbDriveListViewItem(mListView));
       
    92 
       
    93     mFbDriveModel = new FbDriveModel(mEngineWrapper);
       
    94     if (!mListView->model()) {
       
    95         mEngineWrapper->refreshView();
       
    96         mListView->setModel(mFbDriveModel);
       
    97     }
       
    98 
       
    99     //mListView->setRootIndex(mFileSystemModel->index(startPath));
       
   100     //mListView->setRootIndex(model->index());
       
   101 
       
   102 //    mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
       
   103 
       
   104     connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
       
   105     connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)),
       
   106             this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF)));
       
   107 
       
   108     mNaviPane = new HbLabel(this);
       
   109     mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default
       
   110     //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
       
   111     HbFontSpec fontSpec(HbFontSpec::PrimarySmall);
       
   112     mNaviPane->setFontSpec(fontSpec);
       
   113 
       
   114     // Create layout and add list view and naviPane into layout:
       
   115     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
   116     mMainLayout->addItem(mNaviPane);
       
   117     mMainLayout->addItem(mListView);
       
   118     setLayout(mMainLayout);
       
   119 }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 
       
   123 FbDriveView::~FbDriveView()
       
   124 {  
       
   125 //    if (mEngineWrapper) {
       
   126 //        delete mEngineWrapper;
       
   127 //    }
       
   128     if (mContextMenu) {
       
   129         mContextMenu->deleteLater();
       
   130     }
       
   131 
       
   132     delete mFbDriveModel;
       
   133     delete mListView;
       
   134 }
       
   135 
       
   136 /**
       
   137   Initial setup for options menu.
       
   138   Dynamic menu update during the runtime is performed by updateOptionMenu() which
       
   139   to menu's aboutToShow() signal.
       
   140   */
       
   141 void FbDriveView::createMenu()
       
   142 {
       
   143     createFileMenu();
       
   144     createEditMenu();
       
   145     createViewMenu();
       
   146     createToolsMenu();
       
   147 
       
   148     createSettingsMenuItem();
       
   149     createAboutMenuItem();
       
   150     createExitMenuItem();
       
   151 
       
   152     // menu dynamic update
       
   153     connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu()));
       
   154 }
       
   155 
       
   156 /**
       
   157   Initial setup for File submenu
       
   158   */
       
   159 void FbDriveView::createFileMenu()
       
   160 {
       
   161     mOptionMenuActions.mFileMenu = menu()->addMenu("File");
       
   162 
       
   163     mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
       
   164     //mOptionMenuActions.mFileSearch->setVisible(false);
       
   165 
       
   166     //mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New");
       
   167 
       
   168     mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
       
   169     mOptionMenuActions.mFileSetAttributes->setVisible(false);
       
   170 }
       
   171 
       
   172 /**
       
   173   Initial setup for Edit submenu
       
   174   */
       
   175 void FbDriveView::createEditMenu()
       
   176 {
       
   177     mOptionMenuActions.mEditMenu = menu()->addMenu("Edit");
       
   178 
       
   179     mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE()));
       
   180     mOptionMenuActions.mEditSnapShotToE->setVisible(false);
       
   181 }
       
   182 
       
   183 /**
       
   184   Initial setup for View submenu
       
   185   */
       
   186 void FbDriveView::createViewMenu()
       
   187 {
       
   188     mOptionMenuActions.mViewMenu = menu()->addMenu("View");
       
   189     //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false);
       
   190 
       
   191     //mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries()));
       
   192     mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh()));
       
   193 }
       
   194 
       
   195 /**
       
   196   Initial setup for Tools submenu
       
   197   */
       
   198 void FbDriveView::createToolsMenu()
       
   199 {
       
   200     mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools");
       
   201 
       
   202     mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile()));
       
   203     mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false);
       
   204     mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile()));
       
   205     //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false);
       
   206 
       
   207 //    mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache");
       
   208 //    mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false);
       
   209 //    mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable()));
       
   210 //    mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable()));
       
   211 
       
   212     mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors()));
       
   213     mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk()));
       
   214     mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false);
       
   215     mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes()));
       
   216     mOptionMenuActions.mToolsEditDataTypes->setVisible(false);
       
   217     mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors()));
       
   218 
       
   219     mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate");
       
   220     mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave()));
       
   221     mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic()));
       
   222     mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false);
       
   223     mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException()));
       
   224 
       
   225 //    mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity");
       
   226 //    mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared()));
       
   227 //    mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI()));
       
   228 //    mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI()));
       
   229 
       
   230     mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments");
       
   231     mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false);
       
   232     mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox()));
       
   233     mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts()));
       
   234     mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems()));
       
   235     mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox()));
       
   236 
       
   237     mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo()));
       
   238     mOptionMenuActions.mToolsMemoryInfo->setVisible(false);
       
   239 
       
   240     mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup");
       
   241     mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false);
       
   242     mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart()));
       
   243     mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore()));
       
   244     mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop()));
       
   245 
       
   246     mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion()));
       
   247     mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere()));
       
   248     mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false);
       
   249 }
       
   250 
       
   251 /**
       
   252   Creates Setting menu item in option menu
       
   253   */
       
   254 void FbDriveView::createSettingsMenuItem()
       
   255 {
       
   256     mOptionMenuActions.mSetting = menu()->addAction("Settings...");
       
   257     connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView()));
       
   258 }
       
   259 
       
   260 
       
   261 /**
       
   262   Creates About menu item in option menu
       
   263   */
       
   264 void FbDriveView::createAboutMenuItem()
       
   265 {
       
   266     // about note
       
   267     mOptionMenuActions.mAbout = menu()->addAction("About");
       
   268     connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about()));
       
   269 }
       
   270 
       
   271 /**
       
   272   Creates Exit menu item in option menu
       
   273   */
       
   274 void FbDriveView::createExitMenuItem()
       
   275 {
       
   276     // application exit
       
   277     mOptionMenuActions.mExit = menu()->addAction("Exit");
       
   278     connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit()));
       
   279 }
       
   280 
       
   281 /**
       
   282   update menu: disk admin available only in device root view. edit available only in folder view
       
   283   when file or folder content exist in current folder, or clipboard has copied item.
       
   284   file and view menus updated every time regarding the folder content.
       
   285   tools, settings, about, exit always available.
       
   286   If there's remove and add operations at same time, always remove first
       
   287   to keep to the correct menu items order.
       
   288   */
       
   289 void FbDriveView::updateOptionMenu()
       
   290 {
       
   291     bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0;
       
   292 //    bool isDriveListViewActive = true; //mEngineWrapper->isDriveListViewActive();
       
   293     bool isNormalModeActive = true;       //iModel->FileUtils()->IsNormalModeActive();
       
   294 //    bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly();   //iModel->FileUtils()->IsCurrentDriveReadOnly();
       
   295 //    bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir();
       
   296     // bool currentSelected = true;    //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex());
       
   297 //    bool isAllSelected = mListView->selectionModel()->selection().count() == mFbDriveModel->rowCount();
       
   298     //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0;
       
   299 //    bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0;
       
   300     //bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
       
   301     bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse();
       
   302     bool showSnapShot = false;           //iModel->FileUtils()->DriveSnapShotPossible();
       
   303 
       
   304     bool showEditMenu(true);
       
   305     if (!showSnapShot || isFileItemListEmpty && isClipBoardEmpty)
       
   306         showEditMenu = false;
       
   307     else
       
   308         showEditMenu = true;
       
   309 
       
   310     mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu);
       
   311 
       
   312     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileOpen, isFileItemListEmpty || isDriveListViewActive || isCurrentItemDirectory);
       
   313 
       
   314     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive);
       
   315     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive);
       
   316     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory);
       
   317 
       
   318     // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive));
       
   319     // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory || isDriveListViewActive));
       
   320 
       
   321     // TODO mOptionMenuActions.mEditSnapShotToE->setVisible(isDriveListViewActive);
       
   322 
       
   323     // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty));
       
   324     // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive || isDriveListViewActive || isFileItemListEmpty));
       
   325     mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive);
       
   326     //mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty);
       
   327 
       
   328     // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU
       
   329     // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn);
       
   330 
       
   331     // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU
       
   332     // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn);
       
   333 
       
   334     // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU
       
   335     bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists();
       
   336     mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed);
       
   337     mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed);
       
   338 
       
   339 //    bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath);
       
   340 //    bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath);
       
   341 //    bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath);
       
   342 //
       
   343 //    bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed;
       
   344 //    mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon);
       
   345 //
       
   346 //    mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed);
       
   347 //    mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed);
       
   348 //    mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed);
       
   349 }
       
   350 
       
   351 void FbDriveView::createContextMenu()
       
   352 {
       
   353     mContextMenu = new HbMenu();
       
   354     connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu()));
       
   355 
       
   356     createFileContextMenu();
       
   357     createEditContextMenu();
       
   358     createViewContextMenu();
       
   359     createDiskAdminContextMenu();
       
   360 }
       
   361 
       
   362 
       
   363 void FbDriveView::createFileContextMenu()
       
   364 {
       
   365     //mContextMenuActions.mFileMenu = mContextMenu->addMenu("File");
       
   366 
       
   367     //mContextMenuActions.mFileOpenDrive = mContextMenuActions.mFileMenu->addAction("Open drive (->)", this, SLOT(fileOpenDrive()));
       
   368 //    mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
       
   369     //mContextMenuActions.mFileSearch->setVisible(false);
       
   370 
       
   371     //mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties()));
       
   372     mContextMenuActions.mFileProperties = mContextMenu->addAction("Properties", this, SLOT(fileProperties()));
       
   373     mContextMenuActions.mFileSearch = mContextMenu->addAction("Search...", this, SLOT(fileSearch()));
       
   374 
       
   375 //    mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
       
   376 //    mContextMenuActions.mFileSetAttributes->setVisible(false);
       
   377 }
       
   378 
       
   379 void FbDriveView::createEditContextMenu()
       
   380 {
       
   381 //    mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit");
       
   382 
       
   383     //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE()));
       
   384 //    mContextMenuActions.mEditSnapShotToE->setVisible(false);
       
   385 //    mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut()));
       
   386 //    mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy()));
       
   387 //    mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste()));
       
   388 //    mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder()));
       
   389 //    mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder()));
       
   390 }
       
   391 
       
   392 void FbDriveView::createViewContextMenu()
       
   393 {
       
   394 
       
   395 }
       
   396 
       
   397 /**
       
   398   Initial setup for Disk Admin submenu
       
   399   */
       
   400 void FbDriveView::createDiskAdminContextMenu()
       
   401 {
       
   402     mContextMenuActions.mDiskAdminMenu = mContextMenu->addMenu("Disk admin");
       
   403     //mContextMenuActions.mDiskAdminMenu->menuAction()->setVisible(false);
       
   404 
       
   405     mContextMenuActions.mDiskAdminSetDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Set drive password", this, SLOT(diskAdminSetDrivePassword()));
       
   406     mContextMenuActions.mDiskAdminUnlockDrive = mContextMenuActions.mDiskAdminMenu->addAction("Unlock drive", this, SLOT(diskAdminUnlockDrive()));
       
   407     mContextMenuActions.mDiskAdminClearDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Clear drive password", this, SLOT(diskAdminClearDrivePassword()));
       
   408     mContextMenuActions.mDiskAdminEraseDrivePassword = mContextMenuActions.mDiskAdminMenu->addAction("Erase drive password", this, SLOT(diskAdminEraseDrivePassword()));
       
   409 
       
   410     mContextMenuActions.mDiskAdminFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Format drive", this, SLOT(diskAdminFormatDrive()));
       
   411     mContextMenuActions.mDiskAdminFormatDrive->setVisible(false);
       
   412     mContextMenuActions.mDiskAdminQuickFormatDrive = mContextMenuActions.mDiskAdminMenu->addAction("Quick format drive", this, SLOT(diskAdminQuickFormatDrive()));
       
   413     mContextMenuActions.mDiskAdminQuickFormatDrive->setVisible(false);
       
   414 
       
   415     mContextMenuActions.mDiskAdminCheckDisk = mContextMenuActions.mDiskAdminMenu->addAction("Check disk", this, SLOT(diskAdminCheckDisk()));
       
   416     mContextMenuActions.mDiskAdminScanDrive = mContextMenuActions.mDiskAdminMenu->addAction("Scan drive", this, SLOT(diskAdminScanDrive()));
       
   417     mContextMenuActions.mDiskAdminSetDriveName = mContextMenuActions.mDiskAdminMenu->addAction("Set drive name", this, SLOT(diskAdminSetDriveName()));
       
   418     mContextMenuActions.mDiskAdminSetDriveVolumeLabel = mContextMenuActions.mDiskAdminMenu->addAction("Set drive volume label", this, SLOT(diskAdminSetDriveVolumeLabel()));
       
   419     mContextMenuActions.mDiskAdminEjectDrive = mContextMenuActions.mDiskAdminMenu->addAction("Eject drive", this, SLOT(diskAdminEjectDrive()));
       
   420     mContextMenuActions.mDiskAdminDismountDrive = mContextMenuActions.mDiskAdminMenu->addAction("Dismount drive", this, SLOT(diskAdminDismountDrive()));
       
   421     mContextMenuActions.mDiskAdminEraseMBR = mContextMenuActions.mDiskAdminMenu->addAction("Erase MBR", this, SLOT(diskAdminEraseMBR()));
       
   422     mContextMenuActions.mDiskAdminPartitionDrive = mContextMenuActions.mDiskAdminMenu->addAction("Partition drive", this, SLOT(diskAdminPartitionDrive()));
       
   423 }
       
   424 
       
   425 void FbDriveView::updateContextMenu()
       
   426 {
       
   427     bool isFileItemListEmpty = mFbDriveModel->rowCount() == 0;
       
   428     mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty);
       
   429 }
       
   430 
       
   431 // ---------------------------------------------------------------------------
       
   432 
       
   433 void FbDriveView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords)
       
   434 {
       
   435     mCurrentIndex = listViewItem->modelIndex();
       
   436 
       
   437     mContextMenu->setPreferredPos(coords);
       
   438     mContextMenu->show();
       
   439 }
       
   440 
       
   441 /**
       
   442   Refresh FileBrowser view
       
   443   */
       
   444 void FbDriveView::refreshList()
       
   445 {
       
   446     mEngineWrapper->refreshView();
       
   447     mListView->reset();
       
   448 
       
   449     TListingMode listingMode = mEngineWrapper->listingMode();
       
   450     if (listingMode == ENormalEntries)
       
   451         mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
       
   452     else if (listingMode == ESearchResults)
       
   453         mNaviPane->setPlainText(QString(tr("Search results")));
       
   454     else if (listingMode == EOpenFiles)
       
   455         mNaviPane->setPlainText(QString(tr("Open files")));
       
   456     else if (listingMode == EMsgAttachmentsInbox)
       
   457         mNaviPane->setPlainText(QString(tr("Attachments in Inbox")));
       
   458     else if (listingMode == EMsgAttachmentsDrafts)
       
   459         mNaviPane->setPlainText(QString(tr("Attachments in Drafts")));
       
   460     else if (listingMode == EMsgAttachmentsSentItems)
       
   461         mNaviPane->setPlainText(QString(tr("Attachments in Sent Items")));
       
   462     else if (listingMode == EMsgAttachmentsOutbox)
       
   463         mNaviPane->setPlainText(QString(tr("Attachments in Outbox")));
       
   464 }
       
   465 
       
   466 // ---------------------------------------------------------------------------
       
   467 /**
       
   468   Show a list dialog
       
   469   \param List aList of item to select item from.
       
   470   \param Title text titleText of a dialog heading widget
       
   471   \return None
       
   472   */
       
   473 void FbDriveView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member)
       
   474 {
       
   475     // Create a list and some simple content for it
       
   476     HbSelectionDialog *dlg = new HbSelectionDialog();
       
   477     dlg->setAttribute(Qt::WA_DeleteOnClose);
       
   478     // Set items to be popup's content
       
   479     dlg->setStringItems(items);
       
   480     dlg->setSelectionMode(HbAbstractItemView::SingleSelection);
       
   481 
       
   482     HbLabel *title = new HbLabel(dlg);
       
   483     title->setPlainText(titleText);
       
   484     dlg->setHeadingWidget(title);
       
   485 
       
   486     // Launch popup and handle the user response:
       
   487     dlg->open(receiver, member);
       
   488 }
       
   489 
       
   490 // ---------------------------------------------------------------------------
       
   491 
       
   492 void FbDriveView::openPropertyDialog(const QStringList& propertyList, const QString& title)
       
   493 {
       
   494     HbDialog *dialog = new HbDialog();
       
   495     dialog->setDismissPolicy(HbPopup::TapOutside);
       
   496     dialog->setTimeout(HbPopup::NoTimeout);
       
   497 
       
   498     HbLabel *titleWidget = new HbLabel();
       
   499     titleWidget->setPlainText(title);
       
   500     dialog->setHeadingWidget(titleWidget);
       
   501 
       
   502     // Create a list and some simple content for it
       
   503     HbListWidget *list = new HbListWidget();
       
   504     QString str;
       
   505     foreach (str, propertyList) {
       
   506         list->addItem(str);
       
   507     }
       
   508 
       
   509     // Connect list item activation signal to close the popup
       
   510     connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close()));
       
   511 
       
   512     HbAction *cancelAction = new HbAction("Close");
       
   513     dialog->setPrimaryAction(cancelAction);
       
   514 
       
   515     // Set listwidget to be popup's content
       
   516     dialog->setContentWidget(list);
       
   517     // Launch popup and handle the user response:
       
   518     dialog->open();
       
   519 }
       
   520 
       
   521 void FbDriveView::storeSelectedItemsOrCurrentItem()
       
   522 {
       
   523     QItemSelectionModel *selectionIndexes = mListView->selectionModel();
       
   524 
       
   525     // by default use selected items
       
   526     if (selectionIndexes) {
       
   527         if (selectionIndexes->hasSelection()) {
       
   528             mSelectionIndexes = mListView->selectionModel()->selectedIndexes();
       
   529         } else { // or if none selected, use the current item index
       
   530             mSelectionIndexes.clear();
       
   531             mSelectionIndexes.append(mCurrentIndex);
       
   532 //            QModelIndex currentIndex = currentItemIndex();
       
   533 //            if (mFbDriveModel->rowCount(currentItemIndex) > currentItemIndex && currentItemIndex >= 0)
       
   534 //            {
       
   535 //                modelIndexList.append(currentIndex);
       
   536 //            }
       
   537         }
       
   538     }
       
   539 //    mClipBoardInUse = true;
       
   540 }
       
   541 
       
   542 // ---------------------------------------------------------------------------
       
   543 
       
   544 QModelIndex FbDriveView::currentItemIndex()
       
   545 {
       
   546     return mCurrentIndex;//mListView->selectionModel()->currentIndex();
       
   547 }
       
   548 
       
   549 // ---------------------------------------------------------------------------
       
   550 // operations in File Menu
       
   551 // ---------------------------------------------------------------------------
       
   552 
       
   553 void FbDriveView::fileOpenDrive()
       
   554 {
       
   555     // TODO make a separate function to be called from here and fileOpenDirectory()
       
   556     mLocationChanged = true;
       
   557     // get selected drive or directory from list view model and open it:
       
   558     //if (mListView->selectionModel()->hasSelection()) {
       
   559 //    if (mListView->selectionModel()->selection().count() != 0) {
       
   560 //        QModelIndex currentIndex = currentItemIndex();
       
   561         mEngineWrapper->moveDownToDirectory(mCurrentIndex);
       
   562         mListView->setRootIndex(mCurrentIndex);
       
   563         refreshList();
       
   564 //    } else {
       
   565 //        Notifications::showErrorNote("not selected item!");
       
   566 //    }
       
   567 }
       
   568 
       
   569 void FbDriveView::fileSearch()
       
   570 {
       
   571     QString searchPath;
       
   572     HbAction *contextrMenuAction = static_cast<HbAction *>(sender());
       
   573     if (contextrMenuAction
       
   574         && contextrMenuAction->text().compare(QString("Search..."), Qt::CaseInsensitive) == 0
       
   575         && contextrMenuAction == mContextMenuActions.mFileSearch) {
       
   576         FbDriveEntry driveEntry(mEngineWrapper->getDriveEntry(currentItemIndex()));
       
   577         searchPath = driveEntry.driveLetter() + QString(":\\");
       
   578     } else {
       
   579         searchPath = mEngineWrapper->currentPath();
       
   580     }
       
   581     emit aboutToShowSearchView(searchPath);
       
   582 }
       
   583 
       
   584 /**
       
   585   Show file properties
       
   586   */
       
   587 void FbDriveView::fileProperties()
       
   588 {
       
   589     QModelIndex currentIndex = currentItemIndex();
       
   590     QStringList propertyList;
       
   591     QString titleText;
       
   592     mEngineWrapper->properties(currentIndex, propertyList, titleText);
       
   593     openPropertyDialog(propertyList, titleText);
       
   594 }
       
   595 
       
   596 void FbDriveView::fileSetAttributes()
       
   597 {
       
   598 
       
   599 }
       
   600 
       
   601 // edit menu
       
   602 void FbDriveView::editSnapShotToE()
       
   603 {
       
   604 
       
   605 }
       
   606 
       
   607 // ---------------------------------------------------------------------------
       
   608 // view menu
       
   609 // ---------------------------------------------------------------------------
       
   610 
       
   611 /**
       
   612   Refresh view
       
   613   */
       
   614 void FbDriveView::viewRefresh()
       
   615 {
       
   616     refreshList();
       
   617 }
       
   618 
       
   619 // ---------------------------------------------------------------------------
       
   620 // disk admin menu
       
   621 // ---------------------------------------------------------------------------
       
   622 
       
   623 /**
       
   624   Open old password for the selected drive dialog.
       
   625   */
       
   626 void FbDriveView::diskAdminSetDrivePassword()
       
   627 {
       
   628     QModelIndex currentIndex = currentItemIndex();
       
   629     // check if the drive has a password
       
   630     if (mEngineWrapper->hasDrivePassword(currentIndex)) {
       
   631         QString heading = QString("Existing password");
       
   632         HbInputDialog::queryText(heading, this, SLOT(diskAdminSetDrivePasswordNew(HbAction*)), QString(), scene());
       
   633     } else {
       
   634         QString heading = QString("New password");
       
   635         HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene());
       
   636     }
       
   637 }
       
   638 
       
   639 /**
       
   640    Open new password for the selected drive dialog.
       
   641   */
       
   642 void FbDriveView::diskAdminSetDrivePasswordNew(HbAction *action)
       
   643 {
       
   644     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   645     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   646         mOldPassword = dlg->value().toString();
       
   647         QString heading = QString("New password");
       
   648         HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDrivePassword(HbAction*)), mOldPassword, scene());
       
   649     }
       
   650 }
       
   651 
       
   652 /**
       
   653    Set password for the selected drive.
       
   654   */
       
   655 void FbDriveView::doDiskAdminSetDrivePassword(HbAction *action)
       
   656 {
       
   657     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   658     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   659         QString newPassword = dlg->value().toString();
       
   660         QModelIndex currentIndex = currentItemIndex();
       
   661         mEngineWrapper->DiskAdminSetDrivePassword(currentIndex, mOldPassword, newPassword);
       
   662         refreshList();
       
   663         mOldPassword = QString();
       
   664         newPassword = QString();
       
   665     }
       
   666 }
       
   667 
       
   668 /**
       
   669   Open Unlock the selected drive dialog.
       
   670   */
       
   671 void FbDriveView::diskAdminUnlockDrive()
       
   672 {
       
   673     QModelIndex currentIndex = currentItemIndex();
       
   674     // check if the drive is locked
       
   675     if (mEngineWrapper->isDriveLocked(currentIndex)) {
       
   676         QString heading = QString("Existing password");
       
   677         HbInputDialog::queryText(heading, this, SLOT(doDiskAdminUnlockDrive(HbAction*)), QString(), scene());
       
   678     } else {
       
   679         Notifications::showInformationNote(QString("This drive is not locked"));
       
   680     }
       
   681 }
       
   682 
       
   683 /**
       
   684   Unlock the selected drive.
       
   685   */
       
   686 void FbDriveView::doDiskAdminUnlockDrive(HbAction *action)
       
   687 {
       
   688     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   689     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   690         QString oldPassword = dlg->value().toString();
       
   691         QModelIndex currentIndex = currentItemIndex();
       
   692         mEngineWrapper->DiskAdminUnlockDrive(currentIndex, oldPassword);
       
   693         refreshList();
       
   694     }
       
   695 }
       
   696 
       
   697 /**
       
   698   Open clear password of the selected drive dialog.
       
   699   */
       
   700 void FbDriveView::diskAdminClearDrivePassword()
       
   701 {
       
   702     QModelIndex currentIndex = currentItemIndex();
       
   703     // check if the drive has a password
       
   704     if (mEngineWrapper->hasDrivePassword(currentIndex)) {
       
   705         QString heading = QString("Existing password");
       
   706         HbInputDialog::queryText(heading, this, SLOT(doDiskAdminClearDrivePassword(HbAction*)), QString(), scene());
       
   707     } else {
       
   708         Notifications::showInformationNote(QString("This drive has no password"));
       
   709     }
       
   710 }
       
   711 
       
   712 /**
       
   713   Clear password of the selected drive.
       
   714   */
       
   715 void FbDriveView::doDiskAdminClearDrivePassword(HbAction *action)
       
   716 {
       
   717     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   718     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   719         QString oldPassword = dlg->value().toString();
       
   720         QModelIndex currentIndex = currentItemIndex();
       
   721         mEngineWrapper->DiskAdminClearDrivePassword(currentIndex, oldPassword);
       
   722         refreshList();
       
   723     }
       
   724 }
       
   725 
       
   726 
       
   727 /**
       
   728   Question for erase password of the selected drive
       
   729   */
       
   730 void FbDriveView::diskAdminEraseDrivePassword()
       
   731 {
       
   732     // check if the drive has a password
       
   733     QModelIndex currentIndex = currentItemIndex();
       
   734     if (mEngineWrapper->hasDrivePassword(currentIndex)) {
       
   735         HbMessageBox::question(QString("Are you sure? All data can be lost!"),
       
   736                                this,
       
   737                                SLOT(doDiskAdminEraseDrivePassword(int)),
       
   738                                HbMessageBox::Yes | HbMessageBox::No);
       
   739     } else {
       
   740         Notifications::showInformationNote(QString("This drive has no password"));
       
   741     }
       
   742 }
       
   743 
       
   744 /**
       
   745   Erase password of the selected drive
       
   746   */
       
   747 void FbDriveView::doDiskAdminEraseDrivePassword(int action)
       
   748 {
       
   749     if (action == HbMessageBox::Yes) {
       
   750         QModelIndex currentIndex = currentItemIndex();
       
   751         mEngineWrapper->DiskAdminEraseDrivePassword(currentIndex);
       
   752         refreshList();
       
   753     }
       
   754 }
       
   755 
       
   756 /**
       
   757   Performs format on the selected drive
       
   758   */
       
   759 void FbDriveView::diskAdminFormatDrive()
       
   760 {
       
   761     HbMessageBox::question(QString("Are you sure? All data will be lost!"),
       
   762                            this,
       
   763                            SLOT(doDiskAdminFormatDrive(int)),
       
   764                            HbMessageBox::Yes | HbMessageBox::No);
       
   765 }
       
   766 
       
   767 /**
       
   768   Performs format on the selected drive
       
   769   */
       
   770 void FbDriveView::doDiskAdminFormatDrive(int action)
       
   771 {
       
   772     if (action == HbMessageBox::Yes) {
       
   773         QModelIndex currentIndex = currentItemIndex();
       
   774         mEngineWrapper->DiskAdminFormatDrive(currentIndex, false);
       
   775     }
       
   776 }
       
   777 
       
   778 /**
       
   779   Performs quick format on the selected drive
       
   780   */
       
   781 void FbDriveView::diskAdminQuickFormatDrive()
       
   782 {
       
   783     HbMessageBox::question(QString("Are you sure? All data will be lost!"),
       
   784                            this,
       
   785                            SLOT(doDiskAdminQuickFormatDrive(int)),
       
   786                            HbMessageBox::Yes | HbMessageBox::No);
       
   787 }
       
   788 
       
   789 /**
       
   790   Performs quick format on the selected drive
       
   791   */
       
   792 void FbDriveView::doDiskAdminQuickFormatDrive(int action)
       
   793 {
       
   794     if (action == HbMessageBox::Yes) {
       
   795         QModelIndex currentIndex = currentItemIndex();
       
   796         mEngineWrapper->DiskAdminFormatDrive(currentIndex, true);
       
   797     }
       
   798 }
       
   799 
       
   800 /**
       
   801     Checks the disk integrity on the selected drive
       
   802   */
       
   803 void FbDriveView::diskAdminCheckDisk()
       
   804 {
       
   805     QModelIndex currentIndex = currentItemIndex();
       
   806     mEngineWrapper->DiskAdminCheckDisk(currentIndex);
       
   807 }
       
   808 
       
   809 /**
       
   810   Checks the selected drive for errors and corrects them
       
   811   */
       
   812 void FbDriveView::diskAdminScanDrive()
       
   813 {
       
   814     HbMessageBox::question(QString("This finds errors on disk and corrects them. Proceed?"),
       
   815                            this,
       
   816                            SLOT(doDiskAdminScanDrive(int)),
       
   817                            HbMessageBox::Yes | HbMessageBox::No);
       
   818 }
       
   819 
       
   820 /**
       
   821   Checks the selected drive for errors and corrects them
       
   822   */
       
   823 void FbDriveView::doDiskAdminScanDrive(int action)
       
   824 {
       
   825     if (action == HbMessageBox::Yes) {
       
   826         QModelIndex currentIndex = currentItemIndex();
       
   827         mEngineWrapper->DiskAdminScanDrive(currentIndex);
       
   828         refreshList();
       
   829     }
       
   830 }
       
   831 
       
   832 /**
       
   833   Open drive name dialog
       
   834   */
       
   835 void FbDriveView::diskAdminSetDriveName()
       
   836 {
       
   837     QString driveName;
       
   838 
       
   839     // get existing drive name
       
   840     QModelIndex currentIndex = currentItemIndex();
       
   841     mEngineWrapper->GetDriveName(currentIndex, driveName);
       
   842 
       
   843     QString heading = QString("New name");
       
   844     HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDriveName(HbAction*)), driveName, scene());
       
   845 }
       
   846 
       
   847 /**
       
   848   Set drive name.
       
   849   */
       
   850 void FbDriveView::doDiskAdminSetDriveName(HbAction *action)
       
   851 {
       
   852     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   853     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   854         QString driveName = dlg->value().toString();
       
   855 
       
   856         QModelIndex currentIndex = currentItemIndex();
       
   857         mEngineWrapper->DiskAdminSetDriveName(currentIndex, driveName);
       
   858 
       
   859         refreshList();
       
   860     }
       
   861 }
       
   862 
       
   863 /**
       
   864   Open drive volume label dialog
       
   865   */
       
   866 void FbDriveView::diskAdminSetDriveVolumeLabel()
       
   867 {
       
   868     QString volumeLabel;
       
   869 
       
   870     // get existing drive name
       
   871     QModelIndex currentIndex = currentItemIndex();
       
   872     mEngineWrapper->GetDriveVolumeLabel(currentIndex, volumeLabel);
       
   873 
       
   874     QString heading = QString("New volume label");
       
   875     HbInputDialog::queryText(heading, this, SLOT(doDiskAdminSetDriveVolumeLabel(HbAction*)), volumeLabel, scene());
       
   876 }
       
   877 
       
   878 /**
       
   879   Set drive volume label.
       
   880   */
       
   881 void FbDriveView::doDiskAdminSetDriveVolumeLabel(HbAction *action)
       
   882 {
       
   883     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   884     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   885         QString volumeLabel = dlg->value().toString();
       
   886 
       
   887         QModelIndex currentIndex = currentItemIndex();
       
   888         mEngineWrapper->DiskAdminSetDriveVolumeLabel(currentIndex, volumeLabel);
       
   889 
       
   890         refreshList();
       
   891     }
       
   892 }
       
   893 
       
   894 /**
       
   895   Eject the selected drive
       
   896   */
       
   897 void FbDriveView::diskAdminEjectDrive()
       
   898 {
       
   899     QModelIndex currentIndex = currentItemIndex();
       
   900     mEngineWrapper->DiskAdminEjectDrive(currentIndex);
       
   901     refreshList();
       
   902 }
       
   903 
       
   904 /**
       
   905   Dismount the selected drive
       
   906   */
       
   907 void FbDriveView::diskAdminDismountDrive()
       
   908 {
       
   909     HbMessageBox::question(QString("Are you sure you know what are you doing?"),
       
   910                            this,
       
   911                            SLOT(doDiskAdminDismountDrive(int)),
       
   912                            HbMessageBox::Yes | HbMessageBox::No);
       
   913 }
       
   914 
       
   915 void FbDriveView::doDiskAdminDismountDrive(int action)
       
   916 {
       
   917     if (action == HbMessageBox::Yes) {
       
   918         QModelIndex currentIndex = currentItemIndex();
       
   919         mEngineWrapper->DiskAdminDismountDrive(currentIndex);
       
   920         refreshList();
       
   921     }
       
   922 }
       
   923 
       
   924 /**
       
   925   Erase Master Boot Record of the selected drive
       
   926   */
       
   927 void FbDriveView::diskAdminEraseMBR()
       
   928 {
       
   929     // TODO What to do with FB LITE macros?
       
   930     HbMessageBox::question(QString("Are you sure? Your media driver must support this!"),
       
   931                            this,
       
   932                            SLOT(doDiskAdminEraseMBR(int)),
       
   933                            HbMessageBox::Yes | HbMessageBox::No);
       
   934 }
       
   935 
       
   936 void FbDriveView::doDiskAdminEraseMBR(int action)
       
   937 {
       
   938     // TODO What to do with FB LITE macros?
       
   939     if (action == HbMessageBox::Yes) {
       
   940         HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"),
       
   941                                this,
       
   942                                SLOT(doDiskAdminReallyEraseMBR(int)),
       
   943                                HbMessageBox::Yes | HbMessageBox::No);
       
   944     }
       
   945 }
       
   946 
       
   947 void FbDriveView::doDiskAdminReallyEraseMBR(int action)
       
   948 {
       
   949     if (action == HbMessageBox::Yes) {
       
   950         QModelIndex currentIndex = currentItemIndex();
       
   951         // warn if the selected drive is not detected as removable
       
   952         if (mEngineWrapper->isDriveRemovable(currentIndex)) {
       
   953             mEngineWrapper->DiskAdminEraseMBR(currentIndex);
       
   954             refreshList();
       
   955         } else {
       
   956             HbMessageBox::question(QString("Selected drive is not removable, really continue?"),
       
   957                                    this,
       
   958                                    SLOT(doDiskAdminNotRemovableReallyEraseMBR(int)),
       
   959                                    HbMessageBox::Yes | HbMessageBox::No);
       
   960         }
       
   961     }
       
   962 }
       
   963 
       
   964 void FbDriveView::doDiskAdminNotRemovableReallyEraseMBR(int action)
       
   965 {
       
   966     if (action == HbMessageBox::Yes) {
       
   967         QModelIndex currentIndex = currentItemIndex();
       
   968         mEngineWrapper->DiskAdminEraseMBR(currentIndex);
       
   969         refreshList();
       
   970     }
       
   971 
       
   972 }
       
   973 
       
   974 /**
       
   975   Partition the selected drive
       
   976   */
       
   977 void FbDriveView::diskAdminPartitionDrive()
       
   978 {
       
   979     HbMessageBox::question(QString("Are you sure? Your media driver must support this!"),
       
   980                            this,
       
   981                            SLOT(diskAdminPartitionDriveProceed(int)),
       
   982                            HbMessageBox::Yes | HbMessageBox::No);
       
   983 }
       
   984 
       
   985 /**
       
   986   Partition the selected drive if user is sure
       
   987   */
       
   988 void FbDriveView::diskAdminPartitionDriveProceed(int action)
       
   989 {
       
   990     if (action == HbMessageBox::Yes) {
       
   991         HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"),
       
   992                                this,
       
   993                                SLOT(diskAdminPartitionDriveReallyProceed(int)),
       
   994                                HbMessageBox::Yes | HbMessageBox::No);
       
   995     }
       
   996 }
       
   997 
       
   998 /**
       
   999   Partition the selected drive if user is really sure
       
  1000   */
       
  1001 void FbDriveView::diskAdminPartitionDriveReallyProceed(int action)
       
  1002 {
       
  1003     if (action == HbMessageBox::Yes) {
       
  1004         QModelIndex currentIndex = currentItemIndex();
       
  1005         mEraseMBR = false;
       
  1006         // warn if the selected drive is not detected as removable
       
  1007         mProceed = false;
       
  1008         if (mEngineWrapper->isDriveRemovable(currentIndex)) {
       
  1009             mProceed = true;
       
  1010         } else {
       
  1011             HbMessageBox::question(QString("Selected drive is not removable, really continue?"),
       
  1012                                    this,
       
  1013                                    SLOT(diskAdminPartitionDriveIsNotRemovable(int)),
       
  1014                                    HbMessageBox::Yes | HbMessageBox::No);
       
  1015         }
       
  1016 
       
  1017         if (mProceed) {
       
  1018             // query if erase mbr
       
  1019             mEraseMBR = false;
       
  1020 
       
  1021             HbMessageBox::question(QString("Erase MBR first (normally needed)?"),
       
  1022                                    this,
       
  1023                                    SLOT(diskAdminPartitionDriveEraseMbr(int)),
       
  1024                                    HbMessageBox::Yes | HbMessageBox::No);
       
  1025 
       
  1026             // TODO use HbListDialog
       
  1027             QStringList list;
       
  1028             list << "1" << "2" << "3" << "4";
       
  1029             openListDialog(list, QString("Partitions?"), this, SLOT(diskAdminPartitionDriveGetCount(HbAction*)));
       
  1030         }
       
  1031     }
       
  1032 }
       
  1033 
       
  1034 /**
       
  1035   Store result of user query about proceeding when drive is not removable.
       
  1036   */
       
  1037 void FbDriveView::diskAdminPartitionDriveIsNotRemovable(int action)
       
  1038 {
       
  1039     if (action == HbMessageBox::Yes) {
       
  1040         mProceed = true;
       
  1041     } else {
       
  1042         mProceed = false;
       
  1043     }
       
  1044 }
       
  1045 
       
  1046 /**
       
  1047   Store result of user query about erase MBR
       
  1048   */
       
  1049 void FbDriveView::diskAdminPartitionDriveEraseMbr(int action)
       
  1050 {
       
  1051     if (action == HbMessageBox::Yes) {
       
  1052         mEraseMBR = true;
       
  1053     }
       
  1054 }
       
  1055 
       
  1056 /**
       
  1057   Partition the selected drive
       
  1058   */
       
  1059 void FbDriveView::diskAdminPartitionDriveGetCount(HbAction* action)
       
  1060 {
       
  1061     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
       
  1062     if(!action && dlg && dlg->selectedItems().count()){
       
  1063         int selectionIndex = dlg->selectedItems().at(0).toInt();
       
  1064         QModelIndex currentIndex = currentItemIndex();
       
  1065         int amountOfPartitions = selectionIndex + 1;
       
  1066         mEngineWrapper->DiskAdminPartitionDrive(currentIndex, mEraseMBR, amountOfPartitions);
       
  1067         refreshList();
       
  1068     }
       
  1069 }
       
  1070 
       
  1071 // ---------------------------------------------------------------------------
       
  1072 // tools menu
       
  1073 // ---------------------------------------------------------------------------
       
  1074 void FbDriveView::toolsAllAppsToTextFile()
       
  1075 {
       
  1076 
       
  1077 }
       
  1078 
       
  1079 /**
       
  1080   Write all files to text file
       
  1081   */
       
  1082 void FbDriveView::toolsAllFilesToTextFile()
       
  1083 {
       
  1084     mEngineWrapper->toolsWriteAllFiles();
       
  1085 }
       
  1086 
       
  1087 //void FbDriveView::toolsAvkonIconCacheEnable()
       
  1088 //{
       
  1089 //
       
  1090 //}
       
  1091 //void FbDriveView::toolsAvkonIconCacheDisable()
       
  1092 //{
       
  1093 //
       
  1094 //}
       
  1095 
       
  1096 /**
       
  1097   Disable extended errors
       
  1098   */
       
  1099 void FbDriveView::toolsDisableExtendedErrors()
       
  1100 {
       
  1101     mEngineWrapper->ToolsSetErrRd(false);
       
  1102 }
       
  1103 
       
  1104 void FbDriveView::toolsDumpMsgStoreWalk()
       
  1105 {
       
  1106 
       
  1107 }
       
  1108 void FbDriveView::toolsEditDataTypes()
       
  1109 {
       
  1110 
       
  1111 }
       
  1112 
       
  1113 /**
       
  1114   Enable extended errors
       
  1115   */
       
  1116 void FbDriveView::toolsEnableExtendedErrors()
       
  1117 {
       
  1118     mEngineWrapper->ToolsSetErrRd(true);
       
  1119 }
       
  1120 
       
  1121 /**
       
  1122   Open simulate leave dialog
       
  1123   */
       
  1124 void FbDriveView::toolsErrorSimulateLeave()
       
  1125 {
       
  1126     int leaveCode = -6;
       
  1127     QString heading = QString("Leave code");
       
  1128     HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene());
       
  1129 }
       
  1130 
       
  1131 
       
  1132 /**
       
  1133   Simulate leave.
       
  1134   */
       
  1135 void FbDriveView::doToolsErrorSimulateLeave(HbAction *action)
       
  1136 {
       
  1137     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1138     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1139         bool ok;
       
  1140         int leaveCode = dlg->value().toString().toInt(&ok);
       
  1141         if (leaveCode != 0 || ok) {
       
  1142             mEngineWrapper->ToolsErrorSimulateLeave(leaveCode);
       
  1143         }
       
  1144     }
       
  1145 }
       
  1146 
       
  1147 /**
       
  1148   Open simulate panic dialog.
       
  1149   */
       
  1150 void FbDriveView::toolsErrorSimulatePanic()
       
  1151 {
       
  1152     mPanicCategory = QString ("Test Category");
       
  1153     QString heading = QString("Panic category");
       
  1154     HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene());
       
  1155 }
       
  1156 
       
  1157 /**
       
  1158   Simulate panic.
       
  1159   */
       
  1160 void FbDriveView::doToolsErrorSimulatePanicCode(HbAction *action)
       
  1161 {
       
  1162     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1163     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1164         mPanicCategory = dlg->value().toString();
       
  1165         int panicCode(555);
       
  1166         QString heading = QString("Panic code");
       
  1167         HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene());
       
  1168     }
       
  1169 }
       
  1170 
       
  1171 /**
       
  1172   Simulate panic.
       
  1173   */
       
  1174 void FbDriveView::doToolsErrorSimulatePanic(HbAction *action)
       
  1175 {
       
  1176     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1177     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1178         bool ok;
       
  1179         int panicCode = dlg->value().toInt(&ok);
       
  1180         if (panicCode != 0 || ok) {
       
  1181             mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode);
       
  1182         }
       
  1183     }
       
  1184 }
       
  1185 
       
  1186 /**
       
  1187   Open simulate exception dialog.
       
  1188   */
       
  1189 void FbDriveView::toolsErrorSimulateException()
       
  1190 {
       
  1191     int exceptionCode = 0;
       
  1192     QString heading = QString("Exception code");
       
  1193     HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene());
       
  1194 }
       
  1195 
       
  1196 /**
       
  1197   Simulate exception.
       
  1198   */
       
  1199 void FbDriveView::doToolsErrorSimulateException(HbAction *action)
       
  1200 {
       
  1201     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1202     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1203         bool ok;
       
  1204         int exceptionCode = dlg->value().toInt(&ok);
       
  1205         if (exceptionCode != 0 || ok) {
       
  1206             mEngineWrapper->ToolsErrorSimulateException(exceptionCode);
       
  1207         }
       
  1208     }
       
  1209 }
       
  1210 
       
  1211 //    void FbDriveView::toolsLocalConnectivityActivateInfrared()
       
  1212 //{
       
  1213 //
       
  1214 //}
       
  1215 //    void FbDriveView::toolsLocalConnectivityLaunchBTUI()
       
  1216 //{
       
  1217 //
       
  1218 //}
       
  1219 //    void FbDriveView::toolsLocalConnectivityLaunchUSBUI()
       
  1220 //{
       
  1221 //
       
  1222 //}
       
  1223 void FbDriveView::toolsMessageInbox()
       
  1224 {
       
  1225 
       
  1226 }
       
  1227 void FbDriveView::toolsMessageDrafts()
       
  1228 {
       
  1229 
       
  1230 }
       
  1231 void FbDriveView::toolsMessageSentItems()
       
  1232 {
       
  1233 
       
  1234 }
       
  1235 void FbDriveView::toolsMessageOutbox()
       
  1236 {
       
  1237 
       
  1238 }
       
  1239 void FbDriveView::toolsMemoryInfo()
       
  1240 {
       
  1241 
       
  1242 }
       
  1243 void FbDriveView::toolsSecureBackStart()
       
  1244 {
       
  1245 
       
  1246 }
       
  1247 void FbDriveView::toolsSecureBackRestore()
       
  1248 {
       
  1249 
       
  1250 }
       
  1251 void FbDriveView::toolsSecureBackStop()
       
  1252 {
       
  1253 
       
  1254 }
       
  1255 
       
  1256 /**
       
  1257   Open debug mask dialog
       
  1258   */
       
  1259 void FbDriveView::toolsSetDebugMaskQuestion()
       
  1260 {
       
  1261     quint32 dbgMask = mEngineWrapper->getDebugMask();
       
  1262     QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16));
       
  1263     QString heading = QString("Kernel debug mask in hex format");
       
  1264     HbInputDialog::queryText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene());
       
  1265 }
       
  1266 
       
  1267 /**
       
  1268   Set debug mask
       
  1269   */
       
  1270 void FbDriveView::toolsSetDebugMask(HbAction *action)
       
  1271 {
       
  1272     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1273     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1274         QString dbgMaskText = dlg->value().toString();
       
  1275         if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') {
       
  1276             bool ok;
       
  1277             quint32 dbgMask = dbgMaskText.toUInt(&ok, 16);
       
  1278             if (dbgMask != 0 || ok) {
       
  1279                 mEngineWrapper->toolsSetDebugMask(dbgMask);
       
  1280                 Notifications::showConfirmationNote(QString("Changed"));
       
  1281             } else {
       
  1282                 Notifications::showErrorNote(QString("Cannot convert value"));
       
  1283             }
       
  1284         } else {
       
  1285             Notifications::showErrorNote(QString("Not in hex format"));
       
  1286         }
       
  1287     }
       
  1288 }
       
  1289 
       
  1290 void FbDriveView::toolsShowOpenFilesHere()
       
  1291 {
       
  1292 
       
  1293 }
       
  1294 
       
  1295 // ---------------------------------------------------------------------------
       
  1296 // main menu items
       
  1297 // ---------------------------------------------------------------------------
       
  1298 
       
  1299 /**
       
  1300   Show about note
       
  1301   */
       
  1302 void FbDriveView::about()
       
  1303 {
       
  1304     Notifications::showAboutNote();
       
  1305 }
       
  1306 
       
  1307 // ---------------------------------------------------------------------------
       
  1308 // End of operations
       
  1309 // ---------------------------------------------------------------------------
       
  1310 
       
  1311 // ---------------------------------------------------------------------------
       
  1312 
       
  1313 /**
       
  1314   Item is selected from list when selection mode is activated from menu
       
  1315   */
       
  1316 void FbDriveView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
       
  1317 {
       
  1318     //QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1319 }
       
  1320 
       
  1321 /**
       
  1322   An item is clicked from navigation item list. Navigation item list contains
       
  1323   drive-, folder- or file items. Opens selected drive, folder or file popup menu
       
  1324   */
       
  1325 void FbDriveView::activated(const QModelIndex& index)
       
  1326 {
       
  1327     if (mFbDriveModel) {
       
  1328 //        if (mEngineWrapper->isDriveListViewActive()) {
       
  1329             mEngineWrapper->moveDownToDirectory(index);
       
  1330             //emit aboutToShowFileView(QString(mEngineWrapper->currentPath()));
       
  1331             emit aboutToShowFileView();
       
  1332             //refreshList();
       
  1333 //        }
       
  1334     }
       
  1335 }
       
  1336 
       
  1337 // ---------------------------------------------------------------------------