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