filemanager/src/filemanager/src/fmdriverlistwidget.cpp
changeset 46 d58987eac7e8
parent 37 15bc28c9dd51
equal deleted inserted replaced
37:15bc28c9dd51 46:d58987eac7e8
    77          FmDriveModel::FillWithTotalSize | FmDriveModel::FillWithFreeSize );
    77          FmDriveModel::FillWithTotalSize | FmDriveModel::FillWithFreeSize );
    78 	mListView->setModel( mModel );
    78 	mListView->setModel( mModel );
    79 	mLayout->addItem( mListView );	
    79 	mLayout->addItem( mListView );	
    80 	mSearchPanel = new HbSearchPanel( this );
    80 	mSearchPanel = new HbSearchPanel( this );
    81 	mSearchPanel->setObjectName( "searchPanel" );
    81 	mSearchPanel->setObjectName( "searchPanel" );
    82 	mSearchPanel->setSearchOptionsEnabled( true );
    82 	mSearchPanel->setSearchOptionsEnabled( false );
    83 	mSearchPanel->setProgressive( false );
    83 	mSearchPanel->setProgressive( true );
    84 	mSearchPanel->hide();
    84 	mSearchPanel->hide();
    85 	connect( mListView, SIGNAL( activated( const QModelIndex & ) ),
    85 	connect( mListView, SIGNAL( activated( const QModelIndex & ) ),
    86 		     this, SLOT( on_list_activated( const QModelIndex & ) ) );
    86 		     this, SLOT( on_list_activated( const QModelIndex & ) ) );
    87 	connect( mListView, SIGNAL( pressed( const QModelIndex & ) ),
    87 	connect( mListView, SIGNAL( pressed( const QModelIndex & ) ),
    88 	             this, SLOT( on_list_pressed( const QModelIndex & ) ) );
    88 	             this, SLOT( on_list_pressed( const QModelIndex & ) ) );
    89 
    89 
    90     connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ),
    90     connect( mListView, SIGNAL( longPressed( HbAbstractViewItem *, const QPointF & ) ),
    91         this, SLOT( on_list_longPressed( HbAbstractViewItem *, const QPointF & ) ) );
    91         this, SLOT( on_list_longPressed( HbAbstractViewItem *, const QPointF & ) ) );
    92     
    92     
    93     connect( mSearchPanel, SIGNAL( searchOptionsClicked() ),
       
    94         this, SLOT( on_searchPanel_searchOptionsClicked() ), Qt::QueuedConnection );
       
    95     
       
    96     connect( mSearchPanel, SIGNAL( criteriaChanged( const QString & ) ),
    93     connect( mSearchPanel, SIGNAL( criteriaChanged( const QString & ) ),
    97         this, SLOT( on_searchPanel_criteriaChanged( const QString & ) ) );
    94         this, SLOT( on_searchPanel_criteriaChanged( const QString & ) ), Qt::QueuedConnection );
    98        
    95        
    99     connect( mSearchPanel, SIGNAL( exitClicked() ),
    96     connect( mSearchPanel, SIGNAL( exitClicked() ),
   100         this, SLOT( on_searchPanel_exitClicked() ) );
    97         this, SLOT( on_searchPanel_exitClicked() ) );
   101     
    98     
   102     setLayout( mLayout );
    99     setLayout( mLayout );
   249     
   246     
   250     FmDriverInfo::DriveState state = FmUtils::queryDriverInfo( diskName ).driveState();
   247     FmDriverInfo::DriveState state = FmUtils::queryDriverInfo( diskName ).driveState();
   251     FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName );
   248     FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName );
   252 
   249 
   253     if ( state & FmDriverInfo::EDriveWriteProtected ){
   250     if ( state & FmDriverInfo::EDriveWriteProtected ){
   254         FmDlgUtils::information( hbTrId( "Unable to perform operation. Memory card is read only." ) );
   251         FmDlgUtils::warning( hbTrId( "Unable to perform operation. Memory card is read only." ) );
   255         return;
   252         return;
   256         }
   253         }
   257 
   254 
   258     QString title( hbTrId( "Drive name ") );
   255     QString title( hbTrId( "Drive name ") );
   259     //save the volume status, empty or set
   256     //save the volume status, empty or set
   268         if ( oldVolumeName == volumeName && !needToSetVolume ) {
   265         if ( oldVolumeName == volumeName && !needToSetVolume ) {
   269             break;
   266             break;
   270         }
   267         }
   271         int err = FmUtils::renameDrive( diskName, volumeName );
   268         int err = FmUtils::renameDrive( diskName, volumeName );
   272         if ( err == FmErrNone ) {
   269         if ( err == FmErrNone ) {
   273             FmDlgUtils::information( hbTrId( "The name has been changed!" ) );
   270             FmDlgUtils::information( hbTrId( "The name has been changed!" ), HbMessageBox::Ok, true );
   274             mModel->refresh();
   271             mModel->refresh();
   275             break;
   272             break;
   276         } else if( err == FmErrBadName ) {
   273         } else if( err == FmErrBadName ) {
   277             FmDlgUtils::information( hbTrId( "Illegal characters! Use only letters and numbers." ) );
   274             FmDlgUtils::warning( hbTrId( "Illegal characters! Use only letters and numbers." ), HbMessageBox::Ok, true );
   278         } else{
   275         } else{
   279             FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) );
   276             FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) );
   280             break;
   277             break;
   281         }                
   278         }                
   282     }
   279     }
   283 }
   280 }
   284 
   281 
   300     QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
   297     QString diskName = mModel->driveName( mCurrentItem->modelIndex() );
   301 
   298 
   302     QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) );
   299     QString associatedDrives( FmUtils::getDriveLetterFromPath( diskName ) );
   303     if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, FmMaxLengthofDrivePassword, associatedDrives ) ) {
   300     if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, FmMaxLengthofDrivePassword, associatedDrives ) ) {
   304        if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){
   301        if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){
   305             FmDlgUtils::information( hbTrId( "The password has been set!" ) );
   302             FmDlgUtils::information( hbTrId( "The password has been set!" ), HbMessageBox::Ok, true );
   306         }
   303         }
   307         else{
   304         else{
   308             FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) );
   305             FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) );
   309         }
   306         }
   310     }
   307     }
   311 }
   308 }
   312 
   309 
   313 void FmDriverListWidget::on_changePwdAction_triggered()
   310 void FmDriverListWidget::on_changePwdAction_triggered()
   326        if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ){
   323        if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ){
   327             if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, FmMaxLengthofDrivePassword, associatedDrives ) ){
   324             if( FmDlgUtils::showMultiPasswordQuery( firstLabel, secondLabel, newPwd, FmMaxLengthofDrivePassword, associatedDrives ) ){
   328                 if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){
   325                 if ( FmUtils::setDrivePwd( diskName, oldPwd, newPwd ) == 0 ){
   329                     FmDlgUtils::information( hbTrId( "The password has been changed!" ) );
   326                     FmDlgUtils::information( hbTrId( "The password has been changed!" ) );
   330                 } else {
   327                 } else {
   331                     FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) );
   328                     FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) );
   332                 }
   329                 }
   333                 break;
   330                 break;
   334             } else {  
   331             } else {  
   335                 //cancel muti password query
   332                 //cancel muti password query
   336                 break;
   333                 break;
   355             if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ) {
   352             if ( FmUtils::checkDrivePwd( diskName, oldPwd ) == 0 ) {
   356                 if ( FmUtils::removeDrivePwd( diskName, oldPwd ) == 0 ){
   353                 if ( FmUtils::removeDrivePwd( diskName, oldPwd ) == 0 ){
   357                     FmDlgUtils::information( hbTrId( "The password has been removed!" ) );
   354                     FmDlgUtils::information( hbTrId( "The password has been removed!" ) );
   358                 }
   355                 }
   359                 else{
   356                 else{
   360                     FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) );
   357                     FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) );
   361                 }
   358                 }
   362                 break;
   359                 break;
   363             }
   360             }
   364             else {
   361             else {
   365                 FmDlgUtils::information( hbTrId( "The password is incorrect, try again!" ) );
   362                 FmDlgUtils::warning( hbTrId( "The password is incorrect, try again!" ), HbMessageBox::Ok, true );
   366             }
   363             }
   367             
   364             
   368         }
   365         }
   369     }
   366     }
   370 }
   367 }
   379     
   376     
   380     //Do not add associatedDrives as Locked MMC is not available Drive but only present Drive
   377     //Do not add associatedDrives as Locked MMC is not available Drive but only present Drive
   381     while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, FmMaxLengthofDrivePassword ) ) {
   378     while( FmDlgUtils::showSinglePasswordQuery( title, oldPwd, FmMaxLengthofDrivePassword ) ) {
   382         int err = FmUtils::unlockDrive( diskName, oldPwd );
   379         int err = FmUtils::unlockDrive( diskName, oldPwd );
   383         if( err == FmErrNone ) {
   380         if( err == FmErrNone ) {
   384             FmDlgUtils::information( hbTrId( "The memory is unlocked!" ) );
   381             FmDlgUtils::warning( hbTrId( "The memory is unlocked!" ) );
   385             break;
   382             break;
   386         } else if ( err == FmErrAccessDenied ) {
   383         } else if ( err == FmErrAccessDenied ) {
   387             FmDlgUtils::information( hbTrId( "The password is incorrect, try again!" ) );
   384             FmDlgUtils::warning( hbTrId( "The password is incorrect, try again!" ), HbMessageBox::Ok, true );
   388         } else if (err == FmErrAlreadyExists ) {
   385         } else if (err == FmErrAlreadyExists ) {
   389             FmDlgUtils::information( hbTrId( "The disk has already been unlocked!" ) );
   386             FmDlgUtils::information( hbTrId( "The disk has already been unlocked!" ) );
   390             break;
   387             break;
   391         } else if( err == FmErrNotSupported ) {
   388         } else if( err == FmErrNotSupported ) {
   392             FmDlgUtils::information( hbTrId( "The media does not support password locking!" ) );
   389             FmDlgUtils::warning( hbTrId( "The media does not support password locking!" ) );
   393             break;
   390             break;
   394         } else {
   391         } else {
   395             FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) );
   392             FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) );
   396             break;
   393             break;
   397         }
   394         }
   398     }
   395     }
   399 }
   396 }
   400 
   397 
   423     mModel->refresh();
   420     mModel->refresh();
   424 }
   421 }
   425 
   422 
   426 void FmDriverListWidget::activeSearchPanel()
   423 void FmDriverListWidget::activeSearchPanel()
   427 {
   424 {
   428     QStringList driveList;
       
   429     FmUtils::getDriveList( driveList, true );
       
   430     if(driveList.count() > 0 ) {
       
   431         mFindTargetPath =  driveList.first();
       
   432         if( FmUtils::isDriveC( mFindTargetPath ) ) {
       
   433             mFindTargetPath =  QString( Folder_C_Data );
       
   434         }
       
   435     } else {
       
   436         mFindTargetPath.clear();
       
   437     }
       
   438     mLayout->addItem( mSearchPanel );
   425     mLayout->addItem( mSearchPanel );
   439     mSearchPanel->show();
   426     mSearchPanel->show();
   440 }
   427 }
   441 
   428 
   442 void FmDriverListWidget::on_searchPanel_searchOptionsClicked()
       
   443 {
       
   444     mFindTargetPath = FmUtils::fillPathWithSplash( FmFileDialog::getExistingDirectory( 0, hbTrId( "Look in:" ),
       
   445         QString(""), QStringList() ) );
       
   446 }
       
   447 
       
   448 void FmDriverListWidget::on_searchPanel_criteriaChanged( const QString &criteria )
   429 void FmDriverListWidget::on_searchPanel_criteriaChanged( const QString &criteria )
   449 {
   430 {
   450     emit startSearch( mFindTargetPath, criteria );
   431     emit startSearch( criteria );
   451     mSearchPanel->hide();
   432     mSearchPanel->hide();
   452     mLayout->removeItem( mSearchPanel );
   433     mLayout->removeItem( mSearchPanel );
       
   434 
       
   435     // clear keywords in searchpanel without signal criteriaChanged triggered again
       
   436     mSearchPanel->setProgressive( false );
       
   437     mSearchPanel->setCriteria( QString() );
       
   438     mSearchPanel->setProgressive( true );
       
   439     
   453 }
   440 }
   454 
   441 
   455 void FmDriverListWidget::on_searchPanel_exitClicked()
   442 void FmDriverListWidget::on_searchPanel_exitClicked()
   456 {
   443 {
   457     mSearchPanel->hide();
   444     mSearchPanel->hide();