/* В зависимоти от типа элемента fileInfo, копирует файл или создает директорию. Возможно возбуждение исключения CopyExcepion. progressValue порядковый номер элемента для копирования */ void CopyJob::files_copy(int id, const CopyInfo& fileInfo, int progressValue) { QDir destDir; QString sourcePathName = fileInfo.sSourcePath + fileInfo.sFileName; QString destPathName; emit startCopyFile(id, sourcePathName, fileInfo.size); switch ( fileInfo.type ) { case CopyInfo::FILE: destPathName = fileInfo.sDestPath + fileInfo.sFileName; copy(id, sourcePathName, destPathName); break; case CopyInfo::DIR: destDir.setPath(fileInfo.sDestPath); CopyExcepion::throwIf(!destDir.exists(), DestDirNotExists, destDir.absolutePath()); CopyExcepion::throwIf(!destDir.mkdir(fileInfo.sFileName), MakeDirError, fileInfo.sFileName); break; default: throw CopyExcepion(UnknownFileType, "Unknown file type"); } emit endingCopyFile(id, progressValue); }
void MainWindow::timeOut() { ui->statusBar->showMessage("开始同步..."); timer->stop(); disconnect(timer,SIGNAL(timeout()),this,SLOT(timeOut())); timer = NULL; for(auto file : fileQueue) startCopyFile(file); for(auto directory : directoryQueue) startCopyDirectory(directory); if(click == true) { if(!autoSyn) enableInput(true); click = false; } }