filebrowser/ui/src/fbfileview.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 "fbfileview.h"
       
    19 #include "settingsview.h"
       
    20 #include "editorview.h"
       
    21 #include "searchview.h"
       
    22 #include "enginewrapper.h"
       
    23 #include "notifications.h"
       
    24 
       
    25 #include "fbfilemodel.h"
       
    26 #include "filebrowsersortfilterproxymodel.h"
       
    27 //#include "fbfilelistviewitem.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 #include <HbToolBar>
       
    44 #include <HbToolBarExtension>
       
    45 #include <HbSearchPanel>
       
    46 
       
    47 #include <QString>
       
    48 #include <QGraphicsLinearLayout>
       
    49 #include <QItemSelection>
       
    50 #include <QDebug>
       
    51 //TODO check if needed to do this way
       
    52 #include <FB.hrh>
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 
       
    56 FbFileView::FbFileView() :
       
    57     mEngineWrapper(0),
       
    58     mListView(0),
       
    59     mToolBar(0),
       
    60     mNaviPane(0),
       
    61     mSearchPanel(0),
       
    62     mMainLayout(0),
       
    63     mFbFileModel(0),
       
    64     mSortFilterProxyModel(0),
       
    65     mOptionMenuActions(),
       
    66     mContextMenuActions(),
       
    67     mContextMenu(0),
       
    68     mToolbarBackAction(0),
       
    69     mItemHighlighted(false),
       
    70     mLocationChanged(false),
       
    71     mRemoveFileAfterCopied(false),
       
    72 //    mClipBoardInUse(false),
       
    73     mFolderContentChanged(false),
       
    74     mCurrentIndex(),
       
    75     mOldPassword(),
       
    76     mPanicCategory(),
       
    77     mAbsoluteFilePath(),
       
    78     mOverwriteOptions(),
       
    79     mModelIndex(),
       
    80     mNewFileName(),
       
    81     mProceed(false),
       
    82     mEraseMBR(false)
       
    83 {
       
    84     setTitle("File Browser");
       
    85 
       
    86     createMenu();
       
    87     createContextMenu();
       
    88     createToolBar();
       
    89 }
       
    90 
       
    91 // ---------------------------------------------------------------------------	
       
    92 
       
    93 void FbFileView::init(EngineWrapper *engineWrapper)
       
    94 {
       
    95     mEngineWrapper = engineWrapper;
       
    96 
       
    97     mListView = new HbListView(this);
       
    98     mListView->listItemPrototype()->setStretchingStyle(HbListViewItem::StretchLandscape);
       
    99 
       
   100 //    mListView->setItemPrototype(new FbDiskListViewItem(mListView));
       
   101 
       
   102     mFbFileModel = new FbFileModel(mEngineWrapper);
       
   103     if (!mListView->model()) {
       
   104 
       
   105         mEngineWrapper->refreshView();
       
   106 
       
   107         mSortFilterProxyModel = new FileBrowserSortFilterProxyModel(this);
       
   108         mSortFilterProxyModel->setSourceModel(mFbFileModel);
       
   109         mSortFilterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
       
   110         mSearchPanel->setPlaceholderText(QString("Type filter criteria"));
       
   111 
       
   112         mListView->setModel(mSortFilterProxyModel);
       
   113     }
       
   114 
       
   115     //mListView->setRootIndex(mFileSystemModel->index(startPath));
       
   116     //mListView->setRootIndex(model->index());
       
   117 
       
   118     //setItemVisible(Hb::ToolBarItem, !mEngineWrapper->isDriveListViewActive());
       
   119 //    mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
       
   120 
       
   121     connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
       
   122     connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)),
       
   123             this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF)));
       
   124 
       
   125     mNaviPane = new HbLabel(this);
       
   126     mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default
       
   127     //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
       
   128     HbFontSpec fontSpec(HbFontSpec::PrimarySmall);
       
   129     mNaviPane->setFontSpec(fontSpec);
       
   130 
       
   131     // Create layout and add list view and toolbar into layout:
       
   132     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
   133     mMainLayout->addItem(mNaviPane);
       
   134     mMainLayout->addItem(mListView);
       
   135     setLayout(mMainLayout);
       
   136 }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 
       
   140 FbFileView::~FbFileView()
       
   141 {  
       
   142 //    if (mEngineWrapper) {
       
   143 //        delete mEngineWrapper;
       
   144 //    }
       
   145     if (mContextMenu) {
       
   146         mContextMenu->deleteLater();
       
   147     }
       
   148 
       
   149     delete mSortFilterProxyModel;
       
   150     delete mFbFileModel;
       
   151     delete mListView;
       
   152     delete mToolBar;
       
   153 }
       
   154 
       
   155 /**
       
   156   Initial setup for options menu.
       
   157   Dynamic menu update during the runtime is performed by updateOptionMenu() which
       
   158   to menu's aboutToShow() signal.
       
   159   */
       
   160 void FbFileView::createMenu()
       
   161 {
       
   162     createFileMenu();
       
   163     createEditMenu();
       
   164     createViewMenu();
       
   165     createToolsMenu();
       
   166 
       
   167     createSelectionMenuItem();
       
   168     createSettingsMenuItem();
       
   169     createAboutMenuItem();
       
   170     createExitMenuItem();
       
   171 
       
   172     // menu dynamic update
       
   173     connect(menu(), SIGNAL(aboutToShow()), this, SLOT(updateOptionMenu()));
       
   174 }
       
   175 
       
   176 /**
       
   177   Initial setup for File submenu
       
   178   */
       
   179 void FbFileView::createFileMenu()
       
   180 {
       
   181     mOptionMenuActions.mFileMenu = menu()->addMenu("File");
       
   182 
       
   183     mOptionMenuActions.mFileBackMoveUp = mOptionMenuActions.mFileMenu->addAction("Back/Move up", this, SLOT(fileBackMoveUp()));
       
   184     mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
       
   185     //mOptionMenuActions.mFileSearch->setVisible(false);
       
   186 
       
   187     mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New");
       
   188     mOptionMenuActions.mFileNewFile = mOptionMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile()));
       
   189     mOptionMenuActions.mFileNewDirectory = mOptionMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory()));
       
   190 
       
   191     mOptionMenuActions.mFileDelete = mOptionMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
       
   192     mOptionMenuActions.mFileRename = mOptionMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
       
   193     mOptionMenuActions.mFileTouch = mOptionMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
       
   194 
       
   195 //    mOptionMenuActions.mFileChecksumsMenu = mOptionMenuActions.mFileMenu->addMenu("Checksums");
       
   196 //    mOptionMenuActions.mFileChecksumsMD5 = mOptionMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5()));
       
   197 //    mOptionMenuActions.mFileChecksumsMD2 = mOptionMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2()));
       
   198 //    mOptionMenuActions.mFileChecksumsSHA1 = mOptionMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1()));
       
   199 
       
   200     mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
       
   201     mOptionMenuActions.mFileSetAttributes->setVisible(false);
       
   202 }
       
   203 
       
   204 /**
       
   205   Initial setup for Edit submenu
       
   206   */
       
   207 void FbFileView::createEditMenu()
       
   208 {
       
   209     mOptionMenuActions.mEditMenu = menu()->addMenu("Edit");
       
   210 
       
   211     mOptionMenuActions.mEditSnapShotToE = mOptionMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE()));
       
   212     mOptionMenuActions.mEditSnapShotToE->setVisible(false);
       
   213     mOptionMenuActions.mEditCut = mOptionMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut()));
       
   214     mOptionMenuActions.mEditCopy = mOptionMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy()));
       
   215     mOptionMenuActions.mEditPaste = mOptionMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste()));
       
   216 
       
   217     mOptionMenuActions.mEditCopyToFolder = mOptionMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder()));
       
   218     mOptionMenuActions.mEditMoveToFolder = mOptionMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder()));
       
   219 
       
   220     mOptionMenuActions.mEditSelect = mOptionMenuActions.mEditMenu->addAction("Select", this, SLOT(editSelect()));
       
   221     mOptionMenuActions.mEditUnselect = mOptionMenuActions.mEditMenu->addAction("Unselect", this, SLOT(editUnselect()));
       
   222     mOptionMenuActions.mEditSelectAll = mOptionMenuActions.mEditMenu->addAction("Select all", this, SLOT(editSelectAll()));
       
   223     mOptionMenuActions.mEditUnselectAll = mOptionMenuActions.mEditMenu->addAction("Unselect all", this, SLOT(editUnselectAll()));
       
   224 }
       
   225 
       
   226 /**
       
   227   Initial setup for View submenu
       
   228   */
       
   229 void FbFileView::createViewMenu()
       
   230 {
       
   231     mOptionMenuActions.mViewMenu = menu()->addMenu("View");
       
   232     //mOptionMenuActions.mViewMenu->menuAction()->setVisible(false);
       
   233 
       
   234     mOptionMenuActions.mViewFilterEntries = mOptionMenuActions.mViewMenu->addAction("Filter entries", this, SLOT(viewFilterEntries()));
       
   235     mOptionMenuActions.mViewRefresh = mOptionMenuActions.mViewMenu->addAction("Refresh", this, SLOT(viewRefresh()));
       
   236 }
       
   237 
       
   238 /**
       
   239   Initial setup for Tools submenu
       
   240   */
       
   241 void FbFileView::createToolsMenu()
       
   242 {
       
   243     mOptionMenuActions.mToolsMenu = menu()->addMenu("Tools");
       
   244 
       
   245     mOptionMenuActions.mToolsAllAppsToTextFile = mOptionMenuActions.mToolsMenu->addAction("All apps to a text file", this, SLOT(toolsAllAppsToTextFile()));
       
   246     mOptionMenuActions.mToolsAllAppsToTextFile->setVisible(false);
       
   247     mOptionMenuActions.mToolsAllFilesToTextFile = mOptionMenuActions.mToolsMenu->addAction("All files to a text file", this, SLOT(toolsAllFilesToTextFile()));
       
   248     //mOptionMenuActions.mToolsAllFilesToTextFile->setVisible(false);
       
   249 
       
   250 //    mOptionMenuActions.mToolsAvkonIconCacheMenu = mOptionMenuActions.mToolsMenu->addMenu("Avkon icon cache");
       
   251 //    mOptionMenuActions.mToolsAvkonIconCacheMenu->menuAction()->setVisible(false);
       
   252 //    mOptionMenuActions.mToolsAvkonIconCacheEnable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Enable", this, SLOT(toolsAvkonIconCacheEnable()));
       
   253 //    mOptionMenuActions.mToolsAvkonIconCacheDisable = mOptionMenuActions.mToolsAvkonIconCacheMenu->addAction("Clear and disable", this, SLOT(toolsAvkonIconCacheDisable()));
       
   254 
       
   255     mOptionMenuActions.mToolsDisableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Disable extended errors", this, SLOT(toolsDisableExtendedErrors()));
       
   256     mOptionMenuActions.mToolsDumpMsgStoreWalk = mOptionMenuActions.mToolsMenu->addAction("Dump msg. store walk", this, SLOT(toolsDumpMsgStoreWalk()));
       
   257     mOptionMenuActions.mToolsDumpMsgStoreWalk->setVisible(false);
       
   258     mOptionMenuActions.mToolsEditDataTypes = mOptionMenuActions.mToolsMenu->addAction("Edit data types", this, SLOT(toolsEditDataTypes()));
       
   259     mOptionMenuActions.mToolsEditDataTypes->setVisible(false);
       
   260     mOptionMenuActions.mToolsEnableExtendedErrors = mOptionMenuActions.mToolsMenu->addAction("Enable extended errors", this, SLOT(toolsEnableExtendedErrors()));
       
   261 
       
   262     mOptionMenuActions.mToolsErrorSimulateMenu = mOptionMenuActions.mToolsMenu->addMenu("Error simulate");
       
   263     mOptionMenuActions.mToolsErrorSimulateLeave = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Leave", this, SLOT(toolsErrorSimulateLeave()));
       
   264     mOptionMenuActions.mToolsErrorSimulatePanic = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Panic", this, SLOT(toolsErrorSimulatePanic()));
       
   265     mOptionMenuActions.mToolsErrorSimulatePanic->setVisible(false);
       
   266     mOptionMenuActions.mToolsErrorSimulateException = mOptionMenuActions.mToolsErrorSimulateMenu->addAction("Exception", this, SLOT(toolsErrorSimulateException()));
       
   267 
       
   268 //    mOptionMenuActions.mLocalConnectivityMenu = mOptionMenuActions.mToolsMenu->addMenu("Local connectivity");
       
   269 //    mOptionMenuActions.mToolsLocalConnectivityActivateInfrared = mOptionMenuActions.mLocalConnectivityMenu->addAction("Activate infrared", this, SLOT(toolsLocalConnectivityActivateInfrared()));
       
   270 //    mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch BT UI", this, SLOT(toolsLocalConnectivityLaunchBTUI()));
       
   271 //    mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI = mOptionMenuActions.mLocalConnectivityMenu->addAction("Launch USB UI", this, SLOT(toolsLocalConnectivityLaunchUSBUI()));
       
   272 
       
   273     mOptionMenuActions.mToolsMessageAttachmentsMenu = mOptionMenuActions.mToolsMenu->addMenu("Message attachments");
       
   274     mOptionMenuActions.mToolsMessageAttachmentsMenu->menuAction()->setVisible(false);
       
   275     mOptionMenuActions.mToolsMessageInbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Inbox", this, SLOT(toolsMessageInbox()));
       
   276     mOptionMenuActions.mToolsMessageDrafts = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Drafts", this, SLOT(toolsMessageDrafts()));
       
   277     mOptionMenuActions.mToolsMessageSentItems = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Sent items", this, SLOT(toolsMessageSentItems()));
       
   278     mOptionMenuActions.mToolsMessageOutbox = mOptionMenuActions.mToolsMessageAttachmentsMenu->addAction("Outbox", this, SLOT(toolsMessageOutbox()));
       
   279 
       
   280     mOptionMenuActions.mToolsMemoryInfo = mOptionMenuActions.mToolsMenu->addAction("Memory info", this, SLOT(toolsMemoryInfo()));
       
   281     mOptionMenuActions.mToolsMemoryInfo->setVisible(false);
       
   282 
       
   283     mOptionMenuActions.mToolsSecureBackupMenu = mOptionMenuActions.mToolsMenu->addMenu("Secure backup");
       
   284     mOptionMenuActions.mToolsSecureBackupMenu->menuAction()->setVisible(false);
       
   285     mOptionMenuActions.mToolsSecureBackStart = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start backup", this, SLOT(toolsSecureBackStart()));
       
   286     mOptionMenuActions.mToolsSecureBackRestore = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Start restore", this, SLOT(toolsSecureBackRestore()));
       
   287     mOptionMenuActions.mToolsSecureBackStop = mOptionMenuActions.mToolsSecureBackupMenu->addAction("Stop", this, SLOT(toolsSecureBackStop()));
       
   288 
       
   289     mOptionMenuActions.mToolsSetDebugMask = mOptionMenuActions.mToolsMenu->addAction("Set debug mask", this, SLOT(toolsSetDebugMaskQuestion()));
       
   290     mOptionMenuActions.mToolsShowOpenFilesHere = mOptionMenuActions.mToolsMenu->addAction("Show open files here", this, SLOT(toolsShowOpenFilesHere()));
       
   291     mOptionMenuActions.mToolsShowOpenFilesHere->setVisible(false);
       
   292 }
       
   293 
       
   294 /**
       
   295   Creates Selection mode menu item in option menu
       
   296   */
       
   297 void FbFileView::createSelectionMenuItem()
       
   298 {
       
   299     if (!mOptionMenuActions.mSelection) {
       
   300         mOptionMenuActions.mSelection = menu()->addAction("Selection mode");
       
   301         mOptionMenuActions.mSelection->setToolTip("Selection mode");
       
   302         mOptionMenuActions.mSelection->setCheckable(true);
       
   303         connect(mOptionMenuActions.mSelection, SIGNAL(triggered()), this, SLOT(selectionModeChanged()));
       
   304     }
       
   305 }
       
   306 
       
   307 /**
       
   308   Creates Setting menu item in option menu
       
   309   */
       
   310 void FbFileView::createSettingsMenuItem()
       
   311 {
       
   312     mOptionMenuActions.mSetting = menu()->addAction("Settings...");
       
   313     connect(mOptionMenuActions.mSetting, SIGNAL(triggered()), this, SIGNAL(aboutToShowSettingsView()));
       
   314 }
       
   315 
       
   316 
       
   317 /**
       
   318   Creates About menu item in option menu
       
   319   */
       
   320 void FbFileView::createAboutMenuItem()
       
   321 {
       
   322     // about note
       
   323     mOptionMenuActions.mAbout = menu()->addAction("About");
       
   324     connect(mOptionMenuActions.mAbout, SIGNAL(triggered()), this, SLOT(about()));
       
   325 }
       
   326 
       
   327 /**
       
   328   Creates Exit menu item in option menu
       
   329   */
       
   330 void FbFileView::createExitMenuItem()
       
   331 {
       
   332     // application exit
       
   333     mOptionMenuActions.mExit = menu()->addAction("Exit");
       
   334     connect(mOptionMenuActions.mExit, SIGNAL(triggered()), qApp, SLOT(quit()));
       
   335 }
       
   336 
       
   337 /**
       
   338   update menu: disk admin available only in device root view. edit available only in folder view
       
   339   when file or folder content exist in current folder, or clipboard has copied item.
       
   340   file and view menus updated every time regarding the folder content.
       
   341   tools, settings, about, exit always available.
       
   342   If there's remove and add operations at same time, always remove first
       
   343   to keep to the correct menu items order.
       
   344   */
       
   345 void FbFileView::updateOptionMenu()
       
   346 {
       
   347     bool isFileItemListEmpty = mFbFileModel->rowCount() == 0;
       
   348     bool isNormalModeActive = true;       //iModel->FileUtils()->IsNormalModeActive();
       
   349     bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly();   //iModel->FileUtils()->IsCurrentDriveReadOnly();
       
   350     bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir();
       
   351     // bool currentSelected = true;    //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex());
       
   352     bool isAllSelected = mListView->selectionModel()->selection().count() == mFbFileModel->rowCount();
       
   353     //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0;
       
   354     bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0;
       
   355     bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
       
   356     bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse();
       
   357     //bool showSnapShot = false;           //iModel->FileUtils()->DriveSnapShotPossible();
       
   358 
       
   359     bool showEditMenu(true);
       
   360     if (isFileItemListEmpty && isClipBoardEmpty)
       
   361         showEditMenu = false;
       
   362     else
       
   363         showEditMenu = true;
       
   364 
       
   365     mOptionMenuActions.mEditMenu->menuAction()->setVisible(showEditMenu);
       
   366 
       
   367     //mOptionMenuActions.mFileBackMoveUp->setVisible( !isDriveListViewActive);
       
   368 
       
   369     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileView, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory);
       
   370     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory);
       
   371     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory);
       
   372 
       
   373     mOptionMenuActions.mFileNewMenu->menuAction()->setVisible(!isCurrentDriveReadOnly);
       
   374     mOptionMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*isSelectionMode*/);
       
   375     mOptionMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*&& isSelectionMode*/);
       
   376     mOptionMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems);
       
   377 
       
   378     // TODO mOptionMenuActions.mFileChecksumsMenu->setVisible(!(isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory));
       
   379     // TODO mOptionMenuActions.mFileSetAttributes->setVisible(!(isFileItemListEmpty || isCurrentDriveReadOnly));
       
   380     // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory));
       
   381     // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory));
       
   382 
       
   383     mOptionMenuActions.mEditCut->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode);
       
   384     mOptionMenuActions.mEditCopy->setVisible(!isFileItemListEmpty && isSelectionMode);
       
   385     mOptionMenuActions.mEditPaste->setVisible(!(isClipBoardEmpty || isCurrentDriveReadOnly));
       
   386     mOptionMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty);
       
   387     mOptionMenuActions.mEditMoveToFolder->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty));
       
   388 
       
   389     mOptionMenuActions.mEditSelect->setVisible(false/*!currentSelected && !isFileItemListEmpty*/);
       
   390     mOptionMenuActions.mEditUnselect->setVisible(false/*currentSelected && !isFileItemListEmpty*/);
       
   391     mOptionMenuActions.mEditSelectAll->setVisible(isSelectionMode && !isAllSelected && !isFileItemListEmpty);
       
   392     mOptionMenuActions.mEditUnselectAll->setVisible(hasSelectedItems && !isFileItemListEmpty);
       
   393 
       
   394     // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isFileItemListEmpty));
       
   395     // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive  || isFileItemListEmpty));
       
   396     mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive);
       
   397     mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty);
       
   398 
       
   399     // TODO R_FILEBROWSER_VIEW_SORT_SUBMENU
       
   400     // aMenuPane->SetItemButtonState(iModel->FileUtils()->SortMode(), EEikMenuItemSymbolOn);
       
   401 
       
   402     // TODO R_FILEBROWSER_VIEW_ORDER_SUBMENU
       
   403     // aMenuPane->SetItemButtonState(iModel->FileUtils()->OrderMode(), EEikMenuItemSymbolOn);
       
   404 
       
   405     // aResourceId == R_FILEBROWSER_TOOLS_SUBMENU
       
   406     bool noExtendedErrorsAllowed = mEngineWrapper->ErrRdFileExists();
       
   407     mOptionMenuActions.mToolsDisableExtendedErrors->setVisible(noExtendedErrorsAllowed);
       
   408     mOptionMenuActions.mToolsEnableExtendedErrors->setVisible(!noExtendedErrorsAllowed);
       
   409 
       
   410 //    bool infraRedAllowed = mEngineWrapper->FileExists(KIRAppPath);
       
   411 //    bool bluetoothAllowed = mEngineWrapper->FileExists(KBTAppPath);
       
   412 //    bool usbAllowed = mEngineWrapper->FileExists(KUSBAppPath);
       
   413 //
       
   414 //    bool noLocalCon = !infraRedAllowed && !bluetoothAllowed && !usbAllowed;
       
   415 //    mOptionMenuActions.mToolsLocalConnectivityMenu->menuAction()->setVisible(!noLocalCon);
       
   416 //
       
   417 //    mOptionMenuActions.mToolsLocalConnectivityActivateInfrared->setVisible(infraRedAllowed);
       
   418 //    mOptionMenuActions.mToolsLocalConnectivityLaunchBTUI->setVisible(bluetoothAllowed);
       
   419 //    mOptionMenuActions.mToolsLocalConnectivityLaunchUSBUI->setVisible(usbAllowed);
       
   420 }
       
   421 
       
   422 void FbFileView::createContextMenu()
       
   423 {
       
   424     mContextMenu = new HbMenu();
       
   425     connect(mContextMenu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu()));
       
   426 
       
   427     createFileContextMenu();
       
   428     createEditContextMenu();
       
   429     createViewContextMenu();
       
   430 }
       
   431 
       
   432 
       
   433 void FbFileView::createFileContextMenu()
       
   434 {
       
   435     mContextMenuActions.mFileMenu = mContextMenu->addMenu("File");
       
   436 
       
   437     //mContextMenuActions.mFileBackMoveUp = mContextMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp()));
       
   438     mContextMenuActions.mFileOpenDirectory = mContextMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory()));
       
   439 //    mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
       
   440     //mContextMenuActions.mFileSearch->setVisible(false);
       
   441 
       
   442     mContextMenuActions.mFileDelete = mContextMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
       
   443     mContextMenuActions.mFileRename = mContextMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
       
   444     mContextMenuActions.mFileTouch = mContextMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
       
   445     mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties()));
       
   446 
       
   447     mContextMenuActions.mFileChecksumsMenu = mContextMenuActions.mFileMenu->addMenu("Checksums");
       
   448     mContextMenuActions.mFileChecksumsMD5 = mContextMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5()));
       
   449     mContextMenuActions.mFileChecksumsMD2 = mContextMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2()));
       
   450     mContextMenuActions.mFileChecksumsSHA1 = mContextMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1()));
       
   451 
       
   452 //    mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
       
   453 //    mContextMenuActions.mFileSetAttributes->setVisible(false);
       
   454 }
       
   455 
       
   456 void FbFileView::createEditContextMenu()
       
   457 {
       
   458     mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit");
       
   459 
       
   460     //mContextMenuActions.mEditSnapShotToE = mContextMenuActions.mEditMenu->addAction("Snap shot to E:", this, SLOT(editSnapShotToE()));
       
   461 //    mContextMenuActions.mEditSnapShotToE->setVisible(false);
       
   462     mContextMenuActions.mEditCut = mContextMenuActions.mEditMenu->addAction("Cut", this, SLOT(editCut()));
       
   463     mContextMenuActions.mEditCopy = mContextMenuActions.mEditMenu->addAction("Copy", this, SLOT(editCopy()));
       
   464     mContextMenuActions.mEditPaste = mContextMenuActions.mEditMenu->addAction("Paste", this, SLOT(editPaste()));
       
   465 
       
   466     mContextMenuActions.mEditCopyToFolder = mContextMenuActions.mEditMenu->addAction("Copy to folder...", this, SLOT(editCopyToFolder()));
       
   467     mContextMenuActions.mEditMoveToFolder = mContextMenuActions.mEditMenu->addAction("Move to folder...", this, SLOT(editMoveToFolder()));
       
   468 }
       
   469 
       
   470 void FbFileView::createViewContextMenu()
       
   471 {
       
   472 
       
   473 }
       
   474 
       
   475 void FbFileView::updateContextMenu()
       
   476 {
       
   477     bool isFileItemListEmpty = mFbFileModel->rowCount() == 0;
       
   478     bool isDriveListViewActive = mEngineWrapper->isDriveListViewActive();
       
   479 //    bool isNormalModeActive = true;       //iModel->FileUtils()->IsNormalModeActive();
       
   480     bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly();
       
   481     bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir();
       
   482     bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0;
       
   483     bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
       
   484     bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse();
       
   485 
       
   486     // File submenu
       
   487     //mContextMenuActions.mFileBackMoveUp->setVisible( !isDriveListViewActive);
       
   488     mContextMenuActions.mFileOpenDirectory->setVisible( !isFileItemListEmpty && !isDriveListViewActive && isCurrentItemDirectory);
       
   489 
       
   490     mContextMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isDriveListViewActive && !isCurrentDriveReadOnly);
       
   491     mContextMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isDriveListViewActive && !isCurrentDriveReadOnly);
       
   492     mContextMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isDriveListViewActive && !isCurrentDriveReadOnly);
       
   493     mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty && !isSelectionMode);
       
   494 
       
   495     mContextMenuActions.mFileChecksumsMenu->menuAction()->setVisible(!(isFileItemListEmpty || isSelectionMode /*|| !hasSelectedItems*/ || isCurrentItemDirectory || isDriveListViewActive));
       
   496     // Edit submenu
       
   497     mContextMenuActions.mEditMenu->menuAction()->setVisible(!isDriveListViewActive);
       
   498     mContextMenuActions.mEditCut->setVisible(!(isDriveListViewActive || isCurrentDriveReadOnly || isFileItemListEmpty));
       
   499     mContextMenuActions.mEditCopy->setVisible(!(isDriveListViewActive || isFileItemListEmpty));
       
   500     mContextMenuActions.mEditPaste->setVisible(!isDriveListViewActive && !isClipBoardEmpty && !isCurrentDriveReadOnly);
       
   501     mContextMenuActions.mEditCopyToFolder->setVisible(!(isDriveListViewActive || isFileItemListEmpty));
       
   502     mContextMenuActions.mEditMoveToFolder->setVisible(!(isDriveListViewActive || isCurrentDriveReadOnly || isFileItemListEmpty));
       
   503 }
       
   504 
       
   505 // ---------------------------------------------------------------------------
       
   506 
       
   507 void FbFileView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords)
       
   508 {
       
   509     QModelIndex proxyIndex = listViewItem->modelIndex();
       
   510     //map to source model
       
   511     mCurrentIndex = mSortFilterProxyModel->mapToSource(proxyIndex);
       
   512 
       
   513     mContextMenu->setPreferredPos(coords);
       
   514     mContextMenu->show();
       
   515 }
       
   516 
       
   517 /**
       
   518   Create a file browser tool bar
       
   519   */
       
   520 void FbFileView::createToolBar()
       
   521 {
       
   522     mToolBar = toolBar();
       
   523 
       
   524     mToolbarBackAction = new HbAction(mToolBar);
       
   525     mToolbarBackAction->setToolTip("Back");
       
   526     mToolbarBackAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_folder_parent.svg")));
       
   527     connect(mToolbarBackAction, SIGNAL(triggered()), this, SLOT(fileBackMoveUp()));
       
   528     mToolBar->addAction(mToolbarBackAction);
       
   529 
       
   530     // Find button and its extension
       
   531     HbToolBarExtension* filterExtension = new HbToolBarExtension();
       
   532     // Set search panel widget
       
   533     mSearchPanel = new HbSearchPanel(filterExtension);
       
   534     mSearchPanel->setMinimumWidth( 360 ); // TODO should be based on layout, screen width
       
   535     connect(mSearchPanel, SIGNAL(criteriaChanged(const QString &)), this, SLOT(filterCriteriaChanged(const QString &)));
       
   536     connect(mSearchPanel, SIGNAL(exitClicked()), filterExtension, SLOT(close()));
       
   537     connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(clearFilterCriteria()));
       
   538     filterExtension->setContentWidget(mSearchPanel);
       
   539 
       
   540     HbAction* mToolbarFilterAction = mToolBar->addExtension(filterExtension);
       
   541 //    mToolbarFilterAction->setText("Filter");
       
   542     mToolbarFilterAction->setToolTip("Filter");
       
   543     mToolbarFilterAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_find.svg")));
       
   544     //connect(mToolbarFilterAction, SIGNAL(triggered()), this, SLOT(viewFilterEntries()));
       
   545 
       
   546     if (mOptionMenuActions.mSelection) {
       
   547         //mOptionMenuActions.mSelection->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_selection_active.svg")));
       
   548         mToolBar->addAction(mOptionMenuActions.mSelection);
       
   549     }
       
   550 
       
   551 //    // TODO Paste to be added
       
   552 //    if (mOptionMenuActions.mEditPaste) {
       
   553 //        //mOptionMenuActions.mEditPaste->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_selection_active.svg")));
       
   554 //        mToolBar->addAction(mOptionMenuActions.mEditPaste);
       
   555 //    }
       
   556 }
       
   557 
       
   558 /**
       
   559   Refresh FileBrowser view
       
   560   */
       
   561 void FbFileView::refreshList()
       
   562 {
       
   563     editUnselectAll();
       
   564     mEngineWrapper->refreshView();
       
   565     mSearchPanel->setCriteria(QString(""));
       
   566     mListView->model()->revert();
       
   567     mListView->reset();
       
   568 
       
   569     if (mListView->model() && mListView->model()->rowCount() > 0) {
       
   570         QModelIndex firstIndex = mListView->model()->index(0, 0);
       
   571         mListView->scrollTo(firstIndex);
       
   572     }
       
   573 
       
   574     TListingMode listingMode = mEngineWrapper->listingMode();
       
   575     if (listingMode == ENormalEntries)
       
   576         mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
       
   577     else if (listingMode == ESearchResults)
       
   578         mNaviPane->setPlainText(QString(tr("Search results")));
       
   579     else if (listingMode == EOpenFiles)
       
   580         mNaviPane->setPlainText(QString(tr("Open files")));
       
   581     else if (listingMode == EMsgAttachmentsInbox)
       
   582         mNaviPane->setPlainText(QString(tr("Attachments in Inbox")));
       
   583     else if (listingMode == EMsgAttachmentsDrafts)
       
   584         mNaviPane->setPlainText(QString(tr("Attachments in Drafts")));
       
   585     else if (listingMode == EMsgAttachmentsSentItems)
       
   586         mNaviPane->setPlainText(QString(tr("Attachments in Sent Items")));
       
   587     else if (listingMode == EMsgAttachmentsOutbox)
       
   588         mNaviPane->setPlainText(QString(tr("Attachments in Outbox")));
       
   589 }
       
   590 
       
   591 // ---------------------------------------------------------------------------	
       
   592 
       
   593 void FbFileView::fileOpen(HbAction *action)
       
   594 {
       
   595 //    Q_UNUSED(action);
       
   596     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
       
   597     if(!action && dlg && dlg->selectedItems().count()){
       
   598         int selectionIndex = dlg->selectedItems().at(0).toInt();
       
   599 
       
   600         if (selectionIndex == 0) {
       
   601             // open editor view
       
   602             emit aboutToShowEditorView(mAbsoluteFilePath, true);
       
   603         } else if (selectionIndex == 1) {
       
   604             // AppArc
       
   605             mEngineWrapper->openAppArc(mAbsoluteFilePath);
       
   606         } else {
       
   607             // DocHandler
       
   608             mEngineWrapper->openDocHandler(mAbsoluteFilePath, true);
       
   609         }
       
   610     }
       
   611 }
       
   612 
       
   613 /**
       
   614   Open overwrite dialog
       
   615   */
       
   616 void FbFileView::fileOverwriteDialog()
       
   617 {
       
   618     mOverwriteOptions = OverwriteOptions();
       
   619     // open user-dialog to select: view as text/hex,  open w/AppArc or open w/DocH. embed
       
   620     QStringList list;
       
   621     list << QString("Overwrite all")
       
   622          << QString("Skip all existing")
       
   623          << QString("Gen. unique filenames")
       
   624          << QString("Query postfix");
       
   625     openListDialog(list, QString("Overwrite?"), this, SLOT(fileOverwrite(HbAction *)));
       
   626 }
       
   627 
       
   628 /**
       
   629   File overwrite
       
   630   */
       
   631 void FbFileView::fileOverwrite(HbAction *action)
       
   632 {
       
   633     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
       
   634     if(!action && dlg && dlg->selectedItems().count()) {
       
   635         mOverwriteOptions.queryIndex = dlg->selectedItems().at(0).toInt();
       
   636         if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) {
       
   637             QString heading = QString("Postfix");
       
   638             HbInputDialog::getText(heading, this, SLOT(fileOverwritePostfix(HbAction *)), QString(), scene());
       
   639         } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) {
       
   640             mOverwriteOptions.overWriteFlags = 0;
       
   641         }
       
   642     } else {
       
   643         mOverwriteOptions.doFileOperations = false;
       
   644     }
       
   645 }
       
   646 
       
   647 /**
       
   648   File overwrite postfix query dialog
       
   649   */
       
   650 void FbFileView::fileOverwritePostfix(HbAction *action)
       
   651 {
       
   652     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   653     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   654         mOverwriteOptions.postFix = dlg->value().toString();
       
   655     } else {
       
   656         mOverwriteOptions.doFileOperations = false;
       
   657     }
       
   658 }
       
   659 
       
   660 // ---------------------------------------------------------------------------
       
   661 /**
       
   662   Show a list dialog
       
   663   \param List aList of item to select item from.
       
   664   \param Title text titleText of a dialog heading widget
       
   665   \return None
       
   666   */
       
   667 void FbFileView::openListDialog(const QStringList& items, const QString &titleText, QObject* receiver, const char* member)
       
   668 {
       
   669     // Create a list and some simple content for it
       
   670     HbSelectionDialog *dlg = new HbSelectionDialog();
       
   671     dlg->setAttribute(Qt::WA_DeleteOnClose);
       
   672     // Set items to be popup's content
       
   673     dlg->setStringItems(items);
       
   674     dlg->setSelectionMode(HbAbstractItemView::SingleSelection);
       
   675 
       
   676     HbLabel *title = new HbLabel(dlg);
       
   677     title->setPlainText(titleText);
       
   678     dlg->setHeadingWidget(title);
       
   679 
       
   680     // Launch popup and handle the user response:
       
   681     dlg->open(receiver, member);
       
   682 }
       
   683 
       
   684 // ---------------------------------------------------------------------------
       
   685 
       
   686 void FbFileView::openPropertyDialog(const QStringList& propertyList, const QString& title)
       
   687 {
       
   688     HbDialog *dialog = new HbDialog();
       
   689     dialog->setDismissPolicy(HbPopup::TapOutside);
       
   690     dialog->setTimeout(HbPopup::NoTimeout);
       
   691 
       
   692     HbLabel *titleWidget = new HbLabel();
       
   693     titleWidget->setPlainText(title);
       
   694     dialog->setHeadingWidget(titleWidget);
       
   695 
       
   696     // Create a list and some simple content for it
       
   697     HbListWidget *list = new HbListWidget();
       
   698     QString str;
       
   699     foreach (str, propertyList) {
       
   700         list->addItem(str);
       
   701     }
       
   702 
       
   703     // Connect list item activation signal to close the popup
       
   704     connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close()));
       
   705 
       
   706     HbAction *cancelAction = new HbAction("Close");
       
   707     dialog->setPrimaryAction(cancelAction);
       
   708 
       
   709     // Set listwidget to be popup's content
       
   710     dialog->setContentWidget(list);
       
   711     // Launch popup and handle the user response:
       
   712     dialog->open();
       
   713 }
       
   714 
       
   715 /**
       
   716   Stores selection or current index mapped to source model
       
   717   */
       
   718 void FbFileView::storeSelectedItemsOrCurrentItem()
       
   719 {
       
   720     QItemSelectionModel *selectionIndexes = mListView->selectionModel();
       
   721 
       
   722     // by default use selected items
       
   723     if (selectionIndexes) {
       
   724         if (selectionIndexes->hasSelection()) {
       
   725             QItemSelection proxyItemSelection = mListView->selectionModel()->selection();
       
   726             QItemSelection itemSelection = mSortFilterProxyModel->mapSelectionToSource(proxyItemSelection);
       
   727             mSelectionIndexes = itemSelection.indexes();
       
   728         } else { // or if none selected, use the current item index
       
   729             mSelectionIndexes.clear();
       
   730             QModelIndex currentIndex = currentItemIndex();  //alreade mapped to source model
       
   731             mSelectionIndexes.append(currentIndex);
       
   732         }
       
   733     }
       
   734 }
       
   735 
       
   736 // ---------------------------------------------------------------------------
       
   737 
       
   738 QModelIndex FbFileView::currentItemIndex()
       
   739 {
       
   740     return mCurrentIndex;
       
   741 }
       
   742 
       
   743 // ---------------------------------------------------------------------------
       
   744 // operations in File Menu
       
   745 // ---------------------------------------------------------------------------
       
   746 
       
   747 /**
       
   748   Move back/up in folder browsing history
       
   749   */
       
   750 void FbFileView::fileBackMoveUp()
       
   751 {
       
   752     mLocationChanged = true;
       
   753     mEngineWrapper->moveUpOneLevel();
       
   754     //mListView->setRootIndex(currentItemIndex());
       
   755     refreshList();
       
   756     if (mEngineWrapper->isDriveListViewActive()) {
       
   757         emit aboutToShowDriveView();
       
   758     }
       
   759 }
       
   760 
       
   761 void FbFileView::fileOpenDirectory()
       
   762 {
       
   763     mLocationChanged = true;
       
   764     // get selected drive or directory from list view model and open it:
       
   765     //if (mListView->selectionModel()->hasSelection()) {
       
   766 //    if (mListView->selectionModel()->selection().count() != 0) {
       
   767 //        QModelIndex currentIndex = currentItemIndex();
       
   768         mEngineWrapper->moveDownToDirectory(currentItemIndex());
       
   769 //        mListView->setRootIndex(currentItemIndex());
       
   770         refreshList();
       
   771 //    } else {
       
   772 //        Notifications::showErrorNote("not selected item!");
       
   773 //    }
       
   774 }
       
   775 
       
   776 void FbFileView::fileSearch()
       
   777 {
       
   778     QString searchPath;
       
   779 //    if (mEngineWrapper->currentPath() != mInitDirPath.path()) {
       
   780 //        searchPath = mDirectory;
       
   781 //        searchPath.replace("/", "\\");
       
   782 //        searchPath+="\\";
       
   783 //    }
       
   784     searchPath = mEngineWrapper->currentPath();
       
   785 //    mSearch->open(searchPath);
       
   786     emit aboutToShowSearchView(searchPath);
       
   787 }
       
   788 
       
   789 /**
       
   790   Open new file dialog
       
   791   */
       
   792 void FbFileView::fileNewFile()
       
   793 {
       
   794     QString heading = QString("Enter filename");
       
   795     HbInputDialog::getText(heading, this, SLOT(doFileNewFile(HbAction*)), QString(), scene());
       
   796 }
       
   797 
       
   798 /**
       
   799   Create a new file in current directory with a name queried from user
       
   800   */
       
   801 void FbFileView::doFileNewFile(HbAction *action)
       
   802 {
       
   803     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   804     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   805         QString newFileName = dlg->value().toString();
       
   806         mEngineWrapper->createNewFile(newFileName);
       
   807         refreshList();
       
   808     }
       
   809 }
       
   810 
       
   811 /**
       
   812   Open new directory dialog
       
   813   */
       
   814 void FbFileView::fileNewDirectory()
       
   815 {
       
   816     QString heading = QString("Enter directory name");
       
   817     HbInputDialog::getText(heading, this, SLOT(doFileNewDirectory(HbAction*)), QString(), scene());
       
   818 }
       
   819 
       
   820 /**
       
   821   Create a new directory in current directory with a name queried from user
       
   822   */
       
   823 void FbFileView::doFileNewDirectory(HbAction *action)
       
   824 {
       
   825     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   826     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   827         QString newDirectoryName = dlg->value().toString();
       
   828         mEngineWrapper->createNewDirectory(newDirectoryName);
       
   829         refreshList();
       
   830     }
       
   831 }
       
   832 
       
   833 /**
       
   834   Question for Delete actually selected files
       
   835   */
       
   836 void FbFileView::fileDelete()
       
   837 {
       
   838     storeSelectedItemsOrCurrentItem();
       
   839     const QString messageFormat = "Delete %1 entries?";
       
   840     QString message = messageFormat.arg(mSelectionIndexes.count());
       
   841     HbMessageBox::question(message, this, SLOT(doFileDelete(HbAction*)));
       
   842 }
       
   843 
       
   844 /**
       
   845   Delete actually selected files
       
   846   */
       
   847 void FbFileView::doFileDelete(HbAction* action)
       
   848 {
       
   849     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
   850         //storeSelectedItemsOrCurrentItem();
       
   851         mEngineWrapper->deleteItems(mSelectionIndexes);
       
   852         refreshList();
       
   853     }
       
   854 }
       
   855 
       
   856 /**
       
   857   Open rename dialog for actually selected files
       
   858   */
       
   859 void FbFileView::fileRename()
       
   860 {
       
   861     storeSelectedItemsOrCurrentItem();
       
   862     mEngineWrapper->setCurrentSelection(mSelectionIndexes);
       
   863 
       
   864     for (int i(0), ie(mSelectionIndexes.count()); i < ie; ++i ) {
       
   865         mProceed = (i == ie-1); // if the last item
       
   866         mModelIndex = mSelectionIndexes.at(i);
       
   867         FileEntry entry = mEngineWrapper->getFileEntry(mModelIndex);
       
   868 
       
   869         QString heading = QString("Enter new name");
       
   870         HbInputDialog::getText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene());
       
   871     }
       
   872 }
       
   873 
       
   874 /**
       
   875   Rename actually selected files
       
   876   */
       
   877 void FbFileView::doFileRename(HbAction *action)
       
   878 {
       
   879     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   880     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
   881         mNewFileName = dlg->value().toString();
       
   882 
       
   883         if (mEngineWrapper->targetExists(mModelIndex, mNewFileName)) {
       
   884             const QString messageTemplate = QString("%1 already exists, overwrite?");
       
   885             QString message = messageTemplate.arg(mNewFileName);
       
   886             HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(HbAction *)));
       
   887         } else {
       
   888             mEngineWrapper->rename(mModelIndex, mNewFileName);
       
   889             if (mProceed) {
       
   890                 mEngineWrapper->startExecutingCommands(QString("Renaming"));
       
   891                 refreshList();
       
   892             }
       
   893         }
       
   894     }
       
   895 }
       
   896 
       
   897 /**
       
   898   Rename actually selected files
       
   899   */
       
   900 void FbFileView::doFileRenameFileExist(HbAction *action)
       
   901 {
       
   902     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
   903         mEngineWrapper->rename(mModelIndex, mNewFileName);
       
   904         if (mProceed) {
       
   905             mEngineWrapper->startExecutingCommands(QString("Renaming"));
       
   906             refreshList();
       
   907         }
       
   908     }
       
   909 }
       
   910 
       
   911 /**
       
   912   Touch actually selected files
       
   913   */
       
   914 void FbFileView::fileTouch()
       
   915 {
       
   916     storeSelectedItemsOrCurrentItem();
       
   917     mEngineWrapper->setCurrentSelection(mSelectionIndexes);
       
   918 
       
   919     if (mEngineWrapper->selectionHasDirs()) {
       
   920         const QString message = "Recurse touch for all selected dirs?";
       
   921         HbMessageBox::question(message, this, SLOT(doFileTouch(HbAction*)));
       
   922     }
       
   923     else{
       
   924         mEngineWrapper->touch(false);
       
   925         refreshList();
       
   926     }
       
   927 }
       
   928 
       
   929 /**
       
   930   Touch actually selected files
       
   931   */
       
   932 void FbFileView::doFileTouch(HbAction* action)
       
   933 {
       
   934     bool recurse = false;
       
   935     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
       
   936         recurse = true;
       
   937         }
       
   938     mEngineWrapper->touch(recurse);
       
   939     refreshList();
       
   940 }
       
   941 
       
   942 void FbFileView::fileChecksumsMD5()
       
   943 {
       
   944     fileChecksums(EFileChecksumsMD5);
       
   945 }
       
   946 
       
   947 void FbFileView::fileChecksumsMD2()
       
   948 {
       
   949     fileChecksums(EFileChecksumsMD2);
       
   950 }
       
   951 
       
   952 void FbFileView::fileChecksumsSHA1()
       
   953 {
       
   954     fileChecksums(EFileChecksumsSHA1);
       
   955 }
       
   956 
       
   957 void FbFileView::fileChecksums(TFileBrowserCmdFileChecksums checksumType)
       
   958 {
       
   959     mEngineWrapper->showFileCheckSums(currentItemIndex(), checksumType);
       
   960 }
       
   961 
       
   962 /**
       
   963   Show file properties
       
   964   */
       
   965 void FbFileView::fileProperties()
       
   966 {
       
   967     QModelIndex currentIndex = currentItemIndex();
       
   968     QStringList propertyList;
       
   969     QString titleText;
       
   970     mEngineWrapper->properties(currentIndex, propertyList, titleText);
       
   971     openPropertyDialog(propertyList, titleText);
       
   972 }
       
   973 
       
   974 void FbFileView::fileSetAttributes()
       
   975 {
       
   976 
       
   977 }
       
   978 
       
   979 // edit menu
       
   980 void FbFileView::editSnapShotToE()
       
   981 {
       
   982 
       
   983 }
       
   984 
       
   985 /**
       
   986   Set selected files into clipboard.
       
   987   Selected item will be removed after paste operation.
       
   988   */
       
   989 void FbFileView::editCut()
       
   990 {
       
   991     storeSelectedItemsOrCurrentItem();
       
   992 
       
   993     // Store indices to clipboard
       
   994     mClipboardIndexes.clear();
       
   995     for (int i = 0; i < mSelectionIndexes.size(); ++i) {
       
   996         mClipboardIndexes.append(mSelectionIndexes.at(i));
       
   997     }
       
   998 
       
   999     mEngineWrapper->clipboardCut(mClipboardIndexes);
       
  1000 
       
  1001     int operations = mClipboardIndexes.count();
       
  1002     const QString message = QString ("%1 entries cut to clipboard");
       
  1003     QString noteMsg = message.arg(operations);
       
  1004 
       
  1005     Notifications::showInformationNote(noteMsg);
       
  1006 }
       
  1007 
       
  1008 /**
       
  1009   Set selected files into clipboard.
       
  1010   Selected item will not be removed after paste operation.
       
  1011   */
       
  1012 void FbFileView::editCopy()
       
  1013 {
       
  1014     storeSelectedItemsOrCurrentItem();
       
  1015 
       
  1016     // Store indices to clipboard
       
  1017     mClipboardIndexes.clear();
       
  1018     for (int i = 0; i < mSelectionIndexes.size(); ++i) {
       
  1019         mClipboardIndexes.append(mSelectionIndexes.at(i));
       
  1020     }
       
  1021 
       
  1022     mEngineWrapper->clipboardCopy(mClipboardIndexes);
       
  1023 
       
  1024     int operations = mClipboardIndexes.count();
       
  1025 
       
  1026     const QString message = QString ("%1 entries copied to clipboard");
       
  1027     QString noteMsg = message.arg(operations);
       
  1028 
       
  1029     Notifications::showInformationNote(noteMsg);
       
  1030 }
       
  1031 
       
  1032 /**
       
  1033   Moves or copies file selection stored in clipboard to a actual directory.
       
  1034   Removing files depend on previous operation, i.e. Cut or Copy
       
  1035   */
       
  1036 void FbFileView::editPaste()
       
  1037 {
       
  1038     bool someEntryExists(false);
       
  1039 
       
  1040     // TODO Set entry items here
       
  1041 
       
  1042     someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndexes, mEngineWrapper->currentPath());
       
  1043     if (someEntryExists) {
       
  1044         fileOverwriteDialog();
       
  1045     }
       
  1046     
       
  1047     mEngineWrapper->clipboardPaste(mOverwriteOptions);
       
  1048 }
       
  1049 
       
  1050 /**
       
  1051   Open copy to folder new filename dialog
       
  1052   */
       
  1053 void FbFileView::editCopyToFolder()
       
  1054 {
       
  1055     QString heading = QString("Enter new name");
       
  1056     HbInputDialog::getText(heading, this, SLOT(doEditCopyToFolder(HbAction*)), mEngineWrapper->currentPath(), scene());
       
  1057 }
       
  1058 
       
  1059 /**
       
  1060   Copies current file selection to a queried directory.
       
  1061   */
       
  1062 void FbFileView::doEditCopyToFolder(HbAction *action)
       
  1063 {
       
  1064     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1065     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1066         QString targetDir = dlg->value().toString();
       
  1067         bool someEntryExists(false);
       
  1068 
       
  1069         // TODO Set entry items here
       
  1070         storeSelectedItemsOrCurrentItem();
       
  1071         mEngineWrapper->setCurrentSelection(mSelectionIndexes);
       
  1072 
       
  1073         someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir);
       
  1074         if (someEntryExists) {
       
  1075             fileOverwriteDialog();
       
  1076         }
       
  1077         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, false);
       
  1078         refreshList();
       
  1079     }
       
  1080 }
       
  1081 
       
  1082 /**
       
  1083   Open move to folder new filename dialog.
       
  1084   */
       
  1085 void FbFileView::editMoveToFolder()
       
  1086 {
       
  1087     QString heading = QString("Enter new name");
       
  1088     HbInputDialog::getText(heading, this, SLOT(doEditMoveToFolder(HbAction*)), mEngineWrapper->currentPath(), scene());
       
  1089 }
       
  1090 
       
  1091 /**
       
  1092   Moves current file selection to a queried directory.
       
  1093   */
       
  1094 void FbFileView::doEditMoveToFolder(HbAction *action)
       
  1095 {
       
  1096     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1097     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1098         QString targetDir = dlg->value().toString();
       
  1099         bool someEntryExists(false);
       
  1100 
       
  1101         // TODO Set entry items here
       
  1102         storeSelectedItemsOrCurrentItem();
       
  1103         mEngineWrapper->setCurrentSelection(mSelectionIndexes);
       
  1104 
       
  1105         someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir);
       
  1106         if (someEntryExists) {
       
  1107             fileOverwriteDialog();
       
  1108         }
       
  1109         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, true);
       
  1110         refreshList();
       
  1111     }
       
  1112 }
       
  1113 
       
  1114 /**
       
  1115   Select current file
       
  1116   */
       
  1117 void FbFileView::editSelect()
       
  1118 {
       
  1119     QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1120     if (selectionModel) {
       
  1121         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::SelectCurrent);
       
  1122         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Select);
       
  1123 //        itemHighlighted(selectionModel->currentIndex());
       
  1124         refreshList();
       
  1125     }
       
  1126 }
       
  1127 
       
  1128 /**
       
  1129   Unselect current file
       
  1130   */
       
  1131 void FbFileView::editUnselect()
       
  1132 {
       
  1133     QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1134     if (selectionModel) {
       
  1135         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Deselect);
       
  1136 //        itemHighlighted(selectionModel->currentIndex());
       
  1137     }
       
  1138 }
       
  1139 
       
  1140 /**
       
  1141   Select all files
       
  1142   */
       
  1143 void FbFileView::editSelectAll()
       
  1144 {
       
  1145     QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1146     if (selectionModel) {
       
  1147 
       
  1148         //if (mFileBrowserModel->rowCount() > 0) {
       
  1149         if (mListView->model() && mListView->model()->rowCount() > 0) {
       
  1150             QModelIndex firstIndex = mListView->model()->index(0, 0);
       
  1151             QModelIndex lastIndex = mListView->model()->index( (mListView->model()->rowCount() - 1), 0);
       
  1152 
       
  1153             QItemSelection itemSelection(firstIndex, lastIndex);
       
  1154             selectionModel->select(itemSelection, QItemSelectionModel::SelectCurrent);
       
  1155         }
       
  1156     }
       
  1157 }
       
  1158 
       
  1159 /**
       
  1160   Unselect all files
       
  1161   */
       
  1162 void FbFileView::editUnselectAll()
       
  1163 {
       
  1164     QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1165     if (selectionModel) {
       
  1166         selectionModel->clearSelection();
       
  1167     }
       
  1168 }
       
  1169 
       
  1170 // ---------------------------------------------------------------------------
       
  1171 // view menu
       
  1172 // ---------------------------------------------------------------------------
       
  1173 void FbFileView::viewFilterEntries()
       
  1174 {
       
  1175     if (mToolBar && mToolBar->actions().count() > 1 && mToolBar->actions().at(1)) {
       
  1176         HbAction* tbeFilterAction = qobject_cast<HbAction*>(mToolBar->actions().at(1));
       
  1177         if (tbeFilterAction && tbeFilterAction->toolBarExtension()) {
       
  1178             HbToolBarExtension *tbeFilter = tbeFilterAction->toolBarExtension();
       
  1179             tbeFilter->open();
       
  1180         }
       
  1181     }
       
  1182 }
       
  1183 
       
  1184 /**
       
  1185   Set filter criteria to proxy model
       
  1186   */
       
  1187 void FbFileView::filterCriteriaChanged(const QString &criteria)
       
  1188 {
       
  1189     mSortFilterProxyModel->setFilterCriteria(criteria);
       
  1190 }
       
  1191 
       
  1192 /**
       
  1193   Set filter criteria to proxy model
       
  1194   */
       
  1195 void FbFileView::clearFilterCriteria()
       
  1196 {
       
  1197     mSearchPanel->setCriteria(QString(""));
       
  1198 }
       
  1199 
       
  1200 /**
       
  1201   Refresh view
       
  1202   */
       
  1203 void FbFileView::viewRefresh()
       
  1204 {
       
  1205     refreshList();
       
  1206 }
       
  1207 
       
  1208 // ---------------------------------------------------------------------------
       
  1209 // tools menu
       
  1210 // ---------------------------------------------------------------------------
       
  1211 void FbFileView::toolsAllAppsToTextFile()
       
  1212 {
       
  1213 
       
  1214 }
       
  1215 
       
  1216 /**
       
  1217   Write all files to text file
       
  1218   */
       
  1219 void FbFileView::toolsAllFilesToTextFile()
       
  1220 {
       
  1221     mEngineWrapper->toolsWriteAllFiles();
       
  1222 }
       
  1223 
       
  1224 //void FbFileView::toolsAvkonIconCacheEnable()
       
  1225 //{
       
  1226 //
       
  1227 //}
       
  1228 //void FbFileView::toolsAvkonIconCacheDisable()
       
  1229 //{
       
  1230 //
       
  1231 //}
       
  1232 
       
  1233 /**
       
  1234   Disable extended errors
       
  1235   */
       
  1236 void FbFileView::toolsDisableExtendedErrors()
       
  1237 {
       
  1238     mEngineWrapper->ToolsSetErrRd(false);
       
  1239 }
       
  1240 
       
  1241 void FbFileView::toolsDumpMsgStoreWalk()
       
  1242 {
       
  1243 
       
  1244 }
       
  1245 void FbFileView::toolsEditDataTypes()
       
  1246 {
       
  1247 
       
  1248 }
       
  1249 
       
  1250 /**
       
  1251   Enable extended errors
       
  1252   */
       
  1253 void FbFileView::toolsEnableExtendedErrors()
       
  1254 {
       
  1255     mEngineWrapper->ToolsSetErrRd(true);
       
  1256 }
       
  1257 
       
  1258 /**
       
  1259   Open simulate leave dialog
       
  1260   */
       
  1261 void FbFileView::toolsErrorSimulateLeave()
       
  1262 {
       
  1263     int leaveCode = -6;
       
  1264     QString heading = QString("Leave code");
       
  1265     //HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene());
       
  1266     HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene());
       
  1267 }
       
  1268 
       
  1269 
       
  1270 /**
       
  1271   Simulate leave.
       
  1272   */
       
  1273 void FbFileView::doToolsErrorSimulateLeave(HbAction *action)
       
  1274 {
       
  1275     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1276     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1277         bool ok;
       
  1278         int leaveCode = dlg->value().toString().toInt(&ok);
       
  1279         if (leaveCode != 0 || ok) {
       
  1280             mEngineWrapper->ToolsErrorSimulateLeave(leaveCode);
       
  1281         }
       
  1282     }
       
  1283 }
       
  1284 
       
  1285 /**
       
  1286   Open simulate panic dialog.
       
  1287   */
       
  1288 void FbFileView::toolsErrorSimulatePanic()
       
  1289 {
       
  1290     mPanicCategory = QString ("Test Category");
       
  1291     QString heading = QString("Panic category");
       
  1292     HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene());
       
  1293 }
       
  1294 
       
  1295 /**
       
  1296   Simulate panic.
       
  1297   */
       
  1298 void FbFileView::doToolsErrorSimulatePanicCode(HbAction *action)
       
  1299 {
       
  1300     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1301     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1302         mPanicCategory = dlg->value().toString();
       
  1303         int panicCode(555);
       
  1304         QString heading = QString("Panic code");
       
  1305         HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene());
       
  1306     }
       
  1307 }
       
  1308 
       
  1309 /**
       
  1310   Simulate panic.
       
  1311   */
       
  1312 void FbFileView::doToolsErrorSimulatePanic(HbAction *action)
       
  1313 {
       
  1314     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1315     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1316         bool ok;
       
  1317         int panicCode = dlg->value().toInt(&ok);
       
  1318         if (panicCode != 0 || ok) {
       
  1319             mEngineWrapper->ToolsErrorSimulatePanic(mPanicCategory, panicCode);
       
  1320         }
       
  1321     }
       
  1322 }
       
  1323 
       
  1324 /**
       
  1325   Open simulate exception dialog.
       
  1326   */
       
  1327 void FbFileView::toolsErrorSimulateException()
       
  1328 {
       
  1329     int exceptionCode = 0;
       
  1330     QString heading = QString("Exception code");
       
  1331     HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene());
       
  1332 }
       
  1333 
       
  1334 /**
       
  1335   Simulate exception.
       
  1336   */
       
  1337 void FbFileView::doToolsErrorSimulateException(HbAction *action)
       
  1338 {
       
  1339     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1340     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1341         bool ok;
       
  1342         int exceptionCode = dlg->value().toInt(&ok);
       
  1343         if (exceptionCode != 0 || ok) {
       
  1344             mEngineWrapper->ToolsErrorSimulateException(exceptionCode);
       
  1345         }
       
  1346     }
       
  1347 }
       
  1348 
       
  1349 //    void FbFileView::toolsLocalConnectivityActivateInfrared()
       
  1350 //{
       
  1351 //
       
  1352 //}
       
  1353 //    void FbFileView::toolsLocalConnectivityLaunchBTUI()
       
  1354 //{
       
  1355 //
       
  1356 //}
       
  1357 //    void FbFileView::toolsLocalConnectivityLaunchUSBUI()
       
  1358 //{
       
  1359 //
       
  1360 //}
       
  1361 void FbFileView::toolsMessageInbox()
       
  1362 {
       
  1363 
       
  1364 }
       
  1365 void FbFileView::toolsMessageDrafts()
       
  1366 {
       
  1367 
       
  1368 }
       
  1369 void FbFileView::toolsMessageSentItems()
       
  1370 {
       
  1371 
       
  1372 }
       
  1373 void FbFileView::toolsMessageOutbox()
       
  1374 {
       
  1375 
       
  1376 }
       
  1377 void FbFileView::toolsMemoryInfo()
       
  1378 {
       
  1379 
       
  1380 }
       
  1381 void FbFileView::toolsSecureBackStart()
       
  1382 {
       
  1383 
       
  1384 }
       
  1385 void FbFileView::toolsSecureBackRestore()
       
  1386 {
       
  1387 
       
  1388 }
       
  1389 void FbFileView::toolsSecureBackStop()
       
  1390 {
       
  1391 
       
  1392 }
       
  1393 
       
  1394 /**
       
  1395   Open debug mask dialog
       
  1396   */
       
  1397 void FbFileView::toolsSetDebugMaskQuestion()
       
  1398 {
       
  1399     quint32 dbgMask = mEngineWrapper->getDebugMask();
       
  1400     QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16));
       
  1401     QString heading = QString("Kernel debug mask in hex format");
       
  1402     HbInputDialog::getText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene());
       
  1403 }
       
  1404 
       
  1405 /**
       
  1406   Set debug mask
       
  1407   */
       
  1408 void FbFileView::toolsSetDebugMask(HbAction *action)
       
  1409 {
       
  1410     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
  1411     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
       
  1412         QString dbgMaskText = dlg->value().toString();
       
  1413         if (dbgMaskText.length() > 2 && dbgMaskText[0]=='0' && dbgMaskText[1]=='x') {
       
  1414             bool ok;
       
  1415             quint32 dbgMask = dbgMaskText.toUInt(&ok, 16);
       
  1416             if (dbgMask != 0 || ok) {
       
  1417                 mEngineWrapper->toolsSetDebugMask(dbgMask);
       
  1418                 Notifications::showConfirmationNote(QString("Changed"));
       
  1419             } else {
       
  1420                 Notifications::showErrorNote(QString("Cannot convert value"));
       
  1421             }
       
  1422         } else {
       
  1423             Notifications::showErrorNote(QString("Not in hex format"));
       
  1424         }
       
  1425     }
       
  1426 }
       
  1427 
       
  1428 void FbFileView::toolsShowOpenFilesHere()
       
  1429 {
       
  1430 
       
  1431 }
       
  1432 
       
  1433 // ---------------------------------------------------------------------------
       
  1434 // main menu items
       
  1435 // ---------------------------------------------------------------------------
       
  1436 void FbFileView::selectionModeChanged()
       
  1437 {
       
  1438     if (mOptionMenuActions.mSelection->isChecked()) {
       
  1439          activateSelectionMode();
       
  1440      } else {
       
  1441          deActivateSelectionMode();
       
  1442      }
       
  1443 }
       
  1444 
       
  1445 /**
       
  1446   Show about note
       
  1447   */
       
  1448 void FbFileView::about()
       
  1449 {
       
  1450     Notifications::showAboutNote();
       
  1451 }
       
  1452 
       
  1453 // ---------------------------------------------------------------------------
       
  1454 // End of operations
       
  1455 // ---------------------------------------------------------------------------
       
  1456 
       
  1457 // ---------------------------------------------------------------------------
       
  1458 
       
  1459 /**
       
  1460   Item is selected from list when selection mode is activated from menu
       
  1461   */
       
  1462 void FbFileView::selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
       
  1463 {
       
  1464     //QItemSelectionModel *selectionModel = mListView->selectionModel();
       
  1465     //itemHighlighted(selectionModel->currentIndex());
       
  1466 }
       
  1467 
       
  1468 /**
       
  1469   An item is clicked from navigation item list. Navigation item list contains
       
  1470   drive-, folder- or file items. Opens selected drive, folder or file popup menu
       
  1471   */
       
  1472 void FbFileView::activated(const QModelIndex& index)
       
  1473 {
       
  1474     if (mFbFileModel) {
       
  1475         //map to source model
       
  1476         QModelIndex activatedIndex = mSortFilterProxyModel->mapToSource(index);
       
  1477 
       
  1478         if (mEngineWrapper->getFileEntry(activatedIndex).isDir()) {
       
  1479             // populate new content of changed navigation view.
       
  1480             // mLocationChanged = true;
       
  1481             // mDirectory = filePath;
       
  1482             mEngineWrapper->moveDownToDirectory(activatedIndex);
       
  1483             refreshList();
       
  1484         } else {  // file item
       
  1485             // mSelectedFilePath = filePath;
       
  1486             FileEntry fileEntry = mEngineWrapper->getFileEntry(activatedIndex);
       
  1487             mAbsoluteFilePath = fileEntry.path() + fileEntry.name();
       
  1488 
       
  1489             // open user-dialog to select: view as text/hex,  open w/AppArc or open w/DocH. embed
       
  1490             QStringList list;
       
  1491             list << QString("View as text/hex") << QString("Open w/ AppArc") << QString("Open w/ DocH. embed");
       
  1492             openListDialog(list, QString("Open file"), this, SLOT(fileOpen(HbAction *)));
       
  1493         }
       
  1494     }
       
  1495 }
       
  1496 
       
  1497 // ---------------------------------------------------------------------------
       
  1498 
       
  1499 void FbFileView::activateSelectionMode()
       
  1500 {
       
  1501     QString path;
       
  1502     disconnect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
       
  1503     mListView->setSelectionMode(HbListView::MultiSelection);
       
  1504 
       
  1505 //    QModelIndex index = mFileSystemModel->index(path,0);
       
  1506 //    mListView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent);
       
  1507 //    mListView->selectionModel()->select(index, QItemSelectionModel::Select);
       
  1508 //    //mListView->setHighlightMode(HbItemHighlight::HighlightAlwaysVisible);
       
  1509 //    mListView->setFocus();    // TODO use focus in
       
  1510     if (mListView->selectionModel()) {
       
  1511         connect(mListView->selectionModel(),
       
  1512                 SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
       
  1513                 this,
       
  1514                 SLOT(selectionChanged(QItemSelection, QItemSelection)));
       
  1515 //        // flag to indicate that selection mode changed, "edit" sub-menu update needed
       
  1516 //        mFolderContentChanged = true;
       
  1517     }
       
  1518 }
       
  1519 
       
  1520 // ---------------------------------------------------------------------------
       
  1521 
       
  1522 void FbFileView::deActivateSelectionMode()
       
  1523 {
       
  1524     disconnect(mListView->selectionModel(),
       
  1525                SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
       
  1526                this,
       
  1527                SLOT(selectionChanged(QItemSelection, QItemSelection)));
       
  1528     mListView->setSelectionMode(HbListView::NoSelection);
       
  1529     connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
       
  1530     editUnselectAll();
       
  1531     // flag to indicate that selection mode changed, "edit" sub-menu update needed
       
  1532     mFolderContentChanged = true;
       
  1533 }
       
  1534 
       
  1535 // ---------------------------------------------------------------------------