22 #include "fmfilebrowsewidget.h" |
22 #include "fmfilebrowsewidget.h" |
23 #include "fmviewdetailsdialog.h" |
23 #include "fmviewdetailsdialog.h" |
24 #include "fmviewmanager.h" |
24 #include "fmviewmanager.h" |
25 #include "fmfiledialog.h" |
25 #include "fmfiledialog.h" |
26 #include "fmdlgutils.h" |
26 #include "fmdlgutils.h" |
|
27 #include "fmserviceutils.h" |
27 #include "fmfileiconprovider.h" |
28 #include "fmfileiconprovider.h" |
|
29 #include "fmfilesystemproxymodel.h" |
28 |
30 |
29 #include <QFile> |
31 #include <QFile> |
30 #include <QFileSystemModel> |
32 #include <QFileSystemModel> |
31 #include <QSizePolicy> |
33 #include <QSizePolicy> |
32 #include <QGraphicsLinearLayout> |
34 #include <QGraphicsLinearLayout> |
36 #include <hbtreeview.h> |
38 #include <hbtreeview.h> |
37 #include <hbabstractviewitem.h> |
39 #include <hbabstractviewitem.h> |
38 #include <hbaction.h> |
40 #include <hbaction.h> |
39 #include <hbsearchpanel.h> |
41 #include <hbsearchpanel.h> |
40 #include <hblabel.h> |
42 #include <hblabel.h> |
41 |
|
42 #include <shareui.h> |
|
43 |
43 |
44 // These define comes from implementation of QFileSystemModel |
44 // These define comes from implementation of QFileSystemModel |
45 #define QFileSystemSortName 0 |
45 #define QFileSystemSortName 0 |
46 #define QFileSystemSortSize 1 |
46 #define QFileSystemSortSize 1 |
47 #define QFileSystemSortType 2 |
47 #define QFileSystemSortType 2 |
133 emit currentPathChanged( pathName ); |
134 emit currentPathChanged( pathName ); |
134 break; |
135 break; |
135 } |
136 } |
136 case FmErrPathNotExist: |
137 case FmErrPathNotExist: |
137 { |
138 { |
138 FmDlgUtils::information( hbTrId( "Path is not exist" ) ); |
139 FmDlgUtils::warning( hbTrId( "Path is not exist" ) ); |
139 break; |
140 break; |
140 } |
141 } |
141 case FmErrDriveNotAvailable: |
142 case FmErrDriveNotAvailable: |
142 { |
143 { |
143 // do not take any action as widget set note in label already. |
144 // do not take any action as widget set note in label already. |
144 break; |
145 break; |
145 } |
146 } |
146 case FmErrDriveDenied: |
147 case FmErrDriveDenied: |
147 case FmErrPathDenied: |
148 case FmErrPathDenied: |
148 { |
149 { |
149 FmDlgUtils::information( hbTrId( "Can not access" ) ); |
150 FmDlgUtils::warning( hbTrId( "Can not access" ) ); |
150 break; |
151 break; |
151 } |
152 } |
152 default: |
153 default: |
153 Q_ASSERT_X( false, "setRootPath", "please handle all error from isPathAccessabel" ); |
154 Q_ASSERT_X( false, "setRootPath", "please handle all error from isPathAccessabel" ); |
154 break; |
155 break; |
286 HbMenu *contextMenu = new HbMenu(); |
287 HbMenu *contextMenu = new HbMenu(); |
287 mCurrentItem = item; |
288 mCurrentItem = item; |
288 |
289 |
289 HbAction *viewAction = new HbAction(); |
290 HbAction *viewAction = new HbAction(); |
290 viewAction->setObjectName( "viewAction" ); |
291 viewAction->setObjectName( "viewAction" ); |
291 viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_file" ) ); |
292 viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_memory" ) ); |
292 contextMenu->addAction( viewAction ); |
293 contextMenu->addAction( viewAction ); |
293 |
294 |
294 connect( viewAction, SIGNAL( triggered() ), |
295 connect( viewAction, SIGNAL( triggered() ), |
295 this, SLOT( on_viewAction_triggered() ), Qt::QueuedConnection ); |
296 this, SLOT( on_viewAction_triggered() ), Qt::QueuedConnection ); |
296 |
297 |
297 //copy |
298 //copy |
298 HbAction *copyAction = new HbAction(); |
299 HbAction *copyAction = new HbAction(); |
299 copyAction->setObjectName( "copyAction" ); |
300 copyAction->setObjectName( "copyAction" ); |
300 copyAction->setText( hbTrId( "txt_fmgr_menu_copy" ) ); |
301 copyAction->setText( hbTrId( "txt_common_menu_copy_to_folder" ) ); |
301 contextMenu->addAction( copyAction ); |
302 contextMenu->addAction( copyAction ); |
302 |
303 |
303 connect( copyAction, SIGNAL( triggered() ), |
304 connect( copyAction, SIGNAL( triggered() ), |
304 this, SLOT( on_copyAction_triggered() ), Qt::QueuedConnection ); |
305 this, SLOT( on_copyAction_triggered() ), Qt::QueuedConnection ); |
305 |
306 |
310 |
311 |
311 if( ( fileInfo.isFile() ) || ( fileInfo.isDir() && !( FmUtils::isDefaultFolder( formatFilePath ) ) ) ){ |
312 if( ( fileInfo.isFile() ) || ( fileInfo.isDir() && !( FmUtils::isDefaultFolder( formatFilePath ) ) ) ){ |
312 //Move |
313 //Move |
313 HbAction *moveAction = new HbAction(); |
314 HbAction *moveAction = new HbAction(); |
314 moveAction->setObjectName( "moveAction" ); |
315 moveAction->setObjectName( "moveAction" ); |
315 moveAction->setText( hbTrId( "txt_fmgr_menu_move" ) ); |
316 moveAction->setText( hbTrId( "txt_common_menu_move_to_folder" ) ); |
316 contextMenu->addAction( moveAction ); |
317 contextMenu->addAction( moveAction ); |
317 |
318 |
318 connect( moveAction, SIGNAL( triggered() ), |
319 connect( moveAction, SIGNAL( triggered() ), |
319 this, SLOT( on_moveAction_triggered() ), Qt::QueuedConnection ); |
320 this, SLOT( on_moveAction_triggered() ), Qt::QueuedConnection ); |
320 |
321 |
321 //Delete |
322 //Delete |
322 HbAction *deleteAction = new HbAction(); |
323 HbAction *deleteAction = new HbAction(); |
323 deleteAction->setObjectName( "deleteAction" ); |
324 deleteAction->setObjectName( "deleteAction" ); |
324 deleteAction->setText( hbTrId( "txt_fmgr_menu_delete" ) ); |
325 deleteAction->setText( hbTrId( "txt_common_menu_delete" ) ); |
325 contextMenu->addAction( deleteAction ); |
326 contextMenu->addAction( deleteAction ); |
326 |
327 |
327 connect( deleteAction, SIGNAL( triggered() ), |
328 connect( deleteAction, SIGNAL( triggered() ), |
328 this, SLOT( on_deleteAction_triggered() ), Qt::QueuedConnection ); |
329 this, SLOT( on_deleteAction_triggered() ), Qt::QueuedConnection ); |
329 |
330 |
330 //rename |
331 //rename |
331 HbAction *renameAction = new HbAction(); |
332 HbAction *renameAction = new HbAction(); |
332 renameAction->setObjectName( "renameAction" ); |
333 renameAction->setObjectName( "renameAction" ); |
333 renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) ); |
334 renameAction->setText( hbTrId( "txt_common_menu_rename_item" ) ); |
334 contextMenu->addAction( renameAction ); |
335 contextMenu->addAction( renameAction ); |
335 |
336 |
336 connect( renameAction, SIGNAL( triggered() ), |
337 connect( renameAction, SIGNAL( triggered() ), |
337 this, SLOT( on_renameAction_triggered() ), Qt::QueuedConnection ); |
338 this, SLOT( on_renameAction_triggered() ), Qt::QueuedConnection ); |
338 } |
339 } |
339 |
340 |
340 if( fileInfo.isFile() ){ |
341 if( fileInfo.isFile() ){ |
341 HbAction *sendAction = new HbAction(); |
342 HbAction *sendAction = new HbAction(); |
342 sendAction->setObjectName( "sendAction" ); |
343 sendAction->setObjectName( "sendAction" ); |
343 sendAction->setText( hbTrId( "txt_fmgr_menu_send" ) ); |
344 sendAction->setText( hbTrId( "txt_common_menu_send_item" ) ); |
344 contextMenu->addAction( sendAction ); |
345 contextMenu->addAction( sendAction ); |
345 |
346 |
346 connect( sendAction, SIGNAL( triggered() ), |
347 connect( sendAction, SIGNAL( triggered() ), |
347 this, SLOT( on_sendAction_triggered() ), Qt::QueuedConnection ); |
348 this, SLOT( on_sendAction_triggered() ), Qt::QueuedConnection ); |
348 } |
349 } |
410 this, SLOT( on_tree_longPressed( HbAbstractViewItem *, const QPointF & ) ) ); |
412 this, SLOT( on_tree_longPressed( HbAbstractViewItem *, const QPointF & ) ) ); |
411 } |
413 } |
412 |
414 |
413 void FmFileBrowseWidget::initFileModel() |
415 void FmFileBrowseWidget::initFileModel() |
414 { |
416 { |
415 mModel = new QFileSystemModel( this ); |
417 mSourceModel = new QFileSystemModel( this ); |
416 mModel->setReadOnly( false ); |
418 mSourceModel->setReadOnly( false ); |
417 |
419 |
418 mFileIconProvider = new FmFileIconProvider(); |
420 mFileIconProvider = new FmFileIconProvider(); |
419 mModel->setIconProvider( mFileIconProvider ); |
421 mSourceModel->setIconProvider( mFileIconProvider ); |
|
422 |
|
423 mModel = new FmFileSystemProxyModel( this ); |
|
424 mModel->setSourceModel( mSourceModel ); |
|
425 |
420 } |
426 } |
421 |
427 |
422 void FmFileBrowseWidget::initLayout() |
428 void FmFileBrowseWidget::initLayout() |
423 { |
429 { |
424 mLayout = new QGraphicsLinearLayout( this ); |
430 mLayout = new QGraphicsLinearLayout( this ); |
622 case FmErrNone: |
628 case FmErrNone: |
623 // no error, do not show note to user |
629 // no error, do not show note to user |
624 break; |
630 break; |
625 case FmErrAlreadyStarted: |
631 case FmErrAlreadyStarted: |
626 // last operation have not finished |
632 // last operation have not finished |
627 FmDlgUtils::information( hbTrId( "Operatin already started!" ) ); |
633 FmDlgUtils::warning( hbTrId( "Operatin already started!" ) ); |
628 break; |
634 break; |
629 case FmErrWrongParam: |
635 case FmErrWrongParam: |
630 FmDlgUtils::information( hbTrId( "Wrong parameters!" ) ); |
636 FmDlgUtils::warning( hbTrId( "Wrong parameters!" ) ); |
631 break; |
637 break; |
632 default: |
638 default: |
633 FmDlgUtils::information( hbTrId( "Operation fail to start!" ) ); |
639 FmDlgUtils::warning( hbTrId( "Operation fail to start!" ) ); |
634 } |
640 } |
635 } |
641 } |
636 } |
642 } |
637 |
643 |
638 void FmFileBrowseWidget::on_copyAction_triggered() |
644 void FmFileBrowseWidget::on_copyAction_triggered() |
651 case FmErrNone: |
657 case FmErrNone: |
652 // no error, do not show note to user |
658 // no error, do not show note to user |
653 break; |
659 break; |
654 case FmErrAlreadyStarted: |
660 case FmErrAlreadyStarted: |
655 // last operation have not finished |
661 // last operation have not finished |
656 FmDlgUtils::information( hbTrId( "Operatin already started!" ) ); |
662 FmDlgUtils::warning( hbTrId( "Operatin already started!" ) ); |
657 break; |
663 break; |
658 case FmErrWrongParam: |
664 case FmErrWrongParam: |
659 FmDlgUtils::information( hbTrId( "Wrong parameters!" ) ); |
665 FmDlgUtils::warning( hbTrId( "Wrong parameters!" ) ); |
660 break; |
666 break; |
661 default: |
667 default: |
662 FmDlgUtils::information( hbTrId( "Operation fail to start!" ) ); |
668 FmDlgUtils::warning( hbTrId( "Operation fail to start!" ) ); |
663 } |
669 } |
664 } |
670 } |
665 |
671 |
666 } |
672 } |
667 |
673 |
681 case FmErrNone: |
687 case FmErrNone: |
682 // no error, do not show note to user |
688 // no error, do not show note to user |
683 break; |
689 break; |
684 case FmErrAlreadyStarted: |
690 case FmErrAlreadyStarted: |
685 // last operation have not finished |
691 // last operation have not finished |
686 FmDlgUtils::information( hbTrId( "Operatin already started!" ) ); |
692 FmDlgUtils::warning( hbTrId( "Operatin already started!" ) ); |
687 break; |
693 break; |
688 case FmErrWrongParam: |
694 case FmErrWrongParam: |
689 FmDlgUtils::information( hbTrId( "Wrong parameters!" ) ); |
695 FmDlgUtils::warning( hbTrId( "Wrong parameters!" ) ); |
690 break; |
696 break; |
691 default: |
697 default: |
692 FmDlgUtils::information( hbTrId( "Operation fail to start!" ) ); |
698 FmDlgUtils::warning( hbTrId( "Operation fail to start!" ) ); |
693 } |
699 } |
694 } |
700 } |
695 } |
701 } |
696 |
702 |
697 |
703 |
714 QFileInfo newFileInfo( newTargetPath ); |
720 QFileInfo newFileInfo( newTargetPath ); |
715 QString errString; |
721 QString errString; |
716 // check if name/path is available for use |
722 // check if name/path is available for use |
717 // add new Name to check, in order to avoid problem of newName is empty |
723 // add new Name to check, in order to avoid problem of newName is empty |
718 if( !FmUtils::checkNewFolderOrFile( newName, newTargetPath, errString ) ) { |
724 if( !FmUtils::checkNewFolderOrFile( newName, newTargetPath, errString ) ) { |
719 FmDlgUtils::information( errString ); |
725 FmDlgUtils::warning( errString, HbMessageBox::Ok, true ); |
720 continue; |
726 continue; |
721 } |
727 } |
722 if( !rename( fileInfo.absoluteFilePath(), newTargetPath ) ) { |
728 if( !rename( fileInfo.absoluteFilePath(), newTargetPath ) ) { |
723 FmDlgUtils::information( hbTrId("Rename failed!") ); |
729 FmDlgUtils::warning( hbTrId("Rename failed!") ); |
724 } |
730 } |
725 else { |
731 else { |
726 // Rename succeed |
732 // Rename succeed |
727 if ( ( oldSuffix.compare( newFileInfo.suffix(), Qt::CaseInsensitive ) != 0 ) |
733 if ( ( oldSuffix.compare( newFileInfo.suffix(), Qt::CaseInsensitive ) != 0 ) |
728 && newFileInfo.isFile() ) { |
734 && newFileInfo.isFile() ) { |
732 } |
738 } |
733 break; |
739 break; |
734 } |
740 } |
735 } |
741 } |
736 |
742 |
|
743 /*! |
|
744 return BackWasNotConsumed if this view should be closed. |
|
745 return BackWasConsumed if change to up level folder( back to up level folder ) |
|
746 */ |
|
747 FmEventResponse FmFileBrowseWidget::offerBackEvent() |
|
748 { |
|
749 QString currentPath( |
|
750 FmUtils::fillPathWithSplash( this->currentPath().filePath() ) ); |
|
751 // return BackWasNotConsumed to close current view if match root level path |
|
752 if( mRootLevelPath.length() != 0 && |
|
753 mRootLevelPath.compare( currentPath, Qt::CaseInsensitive ) == 0 ) { |
|
754 return BackWasNotConsumed; |
|
755 } else if ( cdUp() ) { |
|
756 return BackWasConsumed; |
|
757 } else { |
|
758 return BackWasNotConsumed; |
|
759 } |
|
760 } |
|
761 |
|
762 /*! |
|
763 \a rootPath used to lock root level path. |
|
764 Root level path is the top leve path that user can view. |
|
765 */ |
|
766 void FmFileBrowseWidget::setRootLevelPath(const QString &rootPath) |
|
767 { |
|
768 mRootLevelPath = rootPath; |
|
769 } |