--- a/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Mon May 03 12:24:39 2010 +0300
+++ b/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Fri May 14 15:42:43 2010 +0300
@@ -38,7 +38,7 @@
FmDriverListWidget::FmDriverListWidget( QGraphicsItem *parent )
: HbWidget( parent ),
mCurrentItem( 0 ),
- mOperationService( 0 )
+ mOperationService( 0 ), mListLongPressed( false )
{
init();
mOperationService = FmViewManager::viewManager()->operationService();
@@ -56,7 +56,13 @@
void FmDriverListWidget::on_list_activated( const QModelIndex &index )
{
- emit activated( mModel->driveName( index ) );
+ FmLogger::log("FmDriverListWidget::on_list_activated");
+ if( mListLongPressed ) {
+ FmLogger::log("FmDriverListWidget::on_list_activated return because long pressed");
+ return;
+ }
+ FmLogger::log("FmDriverListWidget::on_list_activated emit activate to open drive");
+ emit activated( mModel->driveName( index ) );
}
void FmDriverListWidget::init()
@@ -80,9 +86,11 @@
mSearchPanel->hide();
// mLayout->addItem( mSearchPanel );
- mListView->setItemPrototype( new DiskListViewItem( mListView ) );
+ mListView->setItemPrototype( new DiskListViewItem() );
connect( mListView, SIGNAL( activated( const QModelIndex & ) ),
this, SLOT( on_list_activated( const QModelIndex & ) ) );
+ connect( mListView, SIGNAL( pressed( const QModelIndex & ) ),
+ this, SLOT( on_list_pressed( const QModelIndex & ) ) );
connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ),
this, SLOT( on_list_longPressed( HbAbstractViewItem *, const QPointF & ) ) );
@@ -107,73 +115,77 @@
void FmDriverListWidget::on_list_longPressed( HbAbstractViewItem *item, const QPointF &coords )
{
- HbMenu *contextMenu = new HbMenu();
-
+ FmLogger::log("FmDriverListWidget::on_list_longPressed");
+ mListLongPressed = true;
mCurrentItem = item;
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName );
FmDriverInfo::DriveState state = driverInfo.driveState();
-
- if( !( state & FmDriverInfo::EDriveNotPresent ) && !( state & FmDriverInfo::EDriveLocked ) &&
- !( state & FmDriverInfo::EDriveCorrupted ) ) {
- HbAction *viewAction = new HbAction();
- viewAction->setObjectName( "viewAction" );
- viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_memory" ) );
- contextMenu->addAction( viewAction );
-
- //state = 0x210;
+ if( !( state & FmDriverInfo::EDriveNotPresent ) ) {
+ HbMenu *contextMenu = new HbMenu();
+
+ if( state & FmDriverInfo::EDriveAvailable ) {
+ HbAction *viewAction = new HbAction();
+ viewAction->setObjectName( "viewAction" );
+ viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_memory" ) );
+ contextMenu->addAction( viewAction );
- connect( viewAction, SIGNAL( triggered() ),
- this, SLOT( on_viewAction_triggered() ) );
- }
-
- if( ( state & FmDriverInfo::EDriveRemovable ) && !( state & FmDriverInfo::EDriveMassStorage ) ){
- if ( driverInfo.volumeName().length() ){
- HbAction *renameAction = new HbAction();
- renameAction->setObjectName( "renameAction" );
- renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) );
- contextMenu->addAction( renameAction );
-
- connect( renameAction, SIGNAL( triggered() ),
- this, SLOT( on_renameAction_triggered() ) );
+ //state = 0x210;
+
+ connect( viewAction, SIGNAL( triggered() ),
+ this, SLOT( on_viewAction_triggered() ) );
}
- else{
- HbAction *nameAction = new HbAction();
- nameAction->setObjectName( "nameAction" );
- nameAction->setText( hbTrId( "txt_fmgr_menu_name" ) );
- contextMenu->addAction( nameAction );
-
- connect( nameAction, SIGNAL( triggered() ),
- this, SLOT( on_nameAction_triggered() ) );
+
+ if( ( state & FmDriverInfo::EDriveAvailable ) && ( state & FmDriverInfo::EDriveRemovable ) && !( state & FmDriverInfo::EDriveMassStorage ) ){
+ // MMC or Usb memory
+ if ( driverInfo.volumeName().length() ){
+ HbAction *renameAction = new HbAction();
+ renameAction->setObjectName( "renameAction" );
+ renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) );
+ contextMenu->addAction( renameAction );
+
+ connect( renameAction, SIGNAL( triggered() ),
+ this, SLOT( on_renameAction_triggered() ) );
+ }
+ else{
+ HbAction *nameAction = new HbAction();
+ nameAction->setObjectName( "nameAction" );
+ nameAction->setText( hbTrId( "txt_fmgr_menu_name" ) );
+ contextMenu->addAction( nameAction );
+
+ connect( nameAction, SIGNAL( triggered() ),
+ this, SLOT( on_nameAction_triggered() ) );
+ }
+ if( !( state & FmDriverInfo::EDriveUsbMemory ) ) { // MMC
+ if( state & FmDriverInfo::EDrivePasswordProtected ){
+ HbAction *changePwdAction = new HbAction();
+ changePwdAction->setObjectName( "changePwdAction" );
+ changePwdAction->setText( hbTrId( "txt_fmgr_menu_change_password" ) );
+ contextMenu->addAction( changePwdAction );
+
+ HbAction *removePwdAction = new HbAction();
+ removePwdAction->setObjectName( "removePwdAction" );
+ removePwdAction->setText( hbTrId( "txt_fmgr_menu_remove_password" ) );
+ contextMenu->addAction( removePwdAction );
+
+ connect( changePwdAction, SIGNAL( triggered() ),
+ this, SLOT( on_changePwdAction_triggered() ) );
+ connect( removePwdAction, SIGNAL( triggered() ),
+ this, SLOT( on_removePwdAction_triggered() ) );
+ }
+ else{
+ HbAction *setPwdAction = new HbAction();
+ setPwdAction->setObjectName( "setPwdAction" );
+ setPwdAction->setText( hbTrId( "txt_fmgr_menu_set_password" ) );
+ contextMenu->addAction( setPwdAction );
+
+ connect( setPwdAction, SIGNAL( triggered() ),
+ this, SLOT( on_setPwdAction_triggered() ) );
+ }
+ }
}
-
- if( state & FmDriverInfo::EDrivePasswordProtected ){
- HbAction *changePwdAction = new HbAction();
- changePwdAction->setObjectName( "changePwdAction" );
- changePwdAction->setText( hbTrId( "txt_fmgr_menu_change_password" ) );
- contextMenu->addAction( changePwdAction );
-
- HbAction *removePwdAction = new HbAction();
- removePwdAction->setObjectName( "removePwdAction" );
- removePwdAction->setText( hbTrId( "txt_fmgr_menu_remove_password" ) );
- contextMenu->addAction( removePwdAction );
-
- connect( changePwdAction, SIGNAL( triggered() ),
- this, SLOT( on_changePwdAction_triggered() ) );
- connect( removePwdAction, SIGNAL( triggered() ),
- this, SLOT( on_removePwdAction_triggered() ) );
- }
- else{
- HbAction *setPwdAction = new HbAction();
- setPwdAction->setObjectName( "setPwdAction" );
- setPwdAction->setText( hbTrId( "txt_fmgr_menu_set_password" ) );
- contextMenu->addAction( setPwdAction );
-
- connect( setPwdAction, SIGNAL( triggered() ),
- this, SLOT( on_setPwdAction_triggered() ) );
- }
-
+
if( state & FmDriverInfo::EDriveEjectable ){
HbAction *ejectAction = new HbAction();
ejectAction->setObjectName( "ejectAction" );
@@ -182,36 +194,41 @@
connect( ejectAction, SIGNAL( triggered() ),
this, SLOT( on_ejectAction_triggered() ) );
- }
+ }
+
+ #ifndef _DEBUG_ENABLE_FORMATMENU_
+ if ( ( state & FmDriverInfo::EDriveRemovable ) || ( state & FmDriverInfo::EDriveCorrupted )
+ || ( state & FmDriverInfo::EDriveLocked ) ){
+ #endif
+ HbAction *formatAction = new HbAction();
+ formatAction->setObjectName( "formatAction" );
+ formatAction->setText( hbTrId( "txt_fmgr_menu_format" ) );
+ contextMenu->addAction( formatAction );
+
+ connect( formatAction, SIGNAL( triggered() ),
+ this, SLOT( on_formatAction_triggered() ) );
+ #ifndef _DEBUG_ENABLE_FORMATMENU_
+ }
+ #endif
+
+ if( state & FmDriverInfo::EDriveLocked ){
+ HbAction *unLockedAction = new HbAction();
+ unLockedAction->setObjectName( "unLockedAction" );
+ unLockedAction->setText( hbTrId( "Unlock" ) );
+ contextMenu->addAction( unLockedAction );
+
+ connect( unLockedAction, SIGNAL( triggered() ),
+ this, SLOT( on_unLockedAction_triggered() ) );
+ }
+ contextMenu->setPreferredPos( coords );
+ contextMenu->open();
}
-#ifndef _DEBUG_ENABLE_FORMATMENU_
-if ( ( state & FmDriverInfo::EDriveRemovable ) || ( state & FmDriverInfo::EDriveCorrupted )
- || ( state & FmDriverInfo::EDriveLocked ) ){
- if( !( state & FmDriverInfo::EDriveNotPresent ) ){
-#endif
- HbAction *formatAction = new HbAction();
- formatAction->setObjectName( "formatAction" );
- formatAction->setText( hbTrId( "txt_fmgr_menu_format" ) );
- contextMenu->addAction( formatAction );
+
+}
- connect( formatAction, SIGNAL( triggered() ),
- this, SLOT( on_formatAction_triggered() ) );
-#ifndef _DEBUG_ENABLE_FORMATMENU_
- }
- }
-#endif
-
- if( state & FmDriverInfo::EDriveLocked ){
- HbAction *unLockedAction = new HbAction();
- unLockedAction->setObjectName( "unLockedAction" );
- unLockedAction->setText( hbTrId( "Unlock" ) );
- contextMenu->addAction( unLockedAction );
-
- connect( unLockedAction, SIGNAL( triggered() ),
- this, SLOT( on_unLockedAction_triggered() ) );
- }
-
- contextMenu->exec( coords );
+void FmDriverListWidget::on_list_pressed( const QModelIndex & index )
+{
+ mListLongPressed = false;
}
void FmDriverListWidget::on_viewAction_triggered()
@@ -269,7 +286,7 @@
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) );
- if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, associatedDrives ) ) {
+ if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, FmMaxLengthofDrivePassword, associatedDrives ) ) {
if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){
HbMessageBox::information( hbTrId( "The password has been set!" ) );
}
@@ -291,7 +308,7 @@
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) );
- while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, associatedDrives ) ) {
+ while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, FmMaxLengthofDrivePassword, associatedDrives ) ) {
if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ){
if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd ) ){
if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){
@@ -319,9 +336,9 @@
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
//QString password( tr( "a ") );
- if( HbMessageBox::question( tr( "Do you want to remove the password? Memory card becomes unlocked." ) ) ){
+ if( FmDlgUtils::question( tr( "Do you want to remove the password? Memory card becomes unlocked." ) ) ){
QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) );
- while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, associatedDrives ) ) {
+ while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, FmMaxLengthofDrivePassword, associatedDrives ) ) {
if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ) {
if ( FmUtils::removeDrivePwd( diskName, oldPwd ) == 0 ){
HbMessageBox::information( hbTrId( "The password has been removed!" ) );
@@ -372,7 +389,7 @@
{
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
- if( HbMessageBox::question( hbTrId( "Format? Data will be deleted during formatting." ) ) ){
+ if( FmDlgUtils::question( hbTrId( "Format? Data will be deleted during formatting." ) ) ){
if( FmErrNone != mOperationService->asyncFormat( diskName ) )
HbMessageBox::information( hbTrId( "Formatting failed." ) );
}
@@ -382,7 +399,7 @@
{
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
- if( HbMessageBox::question( hbTrId( "Eject memory card? Some applications will be closed." ) ) ){
+ if( FmDlgUtils::question( hbTrId( "Eject memory card? Some applications will be closed." ) ) ){
FmUtils::ejectDrive( diskName );
}
}
@@ -395,7 +412,13 @@
void FmDriverListWidget::activeSearchPanel()
{
- mFindTargetPath.clear();
+ QStringList driveList;
+ FmUtils::getDriveList( driveList, true );
+ if(driveList.count() > 0 ) {
+ mFindTargetPath = driveList.first();
+ } else {
+ mFindTargetPath.clear();
+ }
mLayout->addItem( mSearchPanel );
mSearchPanel->show();
}