filebrowser/ui/src/fbfileview.cpp
changeset 51 b048e15729d6
parent 31 e7a04a6385be
equal deleted inserted replaced
44:5db69f4c3d06 51:b048e15729d6
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "fbfileview.h"
    18 #include "fbfileview.h"
    19 #include "settingsview.h"
    19 #include "fbsettingsview.h"
    20 #include "editorview.h"
    20 #include "fbeditorview.h"
    21 #include "searchview.h"
    21 #include "fbsearchview.h"
    22 #include "enginewrapper.h"
    22 #include "enginewrapper.h"
    23 #include "notifications.h"
    23 #include "notifications.h"
    24 
    24 #include "fbfolderselectiondialog.h"
    25 #include "fbfilemodel.h"
    25 #include "fbfilemodel.h"
    26 #include "filebrowsersortfilterproxymodel.h"
    26 #include "filebrowsersortfilterproxymodel.h"
    27 //#include "fbfilelistviewitem.h"
    27 //#include "fbfilelistviewitem.h"
    28 
    28 
    29 #include <HbMenu>
    29 #include <HbMenu>
    64     mSortFilterProxyModel(0),
    64     mSortFilterProxyModel(0),
    65     mOptionMenuActions(),
    65     mOptionMenuActions(),
    66     mContextMenuActions(),
    66     mContextMenuActions(),
    67     mContextMenu(0),
    67     mContextMenu(0),
    68     mToolbarBackAction(0),
    68     mToolbarBackAction(0),
       
    69     mToolbarFilterAction(0),
       
    70     mToolbarPasteAction(0),
    69     mItemHighlighted(false),
    71     mItemHighlighted(false),
    70     mLocationChanged(false),
    72     mLocationChanged(false),
    71     mRemoveFileAfterCopied(false),
    73     mRemoveFileAfterCopied(false),
    72 //    mClipBoardInUse(false),
    74 //    mClipBoardInUse(false),
    73     mFolderContentChanged(false),
    75     mFolderContentChanged(false),
   119 //    mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
   121 //    mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn);
   120 
   122 
   121     connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
   123     connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
   122     connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)),
   124     connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)),
   123             this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF)));
   125             this, SLOT(onLongPressed(HbAbstractViewItem*, QPointF)));
       
   126     connect(mEngineWrapper, SIGNAL(fileSystemDataChanged()), this, SLOT(refreshList()));
   124 
   127 
   125     mNaviPane = new HbLabel(this);
   128     mNaviPane = new HbLabel(this);
   126     mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default
   129     mNaviPane->setPlainText(QString(" ")); // TODO get from settings or default
   127     //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
   130     //mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
   128     HbFontSpec fontSpec(HbFontSpec::PrimarySmall);
   131     HbFontSpec fontSpec(HbFontSpec::PrimarySmall);
   180 {
   183 {
   181     mOptionMenuActions.mFileMenu = menu()->addMenu("File");
   184     mOptionMenuActions.mFileMenu = menu()->addMenu("File");
   182 
   185 
   183     mOptionMenuActions.mFileBackMoveUp = mOptionMenuActions.mFileMenu->addAction("Back/Move up", this, SLOT(fileBackMoveUp()));
   186     mOptionMenuActions.mFileBackMoveUp = mOptionMenuActions.mFileMenu->addAction("Back/Move up", this, SLOT(fileBackMoveUp()));
   184     mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
   187     mOptionMenuActions.mFileSearch = mOptionMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
   185     //mOptionMenuActions.mFileSearch->setVisible(false);
       
   186 
   188 
   187     mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New");
   189     mOptionMenuActions.mFileNewMenu = mOptionMenuActions.mFileMenu->addMenu("New");
   188     mOptionMenuActions.mFileNewFile = mOptionMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile()));
   190     mOptionMenuActions.mFileNewFile = mOptionMenuActions.mFileNewMenu->addAction("File", this, SLOT(fileNewFile()));
   189     mOptionMenuActions.mFileNewDirectory = mOptionMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory()));
   191     mOptionMenuActions.mFileNewDirectory = mOptionMenuActions.mFileNewMenu->addAction("Directory", this, SLOT(fileNewDirectory()));
   190 
   192 
   191     mOptionMenuActions.mFileDelete = mOptionMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
   193     mOptionMenuActions.mFileDelete = mOptionMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
   192     mOptionMenuActions.mFileRename = mOptionMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
   194     mOptionMenuActions.mFileRename = mOptionMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
   193     mOptionMenuActions.mFileTouch = mOptionMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
   195     mOptionMenuActions.mFileTouch = mOptionMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
   194 
   196 
   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()));
   197     mOptionMenuActions.mFileSetAttributes = mOptionMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
   201     mOptionMenuActions.mFileSetAttributes->setVisible(false);
       
   202 }
   198 }
   203 
   199 
   204 /**
   200 /**
   205   Initial setup for Edit submenu
   201   Initial setup for Edit submenu
   206   */
   202   */
   345 void FbFileView::updateOptionMenu()
   341 void FbFileView::updateOptionMenu()
   346 {
   342 {
   347     bool isFileItemListEmpty = mFbFileModel->rowCount() == 0;
   343     bool isFileItemListEmpty = mFbFileModel->rowCount() == 0;
   348     bool isNormalModeActive = true;       //iModel->FileUtils()->IsNormalModeActive();
   344     bool isNormalModeActive = true;       //iModel->FileUtils()->IsNormalModeActive();
   349     bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly();   //iModel->FileUtils()->IsCurrentDriveReadOnly();
   345     bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly();   //iModel->FileUtils()->IsCurrentDriveReadOnly();
   350     bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir();
   346     // bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir();
   351     // bool currentSelected = true;    //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex());
   347     // bool currentSelected = true;    //iContainer->ListBox()->View()->ItemIsSelected(iContainer->ListBox()->View()->CurrentItemIndex());
   352     bool isAllSelected = mListView->selectionModel()->selection().count() == mFbFileModel->rowCount();
   348     bool isAllSelected = mListView->selectionModel()->selection().count() == mFbFileModel->rowCount();
   353     //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0;
   349     //bool isNoneSelected = mListView->selectionModel()->selection().count() != 0;
   354     bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0;
   350     bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0;
   355     bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
   351     bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
   370     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory);
   366     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileEdit, isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory);
   371     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory);
   367     //aMenuPane->SetItemDimmed(EFileBrowserCmdFileSendTo, isFileItemListEmpty || driveListActive || isCurrentItemDirectory);
   372 
   368 
   373     mOptionMenuActions.mFileNewMenu->menuAction()->setVisible(!isCurrentDriveReadOnly);
   369     mOptionMenuActions.mFileNewMenu->menuAction()->setVisible(!isCurrentDriveReadOnly);
   374     mOptionMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*isSelectionMode*/);
   370     mOptionMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*isSelectionMode*/);
   375     mOptionMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems/*&& isSelectionMode*/);
   371     mOptionMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems /*&& !isSelectionMode*/);
   376     mOptionMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems);
   372     mOptionMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems);
   377 
   373 
   378     // TODO mOptionMenuActions.mFileChecksumsMenu->setVisible(!(isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory));
   374     mOptionMenuActions.mFileSetAttributes->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && hasSelectedItems);
   379     // TODO mOptionMenuActions.mFileSetAttributes->setVisible(!(isFileItemListEmpty || isCurrentDriveReadOnly));
       
   380     // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory));
   375     // TODO mOptionMenuActions.mFileCompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory));
   381     // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory));
   376     // TODO mOptionMenuActions.mFileDecompress->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty || !hasSelectedItems || isCurrentItemDirectory));
   382 
   377 
   383     mOptionMenuActions.mEditCut->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode);
   378     mOptionMenuActions.mEditMenu->menuAction()->setVisible( (!isSelectionMode && !isClipBoardEmpty && !isCurrentDriveReadOnly)
   384     mOptionMenuActions.mEditCopy->setVisible(!isFileItemListEmpty && isSelectionMode);
   379                                                             || (isSelectionMode));
   385     mOptionMenuActions.mEditPaste->setVisible(!(isClipBoardEmpty || isCurrentDriveReadOnly));
   380     mOptionMenuActions.mEditCut->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode && hasSelectedItems);
   386     mOptionMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty);
   381     mOptionMenuActions.mEditCopy->setVisible(!isFileItemListEmpty && isSelectionMode && hasSelectedItems);
   387     mOptionMenuActions.mEditMoveToFolder->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty));
   382     mOptionMenuActions.mEditPaste->setVisible(!isClipBoardEmpty && !isCurrentDriveReadOnly);
       
   383     mOptionMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty && isSelectionMode && hasSelectedItems);
       
   384     mOptionMenuActions.mEditMoveToFolder->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && isSelectionMode && hasSelectedItems);
   388 
   385 
   389     mOptionMenuActions.mEditSelect->setVisible(false/*!currentSelected && !isFileItemListEmpty*/);
   386     mOptionMenuActions.mEditSelect->setVisible(false/*!currentSelected && !isFileItemListEmpty*/);
   390     mOptionMenuActions.mEditUnselect->setVisible(false/*currentSelected && !isFileItemListEmpty*/);
   387     mOptionMenuActions.mEditUnselect->setVisible(false/*currentSelected && !isFileItemListEmpty*/);
   391     mOptionMenuActions.mEditSelectAll->setVisible(isSelectionMode && !isAllSelected && !isFileItemListEmpty);
   388     mOptionMenuActions.mEditSelectAll->setVisible(!isFileItemListEmpty && isSelectionMode && !isAllSelected);
   392     mOptionMenuActions.mEditUnselectAll->setVisible(hasSelectedItems && !isFileItemListEmpty);
   389     mOptionMenuActions.mEditUnselectAll->setVisible(!isFileItemListEmpty && hasSelectedItems);
   393 
   390 
   394     // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isFileItemListEmpty));
   391     // TODO mOptionMenuActions.mViewSort->setVisible(!(!isNormalModeActive || isFileItemListEmpty));
   395     // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive  || isFileItemListEmpty));
   392     // TODO mOptionMenuActions.mViewOrder->setVisible(!(!isNormalModeActive  || isFileItemListEmpty));
   396     mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive);
   393     mOptionMenuActions.mViewRefresh->setVisible(isNormalModeActive);
   397     mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty);
   394     mOptionMenuActions.mViewFilterEntries->setVisible(!isFileItemListEmpty);
   433 void FbFileView::createFileContextMenu()
   430 void FbFileView::createFileContextMenu()
   434 {
   431 {
   435     mContextMenuActions.mFileMenu = mContextMenu->addMenu("File");
   432     mContextMenuActions.mFileMenu = mContextMenu->addMenu("File");
   436 
   433 
   437     //mContextMenuActions.mFileBackMoveUp = mContextMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp()));
   434     //mContextMenuActions.mFileBackMoveUp = mContextMenuActions.mFileMenu->addAction("Back/Move up (<-)", this, SLOT(fileBackMoveUp()));
   438     mContextMenuActions.mFileOpenDirectory = mContextMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory()));
   435 //    mContextMenuActions.mFileOpenDirectory = mContextMenuActions.mFileMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory()));
   439 //    mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
   436     mContextMenuActions.mFileOpenDirectory = mContextMenu->addAction("Open directory (->)", this, SLOT(fileOpenDirectory()));
   440     //mContextMenuActions.mFileSearch->setVisible(false);
   437     mContextMenuActions.mSearch = mContextMenu->addAction("Search...", this, SLOT(fileSearch()));
       
   438     mContextMenuActions.mFileSearch = mContextMenuActions.mFileMenu->addAction("Search...", this, SLOT(fileSearch()));
   441 
   439 
   442     mContextMenuActions.mFileDelete = mContextMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
   440     mContextMenuActions.mFileDelete = mContextMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
   443     mContextMenuActions.mFileRename = mContextMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
   441     mContextMenuActions.mFileRename = mContextMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
   444     mContextMenuActions.mFileTouch = mContextMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
   442     mContextMenuActions.mFileTouch = mContextMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
   445     mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties()));
   443     mContextMenuActions.mFileProperties = mContextMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties()));
   447     mContextMenuActions.mFileChecksumsMenu = mContextMenuActions.mFileMenu->addMenu("Checksums");
   445     mContextMenuActions.mFileChecksumsMenu = mContextMenuActions.mFileMenu->addMenu("Checksums");
   448     mContextMenuActions.mFileChecksumsMD5 = mContextMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5()));
   446     mContextMenuActions.mFileChecksumsMD5 = mContextMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5()));
   449     mContextMenuActions.mFileChecksumsMD2 = mContextMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2()));
   447     mContextMenuActions.mFileChecksumsMD2 = mContextMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2()));
   450     mContextMenuActions.mFileChecksumsSHA1 = mContextMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1()));
   448     mContextMenuActions.mFileChecksumsSHA1 = mContextMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1()));
   451 
   449 
   452 //    mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
   450     mContextMenuActions.mFileSetAttributes = mContextMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
   453 //    mContextMenuActions.mFileSetAttributes->setVisible(false);
       
   454 }
   451 }
   455 
   452 
   456 void FbFileView::createEditContextMenu()
   453 void FbFileView::createEditContextMenu()
   457 {
   454 {
   458     mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit");
   455     mContextMenuActions.mEditMenu = mContextMenu->addMenu("Edit");
   473 }
   470 }
   474 
   471 
   475 void FbFileView::updateContextMenu()
   472 void FbFileView::updateContextMenu()
   476 {
   473 {
   477     bool isFileItemListEmpty = mFbFileModel->rowCount() == 0;
   474     bool isFileItemListEmpty = mFbFileModel->rowCount() == 0;
   478     bool isDriveListViewActive = mEngineWrapper->isDriveListViewActive();
       
   479 //    bool isNormalModeActive = true;       //iModel->FileUtils()->IsNormalModeActive();
   475 //    bool isNormalModeActive = true;       //iModel->FileUtils()->IsNormalModeActive();
   480     bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly();
   476     bool isCurrentDriveReadOnly = mEngineWrapper->isCurrentDriveReadOnly();
   481     bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir();
   477     bool isCurrentItemDirectory = mEngineWrapper->getFileEntry(currentItemIndex()).isDir();
   482     bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0;
   478     bool hasSelectedItems = mListView->selectionModel()->selection().count() != 0;
   483     bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
   479     bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
   484     bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse();
   480     bool isClipBoardEmpty = !mEngineWrapper->isClipBoardListInUse();
   485 
   481 
       
   482     mContextMenuActions.mFileOpenDirectory->setVisible(!isFileItemListEmpty && isCurrentItemDirectory && isSelectionMode);
       
   483     mContextMenuActions.mSearch->setVisible(!isFileItemListEmpty && isSelectionMode && isCurrentItemDirectory);
       
   484     mContextMenuActions.mFileSearch->setVisible(!isFileItemListEmpty && !isSelectionMode && isCurrentItemDirectory);
   486     // File submenu
   485     // File submenu
   487     //mContextMenuActions.mFileBackMoveUp->setVisible( !isDriveListViewActive);
   486     //mContextMenuActions.mFileBackMoveUp->setVisible();
   488     mContextMenuActions.mFileOpenDirectory->setVisible( !isFileItemListEmpty && !isDriveListViewActive && isCurrentItemDirectory);
   487     mContextMenuActions.mFileMenu->menuAction()->setVisible(!isSelectionMode);
   489 
   488 
   490     mContextMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isDriveListViewActive && !isCurrentDriveReadOnly);
   489     mContextMenuActions.mFileDelete->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly);
   491     mContextMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isDriveListViewActive && !isCurrentDriveReadOnly);
   490     mContextMenuActions.mFileRename->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly && !isSelectionMode);
   492     mContextMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isDriveListViewActive && !isCurrentDriveReadOnly);
   491     mContextMenuActions.mFileTouch->setVisible(!isFileItemListEmpty && !isCurrentDriveReadOnly);
   493     mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty && !isSelectionMode);
   492     mContextMenuActions.mFileProperties->setVisible(!isFileItemListEmpty && !isSelectionMode);
   494 
   493 
   495     mContextMenuActions.mFileChecksumsMenu->menuAction()->setVisible(!(isFileItemListEmpty || isSelectionMode /*|| !hasSelectedItems*/ || isCurrentItemDirectory || isDriveListViewActive));
   494     mContextMenuActions.mFileChecksumsMenu->menuAction()->setVisible(!isFileItemListEmpty && !isSelectionMode && !isCurrentItemDirectory);
       
   495 
   496     // Edit submenu
   496     // Edit submenu
   497     mContextMenuActions.mEditMenu->menuAction()->setVisible(!isDriveListViewActive);
   497     mContextMenuActions.mEditMenu->menuAction()->setVisible(!isSelectionMode);
   498     mContextMenuActions.mEditCut->setVisible(!(isDriveListViewActive || isCurrentDriveReadOnly || isFileItemListEmpty));
   498     mContextMenuActions.mEditCut->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty));
   499     mContextMenuActions.mEditCopy->setVisible(!(isDriveListViewActive || isFileItemListEmpty));
   499     mContextMenuActions.mEditCopy->setVisible(!(isFileItemListEmpty));
   500     mContextMenuActions.mEditPaste->setVisible(!isDriveListViewActive && !isClipBoardEmpty && !isCurrentDriveReadOnly);
   500     mContextMenuActions.mEditPaste->setVisible(!isClipBoardEmpty && !isCurrentDriveReadOnly);
   501     mContextMenuActions.mEditCopyToFolder->setVisible(!(isDriveListViewActive || isFileItemListEmpty));
   501     mContextMenuActions.mEditCopyToFolder->setVisible(!isFileItemListEmpty);
   502     mContextMenuActions.mEditMoveToFolder->setVisible(!(isDriveListViewActive || isCurrentDriveReadOnly || isFileItemListEmpty));
   502     mContextMenuActions.mEditMoveToFolder->setVisible(!(isCurrentDriveReadOnly || isFileItemListEmpty));
   503 }
   503 }
   504 
   504 
   505 // ---------------------------------------------------------------------------
   505 // ---------------------------------------------------------------------------
   506 
   506 
   507 void FbFileView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords)
   507 void FbFileView::onLongPressed(HbAbstractViewItem *listViewItem, QPointF coords)
   535     connect(mSearchPanel, SIGNAL(criteriaChanged(const QString &)), this, SLOT(filterCriteriaChanged(const QString &)));
   535     connect(mSearchPanel, SIGNAL(criteriaChanged(const QString &)), this, SLOT(filterCriteriaChanged(const QString &)));
   536     connect(mSearchPanel, SIGNAL(exitClicked()), filterExtension, SLOT(close()));
   536     connect(mSearchPanel, SIGNAL(exitClicked()), filterExtension, SLOT(close()));
   537     connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(clearFilterCriteria()));
   537     connect(mSearchPanel, SIGNAL(exitClicked()), this, SLOT(clearFilterCriteria()));
   538     filterExtension->setContentWidget(mSearchPanel);
   538     filterExtension->setContentWidget(mSearchPanel);
   539 
   539 
   540     HbAction* mToolbarFilterAction = mToolBar->addExtension(filterExtension);
   540     mToolbarFilterAction = mToolBar->addExtension(filterExtension);
   541 //    mToolbarFilterAction->setText("Filter");
       
   542     mToolbarFilterAction->setToolTip("Filter");
   541     mToolbarFilterAction->setToolTip("Filter");
   543     mToolbarFilterAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_find.svg")));
   542     mToolbarFilterAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_find.svg")));
   544     //connect(mToolbarFilterAction, SIGNAL(triggered()), this, SLOT(viewFilterEntries()));
   543     //connect(mToolbarFilterAction, SIGNAL(triggered()), this, SLOT(viewFilterEntries()));
   545 
   544 
   546     if (mOptionMenuActions.mSelection) {
   545     if (mOptionMenuActions.mSelection) {
       
   546         // TODO Selection mode icon to be added
   547         //mOptionMenuActions.mSelection->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_selection_active.svg")));
   547         //mOptionMenuActions.mSelection->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_selection_active.svg")));
   548         mToolBar->addAction(mOptionMenuActions.mSelection);
   548         mToolBar->addAction(mOptionMenuActions.mSelection);
   549     }
   549     }
   550 
   550 
   551 //    // TODO Paste to be added
   551     mToolbarPasteAction = new HbAction(mToolBar);
   552 //    if (mOptionMenuActions.mEditPaste) {
   552     mToolbarPasteAction->setText("Paste");
   553 //        //mOptionMenuActions.mEditPaste->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_selection_active.svg")));
   553     mToolbarPasteAction->setToolTip("Paste");
   554 //        mToolBar->addAction(mOptionMenuActions.mEditPaste);
   554     // TODO Paste icon to be added
   555 //    }
   555     //mToolbarPasteAction->setIcon(HbIcon(QString(":/qgn_indi_tb_filebrowser_folder_parent.svg")));
       
   556     connect(mToolbarPasteAction, SIGNAL(triggered()), this, SLOT(editPaste()));
       
   557     mToolBar->addAction(mToolbarPasteAction);
       
   558     mToolbarPasteAction->setEnabled(false);
   556 }
   559 }
   557 
   560 
   558 /**
   561 /**
   559   Refresh FileBrowser view
   562   Refresh FileBrowser view
   560   */
   563   */
   561 void FbFileView::refreshList()
   564 void FbFileView::refreshList()
   562 {
   565 {
   563     editUnselectAll();
   566     editUnselectAll();
   564     mEngineWrapper->refreshView();
   567     mEngineWrapper->refreshView();
   565     mSearchPanel->setCriteria(QString(""));
   568     mSearchPanel->setCriteria(QString(""));
   566     mListView->model()->revert();
       
   567     mListView->reset();
   569     mListView->reset();
   568 
   570 
   569     if (mListView->model() && mListView->model()->rowCount() > 0) {
   571     if (mListView->model() && mListView->model()->rowCount() > 0) {
   570         QModelIndex firstIndex = mListView->model()->index(0, 0);
   572         QModelIndex firstIndex = mListView->model()->index(0, 0);
   571         mListView->scrollTo(firstIndex);
   573         mListView->scrollTo(firstIndex);
   572     }
   574     }
       
   575 
       
   576     mToolbarPasteAction->setEnabled(mEngineWrapper->isClipBoardListInUse());
   573 
   577 
   574     TListingMode listingMode = mEngineWrapper->listingMode();
   578     TListingMode listingMode = mEngineWrapper->listingMode();
   575     if (listingMode == ENormalEntries)
   579     if (listingMode == ENormalEntries)
   576         mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
   580         mNaviPane->setPlainText(QString(mEngineWrapper->currentPath()));
   577     else if (listingMode == ESearchResults)
   581     else if (listingMode == ESearchResults)
   633     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
   637     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
   634     if(!action && dlg && dlg->selectedItems().count()) {
   638     if(!action && dlg && dlg->selectedItems().count()) {
   635         mOverwriteOptions.queryIndex = dlg->selectedItems().at(0).toInt();
   639         mOverwriteOptions.queryIndex = dlg->selectedItems().at(0).toInt();
   636         if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) {
   640         if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) {
   637             QString heading = QString("Postfix");
   641             QString heading = QString("Postfix");
   638             HbInputDialog::getText(heading, this, SLOT(fileOverwritePostfix(HbAction *)), QString(), scene());
   642             HbInputDialog::queryText(heading, this, SLOT(fileOverwritePostfix(HbAction *)), QString(), scene());
   639         } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) {
   643         } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) {
   640             mOverwriteOptions.overWriteFlags = 0;
   644             mOverwriteOptions.overWriteFlags = 0;
   641         }
   645         }
   642     } else {
   646     } else {
   643         mOverwriteOptions.doFileOperations = false;
   647         mOverwriteOptions.doFileOperations = false;
   719 {
   723 {
   720     QItemSelectionModel *selectionIndexes = mListView->selectionModel();
   724     QItemSelectionModel *selectionIndexes = mListView->selectionModel();
   721 
   725 
   722     // by default use selected items
   726     // by default use selected items
   723     if (selectionIndexes) {
   727     if (selectionIndexes) {
   724         if (selectionIndexes->hasSelection()) {
   728         bool isSelectionMode = mOptionMenuActions.mSelection && mOptionMenuActions.mSelection->isChecked();
   725             QItemSelection proxyItemSelection = mListView->selectionModel()->selection();
   729         if (isSelectionMode) {
   726             QItemSelection itemSelection = mSortFilterProxyModel->mapSelectionToSource(proxyItemSelection);
   730             if (selectionIndexes->hasSelection()) {
   727             mSelectionIndexes = itemSelection.indexes();
   731                 QItemSelection proxyItemSelection = mListView->selectionModel()->selection();
       
   732                 QItemSelection itemSelection = mSortFilterProxyModel->mapSelectionToSource(proxyItemSelection);
       
   733                 mSelectionIndexes = itemSelection.indexes();
       
   734             } else { // or if none selected, clear selection
       
   735                 mSelectionIndexes.clear();
       
   736             }
   728         } else { // or if none selected, use the current item index
   737         } else { // or if none selected, use the current item index
   729             mSelectionIndexes.clear();
   738             mSelectionIndexes.clear();
   730             QModelIndex currentIndex = currentItemIndex();  //alreade mapped to source model
   739             QModelIndex currentIndex = currentItemIndex();  //alreade mapped to source model
   731             mSelectionIndexes.append(currentIndex);
   740             mSelectionIndexes.append(currentIndex);
   732         }
   741         }
   774 }
   783 }
   775 
   784 
   776 void FbFileView::fileSearch()
   785 void FbFileView::fileSearch()
   777 {
   786 {
   778     QString searchPath;
   787     QString searchPath;
   779 //    if (mEngineWrapper->currentPath() != mInitDirPath.path()) {
   788     HbAction *contextrMenuAction = static_cast<HbAction *>(sender());
   780 //        searchPath = mDirectory;
   789     if (contextrMenuAction
   781 //        searchPath.replace("/", "\\");
   790         && (contextrMenuAction == mContextMenuActions.mSearch
   782 //        searchPath+="\\";
   791             || contextrMenuAction == mContextMenuActions.mFileSearch)
   783 //    }
   792         && mEngineWrapper->getFileEntry(currentItemIndex()).isDir()) {
   784     searchPath = mEngineWrapper->currentPath();
   793         searchPath = mEngineWrapper->currentPath()
   785 //    mSearch->open(searchPath);
   794                      + mEngineWrapper->getFileEntry(currentItemIndex()).name()
       
   795                      + QString("\\");
       
   796     } else {
       
   797         searchPath = mEngineWrapper->currentPath();
       
   798     }
       
   799 
   786     emit aboutToShowSearchView(searchPath);
   800     emit aboutToShowSearchView(searchPath);
   787 }
   801 }
   788 
   802 
   789 /**
   803 /**
   790   Open new file dialog
   804   Open new file dialog
   791   */
   805   */
   792 void FbFileView::fileNewFile()
   806 void FbFileView::fileNewFile()
   793 {
   807 {
   794     QString heading = QString("Enter filename");
   808     QString heading = QString("Enter filename");
   795     HbInputDialog::getText(heading, this, SLOT(doFileNewFile(HbAction*)), QString(), scene());
   809     HbInputDialog::queryText(heading, this, SLOT(doFileNewFile(HbAction*)), QString(), scene());
   796 }
   810 }
   797 
   811 
   798 /**
   812 /**
   799   Create a new file in current directory with a name queried from user
   813   Create a new file in current directory with a name queried from user
   800   */
   814   */
   812   Open new directory dialog
   826   Open new directory dialog
   813   */
   827   */
   814 void FbFileView::fileNewDirectory()
   828 void FbFileView::fileNewDirectory()
   815 {
   829 {
   816     QString heading = QString("Enter directory name");
   830     QString heading = QString("Enter directory name");
   817     HbInputDialog::getText(heading, this, SLOT(doFileNewDirectory(HbAction*)), QString(), scene());
   831     HbInputDialog::queryText(heading, this, SLOT(doFileNewDirectory(HbAction*)), QString(), scene());
   818 }
   832 }
   819 
   833 
   820 /**
   834 /**
   821   Create a new directory in current directory with a name queried from user
   835   Create a new directory in current directory with a name queried from user
   822   */
   836   */
   836 void FbFileView::fileDelete()
   850 void FbFileView::fileDelete()
   837 {
   851 {
   838     storeSelectedItemsOrCurrentItem();
   852     storeSelectedItemsOrCurrentItem();
   839     const QString messageFormat = "Delete %1 entries?";
   853     const QString messageFormat = "Delete %1 entries?";
   840     QString message = messageFormat.arg(mSelectionIndexes.count());
   854     QString message = messageFormat.arg(mSelectionIndexes.count());
   841     HbMessageBox::question(message, this, SLOT(doFileDelete(HbAction*)));
   855     HbMessageBox::question(message, this, SLOT(doFileDelete(int)), HbMessageBox::Yes | HbMessageBox::No);
   842 }
   856 }
   843 
   857 
   844 /**
   858 /**
   845   Delete actually selected files
   859   Delete actually selected files
   846   */
   860   */
   847 void FbFileView::doFileDelete(HbAction* action)
   861 void FbFileView::doFileDelete(int action)
   848 {
   862 {
   849     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
   863     if (action == HbMessageBox::Yes) {
   850         //storeSelectedItemsOrCurrentItem();
       
   851         mEngineWrapper->deleteItems(mSelectionIndexes);
   864         mEngineWrapper->deleteItems(mSelectionIndexes);
   852         refreshList();
   865         mEngineWrapper->startExecutingCommands(QString("Deleting"));
   853     }
   866     }
   854 }
   867 }
   855 
   868 
   856 /**
   869 /**
   857   Open rename dialog for actually selected files
   870   Open rename dialog for actually selected files
   862     mEngineWrapper->setCurrentSelection(mSelectionIndexes);
   875     mEngineWrapper->setCurrentSelection(mSelectionIndexes);
   863 
   876 
   864     for (int i(0), ie(mSelectionIndexes.count()); i < ie; ++i ) {
   877     for (int i(0), ie(mSelectionIndexes.count()); i < ie; ++i ) {
   865         mProceed = (i == ie-1); // if the last item
   878         mProceed = (i == ie-1); // if the last item
   866         mModelIndex = mSelectionIndexes.at(i);
   879         mModelIndex = mSelectionIndexes.at(i);
   867         FileEntry entry = mEngineWrapper->getFileEntry(mModelIndex);
   880         FbFileEntry entry = mEngineWrapper->getFileEntry(mModelIndex);
   868 
   881 
   869         QString heading = QString("Enter new name");
   882         QString heading = QString("Enter new name");
   870         HbInputDialog::getText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene());
   883         HbInputDialog::queryText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene());
   871     }
   884     }
   872 }
   885 }
   873 
   886 
   874 /**
   887 /**
   875   Rename actually selected files
   888   Rename actually selected files
   881         mNewFileName = dlg->value().toString();
   894         mNewFileName = dlg->value().toString();
   882 
   895 
   883         if (mEngineWrapper->targetExists(mModelIndex, mNewFileName)) {
   896         if (mEngineWrapper->targetExists(mModelIndex, mNewFileName)) {
   884             const QString messageTemplate = QString("%1 already exists, overwrite?");
   897             const QString messageTemplate = QString("%1 already exists, overwrite?");
   885             QString message = messageTemplate.arg(mNewFileName);
   898             QString message = messageTemplate.arg(mNewFileName);
   886             HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(HbAction *)));
   899             HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(int)), HbMessageBox::Yes | HbMessageBox::No);
   887         } else {
   900         } else {
   888             mEngineWrapper->rename(mModelIndex, mNewFileName);
   901             proceedFileRename();
   889             if (mProceed) {
       
   890                 mEngineWrapper->startExecutingCommands(QString("Renaming"));
       
   891                 refreshList();
       
   892             }
       
   893         }
   902         }
   894     }
   903     }
   895 }
   904 }
   896 
   905 
   897 /**
   906 /**
   898   Rename actually selected files
   907   Rename actually selected files
   899   */
   908   */
   900 void FbFileView::doFileRenameFileExist(HbAction *action)
   909 void FbFileView::doFileRenameFileExist(int action)
   901 {
   910 {
   902     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
   911     if (action == HbMessageBox::Yes) {
   903         mEngineWrapper->rename(mModelIndex, mNewFileName);
   912         proceedFileRename();
   904         if (mProceed) {
   913     }
   905             mEngineWrapper->startExecutingCommands(QString("Renaming"));
   914 }
   906             refreshList();
   915 
   907         }
   916 
       
   917 void FbFileView::proceedFileRename()
       
   918 {
       
   919     mEngineWrapper->rename(mModelIndex, mNewFileName);
       
   920     if (mProceed) {
       
   921         mEngineWrapper->startExecutingCommands(QString("Renaming"));
       
   922         refreshList();
   908     }
   923     }
   909 }
   924 }
   910 
   925 
   911 /**
   926 /**
   912   Touch actually selected files
   927   Touch actually selected files
   916     storeSelectedItemsOrCurrentItem();
   931     storeSelectedItemsOrCurrentItem();
   917     mEngineWrapper->setCurrentSelection(mSelectionIndexes);
   932     mEngineWrapper->setCurrentSelection(mSelectionIndexes);
   918 
   933 
   919     if (mEngineWrapper->selectionHasDirs()) {
   934     if (mEngineWrapper->selectionHasDirs()) {
   920         const QString message = "Recurse touch for all selected dirs?";
   935         const QString message = "Recurse touch for all selected dirs?";
   921         HbMessageBox::question(message, this, SLOT(doFileTouch(HbAction*)));
   936         HbMessageBox::question(message, this, SLOT(doFileTouch(int)), HbMessageBox::Yes | HbMessageBox::No);
   922     }
   937     } else {
   923     else{
   938         proceedFileTouch(false);
   924         mEngineWrapper->touch(false);
       
   925         refreshList();
       
   926     }
   939     }
   927 }
   940 }
   928 
   941 
   929 /**
   942 /**
   930   Touch actually selected files
   943   Touch actually selected files
   931   */
   944   */
   932 void FbFileView::doFileTouch(HbAction* action)
   945 void FbFileView::doFileTouch(int action)
   933 {
   946 {
   934     bool recurse = false;
   947     bool recurse = false;
   935     if (action && action->text().compare(QString("Yes"), Qt::CaseInsensitive) == 0) {
   948     if (action == HbMessageBox::Yes) {
   936         recurse = true;
   949         recurse = true;
   937         }
   950         }
       
   951     proceedFileTouch(recurse);
       
   952 }
       
   953 
       
   954 void FbFileView::proceedFileTouch(bool recurse)
       
   955 {
   938     mEngineWrapper->touch(recurse);
   956     mEngineWrapper->touch(recurse);
       
   957     mEngineWrapper->startExecutingCommands(QString("Touching"));
   939     refreshList();
   958     refreshList();
   940 }
   959 }
   941 
   960 
   942 void FbFileView::fileChecksumsMD5()
   961 void FbFileView::fileChecksumsMD5()
   943 {
   962 {
   971     openPropertyDialog(propertyList, titleText);
   990     openPropertyDialog(propertyList, titleText);
   972 }
   991 }
   973 
   992 
   974 void FbFileView::fileSetAttributes()
   993 void FbFileView::fileSetAttributes()
   975 {
   994 {
   976 
   995     storeSelectedItemsOrCurrentItem();
       
   996     mEngineWrapper->setCurrentSelection(mSelectionIndexes);
       
   997 
       
   998     QString attributesViewTitle("Multiple entries");
       
   999 
       
  1000     quint32 setAttributesMask(0);
       
  1001     quint32 clearAttributesMask(0);
       
  1002     bool recurse(false);
       
  1003 
       
  1004     // set default masks if only one file selected
       
  1005     if (mSelectionIndexes.count() == 1)
       
  1006         {
       
  1007         mModelIndex = mSelectionIndexes.at(0);
       
  1008         FbFileEntry fileEntry = mEngineWrapper->getFileEntry(mModelIndex);
       
  1009 
       
  1010         attributesViewTitle = fileEntry.name();
       
  1011 
       
  1012         if (fileEntry.isArchive())
       
  1013             setAttributesMask |= KEntryAttArchive;
       
  1014         else
       
  1015             clearAttributesMask |= KEntryAttArchive;
       
  1016 
       
  1017         if (fileEntry.isHidden())
       
  1018             setAttributesMask |= KEntryAttHidden;
       
  1019         else
       
  1020             clearAttributesMask |= KEntryAttHidden;
       
  1021 
       
  1022         if (fileEntry.isReadOnly())
       
  1023             setAttributesMask |= KEntryAttReadOnly;
       
  1024         else
       
  1025             clearAttributesMask |= KEntryAttReadOnly;
       
  1026 
       
  1027         if (fileEntry.isSystem())
       
  1028             setAttributesMask |= KEntryAttSystem;
       
  1029         else
       
  1030             clearAttributesMask |= KEntryAttSystem;
       
  1031         }
       
  1032 
       
  1033     emit aboutToShowAttributesView(attributesViewTitle, setAttributesMask, clearAttributesMask, recurse);
   977 }
  1034 }
   978 
  1035 
   979 // edit menu
  1036 // edit menu
   980 void FbFileView::editSnapShotToE()
  1037 void FbFileView::editSnapShotToE()
   981 {
  1038 {
   995     for (int i = 0; i < mSelectionIndexes.size(); ++i) {
  1052     for (int i = 0; i < mSelectionIndexes.size(); ++i) {
   996         mClipboardIndexes.append(mSelectionIndexes.at(i));
  1053         mClipboardIndexes.append(mSelectionIndexes.at(i));
   997     }
  1054     }
   998 
  1055 
   999     mEngineWrapper->clipboardCut(mClipboardIndexes);
  1056     mEngineWrapper->clipboardCut(mClipboardIndexes);
       
  1057     mEngineWrapper->setCurrentSelection(mClipboardIndexes);
  1000 
  1058 
  1001     int operations = mClipboardIndexes.count();
  1059     int operations = mClipboardIndexes.count();
  1002     const QString message = QString ("%1 entries cut to clipboard");
  1060     const QString message = QString ("%1 entries cut to clipboard");
  1003     QString noteMsg = message.arg(operations);
  1061     QString noteMsg = message.arg(operations);
  1004 
  1062 
       
  1063     mToolbarPasteAction->setEnabled(true);
  1005     Notifications::showInformationNote(noteMsg);
  1064     Notifications::showInformationNote(noteMsg);
  1006 }
  1065 }
  1007 
  1066 
  1008 /**
  1067 /**
  1009   Set selected files into clipboard.
  1068   Set selected files into clipboard.
  1018     for (int i = 0; i < mSelectionIndexes.size(); ++i) {
  1077     for (int i = 0; i < mSelectionIndexes.size(); ++i) {
  1019         mClipboardIndexes.append(mSelectionIndexes.at(i));
  1078         mClipboardIndexes.append(mSelectionIndexes.at(i));
  1020     }
  1079     }
  1021 
  1080 
  1022     mEngineWrapper->clipboardCopy(mClipboardIndexes);
  1081     mEngineWrapper->clipboardCopy(mClipboardIndexes);
       
  1082     mEngineWrapper->setCurrentSelection(mClipboardIndexes);
  1023 
  1083 
  1024     int operations = mClipboardIndexes.count();
  1084     int operations = mClipboardIndexes.count();
  1025 
  1085 
  1026     const QString message = QString ("%1 entries copied to clipboard");
  1086     const QString message = QString ("%1 entries copied to clipboard");
  1027     QString noteMsg = message.arg(operations);
  1087     QString noteMsg = message.arg(operations);
  1028 
  1088 
       
  1089     mToolbarPasteAction->setEnabled(true);
  1029     Notifications::showInformationNote(noteMsg);
  1090     Notifications::showInformationNote(noteMsg);
  1030 }
  1091 }
  1031 
  1092 
  1032 /**
  1093 /**
  1033   Moves or copies file selection stored in clipboard to a actual directory.
  1094   Moves or copies file selection stored in clipboard to a actual directory.
  1034   Removing files depend on previous operation, i.e. Cut or Copy
  1095   Removing files depend on previous operation, i.e. Cut or Copy
  1035   */
  1096   */
  1036 void FbFileView::editPaste()
  1097 void FbFileView::editPaste()
  1037 {
  1098 {
  1038     bool someEntryExists(false);
  1099     bool someEntryExists(false);
  1039 
       
  1040     // TODO Set entry items here
       
  1041 
  1100 
  1042     someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndexes, mEngineWrapper->currentPath());
  1101     someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndexes, mEngineWrapper->currentPath());
  1043     if (someEntryExists) {
  1102     if (someEntryExists) {
  1044         fileOverwriteDialog();
  1103         fileOverwriteDialog();
  1045     }
  1104     }
  1046     
  1105     
  1047     mEngineWrapper->clipboardPaste(mOverwriteOptions);
  1106     mEngineWrapper->clipboardPaste(mOverwriteOptions);
       
  1107     mEngineWrapper->startExecutingCommands(mEngineWrapper->getClipBoardMode() == EClipBoardModeCut ?
       
  1108                                            QString("Moving") : QString("Copying") );
  1048 }
  1109 }
  1049 
  1110 
  1050 /**
  1111 /**
  1051   Open copy to folder new filename dialog
  1112   Open copy to folder new filename dialog
  1052   */
  1113   */
  1053 void FbFileView::editCopyToFolder()
  1114 void FbFileView::editCopyToFolder()
  1054 {
  1115 {
  1055     QString heading = QString("Enter new name");
  1116     QString heading = QString("Enter new name");
  1056     HbInputDialog::getText(heading, this, SLOT(doEditCopyToFolder(HbAction*)), mEngineWrapper->currentPath(), scene());
  1117     FbCopyToFolderSelectionDialog *folderSelectionDialog = new FbCopyToFolderSelectionDialog();
       
  1118     folderSelectionDialog->open(this, SLOT(doEditCopyToFolder(int)));
  1057 }
  1119 }
  1058 
  1120 
  1059 /**
  1121 /**
  1060   Copies current file selection to a queried directory.
  1122   Copies current file selection to a queried directory.
  1061   */
  1123   */
  1062 void FbFileView::doEditCopyToFolder(HbAction *action)
  1124 void FbFileView::doEditCopyToFolder(int action)
  1063 {
  1125 {
  1064     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
  1126     FbCopyToFolderSelectionDialog *dlg = qobject_cast<FbCopyToFolderSelectionDialog*>(sender());
  1065     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
  1127     if (dlg && action == HbDialog::Accepted) {
  1066         QString targetDir = dlg->value().toString();
  1128         QString targetDir = dlg->selectedFolder();
       
  1129 
  1067         bool someEntryExists(false);
  1130         bool someEntryExists(false);
  1068 
  1131 
  1069         // TODO Set entry items here
  1132         // TODO Set entry items here
  1070         storeSelectedItemsOrCurrentItem();
  1133         storeSelectedItemsOrCurrentItem();
  1071         mEngineWrapper->setCurrentSelection(mSelectionIndexes);
  1134         mEngineWrapper->setCurrentSelection(mSelectionIndexes);
  1073         someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir);
  1136         someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir);
  1074         if (someEntryExists) {
  1137         if (someEntryExists) {
  1075             fileOverwriteDialog();
  1138             fileOverwriteDialog();
  1076         }
  1139         }
  1077         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, false);
  1140         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, false);
  1078         refreshList();
  1141         mEngineWrapper->startExecutingCommands(QString("Copying"));
  1079     }
  1142     }
  1080 }
  1143 }
  1081 
  1144 
  1082 /**
  1145 /**
  1083   Open move to folder new filename dialog.
  1146   Open move to folder new filename dialog.
  1084   */
  1147   */
  1085 void FbFileView::editMoveToFolder()
  1148 void FbFileView::editMoveToFolder()
  1086 {
  1149 {
  1087     QString heading = QString("Enter new name");
  1150     QString heading = QString("Enter new name");
  1088     HbInputDialog::getText(heading, this, SLOT(doEditMoveToFolder(HbAction*)), mEngineWrapper->currentPath(), scene());
  1151     FbMoveToFolderSelectionDialog *folderSelectionDialog = new FbMoveToFolderSelectionDialog();
       
  1152     folderSelectionDialog->open(this, SLOT(doEditMoveToFolder(int)));
  1089 }
  1153 }
  1090 
  1154 
  1091 /**
  1155 /**
  1092   Moves current file selection to a queried directory.
  1156   Moves current file selection to a queried directory.
  1093   */
  1157   */
  1094 void FbFileView::doEditMoveToFolder(HbAction *action)
  1158 void FbFileView::doEditMoveToFolder(int action)
  1095 {
  1159 {
  1096     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
  1160     FbMoveToFolderSelectionDialog *dlg = qobject_cast<FbMoveToFolderSelectionDialog*>(sender());
  1097     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
  1161     if (dlg && action == HbDialog::Accepted) {
  1098         QString targetDir = dlg->value().toString();
  1162         QString targetDir = dlg->selectedFolder();
       
  1163 
  1099         bool someEntryExists(false);
  1164         bool someEntryExists(false);
  1100 
  1165 
  1101         // TODO Set entry items here
  1166         // TODO Set entry items here
  1102         storeSelectedItemsOrCurrentItem();
  1167         storeSelectedItemsOrCurrentItem();
  1103         mEngineWrapper->setCurrentSelection(mSelectionIndexes);
  1168         mEngineWrapper->setCurrentSelection(mSelectionIndexes);
  1105         someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir);
  1170         someEntryExists = mEngineWrapper->isDestinationEntriesExists(mSelectionIndexes, targetDir);
  1106         if (someEntryExists) {
  1171         if (someEntryExists) {
  1107             fileOverwriteDialog();
  1172             fileOverwriteDialog();
  1108         }
  1173         }
  1109         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, true);
  1174         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, true);
  1110         refreshList();
  1175         mEngineWrapper->startExecutingCommands(QString("Moving"));
  1111     }
  1176     }
  1112 }
  1177 }
  1113 
  1178 
  1114 /**
  1179 /**
  1115   Select current file
  1180   Select current file
  1118 {
  1183 {
  1119     QItemSelectionModel *selectionModel = mListView->selectionModel();
  1184     QItemSelectionModel *selectionModel = mListView->selectionModel();
  1120     if (selectionModel) {
  1185     if (selectionModel) {
  1121         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::SelectCurrent);
  1186         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::SelectCurrent);
  1122         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Select);
  1187         selectionModel->select(selectionModel->currentIndex(), QItemSelectionModel::Select);
  1123 //        itemHighlighted(selectionModel->currentIndex());
       
  1124         refreshList();
  1188         refreshList();
  1125     }
  1189     }
  1126 }
  1190 }
  1127 
  1191 
  1128 /**
  1192 /**
  1171 // view menu
  1235 // view menu
  1172 // ---------------------------------------------------------------------------
  1236 // ---------------------------------------------------------------------------
  1173 void FbFileView::viewFilterEntries()
  1237 void FbFileView::viewFilterEntries()
  1174 {
  1238 {
  1175     if (mToolBar && mToolBar->actions().count() > 1 && mToolBar->actions().at(1)) {
  1239     if (mToolBar && mToolBar->actions().count() > 1 && mToolBar->actions().at(1)) {
  1176         HbAction* tbeFilterAction = qobject_cast<HbAction*>(mToolBar->actions().at(1));
  1240         if (mToolbarFilterAction && mToolbarFilterAction->toolBarExtension()) {
  1177         if (tbeFilterAction && tbeFilterAction->toolBarExtension()) {
  1241             HbToolBarExtension *tbeFilter = mToolbarFilterAction->toolBarExtension();
  1178             HbToolBarExtension *tbeFilter = tbeFilterAction->toolBarExtension();
       
  1179             tbeFilter->open();
  1242             tbeFilter->open();
  1180         }
  1243         }
  1181     }
  1244     }
  1182 }
  1245 }
  1183 
  1246 
  1260   */
  1323   */
  1261 void FbFileView::toolsErrorSimulateLeave()
  1324 void FbFileView::toolsErrorSimulateLeave()
  1262 {
  1325 {
  1263     int leaveCode = -6;
  1326     int leaveCode = -6;
  1264     QString heading = QString("Leave code");
  1327     QString heading = QString("Leave code");
  1265     //HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene());
  1328     //HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), leaveCode, scene());
  1266     HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene());
  1329     HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulateLeave(HbAction*)), QString::number(leaveCode), scene());
  1267 }
  1330 }
  1268 
  1331 
  1269 
  1332 
  1270 /**
  1333 /**
  1271   Simulate leave.
  1334   Simulate leave.
  1287   */
  1350   */
  1288 void FbFileView::toolsErrorSimulatePanic()
  1351 void FbFileView::toolsErrorSimulatePanic()
  1289 {
  1352 {
  1290     mPanicCategory = QString ("Test Category");
  1353     mPanicCategory = QString ("Test Category");
  1291     QString heading = QString("Panic category");
  1354     QString heading = QString("Panic category");
  1292     HbInputDialog::getText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene());
  1355     HbInputDialog::queryText(heading, this, SLOT(doToolsErrorSimulatePanicCode(HbAction*)), mPanicCategory, scene());
  1293 }
  1356 }
  1294 
  1357 
  1295 /**
  1358 /**
  1296   Simulate panic.
  1359   Simulate panic.
  1297   */
  1360   */
  1300     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
  1363     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
  1301     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
  1364     if (dlg && action && action->text().compare(QString("Ok"), Qt::CaseInsensitive) == 0) {
  1302         mPanicCategory = dlg->value().toString();
  1365         mPanicCategory = dlg->value().toString();
  1303         int panicCode(555);
  1366         int panicCode(555);
  1304         QString heading = QString("Panic code");
  1367         QString heading = QString("Panic code");
  1305         HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene());
  1368         HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulatePanic(HbAction*)), panicCode, scene());
  1306     }
  1369     }
  1307 }
  1370 }
  1308 
  1371 
  1309 /**
  1372 /**
  1310   Simulate panic.
  1373   Simulate panic.
  1326   */
  1389   */
  1327 void FbFileView::toolsErrorSimulateException()
  1390 void FbFileView::toolsErrorSimulateException()
  1328 {
  1391 {
  1329     int exceptionCode = 0;
  1392     int exceptionCode = 0;
  1330     QString heading = QString("Exception code");
  1393     QString heading = QString("Exception code");
  1331     HbInputDialog::getInteger(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene());
  1394     HbInputDialog::queryInt(heading, this, SLOT(doToolsErrorSimulateException(HbAction*)), exceptionCode, scene());
  1332 }
  1395 }
  1333 
  1396 
  1334 /**
  1397 /**
  1335   Simulate exception.
  1398   Simulate exception.
  1336   */
  1399   */
  1397 void FbFileView::toolsSetDebugMaskQuestion()
  1460 void FbFileView::toolsSetDebugMaskQuestion()
  1398 {
  1461 {
  1399     quint32 dbgMask = mEngineWrapper->getDebugMask();
  1462     quint32 dbgMask = mEngineWrapper->getDebugMask();
  1400     QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16));
  1463     QString dbgMaskText = QString("0x").append(QString::number(dbgMask, 16));
  1401     QString heading = QString("Kernel debug mask in hex format");
  1464     QString heading = QString("Kernel debug mask in hex format");
  1402     HbInputDialog::getText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene());
  1465     HbInputDialog::queryText(heading, this, SLOT(toolsSetDebugMask(HbAction*)), dbgMaskText, scene());
  1403 }
  1466 }
  1404 
  1467 
  1405 /**
  1468 /**
  1406   Set debug mask
  1469   Set debug mask
  1407   */
  1470   */
  1481             // mDirectory = filePath;
  1544             // mDirectory = filePath;
  1482             mEngineWrapper->moveDownToDirectory(activatedIndex);
  1545             mEngineWrapper->moveDownToDirectory(activatedIndex);
  1483             refreshList();
  1546             refreshList();
  1484         } else {  // file item
  1547         } else {  // file item
  1485             // mSelectedFilePath = filePath;
  1548             // mSelectedFilePath = filePath;
  1486             FileEntry fileEntry = mEngineWrapper->getFileEntry(activatedIndex);
  1549             FbFileEntry fileEntry = mEngineWrapper->getFileEntry(activatedIndex);
  1487             mAbsoluteFilePath = fileEntry.path() + fileEntry.name();
  1550             mAbsoluteFilePath = fileEntry.path() + fileEntry.name();
  1488 
  1551 
  1489             // open user-dialog to select: view as text/hex,  open w/AppArc or open w/DocH. embed
  1552             // open user-dialog to select: view as text/hex,  open w/AppArc or open w/DocH. embed
  1490             QStringList list;
  1553             QStringList list;
  1491             list << QString("View as text/hex") << QString("Open w/ AppArc") << QString("Open w/ DocH. embed");
  1554             list << QString("View as text/hex") << QString("Open w/ AppArc") << QString("Open w/ DocH. embed");