filebrowser/ui/src/filebrowserview.cpp
changeset 25 31fc1277642e
parent 24 6053b7ae82ab
child 27 271e901a9423
equal deleted inserted replaced
24:6053b7ae82ab 25:31fc1277642e
    65     mDirectory(),
    65     mDirectory(),
    66     mSelectedFilePath(),
    66     mSelectedFilePath(),
    67     mFileBrowserModel(0),
    67     mFileBrowserModel(0),
    68     mFileViewMenuActions(),
    68     mFileViewMenuActions(),
    69     mToolbarBackAction(0),
    69     mToolbarBackAction(0),
    70     mEditor(0),
       
    71     mSearch(0),
    70     mSearch(0),
    72     mSettingsView(0),
    71     mSettingsView(0),
    73     mItemHighlighted(false),
    72     mItemHighlighted(false),
    74     mLocationChanged(false),
    73     mLocationChanged(false),
    75     mRemoveFileAfterCopied(false),
    74     mRemoveFileAfterCopied(false),
    76     mClipBoardInUse(false),
    75     mClipBoardInUse(false),
    77     mFolderContentChanged(false),
    76     mFolderContentChanged(false),
       
    77     mOldPassword(),
       
    78     mPanicCategory(),
       
    79     mAbsoluteFilePath(),
       
    80     mOverwriteOptions(),
       
    81     mIsRenameAllowed(true),
       
    82     mProceed(false),
    78     mEraseMBR(false)
    83     mEraseMBR(false)
    79 {
    84 {
    80     setTitle("File Browser");
    85     setTitle("File Browser");
    81 
    86 
    82     createMenu();
    87     createMenu();
   122 
   127 
   123 // ---------------------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
   124 
   129 
   125 FileBrowserView::~FileBrowserView()
   130 FileBrowserView::~FileBrowserView()
   126 {  
   131 {  
   127     if (mEditor){
       
   128         delete mEditor;
       
   129     }
       
   130 //    if (mSearch !=0) {
   132 //    if (mSearch !=0) {
   131 //        delete mSearch;
   133 //        delete mSearch;
   132 //    }
   134 //    }
   133 //    if (mSettingsView != 0) {
   135 //    if (mSettingsView != 0) {
   134 //        delete mSettingsView;
   136 //        delete mSettingsView;
   202 
   204 
   203     mFileViewMenuActions.mFileDelete = mFileViewMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
   205     mFileViewMenuActions.mFileDelete = mFileViewMenuActions.mFileMenu->addAction("Delete", this, SLOT(fileDelete()));
   204     mFileViewMenuActions.mFileRename = mFileViewMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
   206     mFileViewMenuActions.mFileRename = mFileViewMenuActions.mFileMenu->addAction("Rename", this, SLOT(fileRename()));
   205     mFileViewMenuActions.mFileTouch = mFileViewMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
   207     mFileViewMenuActions.mFileTouch = mFileViewMenuActions.mFileMenu->addAction("Touch", this, SLOT(fileTouch()));
   206     mFileViewMenuActions.mFileProperties = mFileViewMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties()));
   208     mFileViewMenuActions.mFileProperties = mFileViewMenuActions.mFileMenu->addAction("Properties", this, SLOT(fileProperties()));
       
   209 
       
   210     mFileViewMenuActions.mFileChecksumsMenu = mFileViewMenuActions.mFileMenu->addMenu("Checksums");
       
   211     mFileViewMenuActions.mFileChecksumsMD5 = mFileViewMenuActions.mFileChecksumsMenu->addAction("MD5", this, SLOT(fileChecksumsMD5()));
       
   212     mFileViewMenuActions.mFileChecksumsMD2 = mFileViewMenuActions.mFileChecksumsMenu->addAction("MD2", this, SLOT(fileChecksumsMD2()));
       
   213     mFileViewMenuActions.mFileChecksumsSHA1 = mFileViewMenuActions.mFileChecksumsMenu->addAction("SHA-1", this, SLOT(fileChecksumsSHA1()));
       
   214 
   207     mFileViewMenuActions.mFileSetAttributes = mFileViewMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
   215     mFileViewMenuActions.mFileSetAttributes = mFileViewMenuActions.mFileMenu->addAction("Set attributes...", this, SLOT(fileSetAttributes()));
   208     mFileViewMenuActions.mFileSetAttributes->setVisible(false);
   216     mFileViewMenuActions.mFileSetAttributes->setVisible(false);
   209 }
   217 }
   210 
   218 
   211 /**
   219 /**
   492     //mListView->setRootIndex(mFileSystemModel->index(directory));
   500     //mListView->setRootIndex(mFileSystemModel->index(directory));
   493 }
   501 }
   494 
   502 
   495 // ---------------------------------------------------------------------------	
   503 // ---------------------------------------------------------------------------	
   496 
   504 
   497 void FileBrowserView::fileOpenDialog(const QString& fileName)
   505 void FileBrowserView::fileOpen(HbAction *action)
   498 {
   506 {  
   499     Q_UNUSED(fileName);
   507     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
   500     HbDialog *dialog = new HbDialog();
   508     if(!action && dlg && dlg->selectedModelIndexes().count()){
   501     dialog->setDismissPolicy(HbPopup::TapOutside);
   509         int selectionIndex = dlg->selectedModelIndexes().at(0).row();
   502     dialog->setTimeout(HbPopup::NoTimeout);
   510 
   503 
   511         if (selectionIndex == 0) {
   504     // Create a list and some simple content for it
   512             // open editor view
   505     HbListWidget *list = new HbListWidget();
   513             emit aboutToShowEditorView(mAbsoluteFilePath, true);
   506     HbLabel *title = new HbLabel();
   514         } else if (selectionIndex == 1) {
   507     title->setPlainText("Open File");
       
   508     dialog->setHeadingWidget(title);
       
   509     list->addItem("View as text/hex");
       
   510     list->addItem("Open w/ AppArc");
       
   511     list->addItem("Open w/ DocH. embed");
       
   512 
       
   513     // Connect list item activation signal to close the popup
       
   514     connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close()));
       
   515 
       
   516     HbAction *cancelAction = new HbAction(cancelActionText);
       
   517     dialog->setPrimaryAction(cancelAction);
       
   518 
       
   519     // Set listwidget to be popup's content
       
   520     dialog->setContentWidget(list);
       
   521     // Launch popup and handle the user response:
       
   522     if (dialog->exec() != cancelAction){
       
   523         if (list->currentRow() == 0) {
       
   524             // create and launch editor with selected file item:
       
   525             if(mEditor != 0){
       
   526                 delete mEditor;
       
   527                 mEditor = 0;
       
   528             }
       
   529             emit aboutToShowEditorView(fileName, true);
       
   530         }
       
   531         else if (list->currentRow() == 1) {
       
   532             // AppArc
   515             // AppArc
   533             mEngineWrapper->openAppArc(fileName);
   516             mEngineWrapper->openAppArc(mAbsoluteFilePath);
   534         } else {
   517         } else {
   535             // DocHandler
   518             // DocHandler
   536             mEngineWrapper->openDocHandler(fileName, true);
   519             mEngineWrapper->openDocHandler(mAbsoluteFilePath, true);
   537         }
   520         }
   538     }
   521     }
   539 }
   522 }
   540 
   523 
   541 // ---------------------------------------------------------------------------
   524 /**
   542 
   525   Open overwrite dialog
   543 OverwriteOptions FileBrowserView::fileOverwriteDialog()
   526   */
   544 {
   527 void FileBrowserView::fileOverwriteDialog()
   545     HbDialog *dialog = new HbDialog();
   528 {
   546     dialog->setDismissPolicy(HbPopup::TapOutside);
   529     mOverwriteOptions = OverwriteOptions();
   547     dialog->setTimeout(HbPopup::NoTimeout);
   530     // open user-dialog to select: view as text/hex,  open w/AppArc or open w/DocH. embed
   548 
   531     QStringList list;
   549     // Create a list and some simple content for it
   532     list << QString("Overwrite all")
   550 
   533             << QString("Skip all existing")
   551     HbLabel *title = new HbLabel();
   534             << QString("Gen. unique filenames")
   552     title->setPlainText("Overwrite?");
   535             << QString("Query postfix");
   553     dialog->setHeadingWidget(title);
   536     openListDialog(list, QString("Overwrite?"), this, SLOT(fileOverwrite(HbAction *)));
   554 
   537 }
   555     HbListWidget *list = new HbListWidget();
   538 
   556     list->addItem("Overwrite all");
   539 /**
   557     list->addItem("Skip all existing");
   540   File overwrite
   558     list->addItem("Gen. unique filenames");
   541   */
   559     list->addItem("Query postfix");
   542 void FileBrowserView::fileOverwrite(HbAction *action)
   560 
   543 {
   561     // Connect list item activation signal to close the popup
   544     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
   562     connect(list, SIGNAL(activated(HbListWidgetItem*)), dialog, SLOT(close()));
   545     if(!action && dlg && dlg->selectedModelIndexes().count()) {
   563 
   546         mOverwriteOptions.queryIndex = dlg->selectedModelIndexes().at(0).row();
   564     HbAction *cancelAction = new HbAction(cancelActionText);
   547         if (mOverwriteOptions.queryIndex == EFileActionQueryPostFix) {
   565     dialog->setPrimaryAction(cancelAction);
   548             QString heading = QString("Postfix");
   566 
   549             HbInputDialog::getText(heading, this, SLOT(fileOverwritePostfix(HbAction *)), QString(), scene());
   567     // Set listwidget to be popup's content
   550         } else if (mOverwriteOptions.queryIndex == EFileActionSkipAllExisting) {
   568     dialog->setContentWidget(list);
   551             mOverwriteOptions.overWriteFlags = 0;
   569 
       
   570     OverwriteOptions overwriteOptions;
       
   571     // Launch popup and handle the user response:
       
   572     if (dialog->exec() != cancelAction) {
       
   573         overwriteOptions.queryIndex = list->currentRow();
       
   574         if (overwriteOptions.queryIndex == EFileActionQueryPostFix) {
       
   575             HbDialog* dialog = filePathQuery(QString("Postfix"),
       
   576                                              QString(),
       
   577                                              okActionText,
       
   578                                              cancelActionText);
       
   579             HbAction *action = 0;
       
   580             action = dialog->exec();
       
   581 
       
   582             HbLineEdit * lineEdit= qobject_cast<HbLineEdit *>(dialog->contentWidget());
       
   583             if (action && action->text() == "OK" && lineEdit && lineEdit->text() != "") {
       
   584                 overwriteOptions.postFix = lineEdit->text();
       
   585             } else {
       
   586                 overwriteOptions.doFileOperations = false;
       
   587             }
       
   588         } else if (overwriteOptions.queryIndex == EFileActionSkipAllExisting) {
       
   589             overwriteOptions.overWriteFlags = 0;
       
   590         }
   552         }
   591     } else {
   553     } else {
   592         overwriteOptions.doFileOperations = false;
   554         mOverwriteOptions.doFileOperations = false;
   593     }
   555     }
   594     return overwriteOptions;
   556 }
       
   557 
       
   558 /**
       
   559   File overwrite postfix query dialog
       
   560   */
       
   561 void FileBrowserView::fileOverwritePostfix(HbAction *action)
       
   562 {
       
   563     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   564     if (action == dlg->primaryAction()) {
       
   565         mOverwriteOptions.postFix = dlg->value().toString();
       
   566     } else {
       
   567         mOverwriteOptions.doFileOperations = false;
       
   568     }
   595 }
   569 }
   596 
   570 
   597 // ---------------------------------------------------------------------------
   571 // ---------------------------------------------------------------------------
   598 /**
   572 /**
   599   Show a list dialog
   573   Show a list dialog
   644     return dialog;
   618     return dialog;
   645 }
   619 }
   646 
   620 
   647 // ---------------------------------------------------------------------------
   621 // ---------------------------------------------------------------------------
   648 
   622 
   649 HbDialog *FileBrowserView::openTextQuery(const QString &headingText,
   623 //HbDialog *FileBrowserView::openTextQuery(const QString &headingText,
   650                                          const QString &text,
   624 //                                         const QString &text,
   651                                          const QString &primaryActionText,
   625 //                                         const QString &primaryActionText,
   652                                          const QString &secondaryActionText)
   626 //                                         const QString &secondaryActionText)
   653 {
   627 //{
   654     HbDialog *dialog = new HbDialog();
   628 //    HbDialog *dialog = new HbDialog();
   655     dialog->setDismissPolicy(HbPopup::TapOutside);
   629 //    dialog->setDismissPolicy(HbPopup::TapOutside);
   656     dialog->setTimeout(HbPopup::NoTimeout);
   630 //    dialog->setTimeout(HbPopup::NoTimeout);
   657     HbLineEdit *edit = new HbLineEdit();
   631 //    HbLineEdit *edit = new HbLineEdit();
   658     HbAction *primaryAction = new HbAction(primaryActionText);
   632 //    HbAction *primaryAction = new HbAction(primaryActionText);
   659     HbAction *secondaryAction = new HbAction(secondaryActionText);
   633 //    HbAction *secondaryAction = new HbAction(secondaryActionText);
   660     // connect signal to close pop-up if cancel selected:
   634 //    // connect signal to close pop-up if cancel selected:
   661     connect(secondaryAction, SIGNAL(triggered()), dialog, SLOT(close()));
   635 //    connect(secondaryAction, SIGNAL(triggered()), dialog, SLOT(close()));
   662     edit->setText(text);
   636 //    edit->setText(text);
   663     dialog->setHeadingWidget(new HbLabel(headingText));
   637 //    dialog->setHeadingWidget(new HbLabel(headingText));
   664     //popup->setHeadingWidget(dlgTitle);
   638 //    //popup->setHeadingWidget(dlgTitle);
   665     dialog->setContentWidget(edit);
   639 //    dialog->setContentWidget(edit);
   666     dialog->setPrimaryAction(primaryAction);
   640 //    dialog->setPrimaryAction(primaryAction);
   667     dialog->setSecondaryAction(secondaryAction);
   641 //    dialog->setSecondaryAction(secondaryAction);
   668 
   642 //
   669     return dialog;
   643 //    return dialog;
   670 }
   644 //}
   671 
   645 
   672 // ---------------------------------------------------------------------------
   646 // ---------------------------------------------------------------------------
   673 
   647 
   674 HbDialog *FileBrowserView::openNumberQuery(const QString &headingText,
   648 HbDialog *FileBrowserView::openNumberQuery(const QString &headingText,
   675                                            const QString &text,
   649                                            const QString &text,
   910         refreshList();
   884         refreshList();
   911     }
   885     }
   912 }
   886 }
   913 
   887 
   914 /**
   888 /**
   915   Rename actually selected files
   889   Open rename dialog for actually selected files
   916   */
   890   */
   917 void FileBrowserView::fileRename()
   891 void FileBrowserView::fileRename()
   918 {
   892 {
   919     QModelIndex index;
       
   920     QModelIndexList currentSelection = getSelectedItemsOrCurrentItem();
   893     QModelIndexList currentSelection = getSelectedItemsOrCurrentItem();
   921     mEngineWrapper->setCurrentSelection(currentSelection);
   894     mEngineWrapper->setCurrentSelection(currentSelection);
   922 
   895 
   923     for (int i(0), ie(currentSelection.count()); i<ie; ++i ) {
   896     for (int i(0), ie(currentSelection.count()); i < ie; ++i ) {
   924         index = currentSelection.at(i);
   897         mModelIndex = currentSelection.at(i);
   925         QString newName;
   898         FileEntry entry = mEngineWrapper->getFileEntry(mModelIndex);
   926         FileEntry entry = mEngineWrapper->getFileEntry(index);
   899 
   927         HbDialog* dialog = filePathQuery(QString("Enter new name"),
   900         QString heading = QString("Enter new name");
   928                                          entry.name(),
   901         HbInputDialog::getText(heading, this, SLOT(doFileRename(HbAction*)), entry.name(), scene());
   929                                          okActionText,
   902 
   930                                          cancelActionText);
       
   931         HbAction *action = 0;
       
   932         action = dialog->exec();
       
   933 
       
   934         bool doRenameOperation(true);
       
   935         HbLineEdit * lineEdit= qobject_cast<HbLineEdit *>(dialog->contentWidget());
       
   936         if (action && action->text() == okActionText && lineEdit && lineEdit->text() != "") {
       
   937             newName = lineEdit->text();
       
   938 
       
   939             if (mEngineWrapper->targetExists(index, newName)) {
       
   940                 const QString messageTemplate = QString("%1 already exists, overwrite?");
       
   941                 QString message = messageTemplate.arg(newName);
       
   942 // TODO: deprecated
       
   943                 if (HbMessageBox::question(message)) {
       
   944                     doRenameOperation = false;
       
   945                 }
       
   946             }
       
   947             if (doRenameOperation) {
       
   948                 mEngineWrapper->rename(index, newName);
       
   949             }
       
   950         }
       
   951     }
   903     }
   952     mEngineWrapper->startExecutingCommands(QString("Renaming"));
   904     mEngineWrapper->startExecutingCommands(QString("Renaming"));
   953     refreshList();
   905     refreshList();
       
   906 }
       
   907 
       
   908 /**
       
   909   Rename actually selected files
       
   910   */
       
   911 void FileBrowserView::doFileRename(HbAction *action)
       
   912 {
       
   913     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
       
   914     if (action == dlg->primaryAction())
       
   915     {
       
   916         QString newName = dlg->value().toString();
       
   917 
       
   918         if (mEngineWrapper->targetExists(mModelIndex, newName)) {
       
   919 
       
   920             const QString messageTemplate = QString("%1 already exists, overwrite?");
       
   921             QString message = messageTemplate.arg(newName);
       
   922             HbMessageBox::question(message, this, SLOT(doFileRenameFileExist(HbAction *)));
       
   923         }
       
   924         if (mIsRenameAllowed) {
       
   925             mEngineWrapper->rename(mModelIndex, newName);
       
   926         }
       
   927     }
       
   928 }
       
   929 
       
   930 /**
       
   931   Rename actually selected files
       
   932   */
       
   933 void FileBrowserView::doFileRenameFileExist(HbAction *action)
       
   934 {
       
   935     HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender());
       
   936     if (action == dlg->secondaryAction()) {
       
   937         mIsRenameAllowed = false;
       
   938     }
   954 }
   939 }
   955 
   940 
   956 /**
   941 /**
   957   Touch actually selected files
   942   Touch actually selected files
   958   */
   943   */
   981     if (action == dlg->primaryAction()) {
   966     if (action == dlg->primaryAction()) {
   982         recurse = true;
   967         recurse = true;
   983         }
   968         }
   984     mEngineWrapper->touch(recurse);
   969     mEngineWrapper->touch(recurse);
   985     refreshList();
   970     refreshList();
       
   971 }
       
   972 
       
   973 void FileBrowserView::fileChecksumsMD5()
       
   974 {
       
   975     fileChecksums(EFileChecksumsMD5);
       
   976 }
       
   977 
       
   978 void FileBrowserView::fileChecksumsMD2()
       
   979 {
       
   980     fileChecksums(EFileChecksumsMD2);
       
   981 }
       
   982 
       
   983 void FileBrowserView::fileChecksumsSHA1()
       
   984 {
       
   985     fileChecksums(EFileChecksumsSHA1);
       
   986 }
       
   987 
       
   988 void FileBrowserView::fileChecksums(TFileBrowserCmdFileChecksums checksumType)
       
   989 {
       
   990     QModelIndex currentIndex = currentItemIndex();
       
   991     mEngineWrapper->showFileCheckSums(currentIndex, checksumType);
   986 }
   992 }
   987 
   993 
   988 /**
   994 /**
   989   Show file properties
   995   Show file properties
   990   */
   996   */
  1048   Removing files depend on previous operation, i.e. Cut or Copy
  1054   Removing files depend on previous operation, i.e. Cut or Copy
  1049   */
  1055   */
  1050 void FileBrowserView::editPaste()
  1056 void FileBrowserView::editPaste()
  1051 {
  1057 {
  1052     bool someEntryExists(false);
  1058     bool someEntryExists(false);
  1053     OverwriteOptions overwriteOptions;
       
  1054 
  1059 
  1055     // TODO Set entry items here
  1060     // TODO Set entry items here
  1056 
  1061 
  1057     someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndices, mEngineWrapper->currentPath());
  1062     someEntryExists = mEngineWrapper->isDestinationEntriesExists(mClipboardIndices, mEngineWrapper->currentPath());
  1058     if (someEntryExists) {
  1063     if (someEntryExists) {
  1059         overwriteOptions = fileOverwriteDialog();
  1064         fileOverwriteDialog();
  1060     }
  1065     }
  1061     mEngineWrapper->clipboardPaste(overwriteOptions);
  1066     mEngineWrapper->clipboardPaste(mOverwriteOptions);
  1062 }
  1067 }
  1063 
  1068 
  1064 /**
  1069 /**
  1065   Open copy to folder new filename dialog
  1070   Open copy to folder new filename dialog
  1066   */
  1071   */
  1078     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
  1083     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
  1079     if (action == dlg->primaryAction())
  1084     if (action == dlg->primaryAction())
  1080     {
  1085     {
  1081         QString targetDir = dlg->value().toString();
  1086         QString targetDir = dlg->value().toString();
  1082         bool someEntryExists(false);
  1087         bool someEntryExists(false);
  1083         OverwriteOptions overwriteOptions;
       
  1084 
  1088 
  1085         // TODO Set entry items here
  1089         // TODO Set entry items here
  1086         QModelIndexList currentSelection = getSelectedItemsOrCurrentItem();
  1090         QModelIndexList currentSelection = getSelectedItemsOrCurrentItem();
  1087         mEngineWrapper->setCurrentSelection(currentSelection);
  1091         mEngineWrapper->setCurrentSelection(currentSelection);
  1088 
  1092 
  1089         someEntryExists = mEngineWrapper->isDestinationEntriesExists(currentSelection, targetDir);
  1093         someEntryExists = mEngineWrapper->isDestinationEntriesExists(currentSelection, targetDir);
  1090         if (someEntryExists) {
  1094         if (someEntryExists) {
  1091             overwriteOptions = fileOverwriteDialog();
  1095             fileOverwriteDialog();
  1092         }
  1096         }
  1093         mEngineWrapper->copyToFolder(targetDir, overwriteOptions, false);
  1097         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, false);
  1094         refreshList();
  1098         refreshList();
  1095     }
  1099     }
  1096 }
  1100 }
  1097 
  1101 
  1098 /**
  1102 /**
  1112     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
  1116     HbInputDialog *dlg = static_cast<HbInputDialog*>(sender());
  1113     if (action == dlg->primaryAction())
  1117     if (action == dlg->primaryAction())
  1114     {
  1118     {
  1115         QString targetDir = dlg->value().toString();
  1119         QString targetDir = dlg->value().toString();
  1116         bool someEntryExists(false);
  1120         bool someEntryExists(false);
  1117         OverwriteOptions overwriteOptions;
       
  1118 
  1121 
  1119         // TODO Set entry items here
  1122         // TODO Set entry items here
  1120         QModelIndexList currentSelection = getSelectedItemsOrCurrentItem();
  1123         QModelIndexList currentSelection = getSelectedItemsOrCurrentItem();
  1121         mEngineWrapper->setCurrentSelection(currentSelection);
  1124         mEngineWrapper->setCurrentSelection(currentSelection);
  1122 
  1125 
  1123         someEntryExists = mEngineWrapper->isDestinationEntriesExists(currentSelection, targetDir);
  1126         someEntryExists = mEngineWrapper->isDestinationEntriesExists(currentSelection, targetDir);
  1124         if (someEntryExists) {
  1127         if (someEntryExists) {
  1125             overwriteOptions = fileOverwriteDialog();
  1128             fileOverwriteDialog();
  1126         }
  1129         }
  1127         mEngineWrapper->copyToFolder(targetDir, overwriteOptions, true);
  1130         mEngineWrapper->copyToFolder(targetDir, mOverwriteOptions, true);
  1128         refreshList();
  1131         refreshList();
  1129     }
  1132     }
  1130 }
  1133 }
  1131 
  1134 
  1132 /**
  1135 /**
  1535 }
  1538 }
  1536 
  1539 
  1537 /**
  1540 /**
  1538   Partition the selected drive
  1541   Partition the selected drive
  1539   */
  1542   */
       
  1543 void FileBrowserView::diskAdminPartitionDrive()
       
  1544 {
       
  1545     const QString message("Are you sure? Your media driver must support this!");
       
  1546     HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveProceed(HbAction *)));
       
  1547 }
       
  1548 
       
  1549 /**
       
  1550   Partition the selected drive if user is sure
       
  1551   */
       
  1552 void FileBrowserView::diskAdminPartitionDriveProceed(HbAction *action)
       
  1553 {
       
  1554     HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender());
       
  1555     if (action == dlg->primaryAction()) {
       
  1556         const QString message("Are you really sure you know what are you doing ?!?");
       
  1557         HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveReallyProceed(HbAction *)));
       
  1558     }
       
  1559 }
       
  1560 
       
  1561 /**
       
  1562   Partition the selected drive if user is really sure
       
  1563   */
       
  1564 void FileBrowserView::diskAdminPartitionDriveReallyProceed(HbAction *action)
       
  1565 {
       
  1566     HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender());
       
  1567     if (action == dlg->primaryAction()) {
       
  1568         QModelIndex currentIndex = currentItemIndex();
       
  1569         mEraseMBR = false;
       
  1570         // warn if the selected drive is not detected as removable
       
  1571         if (mEngineWrapper->isDriveRemovable(currentIndex)) {
       
  1572             mProceed = true;
       
  1573         } else {
       
  1574             const QString message("Selected drive is not removable, really continue?");
       
  1575             HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveIsNotRemovable(HbAction *)));
       
  1576         }
       
  1577 
       
  1578         if (mProceed) {
       
  1579             // query if erase mbr
       
  1580             mEraseMBR = false;
       
  1581 
       
  1582             QString message("Erase MBR first (normally needed)?");
       
  1583             HbMessageBox::question(message, this, SLOT(diskAdminPartitionDriveEraseMbr(HbAction *)));
       
  1584 
       
  1585             // TODO use HbListDialog
       
  1586             QStringList list;
       
  1587             list << "1" << "2" << "3" << "4";
       
  1588             openListDialog(list, QString("Partitions?"), this, SLOT(diskAdminPartitionDriveGetCount(HbAction*)));
       
  1589         }
       
  1590     }
       
  1591 }
       
  1592 
       
  1593 /**
       
  1594   Store result of user query about proceeding when drive is not removable.
       
  1595   */
       
  1596 void FileBrowserView::diskAdminPartitionDriveIsNotRemovable(HbAction *action)
       
  1597 {
       
  1598     HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender());
       
  1599     if (action == dlg->primaryAction()) {
       
  1600         mProceed = true;
       
  1601     } else {
       
  1602         mProceed = false;
       
  1603     }
       
  1604 }
       
  1605 
       
  1606 /**
       
  1607   Store result of user query about erase MBR
       
  1608   */
       
  1609 void FileBrowserView::diskAdminPartitionDriveEraseMbr(HbAction *action)
       
  1610 {
       
  1611     HbMessageBox *dlg = qobject_cast<HbMessageBox*>(sender());
       
  1612     if (action == dlg->primaryAction()) {
       
  1613         mEraseMBR = true;
       
  1614     }
       
  1615 }
       
  1616 
       
  1617 /**
       
  1618   Partition the selected drive
       
  1619   */
  1540 void FileBrowserView::diskAdminPartitionDriveGetCount(HbAction* action)
  1620 void FileBrowserView::diskAdminPartitionDriveGetCount(HbAction* action)
  1541 {
  1621 {
  1542     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
  1622     HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender());
  1543     if(!action && dlg->selectedItems().count()){
  1623     if(!action && dlg && dlg->selectedItems().count()){
  1544         int selectionIndex = dlg->selectedItems().at(0).toInt(); 
  1624         int selectionIndex = dlg->selectedItems().at(0).toInt();
  1545         QModelIndex currentIndex = currentItemIndex();
  1625         QModelIndex currentIndex = currentItemIndex();
  1546         int amountOfPartitions = selectionIndex + 1;
  1626         int amountOfPartitions = selectionIndex + 1;
  1547         mEngineWrapper->DiskAdminPartitionDrive(currentIndex, mEraseMBR, amountOfPartitions);
  1627         mEngineWrapper->DiskAdminPartitionDrive(currentIndex, mEraseMBR, amountOfPartitions);
  1548         refreshList();
  1628         refreshList();
  1549     }
       
  1550 }
       
  1551 void FileBrowserView::diskAdminPartitionDrive()
       
  1552 {
       
  1553     if (HbMessageBox::question(QString("Are you sure? Your media driver must support this!"))) {
       
  1554         if (HbMessageBox::question(QString("Are you really sure you know what are you doing ?!?"))) {
       
  1555             QModelIndex currentIndex = currentItemIndex();
       
  1556             // warn if the selected drive is not detected as removable
       
  1557             bool proceed(false);
       
  1558             if (mEngineWrapper->isDriveRemovable(currentIndex)) {
       
  1559                 proceed = true;
       
  1560             } else {
       
  1561                 proceed = HbMessageBox::question(QString("Selected drive is not removable, really continue?"));
       
  1562             }
       
  1563 
       
  1564             if (proceed) {
       
  1565                 // query if erase mbr
       
  1566                 mEraseMBR = false;
       
  1567 
       
  1568                 if (HbMessageBox::question(QString("Erase MBR first (normally needed)?"))) {
       
  1569                     mEraseMBR = true;
       
  1570                 }
       
  1571 
       
  1572                 // TODO use HbListDialog
       
  1573                 QStringList list;
       
  1574                 list << "1" << "2" << "3" << "4";
       
  1575                 openListDialog(list, QString("Partitions?"), this, SLOT(diskAdminPartitionDriveGetCount(HbAction*)));
       
  1576             }
       
  1577         }
       
  1578     }
  1629     }
  1579 }
  1630 }
  1580 
  1631 
  1581 // ---------------------------------------------------------------------------
  1632 // ---------------------------------------------------------------------------
  1582 // tools menu
  1633 // tools menu
  1814 /**
  1865 /**
  1815   Show about note
  1866   Show about note
  1816   */
  1867   */
  1817 void FileBrowserView::about()
  1868 void FileBrowserView::about()
  1818 {
  1869 {
  1819     Notifications::about();
  1870     Notifications::showAboutNote();
  1820 }
  1871 }
  1821 
  1872 
  1822 // ---------------------------------------------------------------------------
  1873 // ---------------------------------------------------------------------------
  1823 // End of operations
  1874 // End of operations
  1824 // ---------------------------------------------------------------------------
  1875 // ---------------------------------------------------------------------------
  1862             mEngineWrapper->moveDownToDirectory(index);
  1913             mEngineWrapper->moveDownToDirectory(index);
  1863             populateFolderContent();
  1914             populateFolderContent();
  1864         } else {  // file item
  1915         } else {  // file item
  1865             // mSelectedFilePath = filePath;
  1916             // mSelectedFilePath = filePath;
  1866             FileEntry fileEntry = mEngineWrapper->getFileEntry(index);
  1917             FileEntry fileEntry = mEngineWrapper->getFileEntry(index);
  1867             QString absolutePath = fileEntry.path() + fileEntry.name();
  1918             mAbsoluteFilePath = fileEntry.path() + fileEntry.name();
       
  1919 
  1868             // open user-dialog to select: view as text/hex,  open w/AppArc or open w/DocH. embed
  1920             // open user-dialog to select: view as text/hex,  open w/AppArc or open w/DocH. embed
  1869             fileOpenDialog(absolutePath);
  1921             QStringList list;
       
  1922             list << QString("View as text/hex") << QString("Open w/ AppArc") << QString("Open w/ DocH. embed");
       
  1923             openListDialog(list, QString("Open file"), this, SLOT(fileOpen(HbAction *)));
  1870         }
  1924         }
  1871     }
  1925     }
  1872 }
  1926 }
  1873 
  1927 
  1874 // ---------------------------------------------------------------------------
  1928 // ---------------------------------------------------------------------------