93 ret = FmErrCannotRemove; |
93 ret = FmErrCannotRemove; |
94 break; |
94 break; |
95 } |
95 } |
96 destFi.setFile( destFi.absoluteFilePath() ); |
96 destFi.setFile( destFi.absoluteFilePath() ); |
97 } else { |
97 } else { |
98 emit askForRename( destFi.absoluteFilePath(), &newName ); |
98 queryForRename( destFi.absoluteFilePath(), &newName ); |
99 if( newName.isEmpty() ) { |
99 if( newName.isEmpty() ) { |
100 ret = FmErrCancel; |
100 ret = FmErrCancel; |
101 break; |
101 break; |
102 } |
102 } |
103 QString targetName = mTargetPath + newName; |
103 QString targetName = mTargetPath + newName; |
104 destFi.setFile( targetName ); |
104 destFi.setFile( targetName ); |
105 } |
105 } |
106 } else{ |
106 } else{ |
107 // destination is dir |
107 // destination is dir |
108 emit askForRename( destFi.absoluteFilePath(), &newName ); |
108 queryForRename( destFi.absoluteFilePath(), &newName ); |
109 if( newName.isEmpty() ) { |
109 if( newName.isEmpty() ) { |
110 ret = FmErrCancel; |
110 ret = FmErrCancel; |
111 break; |
111 break; |
112 } |
112 } |
113 QString targetName = mTargetPath + newName; |
113 QString targetName = mTargetPath + newName; |
153 } |
153 } |
154 if( !QFile::remove( source ) ) { |
154 if( !QFile::remove( source ) ) { |
155 *mErrString = source; |
155 *mErrString = source; |
156 ret = FmErrCannotRemove; |
156 ret = FmErrCannotRemove; |
157 } |
157 } |
158 IncreaseProgress( fileSize ); |
158 increaseProgress( fileSize ); |
159 } else if (fi.isDir()) { |
159 } else if (fi.isDir()) { |
160 if( FmUtils::isDefaultFolder( source ) ){ |
160 if( FmUtils::isDefaultFolder( source ) ){ |
161 ret = FmErrRemoveDefaultFolder; |
161 ret = FmErrRemoveDefaultFolder; |
162 } |
162 } |
163 else{ |
163 else{ |
178 |
178 |
179 return ret; |
179 return ret; |
180 } |
180 } |
181 int FmOperationMove::moveDirInsideContent( const QString &srcPath, const QString &destPath ) |
181 int FmOperationMove::moveDirInsideContent( const QString &srcPath, const QString &destPath ) |
182 { |
182 { |
183 if( destPath.contains( srcPath, Qt::CaseInsensitive ) ) { |
183 QFileInfo srcInfo( srcPath ); |
|
184 QFileInfo destInfo( destPath ); |
|
185 |
|
186 QString destUpPath = FmUtils::fillPathWithSplash( destInfo.absolutePath() ); |
|
187 if( destUpPath.contains( srcPath, Qt::CaseInsensitive ) ) { |
184 *mErrString = destPath; |
188 *mErrString = destPath; |
185 return FmErrMoveDestToSubFolderInSrc; |
189 return FmErrMoveDestToSubFolderInSrc; |
186 } |
190 } |
187 |
191 |
188 QFileInfo srcInfo( srcPath ); |
|
189 if( !srcInfo.isDir() || !srcInfo.exists() ) { |
192 if( !srcInfo.isDir() || !srcInfo.exists() ) { |
190 *mErrString = srcPath; |
193 *mErrString = srcPath; |
191 return FmErrSrcPathDoNotExist; |
194 return FmErrSrcPathDoNotExist; |
192 } |
195 } |
193 |
196 |
194 QFileInfo destInfo( destPath ); |
|
195 if( !destInfo.exists() ) { |
197 if( !destInfo.exists() ) { |
196 if( !destInfo.dir().mkdir( destInfo.absoluteFilePath() ) ) { |
198 if( !destInfo.dir().mkdir( destInfo.absoluteFilePath() ) ) { |
197 *mErrString = destPath; |
199 *mErrString = destPath; |
198 return FmErrCannotMakeDir; |
200 return FmErrCannotMakeDir; |
199 } |
201 } |
221 } |
223 } |
222 if( !QFile::remove( fileInfo.absoluteFilePath() ) ) { |
224 if( !QFile::remove( fileInfo.absoluteFilePath() ) ) { |
223 *mErrString = fileInfo.absoluteFilePath(); |
225 *mErrString = fileInfo.absoluteFilePath(); |
224 return FmErrCannotRemove; |
226 return FmErrCannotRemove; |
225 } |
227 } |
226 IncreaseProgress( fileSize ); |
228 increaseProgress( fileSize ); |
227 } else if( fileInfo.isDir() ) { |
229 } else if( fileInfo.isDir() ) { |
228 //makedir |
230 //makedir |
229 QString newDirPath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() ); |
231 QString newDirPath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() ); |
230 if( !QDir( newDirPath ).exists() && !QDir( destPath ).mkdir( newDirPath ) ) { |
232 if( !QDir( newDirPath ).exists() && !QDir( destPath ).mkdir( newDirPath ) ) { |
231 *mErrString = newDirPath; |
233 *mErrString = newDirPath; |