filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp
changeset 37 15bc28c9dd51
parent 16 ada7962b4308
child 46 d58987eac7e8
equal deleted inserted replaced
16:ada7962b4308 37:15bc28c9dd51
    16 */
    16 */
    17 #include "fmoperationresultprocesser.h"
    17 #include "fmoperationresultprocesser.h"
    18 #include "fmoperationbase.h"
    18 #include "fmoperationbase.h"
    19 #include "fmoperationservice.h"
    19 #include "fmoperationservice.h"
    20 #include "fmoperationformat.h"
    20 #include "fmoperationformat.h"
       
    21 #include "fmbkupengine.h"
       
    22 #include "fmbackupsettings.h"
       
    23 #include "fmbackuprestorehandler.h"
       
    24 #include "fmoperationviewdetails.h"
    21 #include "fmviewdetailsdialog.h"
    25 #include "fmviewdetailsdialog.h"
    22 #include "fmdlgutils.h"
    26 #include "fmdlgutils.h"
    23 #include "fmutils.h"
    27 #include "fmutils.h"
    24 
    28 #include <hbaction.h>
    25 #include <hbprogressdialog.h>
    29 #include <hbprogressdialog.h>
    26 #include <hbaction.h>
    30 #include <hbaction.h>
    27 #include <hbmessagebox.h>
    31 #include <hbglobal.h>
    28 
    32 #include <QFileInfo>
       
    33 
       
    34 /*
       
    35  * Constructs one operation result processer with \a operation Service.
       
    36  */
    29 FmOperationResultProcesser::FmOperationResultProcesser( FmOperationService *operationService )
    37 FmOperationResultProcesser::FmOperationResultProcesser( FmOperationService *operationService )
    30     : mOperationService( operationService ), mNote( 0 )
    38     : mOperationService( operationService ), mNote( 0 )
    31 {
    39 {
    32 }
    40 }
    33 
    41 
       
    42 /*
       
    43  * Destructs the operation result processer
       
    44  */
    34 FmOperationResultProcesser::~FmOperationResultProcesser(void)
    45 FmOperationResultProcesser::~FmOperationResultProcesser(void)
    35 {
    46 {
    36 }
    47 }
    37 
    48 
       
    49 /*
       
    50  * Called by operation service on_operation_askForRename
       
    51  * \sa FmOperationService::on_operation_askForRename
       
    52  */
    38 void FmOperationResultProcesser::onAskForRename(
    53 void FmOperationResultProcesser::onAskForRename(
    39     FmOperationBase* operationBase, const QString &srcFile, QString *destFile )
    54     FmOperationBase* operationBase, const QString &srcFile, QString *destFile )
    40 {
    55 {
    41     Q_UNUSED( operationBase );
    56     Q_UNUSED( operationBase );
       
    57     int maxFileNameLength = FmUtils::getMaxFileNameLength();
    42     
    58     
    43     QString questionText = QString( "file " ) +
    59     QString questionText = QString( "file " ) +
    44         srcFile + QString( " already exist, please rename:" );
    60         srcFile + QString( " already exist, please rename:" );
    45     QString value;
    61     QString value;   
    46     FmDlgUtils::showTextQuery( questionText, value, true );
    62     QFileInfo srcFileInfo(srcFile);
    47     *destFile = value;
    63     QStringList regExpList = (QStringList() << Regex_ValidFileFolderName << Regex_ValidNotEndWithDot );
    48 }
    64 
    49 
    65     bool ret = FmDlgUtils::showTextQuery( questionText, value, regExpList,
       
    66         maxFileNameLength, QString(), false );
       
    67     while ( ret ) {
       
    68         // remove whitespace from the start and the end.
       
    69         value = value.trimmed();
       
    70         QString newTargetPath = FmUtils::fillPathWithSplash(
       
    71                                 srcFileInfo.absolutePath() ) + value;
       
    72         QString errString;
       
    73         // check if name/path is available for use.
       
    74         if( !FmUtils::checkNewFolderOrFile( value, newTargetPath, errString ) ) {
       
    75             FmDlgUtils::information( errString );
       
    76             ret = FmDlgUtils::showTextQuery( questionText, value, regExpList, maxFileNameLength, QString(), false );
       
    77             continue;
       
    78         } else {
       
    79             break;
       
    80         }
       
    81     }   
       
    82 	if( ret ) {
       
    83         // Got file/folder name for rename, save it to destFile
       
    84 		*destFile = value;
       
    85         QFileInfo destFileInfo( *destFile );
       
    86         if ( ( srcFileInfo.suffix().compare( destFileInfo.suffix(), Qt::CaseInsensitive ) != 0 )
       
    87             && srcFileInfo.isFile() ) {
       
    88             // popup warning when the suffix of file is changed.
       
    89             FmDlgUtils::information( hbTrId( "File may become unusable when file name extension is changed" ) );        
       
    90         }   
       
    91 	}
       
    92 }
       
    93 
       
    94 /*
       
    95  * Called by operation service on_operation_askForReplace
       
    96  * \sa FmOperationService::on_operation_askForReplace
       
    97  */
    50 void FmOperationResultProcesser::onAskForReplace(
    98 void FmOperationResultProcesser::onAskForReplace(
    51     FmOperationBase* operationBase, const QString &srcFile, const QString &destFile, bool *isAccepted )
    99     FmOperationBase* operationBase, const QString &srcFile, const QString &destFile, bool *isAccepted )
    52 {
   100 {
    53     Q_UNUSED( operationBase );
   101     Q_UNUSED( operationBase );
    54     Q_UNUSED( destFile );
   102     Q_UNUSED( destFile );
    55     
   103     
    56     QString questionText = QString( "file " ) +
   104     QString questionText = QString( "file " ) +
    57         srcFile + QString( " already exist, replace it?" );
   105         srcFile + QString( " already exist, replace it?" );
    58     if( HbMessageBox::question( questionText ) ) {
   106     if( FmDlgUtils::question( questionText ) ) {
    59         *isAccepted = true;
   107         *isAccepted = true;
    60     } else {
   108     } else {
    61         *isAccepted = false;
   109         *isAccepted = false;
    62     }
   110     }
    63 }
   111 }
    64 
   112 
       
   113 /*
       
   114  * Called by operation service on_operation_showNote
       
   115  * \sa FmOperationService::on_operation_showNote
       
   116  */
       
   117 void FmOperationResultProcesser::onShowNote( FmOperationBase* operationBase, const char *noteString )
       
   118 {
       
   119     Q_UNUSED( operationBase );
       
   120     FmDlgUtils::information(hbTrId(noteString));
       
   121 }
       
   122 
       
   123 /*
       
   124  * Called by operation service on_operation_notifyWaiting
       
   125  * \sa FmOperationService::on_operation_notifyWaiting
       
   126  */
    65 void FmOperationResultProcesser::onNotifyWaiting( FmOperationBase* operationBase, bool cancelable )
   127 void FmOperationResultProcesser::onNotifyWaiting( FmOperationBase* operationBase, bool cancelable )
    66 {
   128 {
    67     QString title = tr("Operation");
   129     QString title = hbTrId("Operation");
    68     switch( operationBase->operationType() )
   130     switch( operationBase->operationType() )
    69     {
   131     {
    70     case FmOperationService::EOperationTypeBackup:
   132     case FmOperationService::EOperationTypeBackup:
    71         title = hbTrId("backuping");
   133         title = hbTrId("backuping");
    72         break;
   134         break;
    85     }
   147     }
    86 
   148 
    87     showWaiting( title, cancelable );
   149     showWaiting( title, cancelable );
    88 }
   150 }
    89 
   151 
       
   152 /*
       
   153  * Called by operation service on_operation_notifyPreparing
       
   154  * \sa FmOperationService::on_operation_notifyPreparing
       
   155  */
    90 void FmOperationResultProcesser::onNotifyPreparing( FmOperationBase* operationBase, bool cancelable )
   156 void FmOperationResultProcesser::onNotifyPreparing( FmOperationBase* operationBase, bool cancelable )
    91 {
   157 {
    92     QString title = hbTrId("Operation");
   158     QString title = hbTrId("Operation");
    93     switch( operationBase->operationType() )
   159     switch( operationBase->operationType() )
    94     {
   160     {
   115     }
   181     }
   116 
   182 
   117     showPreparing( title, cancelable );
   183     showPreparing( title, cancelable );
   118 }
   184 }
   119 
   185 
       
   186 /*
       
   187  * Called by operation service on_operation_notifyStart
       
   188  * \sa FmOperationService::on_operation_notifyStart
       
   189  */
   120 void FmOperationResultProcesser::onNotifyStart( FmOperationBase* operationBase, bool cancelable, int maxSteps )
   190 void FmOperationResultProcesser::onNotifyStart( FmOperationBase* operationBase, bool cancelable, int maxSteps )
   121 {
   191 {
   122     QString title = tr("Operation");
   192     QString title = hbTrId("Operation");
   123     switch( operationBase->operationType() )
   193     switch( operationBase->operationType() )
   124     {
   194     {
   125     case FmOperationService::EOperationTypeBackup:
   195     case FmOperationService::EOperationTypeBackup:
   126         title = hbTrId("backup...");
   196         title = hbTrId("backup...");
   127         break;
   197         break;
   145     }
   215     }
   146 
   216 
   147     showProgress( title, cancelable, maxSteps );   
   217     showProgress( title, cancelable, maxSteps );   
   148 }
   218 }
   149 
   219 
       
   220 /*
       
   221  * Called by operation service on_operation_notifyProgress
       
   222  * \sa FmOperationService::on_operation_notifyProgress
       
   223  */
   150 void FmOperationResultProcesser::onNotifyProgress( FmOperationBase* operationBase, int currentStep )
   224 void FmOperationResultProcesser::onNotifyProgress( FmOperationBase* operationBase, int currentStep )
   151 {
   225 {
   152     Q_UNUSED( operationBase );
   226     Q_UNUSED( operationBase );
   153     setProgress( currentStep );
   227     setProgress( currentStep );
   154 }
   228 }
   155 
   229 
       
   230 /*
       
   231  * Called by operation service on_operation_notifyFinish
       
   232  * \sa FmOperationService::on_operation_notifyFinish
       
   233  */
   156 void FmOperationResultProcesser::onNotifyFinish( FmOperationBase* operationBase )
   234 void FmOperationResultProcesser::onNotifyFinish( FmOperationBase* operationBase )
   157 {
   235 {
   158     
   236     
   159     finishProgress();
   237     finishProgress();
   160     switch( operationBase->operationType() )
   238     switch( operationBase->operationType() )
   177 				FmUtils::getDriveLetterFromPath( paramFolderDetails->folderPath() ) );
   255 				FmUtils::getDriveLetterFromPath( paramFolderDetails->folderPath() ) );
   178             break;
   256             break;
   179         }
   257         }
   180     case FmOperationService::EOperationTypeFormat:
   258     case FmOperationService::EOperationTypeFormat:
   181         {
   259         {
   182             HbMessageBox::information( QString( hbTrId("Format succeed!")) );
   260             FmDlgUtils::information( QString( hbTrId("Format succeed!")) );
   183             FmOperationFormat *paramFormat = static_cast<FmOperationFormat*>( operationBase );
   261             FmOperationFormat *paramFormat = static_cast<FmOperationFormat*>( operationBase );
   184             QString title( tr( "Drive name ") );  
   262             QString title( hbTrId( "Drive name ") );  
   185             QString driveName( paramFormat->driverName() );
   263             QString driveName( paramFormat->driverName() );
   186             QString volumeName;
   264             FmDriverInfo driverInfo = FmUtils::queryDriverInfo( driveName );
   187             while( FmDlgUtils::showTextQuery( title, volumeName, false, FmMaxLengthofDriveName ) ){
   265             FmDriverInfo::DriveState state = driverInfo.driveState();
       
   266             FmDriverInfo::DriveType driveType = driverInfo.driveType();
       
   267             
       
   268             // If drive is available and it is mmc or usb memory
       
   269             if( ( state & FmDriverInfo::EDriveAvailable ) &&
       
   270                 ( driveType == FmDriverInfo::EDriveTypeMemoryCard ||
       
   271                   driveType == FmDriverInfo::EDriveTypeUsbMemory ) ) { 
       
   272                 bool needToSetVolume = false;
       
   273                 QString volumeName = FmUtils::getVolumeNameWithDefaultNameIfNull( driveName, needToSetVolume );                            
       
   274                 //use isReturnFalseWhenNoTextChanged = false in order that FmUtils::renameDrive( driveName, volumeName ) will
       
   275                 //be excuted at lease once to set the volume name.
       
   276                 while( FmDlgUtils::showTextQuery( title, volumeName, QStringList(), FmMaxLengthofDriveName, QString(), false ) ){                    
   188                     int err = FmUtils::renameDrive( driveName, volumeName );
   277                     int err = FmUtils::renameDrive( driveName, volumeName );
   189                     if ( err == FmErrNone ){
   278                     if ( err == FmErrNone ) {
   190                         HbMessageBox::information( hbTrId( "The name has been changed!" ) );
   279                         FmDlgUtils::information( hbTrId( "The name has been changed!" ) );
   191                         mOperationService->on_operationThread_refreshModel( driveName );
   280                         mOperationService->on_operation_driveSpaceChanged();
   192                         break;
   281                         break;
   193                     } else if( err == FmErrBadName ) {
   282                     } else if( err == FmErrBadName ) {
   194                         HbMessageBox::information( hbTrId( "Illegal characters! Use only letters and numbers." ) );
   283                         FmDlgUtils::information( hbTrId( "Illegal characters! Use only letters and numbers." ) );
   195                     } else{
   284                     } else{
   196                         HbMessageBox::information( hbTrId( "Error occurred, operation cancelled!" ) );
   285                         FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) );
   197                         break;
   286                         break;
   198                     }                
   287                     }                
   199                 }
   288                 }
       
   289             }
   200             break;
   290             break;
   201         }
   291         }
   202     case FmOperationService::EOperationTypeBackup:
   292     case FmOperationService::EOperationTypeBackup:
   203         {
   293         {
   204             HbMessageBox::information( QString( hbTrId("Backup succeed!")) );
   294             FmDlgUtils::information( QString( hbTrId("Backup succeed!")) );
   205             break;
   295             break;
   206         }
   296         }
   207     case FmOperationService::EOperationTypeRestore:
   297     case FmOperationService::EOperationTypeRestore:
   208         {
   298         {
   209             HbMessageBox::information( QString( hbTrId("Restore succeed!")) );
   299             FmDlgUtils::information( QString( hbTrId("Restore succeed!")) );
   210             break;
   300             break;
   211         }
   301         }
   212     default:
   302     default:
   213         HbMessageBox::information( QString( hbTrId("Operation finished")) );
   303         FmDlgUtils::information( QString( hbTrId("Operation finished")) );
   214 
   304 
   215     }
   305     }
   216 }
   306 }
   217 void FmOperationResultProcesser::onNotifyError( FmOperationBase* operationBase, int error, QString errString )
   307 
       
   308 /*
       
   309  * Called by operation service on_operation_notifyError
       
   310  * \sa FmOperationService::on_operation_notifyError
       
   311  */
       
   312 void FmOperationResultProcesser::onNotifyError( FmOperationBase* operationBase, int error, const QString &errString )
   218 {
   313 {
   219     Q_UNUSED( errString );
   314     Q_UNUSED( errString );
   220     failAndCloseProgress();
   315     failAndCloseProgress();
   221     switch( error )
   316     switch( error )
   222     {
   317     {
       
   318         case FmErrCancel:
       
   319             cancelProgress();
       
   320             // Do not pop up general cancel note as it is not needed( according to TB9.2 ).
       
   321             // If it should be added later, please do not use blocking note. 
       
   322             // Blocking note will cause second backup operaion freeze after cancel previous backup operation
       
   323             // as QEventLoop::exec will cause some problem when used for blocking dialog.
       
   324 			// HbDialog has already removed exec function which is implemented with QEventLoop::exec.
       
   325 			// If need use QEventLoop::exec to block code execute sequence, It should be invoked in a Qt::QueuedConnection slot.
       
   326             return;
   223         case FmErrAlreadyStarted:
   327         case FmErrAlreadyStarted:
   224             HbMessageBox::information( QString( hbTrId("Operation already started!")) );
   328             FmDlgUtils::information( QString( hbTrId("Operation already started!")) );
       
   329             return;
       
   330         case FmErrLocked:
       
   331             {
       
   332                 FmOperationBackup *operationBackup = qobject_cast<FmOperationBackup*>(operationBase);
       
   333                 if( operationBackup ) {
       
   334                     // special error note for backup
       
   335                     QString targetDrive( operationBackup->targetDrive() );
       
   336                     QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) );
       
   337                     QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume );
       
   338                     FmDlgUtils::information( QString( hbTrId("txt_fmgr_info_backup_locked") ).arg( driveString ) );
       
   339                 } else {
       
   340                     FmDlgUtils::information( QString( hbTrId("Operation failed because drive is locked!")) );
       
   341                 }
       
   342                 return;
       
   343             }
       
   344         case FmErrPathNotFound:
       
   345             FmDlgUtils::information( QString( hbTrId("Operation failed because can not find target path or drive is not available!") ) );
       
   346             return;
       
   347         case FmErrCorrupt:
       
   348             {
       
   349                 FmOperationBackup *operationBackup = qobject_cast<FmOperationBackup*>(operationBase);
       
   350                 if( operationBackup ) {
       
   351                     // special error note for backup
       
   352                     QString targetDrive( operationBackup->targetDrive() );
       
   353                     QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) );
       
   354                     QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume );
       
   355                     FmDlgUtils::information( QString( hbTrId("txt_fmgr_info_backup_corrupted") ).arg( driveString ) );
       
   356                 } else {
       
   357                     FmDlgUtils::information( QString( hbTrId("Operation failed because target media is corrupted!") ) );
       
   358                 }
       
   359                 return;
       
   360             }
       
   361         case FmErrNotReady: // Caused when MMC & OTG is not inserted when start backup
       
   362             {
       
   363                 FmOperationBackup *operationBackup = qobject_cast<FmOperationBackup*>(operationBase);
       
   364                 if( operationBackup ) {
       
   365                     // special error note for backup
       
   366                     QString targetDrive( operationBackup->targetDrive() );
       
   367                     QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) );
       
   368                     QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume );
       
   369                     FmDlgUtils::information( QString( hbTrId("txt_fmgr_info_backup_unavailable") ).arg( driveString ) );
       
   370                 } else {
       
   371                     FmDlgUtils::information( QString( hbTrId("Operation failed because device is not ready!") ) );
       
   372                 }
       
   373                 return;
       
   374             }
       
   375         case FmErrDisMounted: // Caused by eject MMC when preparing backup, will be localized later
       
   376             FmDlgUtils::information( QString( hbTrId("Operation failed because backup target drive has been removed!") ) );
   225             return;
   377             return;
   226         case FmErrDiskFull:
   378         case FmErrDiskFull:
   227             HbMessageBox::information( QString( hbTrId("Not enough space. Operation cancelled.!")) );
   379             FmDlgUtils::information( QString( hbTrId("Not enough space. Operation cancelled!")) );
   228             return;
   380             return;
   229         case FmErrCopyDestToSubFolderInSrc:
   381         case FmErrCopyDestToSubFolderInSrc:
   230             HbMessageBox::information( QString( hbTrId("Can not copy to sub folder!")) );
   382             FmDlgUtils::information( QString( hbTrId("Can not copy to sub folder!")) );
   231             return;
   383             return;
   232         case FmErrMoveDestToSubFolderInSrc:
   384         case FmErrMoveDestToSubFolderInSrc:
   233             HbMessageBox::information( QString( hbTrId("Can not move to sub folder!")) );
   385             FmDlgUtils::information( QString( hbTrId("Can not move to sub folder!")) );
   234             return;
   386             return;
   235         case FmErrCannotRemove:{
   387         case FmErrCannotRemove:{
   236             if( operationBase->operationType() == FmOperationService::EOperationTypeCopy ) {
   388             if( operationBase->operationType() == FmOperationService::EOperationTypeCopy ) {
   237                 // when copy a file/dir to same name destination, and delete dest fail, this error will occur
   389                 // when copy a file/dir to same name destination, and delete dest fail, this error will occur
   238                 HbMessageBox::information( QString( hbTrId( "Can not copy because %1 can not be deleted!" ).arg( errString ) ) );
   390                 FmDlgUtils::information( QString( hbTrId( "Can not copy because %1 can not be deleted!" ).arg( errString ) ) );
   239                 return;
   391                 return;
   240             }
   392             }
   241             else if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) {
   393             else if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) {
   242                 // when move a file/dir to same name destination, and delete dest fail, this error will occur
   394                 // when move a file/dir to same name destination, and delete dest fail, this error will occur
   243                 HbMessageBox::information( QString( hbTrId( "Can not move because %1 can not be deleted!" ).arg( errString ) ) );
   395                 FmDlgUtils::information( QString( hbTrId( "Can not move because %1 can not be deleted!" ).arg( errString ) ) );
   244                 return;
   396                 return;
   245             }
   397             }
   246             // when delete file/dir fail, this error will occur
   398             // when delete file/dir fail, this error will occur
   247             HbMessageBox::information( QString( hbTrId( "Can not delete %1!" ).arg( errString ) ) );
   399             FmDlgUtils::information( QString( hbTrId( "Can not delete %1!" ).arg( errString ) ) );
   248             return; 
   400             return; 
   249         }      
   401         }      
   250         case FmErrRemoveDefaultFolder:{
   402         case FmErrRemoveDefaultFolder:{
   251             if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) {
   403             if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) {
   252                 // when move a default folder
   404                 // when move a default folder
   253                 HbMessageBox::information( QString( hbTrId( "Could not move because the default folder %1 can not be deleted!" ).arg( errString ) ) );
   405                 FmDlgUtils::information( QString( hbTrId( "Could not move because the default folder %1 can not be deleted!" ).arg( errString ) ) );
   254                 return;
   406                 return;
   255             }
   407             }
   256             else {
   408             else {
   257                // when delete the default folder
   409                // when delete the default folder
   258                HbMessageBox::information( QString( hbTrId( "Could not remove the default folder %1 " ).arg( errString ) ) );
   410                FmDlgUtils::information( QString( hbTrId( "Could not remove the default folder %1 " ).arg( errString ) ) );
   259                return;
   411                return;
   260             }
   412             }
   261         }
   413         }
   262     }
   414     }
   263 
   415 
   264     switch( operationBase->operationType() )
   416     switch( operationBase->operationType() )
   265     {
   417     {
   266     case FmOperationService::EOperationTypeFormat:
   418     case FmOperationService::EOperationTypeFormat:
   267         HbMessageBox::information( QString( hbTrId("Format failed!")) );
   419         FmDlgUtils::information( QString( hbTrId("Format failed!")) );
   268         break;
   420         break;
   269     default:
   421     default:
   270         HbMessageBox::information( QString( hbTrId("Operation failed")) );
   422         FmDlgUtils::information( QString( hbTrId("Operation failed")) );
   271     }
   423     }
   272 
   424 
   273 }
   425 }
   274 
   426 
   275 void FmOperationResultProcesser::onNotifyCanceled( FmOperationBase* operationBase )
   427 /*
   276 {
   428  * Responds to waiting note's cancel signal.
   277     Q_UNUSED( operationBase );
   429  */
   278     cancelProgress();
       
   279     HbMessageBox::information( QString( hbTrId("Operation Canceled!") ) );
       
   280 }
       
   281 
       
   282 
       
   283 void FmOperationResultProcesser::onProgressCancelled()
   430 void FmOperationResultProcesser::onProgressCancelled()
   284 {
   431 {
   285     mOperationService->cancelOperation();
   432     mOperationService->cancelOperation();
   286 }
   433 }
   287 
   434 
   288 
   435 
   289 //
   436 /*
       
   437  * Shows the waiting dialog with 
       
   438  * \a title the title of the dialog.
       
   439  * \a cancelable whether it could be cancelled.
       
   440  */
   290 void FmOperationResultProcesser::showWaiting( QString title, bool cancelable )
   441 void FmOperationResultProcesser::showWaiting( QString title, bool cancelable )
   291 {
   442 {
   292     qDebug("show warning");
   443     qDebug("show warning");
   293     if( mNote ){
   444     if( mNote ){
   294         mNote->close();
   445         mNote->close();
   302 //        connect( mNote, SIGNAL( cancelled() ), this, SLOT(onProgressCancelled() ) );
   453 //        connect( mNote, SIGNAL( cancelled() ), this, SLOT(onProgressCancelled() ) );
   303 //    } else {
   454 //    } else {
   304 //        mNote->setProgressDialogType( HbProgressDialog::WaitNote );
   455 //        mNote->setProgressDialogType( HbProgressDialog::WaitNote );
   305 //    }
   456 //    }
   306     mNote->setText( title );
   457     mNote->setText( title );
   307     if( !cancelable )
   458     //KRAZY: ignore krazy warning because QAction must be used.
   308         mNote->primaryAction()->setDisabled( true );
   459     QList<QAction *> actionList = mNote->actions();
   309     else
   460     if (actionList.size() > 0) {        
   310         mNote->primaryAction()->setDisabled( false );
   461         QAction *cancelAction = actionList.at(0);
   311     mNote->exec();
   462         if (!cancelable) {
   312 
   463             cancelAction->setDisabled( true );
   313 }
   464         } else {
   314 
   465             cancelAction->setDisabled( false );
       
   466         }        
       
   467     } 
       
   468     mNote->open();
       
   469 
       
   470 }
       
   471 
       
   472 /*
       
   473  * Shows the preparing dialog with 
       
   474  * \a title the title of the dialog.
       
   475  * \a cancelable whether it could be cancelled.
       
   476  */
   315 void FmOperationResultProcesser::showPreparing( QString title, bool cancelable )
   477 void FmOperationResultProcesser::showPreparing( QString title, bool cancelable )
   316 {
   478 {
   317     qDebug("show preparing");
   479     qDebug("show preparing");
   318     
   480     
   319     if( mNote ){
   481     if( mNote ){
   331 //    }
   493 //    }
   332     mNote->setMinimum(0);
   494     mNote->setMinimum(0);
   333     mNote->setMaximum( 65535 );
   495     mNote->setMaximum( 65535 );
   334     mNote->setProgressValue( 0 );
   496     mNote->setProgressValue( 0 );
   335     mNote->setText( title );
   497     mNote->setText( title );
   336     if( !cancelable ){
   498     //KRAZY: ignore krazy warning because QAction must be used.
   337         mNote->primaryAction()->setDisabled( true );  
   499     QList<QAction *> actionList = mNote->actions();
   338     }
   500     if (actionList.size() > 0) {        
   339     else{
   501         QAction *cancelAction = actionList.at(0);
   340         mNote->primaryAction()->setDisabled( false );       
   502         if (!cancelable) {
   341     }
   503             cancelAction->setDisabled( true );
   342     mNote->exec();
   504         } else {
   343 }
   505             cancelAction->setDisabled( false );
   344 
   506         }        
       
   507     } 
       
   508     mNote->open();
       
   509 }
       
   510 
       
   511 /*
       
   512  * Shows the progress dialog with 
       
   513  * \a title the title of the dialog.
       
   514  * \a cancelable whether it could be cancelled.
       
   515  */
   345 void FmOperationResultProcesser::showProgress( QString title, bool cancelable, int maxValue )
   516 void FmOperationResultProcesser::showProgress( QString title, bool cancelable, int maxValue )
   346 {
   517 {
   347     qDebug("show progress");
   518     qDebug("show progress");
   348     
   519     
   349     if( mNote ){
   520     if( mNote ){
   363 
   534 
   364     mNote->setMinimum(0);
   535     mNote->setMinimum(0);
   365     mNote->setMaximum( maxValue );
   536     mNote->setMaximum( maxValue );
   366 
   537 
   367     mNote->setProgressValue( 0 );
   538     mNote->setProgressValue( 0 );
   368 
   539     //KRAZY: ignore krazy warning because QAction must be used.
   369     if( !cancelable ){
   540     QList<QAction *> actionList = mNote->actions();
   370         mNote->primaryAction()->setDisabled( true );
   541     if (actionList.size() > 0) {        
   371     }
   542         QAction *cancelAction = actionList.at(0);
   372     else{
   543         if(!cancelable) {
   373         mNote->primaryAction()->setDisabled( false );
   544             cancelAction->setDisabled( true );
   374     }
   545         } else {
   375 
   546             cancelAction->setDisabled( false );
   376     mNote->exec();
   547         }        
   377 }
   548     } 
   378 
   549     mNote->open();
       
   550 }
       
   551 
       
   552 /*
       
   553  * Sets the current progress value to be \a value 
       
   554  */
   379 void FmOperationResultProcesser::setProgress( int value )
   555 void FmOperationResultProcesser::setProgress( int value )
   380 {
   556 {
   381     qDebug("set progress");
   557     qDebug("set progress");
   382     if( mNote )
   558     if( mNote )
   383         mNote->setProgressValue( value );
   559         mNote->setProgressValue( value );
   384 }
   560 }
       
   561 
       
   562 /*
       
   563  * Finishes the progress.
       
   564  */
   385 void FmOperationResultProcesser::finishProgress()
   565 void FmOperationResultProcesser::finishProgress()
   386 {
   566 {
   387     qDebug("finish progress");
   567     qDebug("finish progress");
   388     if( mNote ) {
   568     if( mNote ) {
   389         mNote->close();
   569         mNote->close();
   390     }
   570     }
   391 }
   571 }
   392 
   572 
       
   573 /*
       
   574  * Cancels the progress bar.
       
   575  */
   393 void FmOperationResultProcesser::cancelProgress()
   576 void FmOperationResultProcesser::cancelProgress()
   394 {
   577 {
   395     qDebug("cancel progress");
   578     qDebug("cancel progress");
   396     if( mNote ) {
   579     if( mNote ) {
   397         mNote->close();
   580         mNote->close();
   398     }
   581     }
   399 }
   582 }
   400 
   583 
       
   584 /*
       
   585  * Fails and closes the progress bar.
       
   586  */
   401 void FmOperationResultProcesser::failAndCloseProgress()
   587 void FmOperationResultProcesser::failAndCloseProgress()
   402 {
   588 {
   403     qDebug("fail progress");
   589     qDebug("fail progress");
   404     if( mNote ) {
   590     if( mNote ) {
   405         mNote->close();
   591         mNote->close();