--- a/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Tue Jul 06 14:06:28 2010 +0300
+++ b/filemanager/src/filemanager/src/fmdriverlistwidget.cpp Wed Aug 18 09:39:39 2010 +0300
@@ -58,12 +58,12 @@
void FmDriverListWidget::on_list_activated( const QModelIndex &index )
{
- FmLogger::log("FmDriverListWidget::on_list_activated");
+ FM_LOG("FmDriverListWidget::on_list_activated");
if( mListLongPressed ) {
- FmLogger::log("FmDriverListWidget::on_list_activated return because long pressed");
+ FM_LOG("FmDriverListWidget::on_list_activated return because long pressed");
return;
}
- FmLogger::log("FmDriverListWidget::on_list_activated emit activate to open drive");
+ FM_LOG("FmDriverListWidget::on_list_activated emit activate to open drive");
emit activated( mModel->driveName( index ) );
}
@@ -109,15 +109,14 @@
setLayout( mLayout );
}
-void FmDriverListWidget::refreshModel( const QString &path )
+void FmDriverListWidget::refreshDrive()
{
- Q_UNUSED( path );
mModel->refresh();
}
void FmDriverListWidget::on_list_longPressed( HbAbstractViewItem *item, const QPointF &coords )
{
- FmLogger::log("FmDriverListWidget::on_list_longPressed");
+ FM_LOG("FmDriverListWidget::on_list_longPressed");
mListLongPressed = true;
mCurrentItem = item;
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
@@ -128,6 +127,7 @@
mContextMenu->clearActions();
}
FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName );
+ FmDriverInfo::DriveType driveType = driverInfo.driveType();
FmDriverInfo::DriveState state = driverInfo.driveState();
if( !( state & FmDriverInfo::EDriveNotPresent ) ) {
if( state & FmDriverInfo::EDriveAvailable ) {
@@ -135,76 +135,76 @@
viewAction->setObjectName( "viewAction" );
viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_memory" ) );
mContextMenu->addAction( viewAction );
-
- //state = 0x210;
-
connect( viewAction, SIGNAL( triggered() ),
this, SLOT( on_viewAction_triggered() ), Qt::QueuedConnection );
- }
-
- 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" ) );
- mContextMenu->addAction( renameAction );
-
- connect( renameAction, SIGNAL( triggered() ),
- this, SLOT( on_renameAction_triggered() ), Qt::QueuedConnection );
- }
- else{
- HbAction *nameAction = new HbAction();
- nameAction->setObjectName( "nameAction" );
- nameAction->setText( hbTrId( "txt_fmgr_menu_name" ) );
- mContextMenu->addAction( nameAction );
-
- connect( nameAction, SIGNAL( triggered() ),
- this, SLOT( on_nameAction_triggered() ), Qt::QueuedConnection );
- }
- if( !( state & FmDriverInfo::EDriveUsbMemory ) ) { // MMC
- if( state & FmDriverInfo::EDrivePasswordProtected ){
- HbAction *changePwdAction = new HbAction();
- changePwdAction->setObjectName( "changePwdAction" );
- changePwdAction->setText( hbTrId( "txt_fmgr_menu_change_password" ) );
- mContextMenu->addAction( changePwdAction );
+
+ if( driveType == FmDriverInfo::EDriveTypeMemoryCard || driveType == FmDriverInfo::EDriveTypeUsbMemory ) {
+ // MMC or Usb memory
+
+ // Name/Rename action
+ if ( driverInfo.volumeName().length() ){
+ HbAction *renameAction = new HbAction();
+ renameAction->setObjectName( "renameAction" );
+ renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) );
+ mContextMenu->addAction( renameAction );
+
+ connect( renameAction, SIGNAL( triggered() ),
+ this, SLOT( on_renameAction_triggered() ), Qt::QueuedConnection );
+ } else {
+ HbAction *nameAction = new HbAction();
+ nameAction->setObjectName( "nameAction" );
+ nameAction->setText( hbTrId( "txt_fmgr_menu_name" ) );
+ mContextMenu->addAction( nameAction );
- HbAction *removePwdAction = new HbAction();
- removePwdAction->setObjectName( "removePwdAction" );
- removePwdAction->setText( hbTrId( "txt_fmgr_menu_remove_password" ) );
- mContextMenu->addAction( removePwdAction );
-
- connect( changePwdAction, SIGNAL( triggered() ),
- this, SLOT( on_changePwdAction_triggered() ), Qt::QueuedConnection );
- connect( removePwdAction, SIGNAL( triggered() ),
- this, SLOT( on_removePwdAction_triggered() ), Qt::QueuedConnection );
+ connect( nameAction, SIGNAL( triggered() ),
+ this, SLOT( on_nameAction_triggered() ), Qt::QueuedConnection );
}
- else{
- HbAction *setPwdAction = new HbAction();
- setPwdAction->setObjectName( "setPwdAction" );
- setPwdAction->setText( hbTrId( "txt_fmgr_menu_set_password" ) );
- mContextMenu->addAction( setPwdAction );
-
- connect( setPwdAction, SIGNAL( triggered() ),
- this, SLOT( on_setPwdAction_triggered() ), Qt::QueuedConnection );
+
+ // Set/Change/Remove password action
+ if( driveType == FmDriverInfo::EDriveTypeMemoryCard ) { // MMC
+ if( state & FmDriverInfo::EDrivePasswordProtected ){
+ HbAction *changePwdAction = new HbAction();
+ changePwdAction->setObjectName( "changePwdAction" );
+ changePwdAction->setText( hbTrId( "txt_fmgr_menu_change_password" ) );
+ mContextMenu->addAction( changePwdAction );
+
+ HbAction *removePwdAction = new HbAction();
+ removePwdAction->setObjectName( "removePwdAction" );
+ removePwdAction->setText( hbTrId( "txt_fmgr_menu_remove_password" ) );
+ mContextMenu->addAction( removePwdAction );
+
+ connect( changePwdAction, SIGNAL( triggered() ),
+ this, SLOT( on_changePwdAction_triggered() ), Qt::QueuedConnection );
+ connect( removePwdAction, SIGNAL( triggered() ),
+ this, SLOT( on_removePwdAction_triggered() ), Qt::QueuedConnection );
+ }
+ else{
+ HbAction *setPwdAction = new HbAction();
+ setPwdAction->setObjectName( "setPwdAction" );
+ setPwdAction->setText( hbTrId( "txt_fmgr_menu_set_password" ) );
+ mContextMenu->addAction( setPwdAction );
+
+ connect( setPwdAction, SIGNAL( triggered() ),
+ this, SLOT( on_setPwdAction_triggered() ), Qt::QueuedConnection );
+ }
}
+
+ // Eject action
+ if( state & FmDriverInfo::EDriveEjectable ){
+ HbAction *ejectAction = new HbAction();
+ ejectAction->setObjectName( "ejectAction" );
+ ejectAction->setText( hbTrId( "txt_fmgr_menu_eject" ) );
+ mContextMenu->addAction( ejectAction );
+
+ connect( ejectAction, SIGNAL( triggered() ),
+ this, SLOT( on_ejectAction_triggered() ), Qt::QueuedConnection );
+ }
}
}
- if( state & FmDriverInfo::EDriveEjectable ){
- HbAction *ejectAction = new HbAction();
- ejectAction->setObjectName( "ejectAction" );
- ejectAction->setText( hbTrId( "txt_fmgr_menu_eject" ) );
- mContextMenu->addAction( ejectAction );
-
- connect( ejectAction, SIGNAL( triggered() ),
- this, SLOT( on_ejectAction_triggered() ), Qt::QueuedConnection );
- }
-
- #ifndef _DEBUG_ENABLE_FORMATMENU_
- if ( ( state & FmDriverInfo::EDriveRemovable ) || ( state & FmDriverInfo::EDriveCorrupted )
+ // Format action
+ 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" ) );
@@ -212,20 +212,23 @@
connect( formatAction, SIGNAL( triggered() ),
this, SLOT( on_formatAction_triggered() ), Qt::QueuedConnection );
- #ifndef _DEBUG_ENABLE_FORMATMENU_
- }
- #endif
-
- if( state & FmDriverInfo::EDriveLocked ){
- HbAction *unLockedAction = new HbAction();
- unLockedAction->setObjectName( "unLockedAction" );
- unLockedAction->setText( hbTrId( "Unlock" ) );
- mContextMenu->addAction( unLockedAction );
-
- connect( unLockedAction, SIGNAL( triggered() ),
- this, SLOT( on_unLockedAction_triggered() ), Qt::QueuedConnection );
}
}
+
+ // Unlock action
+ // put ouside of !EDriveNotPresent judgement so that
+ // user could unlock drive if connected to PC with mass storage mode
+ if( state & FmDriverInfo::EDriveLocked ){
+ HbAction *unLockedAction = new HbAction();
+ unLockedAction->setObjectName( "unLockedAction" );
+ unLockedAction->setText( hbTrId( "Unlock" ) );
+ mContextMenu->addAction( unLockedAction );
+
+ connect( unLockedAction, SIGNAL( triggered() ),
+ this, SLOT( on_unLockedAction_triggered() ), Qt::QueuedConnection );
+ }
+
+ // Pop up menu or open drive
if( mContextMenu->actions().count() > 0 ) {
mContextMenu->setPreferredPos( coords );
mContextMenu->open();
@@ -257,13 +260,21 @@
return;
}
- QString title( hbTrId( "Drive name ") );
- QString volumeName = driverInfo.volumeName();
-
+ QString title( hbTrId( "Drive name ") );
+ //save the volume status, empty or set
+ bool needToSetVolume = false;
+ QString volumeName = FmUtils::getVolumeNameWithDefaultNameIfNull( diskName, needToSetVolume );
+ QString oldVolumeName( volumeName );
QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) );
- while( FmDlgUtils::showTextQuery( title, volumeName, false, FmMaxLengthofDriveName, associatedDrives ) ){
+ //use isReturnFalseWhenNoTextChanged = false in order that FmUtils::renameDrive( driveName, volumeName ) will
+ //be excuted at lease once to set the volume name.
+ while( FmDlgUtils::showTextQuery( title, volumeName, QStringList(), FmMaxLengthofDriveName, associatedDrives, false ) ){
+ //if volume is not set or oldVolumeName != volumeName , FmUtils::renameDrive will be called
+ if ( oldVolumeName == volumeName && !needToSetVolume ) {
+ break;
+ }
int err = FmUtils::renameDrive( diskName, volumeName );
- if ( err == FmErrNone ){
+ if ( err == FmErrNone ) {
FmDlgUtils::information( hbTrId( "The name has been changed!" ) );
mModel->refresh();
break;
@@ -318,7 +329,7 @@
QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) );
while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, FmMaxLengthofDrivePassword, associatedDrives ) ) {
if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ){
- if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd ) ){
+ if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, FmMaxLengthofDrivePassword, associatedDrives ) ){
if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){
FmDlgUtils::information( hbTrId( "The password has been changed!" ) );
} else {
@@ -372,7 +383,7 @@
QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
//Do not add associatedDrives as Locked MMC is not available Drive but only present Drive
- while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd ) ) {
+ while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, FmMaxLengthofDrivePassword ) ) {
int err = FmUtils::unlockDrive( diskName, oldPwd );
if( err == FmErrNone ) {
FmDlgUtils::information( hbTrId( "The memory is unlocked!" ) );