37 |
38 |
38 void FmOperationResultProcesser::onAskForRename( |
39 void FmOperationResultProcesser::onAskForRename( |
39 FmOperationBase* operationBase, const QString &srcFile, QString *destFile ) |
40 FmOperationBase* operationBase, const QString &srcFile, QString *destFile ) |
40 { |
41 { |
41 Q_UNUSED( operationBase ); |
42 Q_UNUSED( operationBase ); |
|
43 int maxFileNameLength = FmUtils::getMaxFileNameLength(); |
42 |
44 |
43 QString questionText = QString( "file " ) + |
45 QString questionText = QString( "file " ) + |
44 srcFile + QString( " already exist, please rename:" ); |
46 srcFile + QString( " already exist, please rename:" ); |
45 QString value; |
47 QString value; |
46 FmDlgUtils::showTextQuery( questionText, value, true ); |
48 QFileInfo fileInfo(srcFile); |
47 *destFile = value; |
49 bool ret = FmDlgUtils::showTextQuery( questionText, value, true, maxFileNameLength, QString(), false ); |
|
50 while ( ret ) { |
|
51 // remove whitespace from the start and the end. |
|
52 value = value.trimmed(); |
|
53 QString newTargetPath = FmUtils::fillPathWithSplash( |
|
54 fileInfo.absolutePath() ) + value; |
|
55 QString errString; |
|
56 // check if name/path is available for use. |
|
57 if( !FmUtils::checkNewFolderOrFile( newTargetPath, errString ) ) { |
|
58 FmDlgUtils::information( errString ); |
|
59 ret = FmDlgUtils::showTextQuery( questionText, value, true, maxFileNameLength, QString(), false ); |
|
60 continue; |
|
61 } else { |
|
62 break; |
|
63 } |
|
64 } |
|
65 if( ret ) { |
|
66 *destFile = value; |
|
67 } |
48 } |
68 } |
49 |
69 |
50 void FmOperationResultProcesser::onAskForReplace( |
70 void FmOperationResultProcesser::onAskForReplace( |
51 FmOperationBase* operationBase, const QString &srcFile, const QString &destFile, bool *isAccepted ) |
71 FmOperationBase* operationBase, const QString &srcFile, const QString &destFile, bool *isAccepted ) |
52 { |
72 { |
53 Q_UNUSED( operationBase ); |
73 Q_UNUSED( operationBase ); |
54 Q_UNUSED( destFile ); |
74 Q_UNUSED( destFile ); |
55 |
75 |
56 QString questionText = QString( "file " ) + |
76 QString questionText = QString( "file " ) + |
57 srcFile + QString( " already exist, replace it?" ); |
77 srcFile + QString( " already exist, replace it?" ); |
58 if( HbMessageBox::question( questionText ) ) { |
78 if( FmDlgUtils::question( questionText ) ) { |
59 *isAccepted = true; |
79 *isAccepted = true; |
60 } else { |
80 } else { |
61 *isAccepted = false; |
81 *isAccepted = false; |
62 } |
82 } |
63 } |
83 } |
64 |
84 |
|
85 void FmOperationResultProcesser::onShowNote( FmOperationBase* operationBase, const char *noteString ) |
|
86 { |
|
87 FmDlgUtils::information(hbTrId(noteString)); |
|
88 } |
|
89 |
65 void FmOperationResultProcesser::onNotifyWaiting( FmOperationBase* operationBase, bool cancelable ) |
90 void FmOperationResultProcesser::onNotifyWaiting( FmOperationBase* operationBase, bool cancelable ) |
66 { |
91 { |
67 QString title = tr("Operation"); |
92 QString title = hbTrId("Operation"); |
68 switch( operationBase->operationType() ) |
93 switch( operationBase->operationType() ) |
69 { |
94 { |
70 case FmOperationService::EOperationTypeBackup: |
95 case FmOperationService::EOperationTypeBackup: |
71 title = hbTrId("backuping"); |
96 title = hbTrId("backuping"); |
72 break; |
97 break; |
177 FmUtils::getDriveLetterFromPath( paramFolderDetails->folderPath() ) ); |
202 FmUtils::getDriveLetterFromPath( paramFolderDetails->folderPath() ) ); |
178 break; |
203 break; |
179 } |
204 } |
180 case FmOperationService::EOperationTypeFormat: |
205 case FmOperationService::EOperationTypeFormat: |
181 { |
206 { |
182 HbMessageBox::information( QString( hbTrId("Format succeed!")) ); |
207 FmDlgUtils::information( QString( hbTrId("Format succeed!")) ); |
183 FmOperationFormat *paramFormat = static_cast<FmOperationFormat*>( operationBase ); |
208 FmOperationFormat *paramFormat = static_cast<FmOperationFormat*>( operationBase ); |
184 QString title( tr( "Drive name ") ); |
209 QString title( hbTrId( "Drive name ") ); |
185 QString driveName( paramFormat->driverName() ); |
210 QString driveName( paramFormat->driverName() ); |
186 QString volumeName; |
211 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( driveName ); |
187 while( FmDlgUtils::showTextQuery( title, volumeName, false, FmMaxLengthofDriveName ) ){ |
212 FmDriverInfo::DriveState state = driverInfo.driveState(); |
|
213 if( ( state & FmDriverInfo::EDriveAvailable ) && |
|
214 ( state & FmDriverInfo::EDriveRemovable ) && |
|
215 !( state & FmDriverInfo::EDriveMassStorage ) ) { |
|
216 QString volumeName; |
|
217 while( FmDlgUtils::showTextQuery( title, volumeName, false, FmMaxLengthofDriveName ) ){ |
188 int err = FmUtils::renameDrive( driveName, volumeName ); |
218 int err = FmUtils::renameDrive( driveName, volumeName ); |
189 if ( err == FmErrNone ){ |
219 if ( err == FmErrNone ){ |
190 HbMessageBox::information( hbTrId( "The name has been changed!" ) ); |
220 FmDlgUtils::information( hbTrId( "The name has been changed!" ) ); |
191 mOperationService->on_operationThread_refreshModel( driveName ); |
221 mOperationService->on_operationThread_refreshModel( driveName ); |
192 break; |
222 break; |
193 } else if( err == FmErrBadName ) { |
223 } else if( err == FmErrBadName ) { |
194 HbMessageBox::information( hbTrId( "Illegal characters! Use only letters and numbers." ) ); |
224 FmDlgUtils::information( hbTrId( "Illegal characters! Use only letters and numbers." ) ); |
195 } else{ |
225 } else{ |
196 HbMessageBox::information( hbTrId( "Error occurred, operation cancelled!" ) ); |
226 FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) ); |
197 break; |
227 break; |
198 } |
228 } |
199 } |
229 } |
|
230 } |
200 break; |
231 break; |
201 } |
232 } |
202 case FmOperationService::EOperationTypeBackup: |
233 case FmOperationService::EOperationTypeBackup: |
203 { |
234 { |
204 HbMessageBox::information( QString( hbTrId("Backup succeed!")) ); |
235 FmDlgUtils::information( QString( hbTrId("Backup succeed!")) ); |
205 break; |
236 break; |
206 } |
237 } |
207 case FmOperationService::EOperationTypeRestore: |
238 case FmOperationService::EOperationTypeRestore: |
208 { |
239 { |
209 HbMessageBox::information( QString( hbTrId("Restore succeed!")) ); |
240 FmDlgUtils::information( QString( hbTrId("Restore succeed!")) ); |
210 break; |
241 break; |
211 } |
242 } |
212 default: |
243 default: |
213 HbMessageBox::information( QString( hbTrId("Operation finished")) ); |
244 FmDlgUtils::information( QString( hbTrId("Operation finished")) ); |
214 |
245 |
215 } |
246 } |
216 } |
247 } |
217 void FmOperationResultProcesser::onNotifyError( FmOperationBase* operationBase, int error, QString errString ) |
248 void FmOperationResultProcesser::onNotifyError( FmOperationBase* operationBase, int error, QString errString ) |
218 { |
249 { |
219 Q_UNUSED( errString ); |
250 Q_UNUSED( errString ); |
220 failAndCloseProgress(); |
251 failAndCloseProgress(); |
221 switch( error ) |
252 switch( error ) |
222 { |
253 { |
223 case FmErrAlreadyStarted: |
254 case FmErrAlreadyStarted: |
224 HbMessageBox::information( QString( hbTrId("Operation already started!")) ); |
255 FmDlgUtils::information( QString( hbTrId("Operation already started!")) ); |
|
256 return; |
|
257 case FmErrLocked: |
|
258 FmDlgUtils::information( QString( hbTrId("Operation failed because drive is locked!")) ); |
|
259 return; |
|
260 case FmErrPathNotFound: |
|
261 FmDlgUtils::information( QString( hbTrId("Operation failed because can not find target path or drive is not available!") ) ); |
|
262 return; |
|
263 case FmErrCorrupt: |
|
264 FmDlgUtils::information( QString( hbTrId("Operation failed because target media is corrupted!") ) ); |
|
265 return; |
|
266 case FmErrNotReady: // Caused when MMC & OTG is not inserted when start backup |
|
267 FmDlgUtils::information( QString( hbTrId("Operation failed because device is not ready!") ) ); |
|
268 return; |
|
269 case FmErrDisMounted: // Caused by eject MMC when preparing backup |
|
270 FmDlgUtils::information( QString( hbTrId("Operation failed because device has been removed!") ) ); |
225 return; |
271 return; |
226 case FmErrDiskFull: |
272 case FmErrDiskFull: |
227 HbMessageBox::information( QString( hbTrId("Not enough space. Operation cancelled.!")) ); |
273 FmDlgUtils::information( QString( hbTrId("Not enough space. Operation cancelled!")) ); |
228 return; |
274 return; |
229 case FmErrCopyDestToSubFolderInSrc: |
275 case FmErrCopyDestToSubFolderInSrc: |
230 HbMessageBox::information( QString( hbTrId("Can not copy to sub folder!")) ); |
276 FmDlgUtils::information( QString( hbTrId("Can not copy to sub folder!")) ); |
231 return; |
277 return; |
232 case FmErrMoveDestToSubFolderInSrc: |
278 case FmErrMoveDestToSubFolderInSrc: |
233 HbMessageBox::information( QString( hbTrId("Can not move to sub folder!")) ); |
279 FmDlgUtils::information( QString( hbTrId("Can not move to sub folder!")) ); |
234 return; |
280 return; |
235 case FmErrCannotRemove:{ |
281 case FmErrCannotRemove:{ |
236 if( operationBase->operationType() == FmOperationService::EOperationTypeCopy ) { |
282 if( operationBase->operationType() == FmOperationService::EOperationTypeCopy ) { |
237 // when copy a file/dir to same name destination, and delete dest fail, this error will occur |
283 // 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 ) ) ); |
284 FmDlgUtils::information( QString( hbTrId( "Can not copy because %1 can not be deleted!" ).arg( errString ) ) ); |
239 return; |
285 return; |
240 } |
286 } |
241 else if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) { |
287 else if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) { |
242 // when move a file/dir to same name destination, and delete dest fail, this error will occur |
288 // 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 ) ) ); |
289 FmDlgUtils::information( QString( hbTrId( "Can not move because %1 can not be deleted!" ).arg( errString ) ) ); |
244 return; |
290 return; |
245 } |
291 } |
246 // when delete file/dir fail, this error will occur |
292 // when delete file/dir fail, this error will occur |
247 HbMessageBox::information( QString( hbTrId( "Can not delete %1!" ).arg( errString ) ) ); |
293 FmDlgUtils::information( QString( hbTrId( "Can not delete %1!" ).arg( errString ) ) ); |
248 return; |
294 return; |
249 } |
295 } |
250 case FmErrRemoveDefaultFolder:{ |
296 case FmErrRemoveDefaultFolder:{ |
251 if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) { |
297 if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) { |
252 // when move a default folder |
298 // when move a default folder |
253 HbMessageBox::information( QString( hbTrId( "Could not move because the default folder %1 can not be deleted!" ).arg( errString ) ) ); |
299 FmDlgUtils::information( QString( hbTrId( "Could not move because the default folder %1 can not be deleted!" ).arg( errString ) ) ); |
254 return; |
300 return; |
255 } |
301 } |
256 else { |
302 else { |
257 // when delete the default folder |
303 // when delete the default folder |
258 HbMessageBox::information( QString( hbTrId( "Could not remove the default folder %1 " ).arg( errString ) ) ); |
304 FmDlgUtils::information( QString( hbTrId( "Could not remove the default folder %1 " ).arg( errString ) ) ); |
259 return; |
305 return; |
260 } |
306 } |
261 } |
307 } |
262 } |
308 } |
263 |
309 |
264 switch( operationBase->operationType() ) |
310 switch( operationBase->operationType() ) |
265 { |
311 { |
266 case FmOperationService::EOperationTypeFormat: |
312 case FmOperationService::EOperationTypeFormat: |
267 HbMessageBox::information( QString( hbTrId("Format failed!")) ); |
313 FmDlgUtils::information( QString( hbTrId("Format failed!")) ); |
268 break; |
314 break; |
269 default: |
315 default: |
270 HbMessageBox::information( QString( hbTrId("Operation failed")) ); |
316 FmDlgUtils::information( QString( hbTrId("Operation failed")) ); |
271 } |
317 } |
272 |
318 |
273 } |
319 } |
274 |
320 |
275 void FmOperationResultProcesser::onNotifyCanceled( FmOperationBase* operationBase ) |
321 void FmOperationResultProcesser::onNotifyCanceled( FmOperationBase* operationBase ) |
276 { |
322 { |
277 Q_UNUSED( operationBase ); |
323 Q_UNUSED( operationBase ); |
278 cancelProgress(); |
324 cancelProgress(); |
279 HbMessageBox::information( QString( hbTrId("Operation Canceled!") ) ); |
325 FmDlgUtils::information( QString( hbTrId("Operation Canceled!") ) ); |
280 } |
326 } |
281 |
327 |
282 |
328 |
283 void FmOperationResultProcesser::onProgressCancelled() |
329 void FmOperationResultProcesser::onProgressCancelled() |
284 { |
330 { |