diff options
Diffstat (limited to 'plugins/CopyEngine/Ultracopier/ListThread.cpp')
-rw-r--r-- | plugins/CopyEngine/Ultracopier/ListThread.cpp | 617 |
1 files changed, 319 insertions, 298 deletions
diff --git a/plugins/CopyEngine/Ultracopier/ListThread.cpp b/plugins/CopyEngine/Ultracopier/ListThread.cpp index 48e06db..4b9cde5 100644 --- a/plugins/CopyEngine/Ultracopier/ListThread.cpp +++ b/plugins/CopyEngine/Ultracopier/ListThread.cpp @@ -1,6 +1,7 @@ #include "ListThread.h" #include <QStorageInfo> #include <QMutexLocker> +#include "../../../cpp11addition.h" ListThread::ListThread(FacilityInterface * facilityInterface) { @@ -78,12 +79,12 @@ void ListThread::transferInodeIsClosed() { numberOfInodeOperation--; #ifdef ULTRACOPIER_PLUGIN_DEBUG_SCHEDULER - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("numberOfInodeOperation: %1").arg(numberOfInodeOperation)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"numberOfInodeOperation: "+std::to_string(numberOfInodeOperation)); #endif TransferThread *temp_transfer_thread=qobject_cast<TransferThread *>(QObject::sender()); if(temp_transfer_thread==NULL) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("transfer thread not located!")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"transfer thread not located!"); return; } bool isFound=false; @@ -92,7 +93,7 @@ void ListThread::transferInodeIsClosed() #endif if(temp_transfer_thread->getStat()!=TransferStat_Idle) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("transfer thread not idle!")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"transfer thread not idle!"); return; } int int_for_internal_loop=0; @@ -101,17 +102,17 @@ void ListThread::transferInodeIsClosed() { if(actionToDoListTransfer.at(int_for_internal_loop).id==temp_transfer_thread->transferId) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[%1] have finish, put at idle; for id: %2").arg(int_for_internal_loop).arg(temp_transfer_thread->transferId)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[%1] have finish, put at idle; for id: %2").arg(int_for_internal_loop).arg(temp_transfer_thread->transferId).toStdString()); Ultracopier::ReturnActionOnCopyList newAction; newAction.type=Ultracopier::RemoveItem; newAction.userAction.moveAt=0; newAction.addAction=actionToDoTransferToItemOfCopyList(actionToDoListTransfer.at(int_for_internal_loop)); newAction.userAction.position=int_for_internal_loop; - actionDone << newAction; + actionDone.push_back(newAction); /// \todo check if item is at the right thread - actionToDoListTransfer.removeAt(int_for_internal_loop); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, actionToDoListInode: %2, actionToDoListInode_afterTheTransfer: %3").arg(actionToDoListTransfer.size()).arg(actionToDoListInode.size()).arg(actionToDoListInode_afterTheTransfer.size())); - if(actionToDoListTransfer.isEmpty() && actionToDoListInode.isEmpty() && actionToDoListInode_afterTheTransfer.isEmpty()) + actionToDoListTransfer.erase(actionToDoListTransfer.cbegin()+int_for_internal_loop); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, actionToDoListInode: %2, actionToDoListInode_afterTheTransfer: %3").arg(actionToDoListTransfer.size()).arg(actionToDoListInode.size()).arg(actionToDoListInode_afterTheTransfer.size()).toStdString()); + if(actionToDoListTransfer.empty() && actionToDoListInode.empty() && actionToDoListInode_afterTheTransfer.empty()) updateTheStatus(); //add the current size of file, to general size because it's finish @@ -119,7 +120,7 @@ void ListThread::transferInodeIsClosed() if(copiedSize>(qint64)temp_transfer_thread->transferSize) { oversize=copiedSize-temp_transfer_thread->transferSize; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("add oversize of: %1").arg(oversize)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"add oversize of: "+std::to_string(oversize)); bytesToTransfer+=oversize; bytesTransfered+=oversize; } @@ -127,7 +128,7 @@ void ListThread::transferInodeIsClosed() if(temp_transfer_thread->haveStartTime) { - timeToTransfer << QPair<quint64,quint32>(temp_transfer_thread->transferSize,temp_transfer_thread->startTransferTime.elapsed()); + timeToTransfer.push_back(std::pair<uint64_t,uint32_t>(temp_transfer_thread->transferSize,temp_transfer_thread->startTransferTime.elapsed())); temp_transfer_thread->haveStartTime=false; } temp_transfer_thread->transferId=0; @@ -136,10 +137,10 @@ void ListThread::transferInodeIsClosed() countLocalParse++; #endif isFound=true; - if(actionToDoListTransfer.isEmpty()) + if(actionToDoListTransfer.empty()) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"actionToDoListTransfer==0"); - actionToDoListInode << actionToDoListInode_afterTheTransfer; + actionToDoListInode.insert(actionToDoListInode.cbegin(),actionToDoListInode_afterTheTransfer.cbegin(),actionToDoListInode_afterTheTransfer.cend()); actionToDoListInode_afterTheTransfer.clear(); doNewActions_inode_manipulation(); } @@ -151,14 +152,14 @@ void ListThread::transferInodeIsClosed() deleteTransferThread(); else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("unable to found item into the todo list, id: %1, index: %2").arg(temp_transfer_thread->transferId).arg(int_for_internal_loop)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("unable to found item into the todo list, id: %1, index: %2").arg(temp_transfer_thread->transferId).arg(int_for_internal_loop).toStdString()); temp_transfer_thread->transferId=0; temp_transfer_thread->transferSize=0; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("countLocalParse: %1, actionToDoList.size(): %2").arg(countLocalParse).arg(actionToDoListTransfer.size())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("countLocalParse: %1, actionToDoList.size(): %2").arg(countLocalParse).arg(actionToDoListTransfer.size()).toStdString()); #ifdef ULTRACOPIER_PLUGIN_DEBUG if(countLocalParse!=1) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("countLocalParse != 1")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"countLocalParse != 1"); #endif doNewActions_inode_manipulation(); } @@ -170,29 +171,30 @@ void ListThread::transferPutAtBottom() TransferThread *transfer=qobject_cast<TransferThread *>(QObject::sender()); if(transfer==NULL) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("transfer thread not located!")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"transfer thread not located!"); return; } bool isFound=false; #ifdef ULTRACOPIER_PLUGIN_DEBUG int countLocalParse=0; #endif - int indexAction=0; + unsigned int indexAction=0; while(indexAction<actionToDoListTransfer.size()) { if(actionToDoListTransfer.at(indexAction).id==transfer->transferId) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("Put at the end: %1").arg(transfer->transferId)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Put at the end: "+std::to_string(transfer->transferId)); //push for interface at the end Ultracopier::ReturnActionOnCopyList newAction; newAction.type=Ultracopier::MoveItem; newAction.addAction.id=transfer->transferId; newAction.userAction.position=actionToDoListTransfer.size()-1; - actionDone << newAction; + actionDone.push_back(newAction); //do the wait stat actionToDoListTransfer[indexAction].isRunning=false; //move at the end - actionToDoListTransfer.move(indexAction,actionToDoListTransfer.size()-1); + actionToDoListTransfer.push_back(actionToDoListTransfer.at(indexAction)); + actionToDoListTransfer.erase(actionToDoListTransfer.cbegin()+indexAction); //reset the thread list stat transfer->transferId=0; transfer->transferSize=0; @@ -206,14 +208,14 @@ void ListThread::transferPutAtBottom() } if(!isFound) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("unable to found item into the todo list, id: %1, index: %2").arg(transfer->transferId)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("unable to found item into the todo list, id: %1, index: %2").arg(transfer->transferId).toStdString()); transfer->transferId=0; transfer->transferSize=0; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("countLocalParse: %1").arg(countLocalParse)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"countLocalParse: "+std::to_string(countLocalParse)); #ifdef ULTRACOPIER_PLUGIN_DEBUG if(countLocalParse!=1) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("countLocalParse != 1")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"countLocalParse != 1"); #endif transfer->skip(); } @@ -272,7 +274,7 @@ void ListThread::setAutoStart(const bool autoStart) /// \brief set rsync void ListThread::setRsync(const bool rsync) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"set rsync: "+QString::number(rsync)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"set rsync: "+std::to_string(rsync)); this->rsync=rsync; int index=0; int loop_sub_size_transfer_thread_search=transferThreadList.size(); @@ -281,7 +283,7 @@ void ListThread::setRsync(const bool rsync) transferThreadList.at(index)->setRsync(rsync); index++; } - for(int i=0;i<scanFileOrFolderThreadsPool.size();i++) + for(unsigned int i=0;i<scanFileOrFolderThreadsPool.size();i++) scanFileOrFolderThreadsPool.at(i)->setRsync(rsync); } #endif @@ -290,7 +292,7 @@ void ListThread::setRsync(const bool rsync) void ListThread::setCheckDestinationFolderExists(const bool checkDestinationFolderExists) { this->checkDestinationFolderExists=checkDestinationFolderExists; - for(int i=0;i<scanFileOrFolderThreadsPool.size();i++) + for(unsigned int i=0;i<scanFileOrFolderThreadsPool.size();i++) scanFileOrFolderThreadsPool.at(i)->setCheckDestinationFolderExists(checkDestinationFolderExists && alwaysDoThisActionForFolderExists!=FolderExists_Merge); } @@ -302,7 +304,7 @@ void ListThread::fileTransfer(const QFileInfo &sourceFileInfo,const QFileInfo &d } // -> add thread safe, by Qt::BlockingQueuedConnection -bool ListThread::haveSameSource(const QStringList &sources) +bool ListThread::haveSameSource(const std::vector<std::string> &sources) { if(stopIt) return false; @@ -311,12 +313,12 @@ bool ListThread::haveSameSource(const QStringList &sources) ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"sourceDriveMultiple"); return false; } - if(sourceDrive.isEmpty()) + if(sourceDrive.empty()) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"sourceDrive.isEmpty()"); return true; } - int index=0; + unsigned int index=0; while(index<sources.size()) { if(driveManagement.getDrive(sources.at(index))!=sourceDrive) @@ -331,7 +333,7 @@ bool ListThread::haveSameSource(const QStringList &sources) } // -> add thread safe, by Qt::BlockingQueuedConnection -bool ListThread::haveSameDestination(const QString &destination) +bool ListThread::haveSameDestination(const std::string &destination) { if(stopIt) return false; @@ -340,7 +342,7 @@ bool ListThread::haveSameDestination(const QString &destination) ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destinationDriveMultiple"); return false; } - if(destinationDrive.isEmpty()) + if(destinationDrive.empty()) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destinationDrive.isEmpty()"); return true; @@ -355,52 +357,52 @@ bool ListThread::haveSameDestination(const QString &destination) } /// \return empty if multiple or no destination -QString ListThread::getUniqueDestinationFolder() const +std::string ListThread::getUniqueDestinationFolder() const { if(stopIt) - return QString(); + return std::string(); if(destinationFolderMultiple) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destinationDriveMultiple"); - return QString(); + return std::string(); } return destinationFolder; } ScanFileOrFolder * ListThread::newScanThread(Ultracopier::CopyMode mode) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start with: ")+QString::number(mode)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start with: "+std::to_string(mode)); //create new thread because is auto-detroyed - scanFileOrFolderThreadsPool << new ScanFileOrFolder(mode); - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::finishedTheListing, this,&ListThread::scanThreadHaveFinishSlot, Qt::QueuedConnection); - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::fileTransfer, this,&ListThread::fileTransfer, Qt::QueuedConnection); + scanFileOrFolderThreadsPool.push_back(new ScanFileOrFolder(mode)); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::finishedTheListing, this,&ListThread::scanThreadHaveFinishSlot, Qt::QueuedConnection); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::fileTransfer, this,&ListThread::fileTransfer, Qt::QueuedConnection); #ifdef ULTRACOPIER_PLUGIN_DEBUG - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::debugInformation, this,&ListThread::debugInformation, Qt::QueuedConnection); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::debugInformation, this,&ListThread::debugInformation, Qt::QueuedConnection); #endif - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::newFolderListing, this,&ListThread::newFolderListing); - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::addToMovePath, this,&ListThread::addToMovePath, Qt::QueuedConnection); - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::addToRealMove, this,&ListThread::addToRealMove, Qt::QueuedConnection); - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::addToMkPath, this,&ListThread::addToMkPath, Qt::QueuedConnection); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::newFolderListing, this,&ListThread::newFolderListing); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::addToMovePath, this,&ListThread::addToMovePath, Qt::QueuedConnection); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::addToRealMove, this,&ListThread::addToRealMove, Qt::QueuedConnection); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::addToMkPath, this,&ListThread::addToMkPath, Qt::QueuedConnection); #ifdef ULTRACOPIER_PLUGIN_RSYNC - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::addToRmForRsync, this,&ListThread::addToRmForRsync, Qt::QueuedConnection); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::addToRmForRsync, this,&ListThread::addToRmForRsync, Qt::QueuedConnection); #endif - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::errorOnFolder, this,&ListThread::errorOnFolder, Qt::QueuedConnection); - connect(scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::folderAlreadyExists, this,&ListThread::folderAlreadyExists, Qt::QueuedConnection); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::errorOnFolder, this,&ListThread::errorOnFolder, Qt::QueuedConnection); + connect(scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::folderAlreadyExists, this,&ListThread::folderAlreadyExists, Qt::QueuedConnection); - connect(this,&ListThread::send_updateMount, scanFileOrFolderThreadsPool.last(),&ScanFileOrFolder::set_updateMount, Qt::QueuedConnection); + connect(this,&ListThread::send_updateMount, scanFileOrFolderThreadsPool.back(),&ScanFileOrFolder::set_updateMount, Qt::QueuedConnection); - scanFileOrFolderThreadsPool.last()->setFilters(include,exclude); - scanFileOrFolderThreadsPool.last()->setCheckDestinationFolderExists(checkDestinationFolderExists && alwaysDoThisActionForFolderExists!=FolderExists_Merge); - scanFileOrFolderThreadsPool.last()->setMoveTheWholeFolder(moveTheWholeFolder); + scanFileOrFolderThreadsPool.back()->setFilters(include,exclude); + scanFileOrFolderThreadsPool.back()->setCheckDestinationFolderExists(checkDestinationFolderExists && alwaysDoThisActionForFolderExists!=FolderExists_Merge); + scanFileOrFolderThreadsPool.back()->setMoveTheWholeFolder(moveTheWholeFolder); #ifdef ULTRACOPIER_PLUGIN_RSYNC - scanFileOrFolderThreadsPool.last()->setRsync(rsync); + scanFileOrFolderThreadsPool.back()->setRsync(rsync); #endif if(scanFileOrFolderThreadsPool.size()==1) updateTheStatus(); - scanFileOrFolderThreadsPool.last()->setRenamingRules(firstRenamingRule,otherRenamingRule); - return scanFileOrFolderThreadsPool.last(); + scanFileOrFolderThreadsPool.back()->setRenamingRules(firstRenamingRule,otherRenamingRule); + return scanFileOrFolderThreadsPool.back(); } void ListThread::scanThreadHaveFinishSlot() @@ -410,7 +412,7 @@ void ListThread::scanThreadHaveFinishSlot() void ListThread::scanThreadHaveFinish(bool skipFirstRemove) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("listing thread have finish, skipFirstRemove: ")+QString::number(skipFirstRemove)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"listing thread have finish, skipFirstRemove: "+std::to_string(skipFirstRemove)); if(!skipFirstRemove) { ScanFileOrFolder * senderThread = qobject_cast<ScanFileOrFolder *>(QObject::sender()); @@ -418,21 +420,21 @@ void ListThread::scanThreadHaveFinish(bool skipFirstRemove) ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"sender pointer null (plugin copy engine)"); else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start the next thread, scanFileOrFolderThreadsPool.size(): ")+QString::number(scanFileOrFolderThreadsPool.size())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start the next thread, scanFileOrFolderThreadsPool.size(): "+std::to_string(scanFileOrFolderThreadsPool.size())); delete senderThread; - scanFileOrFolderThreadsPool.removeOne(senderThread); - if(scanFileOrFolderThreadsPool.isEmpty()) + vectorremoveOne(scanFileOrFolderThreadsPool,senderThread); + if(scanFileOrFolderThreadsPool.empty()) updateTheStatus(); } } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start the next thread, scanFileOrFolderThreadsPool.size(): ")+QString::number(scanFileOrFolderThreadsPool.size())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start the next thread, scanFileOrFolderThreadsPool.size(): "+std::to_string(scanFileOrFolderThreadsPool.size())); if(scanFileOrFolderThreadsPool.size()>0) { //then start the next listing threads - if(scanFileOrFolderThreadsPool.first()->isFinished()) + if(scanFileOrFolderThreadsPool.front()->isFinished()) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Start listing thread"); - scanFileOrFolderThreadsPool.first()->start(); + scanFileOrFolderThreadsPool.front()->start(); } else ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"The listing thread is already running"); @@ -472,9 +474,9 @@ void ListThread::startGeneralTransfer() } // -> add thread safe, by Qt::BlockingQueuedConnection -bool ListThread::newCopy(const QStringList &sources,const QString &destination) +bool ListThread::newCopy(const std::vector<std::string> &sources,const std::string &destination) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("start: ")+sources.join(";")+QStringLiteral(", destination: ")+destination); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start: "+stringimplode(sources,";")+", destination: "+destination); ScanFileOrFolder * scanFileOrFolderThread = newScanThread(Ultracopier::Copy); if(scanFileOrFolderThread==NULL) { @@ -488,7 +490,7 @@ bool ListThread::newCopy(const QStringList &sources,const QString &destination) } // -> add thread safe, by Qt::BlockingQueuedConnection -bool ListThread::newMove(const QStringList &sources,const QString &destination) +bool ListThread::newMove(const std::vector<std::string> &sources,const std::string &destination) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); ScanFileOrFolder * scanFileOrFolderThread = newScanThread(Ultracopier::Move); @@ -503,17 +505,17 @@ bool ListThread::newMove(const QStringList &sources,const QString &destination) return true; } -void ListThread::detectDrivesOfCurrentTransfer(const QStringList &sources,const QString &destination) +void ListThread::detectDrivesOfCurrentTransfer(const std::vector<std::string> &sources,const std::string &destination) { /* code to detect volume/mount point to group by windows */ if(!sourceDriveMultiple) { - int index=0; + unsigned int index=0; while(index<sources.size()) { - const QString &tempDrive=driveManagement.getDrive(sources.at(index)); + const std::string &tempDrive=driveManagement.getDrive(sources.at(index)); //if have not already source, set the source - if(sourceDrive.isEmpty()) + if(sourceDrive.empty()) sourceDrive=tempDrive; //if have previous source and the news source is not the same if(sourceDrive!=tempDrive) @@ -524,12 +526,12 @@ void ListThread::detectDrivesOfCurrentTransfer(const QStringList &sources,const index++; } } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source informations, sourceDrive: %1, sourceDriveMultiple: %2").arg(sourceDrive).arg(sourceDriveMultiple)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source informations, sourceDrive: %1, sourceDriveMultiple: %2").arg(QString::fromStdString(sourceDrive)).arg(sourceDriveMultiple).toStdString()); if(!destinationDriveMultiple) { - const QString &tempDrive=driveManagement.getDrive(destination); + const std::string &tempDrive=driveManagement.getDrive(destination); //if have not already destination, set the destination - if(destinationDrive.isEmpty()) + if(destinationDrive.empty()) destinationDrive=tempDrive; //if have previous destination and the news destination is not the same if(destinationDrive!=tempDrive) @@ -538,13 +540,13 @@ void ListThread::detectDrivesOfCurrentTransfer(const QStringList &sources,const if(!destinationFolderMultiple) { //if have not already destination, set the destination - if(destinationFolder.isEmpty()) + if(destinationFolder.empty()) destinationFolder=destination; //if have previous destination and the news destination is not the same if(destinationFolder!=destination) destinationFolderMultiple=true; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("destination informations, destinationDrive: %1, destinationDriveMultiple: %2").arg(destinationDrive).arg(destinationDriveMultiple)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("destination informations, destinationDrive: %1, destinationDriveMultiple: %2").arg(QString::fromStdString(destinationDrive)).arg(destinationDriveMultiple).toStdString()); } void ListThread::setCollisionAction(const FileExistsAction &alwaysDoThisActionForFileExists) @@ -578,7 +580,7 @@ bool ListThread::getReturnBoolToCopyEngine() const return returnBoolToCopyEngine; } -QPair<quint64,quint64> ListThread::getReturnPairQuint64ToCopyEngine() const +std::pair<quint64, quint64> ListThread::getReturnPairQuint64ToCopyEngine() const { return returnPairQuint64ToCopyEngine; } @@ -701,12 +703,12 @@ void ListThread::resume() emit isInPause(false); } -void ListThread::skip(const quint64 &id) +void ListThread::skip(const uint64_t &id) { skipInternal(id); } -bool ListThread::skipInternal(const quint64 &id) +bool ListThread::skipInternal(const uint64_t &id) { int index=0; int loop_sub_size_transfer_thread_search=transferThreadList.size(); @@ -714,7 +716,7 @@ bool ListThread::skipInternal(const quint64 &id) { if(transferThreadList.at(index)->transferId==id) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("skip one transfer: %1").arg(id)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"skip one transfer: "+std::to_string(id)); transferThreadList.at(index)->skip(); return true; } @@ -726,22 +728,22 @@ bool ListThread::skipInternal(const quint64 &id) { if(actionToDoListTransfer.at(int_for_internal_loop).id==id) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[%1] remove at not running, for id: %2").arg(int_for_internal_loop).arg(id)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[%1] remove at not running, for id: %2").arg(int_for_internal_loop).arg(id).toStdString()); Ultracopier::ReturnActionOnCopyList newAction; newAction.type=Ultracopier::RemoveItem; newAction.userAction.moveAt=1; newAction.addAction=actionToDoTransferToItemOfCopyList(actionToDoListTransfer.at(int_for_internal_loop)); newAction.userAction.position=int_for_internal_loop; - actionDone << newAction; - actionToDoListTransfer.removeAt(int_for_internal_loop); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, actionToDoListInode: %2, actionToDoListInode_afterTheTransfer: %3").arg(actionToDoListTransfer.size()).arg(actionToDoListInode.size()).arg(actionToDoListInode_afterTheTransfer.size())); - if(actionToDoListTransfer.isEmpty() && actionToDoListInode.isEmpty() && actionToDoListInode_afterTheTransfer.isEmpty()) + actionDone.push_back(newAction); + actionToDoListTransfer.erase(actionToDoListTransfer.cbegin()+int_for_internal_loop); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, actionToDoListInode: %2, actionToDoListInode_afterTheTransfer: %3").arg(actionToDoListTransfer.size()).arg(actionToDoListInode.size()).arg(actionToDoListInode_afterTheTransfer.size()).toStdString()); + if(actionToDoListTransfer.empty() && actionToDoListInode.empty() && actionToDoListInode_afterTheTransfer.empty()) updateTheStatus(); return true; } int_for_internal_loop++; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("skip transfer not found: %1").arg(id)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"skip transfer not found: "+std::to_string(id)); return false; } @@ -796,7 +798,7 @@ void ListThread::checkIfReadyToCancel() return; delete transferThreadList.at(index);//->deleteLayer(); transferThreadList[index]=NULL; - transferThreadList.removeAt(index); + transferThreadList.erase(transferThreadList.cbegin()+index); loop_size=transferThreadList.size(); index--; } @@ -814,10 +816,10 @@ void ListThread::checkIfReadyToCancel() } //speedLimitation in KB/s -bool ListThread::setSpeedLimitation(const qint64 &speedLimitation) +bool ListThread::setSpeedLimitation(const int64_t &speedLimitation) { #ifdef ULTRACOPIER_PLUGIN_SPEED_SUPPORT - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("maxSpeed in KB/s: ")+QString::number(speedLimitation)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"maxSpeed in KB/s: "+std::to_string(speedLimitation)); if(speedLimitation>1024*1024) { @@ -881,6 +883,7 @@ bool ListThread::setSpeedLimitation(const qint64 &speedLimitation) .arg(multiForBigSpeed) .arg(newInterval) .arg(maxSpeed) + .toStdString() ); clockForTheCopySpeed->setInterval(newInterval); @@ -933,7 +936,7 @@ void ListThread::updateTheStatus() updateTheStatus_action_in_progress=Ultracopier::Copying; else updateTheStatus_action_in_progress=Ultracopier::Idle; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("emit actionInProgess(")+QString::number(updateTheStatus_action_in_progress)+QStringLiteral(")")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"emit actionInProgess("+std::to_string(updateTheStatus_action_in_progress)+")"); emit actionInProgess(updateTheStatus_action_in_progress); } @@ -951,20 +954,20 @@ void ListThread::setAlwaysFileExistsAction(const FileExistsAction &alwaysDoThisA } //mk path to do -quint64 ListThread::addToMkPath(const QFileInfo& source,const QFileInfo& destination, const int& inode) +uint64_t ListThread::addToMkPath(const QFileInfo& source,const QFileInfo& destination, const int& inode) { if(stopIt) return 0; if(inode!=0 && (!keepDate && !doRightTransfer)) return 0; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1, destination: %2").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1, destination: %2").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath()).toStdString()); ActionToDoInode temp; temp.type = ActionType_MkPath; temp.id = generateIdNumber(); temp.source = source; temp.destination= destination; temp.isRunning = false; - actionToDoListInode << temp; + actionToDoListInode.push_back(temp); return temp.id; } @@ -973,7 +976,7 @@ void ListThread::addToMovePath(const QFileInfo& source, const QFileInfo &destina { if(stopIt) return; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1, destination: %2, inodeToRemove: %3").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath()).arg(inodeToRemove)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1, destination: %2, inodeToRemove: %3").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath()).arg(inodeToRemove).toStdString()); ActionToDoInode temp; temp.type = ActionType_MovePath; temp.id = generateIdNumber(); @@ -981,14 +984,14 @@ void ListThread::addToMovePath(const QFileInfo& source, const QFileInfo &destina temp.source = source; temp.destination= destination; temp.isRunning = false; - actionToDoListInode << temp; + actionToDoListInode.push_back(temp); } void ListThread::addToRealMove(const QFileInfo& source,const QFileInfo& destination) { if(stopIt) return; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1, destination: %2").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1, destination: %2").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath()).toStdString()); ActionToDoInode temp; temp.type = ActionType_RealMove; temp.id = generateIdNumber(); @@ -996,32 +999,32 @@ void ListThread::addToRealMove(const QFileInfo& source,const QFileInfo& destinat temp.source = source; temp.destination= destination; temp.isRunning = false; - actionToDoListInode << temp; + actionToDoListInode.push_back(temp); } #ifdef ULTRACOPIER_PLUGIN_RSYNC //rsync rm void ListThread::addToRmForRsync(const QFileInfo& destination) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"inode: "+destination.absoluteFilePath()); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"inode: "+destination.absoluteFilePath().toStdString()); ActionToDoInode temp; temp.type = ActionType_RmSync; temp.id = generateIdNumber(); temp.destination= destination; temp.isRunning = false; - actionToDoListInode << temp; + actionToDoListInode.push_back(temp); } #endif //send action done void ListThread::sendActionDone() { - if(!actionDone.isEmpty()) + if(!actionDone.empty()) { emit newActionOnList(actionDone); actionDone.clear(); } - if(!timeToTransfer.isEmpty()) + if(!timeToTransfer.empty()) { emit doneTime(timeToTransfer); timeToTransfer.clear(); @@ -1031,7 +1034,7 @@ void ListThread::sendActionDone() //send progression void ListThread::sendProgression() { - if(actionToDoListTransfer.isEmpty()) + if(actionToDoListTransfer.empty()) return; oversize=0; currentProgression=0; @@ -1060,12 +1063,12 @@ void ListThread::sendProgression() //the current size copied totalSize=temp_transfer_thread->transferSize+localOverSize; - QPair<quint64,quint64> progression=temp_transfer_thread->progression(); + std::pair<uint64_t,uint64_t> progression=temp_transfer_thread->progression(); tempItem.currentRead=progression.first; tempItem.currentWrite=progression.second; tempItem.id=temp_transfer_thread->transferId; tempItem.total=totalSize; - progressionList << tempItem; + progressionList.push_back(tempItem); //add the oversize to the general progression oversize+=localOverSize; @@ -1099,14 +1102,14 @@ void ListThread::syncTransferList_internal() Ultracopier::ReturnActionOnCopyList newAction; newAction.type = Ultracopier::PreOperation; newAction.addAction.id = item.id; - newAction.addAction.sourceFullPath = item.source.absoluteFilePath(); - newAction.addAction.sourceFileName = item.source.fileName(); - newAction.addAction.destinationFullPath = item.destination.absoluteFilePath(); - newAction.addAction.destinationFileName = item.destination.fileName(); + newAction.addAction.sourceFullPath = item.source.absoluteFilePath().toStdString(); + newAction.addAction.sourceFileName = item.source.fileName().toStdString(); + newAction.addAction.destinationFullPath = item.destination.absoluteFilePath().toStdString(); + newAction.addAction.destinationFileName = item.destination.fileName().toStdString(); newAction.addAction.size = item.size; newAction.addAction.mode = item.mode; - actionDone << newAction; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("id: %1, size: %2, name: %3, size2: %4").arg(item.id).arg(item.size).arg(item.source.absoluteFilePath()).arg(newAction.addAction.size)); + actionDone.push_back(newAction); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("id: %1, size: %2, name: %3, size2: %4").arg(item.id).arg(item.size).arg(item.source.absoluteFilePath()).arg(newAction.addAction.size).toStdString()); if(item.isRunning) { for(int_for_internal_loop=0; int_for_internal_loop<loop_sub_size; ++int_for_internal_loop) { @@ -1114,13 +1117,13 @@ void ListThread::syncTransferList_internal() Ultracopier::ReturnActionOnCopyList newAction; newAction.type = Ultracopier::PreOperation; newAction.addAction.id = item.id; - newAction.addAction.sourceFullPath = item.source.absoluteFilePath(); - newAction.addAction.sourceFileName = item.source.fileName(); - newAction.addAction.destinationFullPath = item.destination.absoluteFilePath(); - newAction.addAction.destinationFileName = item.destination.fileName(); + newAction.addAction.sourceFullPath = item.source.absoluteFilePath().toStdString(); + newAction.addAction.sourceFileName = item.source.fileName().toStdString(); + newAction.addAction.destinationFullPath = item.destination.absoluteFilePath().toStdString(); + newAction.addAction.destinationFileName = item.destination.fileName().toStdString(); newAction.addAction.size = item.size; newAction.addAction.mode = item.mode; - actionDone << newAction; + actionDone.push_back(newAction); if(transferThread->getStat()!=TransferStat_PreOperation) { Ultracopier::ReturnActionOnCopyList newAction; @@ -1139,7 +1142,7 @@ void ListThread::syncTransferList_internal() break; } newAction.addAction.id = item.id; - actionDone << newAction; + actionDone.push_back(newAction); } } } @@ -1147,7 +1150,7 @@ void ListThread::syncTransferList_internal() } //add file transfer to do -quint64 ListThread::addToTransfer(const QFileInfo& source,const QFileInfo& destination,const Ultracopier::CopyMode& mode) +uint64_t ListThread::addToTransfer(const QFileInfo& source,const QFileInfo& destination,const Ultracopier::CopyMode& mode) { if(stopIt) return 0; @@ -1156,20 +1159,20 @@ quint64 ListThread::addToTransfer(const QFileInfo& source,const QFileInfo& desti quint64 size=0; if(!source.isSymLink()) size=source.size(); - const QString &drive=driveManagement.getDrive(destination.absoluteFilePath()); - if(drive.isEmpty()) + const std::string &drive=driveManagement.getDrive(destination.absoluteFilePath().toStdString()); + if(drive.empty()) abort(); - if(mode!=Ultracopier::Move || drive!=driveManagement.getDrive(source.absoluteFilePath())) + if(mode!=Ultracopier::Move || drive!=driveManagement.getDrive(source.absoluteFilePath().toStdString())) { - if(requiredSpace.contains(drive)) + if(requiredSpace.find(drive)!=requiredSpace.cend()) { requiredSpace[drive]+=size; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("space needed add: %1, space needed: %2, on: %3").arg(size).arg(requiredSpace.value(drive)).arg(drive)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("space needed add: %1, space needed: %2, on: %3").arg(size).arg(requiredSpace.at(drive)).arg(QString::fromStdString(drive)).toStdString()); } else { requiredSpace[drive]=size; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("set space %1 needed, on: %2").arg(size).arg(drive)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("set space %1 needed, on: %2").arg(size).arg(QString::fromStdString(drive)).toStdString()); } } bytesToTransfer+= size; @@ -1180,13 +1183,13 @@ quint64 ListThread::addToTransfer(const QFileInfo& source,const QFileInfo& desti temp.destination= destination; temp.mode = mode; temp.isRunning = false; - actionToDoListTransfer << temp; + actionToDoListTransfer.push_back(temp); //push the new transfer to interface Ultracopier::ReturnActionOnCopyList newAction; newAction.type = Ultracopier::AddingItem; newAction.addAction=actionToDoTransferToItemOfCopyList(temp); - actionDone << newAction; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1, destination: %2, add entry: %3, size: %4, size2: %5, isSymLink: %6").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath()).arg(temp.id).arg(temp.size).arg(size).arg(source.isSymLink())); + actionDone.push_back(newAction); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("source: %1, destination: %2, add entry: %3, size: %4, size2: %5, isSymLink: %6").arg(source.absoluteFilePath()).arg(destination.absoluteFilePath()).arg(temp.id).arg(temp.size).arg(size).arg(source.isSymLink()).toStdString()); return temp.id; } @@ -1194,17 +1197,17 @@ Ultracopier::ItemOfCopyList ListThread::actionToDoTransferToItemOfCopyList(const { Ultracopier::ItemOfCopyList itemOfCopyList; itemOfCopyList.id = actionToDoTransfer.id; - itemOfCopyList.sourceFullPath = actionToDoTransfer.source.absoluteFilePath(); - itemOfCopyList.sourceFileName = actionToDoTransfer.source.fileName(); - itemOfCopyList.destinationFullPath = actionToDoTransfer.destination.absoluteFilePath(); - itemOfCopyList.destinationFileName = actionToDoTransfer.destination.fileName(); + itemOfCopyList.sourceFullPath = actionToDoTransfer.source.absoluteFilePath().toStdString(); + itemOfCopyList.sourceFileName = actionToDoTransfer.source.fileName().toStdString(); + itemOfCopyList.destinationFullPath = actionToDoTransfer.destination.absoluteFilePath().toStdString(); + itemOfCopyList.destinationFileName = actionToDoTransfer.destination.fileName().toStdString(); itemOfCopyList.size = actionToDoTransfer.size; itemOfCopyList.mode = actionToDoTransfer.mode; return itemOfCopyList; } //generate id number -quint64 ListThread::generateIdNumber() +uint64_t ListThread::generateIdNumber() { idIncrementNumber++; if(idIncrementNumber>(((quint64)1024*1024)*1024*1024*2)) @@ -1213,14 +1216,14 @@ quint64 ListThread::generateIdNumber() } //warning the first entry is accessible will copy -void ListThread::removeItems(const QList<int> &ids) +void ListThread::removeItems(const std::vector<uint64_t> &ids) { - for(int i=0;i<ids.size();i++) + for(unsigned int i=0;i<ids.size();i++) skipInternal(ids.at(i)); } //put on top -void ListThread::moveItemsOnTop(QList<int> ids) +void ListThread::moveItemsOnTop(std::vector<uint64_t> ids) { if(actionToDoListTransfer.size()<=1) { @@ -1230,21 +1233,22 @@ void ListThread::moveItemsOnTop(QList<int> ids) ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); //do list operation int indexToMove=0; - const int &loop_size=actionToDoListTransfer.size(); - for (int i=0; i<loop_size; ++i) { - if(ids.contains(actionToDoListTransfer.at(i).id)) + for (unsigned int i=0; i<actionToDoListTransfer.size(); ++i) { + if(vectorcontainsAtLeastOne(ids,actionToDoListTransfer.at(i).id)) { - ids.removeOne(actionToDoListTransfer.at(i).id); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("move item ")+QString::number(i)+QStringLiteral(" to ")+QString::number(indexToMove)); + vectorremoveOne(ids,actionToDoListTransfer.at(i).id); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"move item "+std::to_string(i)+" to "+std::to_string(indexToMove)); Ultracopier::ReturnActionOnCopyList newAction; newAction.type=Ultracopier::MoveItem; newAction.addAction.id=actionToDoListTransfer.at(i).id; newAction.userAction.moveAt=indexToMove; newAction.userAction.position=i; - actionDone << newAction; - actionToDoListTransfer.move(i,indexToMove); + actionDone.push_back(newAction); + ActionToDoTransfer temp=actionToDoListTransfer.at(i); + actionToDoListTransfer.erase(actionToDoListTransfer.cbegin()+i); + actionToDoListTransfer.insert(actionToDoListTransfer.cbegin()+indexToMove,temp); indexToMove++; - if(ids.isEmpty()) + if(ids.empty()) return; } } @@ -1253,7 +1257,7 @@ void ListThread::moveItemsOnTop(QList<int> ids) } //move up -void ListThread::moveItemsUp(QList<int> ids) +void ListThread::moveItemsUp(std::vector<uint64_t> ids) { if(actionToDoListTransfer.size()<=1) { @@ -1264,25 +1268,27 @@ void ListThread::moveItemsUp(QList<int> ids) //do list operation int lastGoodPositionReal=0; bool haveGoodPosition=false; - const int &loop_size=actionToDoListTransfer.size(); - for (int i=0; i<loop_size; ++i) { - if(ids.contains(actionToDoListTransfer.at(i).id)) + for (unsigned int i=0; i<actionToDoListTransfer.size(); ++i) { + if(vectorcontainsAtLeastOne(ids,actionToDoListTransfer.at(i).id)) { if(haveGoodPosition) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("move item ")+QString::number(i)+QStringLiteral(" to ")+QString::number(i-1)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"move item "+std::to_string(i)+" to "+std::to_string(i-1)); Ultracopier::ReturnActionOnCopyList newAction; newAction.type=Ultracopier::MoveItem; newAction.addAction.id=actionToDoListTransfer.at(i).id; newAction.userAction.moveAt=lastGoodPositionReal; newAction.userAction.position=i; - actionDone << newAction; - actionToDoListTransfer.swap(i,lastGoodPositionReal); + actionDone.push_back(newAction); + ActionToDoTransfer temp1=actionToDoListTransfer.at(i); + ActionToDoTransfer temp2=actionToDoListTransfer.at(lastGoodPositionReal); + actionToDoListTransfer[i]=temp2; + actionToDoListTransfer[lastGoodPositionReal]=temp1; } else - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("Try move up false, item ")+QString::number(i)); - ids.removeOne(actionToDoListTransfer.at(i).id); - if(ids.isEmpty()) + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Try move up false, item "+std::to_string(i)); + vectorremoveOne(ids,actionToDoListTransfer.at(i).id); + if(ids.empty()) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"stop with return"); return; @@ -1299,7 +1305,7 @@ void ListThread::moveItemsUp(QList<int> ids) } //move down -void ListThread::moveItemsDown(QList<int> ids) +void ListThread::moveItemsDown(std::vector<uint64_t> ids) { if(actionToDoListTransfer.size()<=1) { @@ -1311,25 +1317,28 @@ void ListThread::moveItemsDown(QList<int> ids) int lastGoodPositionReal=0; bool haveGoodPosition=false; for (int i=actionToDoListTransfer.size()-1; i>=0; --i) { - if(ids.contains(actionToDoListTransfer.at(i).id)) + if(vectorcontainsAtLeastOne(ids,actionToDoListTransfer.at(i).id)) { if(haveGoodPosition) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("move item ")+QString::number(i)+QStringLiteral(" to ")+QString::number(i+1)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"move item "+std::to_string(i)+" to "+std::to_string(i+1)); Ultracopier::ReturnActionOnCopyList newAction; newAction.type=Ultracopier::MoveItem; newAction.addAction.id=actionToDoListTransfer.at(i).id; newAction.userAction.moveAt=lastGoodPositionReal; newAction.userAction.position=i; - actionDone << newAction; - actionToDoListTransfer.swap(i,lastGoodPositionReal); + actionDone.push_back(newAction); + ActionToDoTransfer temp1=actionToDoListTransfer.at(i); + ActionToDoTransfer temp2=actionToDoListTransfer.at(lastGoodPositionReal); + actionToDoListTransfer[i]=temp2; + actionToDoListTransfer[lastGoodPositionReal]=temp1; } else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("Try move up false, item ")+QString::number(i)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Try move up false, item "+std::to_string(i)); } - ids.removeOne(actionToDoListTransfer.at(i).id); - if(ids.isEmpty()) + vectorremoveOne(ids,actionToDoListTransfer.at(i).id); + if(ids.empty()) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"stop with return"); return; @@ -1346,7 +1355,7 @@ void ListThread::moveItemsDown(QList<int> ids) } //put on bottom -void ListThread::moveItemsOnBottom(QList<int> ids) +void ListThread::moveItemsOnBottom(std::vector<uint64_t> ids) { if(actionToDoListTransfer.size()<=1) { @@ -1357,20 +1366,22 @@ void ListThread::moveItemsOnBottom(QList<int> ids) //do list operation int lastGoodPositionReal=actionToDoListTransfer.size()-1; for (int i=lastGoodPositionReal; i>=0; --i) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("Check action on item ")+QString::number(i)); - if(ids.contains(actionToDoListTransfer.at(i).id)) + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Check action on item "+std::to_string(i)); + if(vectorcontainsAtLeastOne(ids,actionToDoListTransfer.at(i).id)) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("move item ")+QString::number(i)+QStringLiteral(" to ")+QString::number(lastGoodPositionReal)); - ids.removeOne(actionToDoListTransfer.at(i).id); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"move item "+std::to_string(i)+" to "+std::to_string(lastGoodPositionReal)); + vectorremoveOne(ids,actionToDoListTransfer.at(i).id); Ultracopier::ReturnActionOnCopyList newAction; newAction.type=Ultracopier::MoveItem; newAction.addAction.id=actionToDoListTransfer.at(i).id; newAction.userAction.moveAt=lastGoodPositionReal; newAction.userAction.position=i; - actionDone << newAction; - actionToDoListTransfer.move(i,lastGoodPositionReal); + actionDone.push_back(newAction); + ActionToDoTransfer temp=actionToDoListTransfer.at(i); + actionToDoListTransfer.erase(actionToDoListTransfer.cbegin()+i); + actionToDoListTransfer.insert(actionToDoListTransfer.cbegin()+lastGoodPositionReal,temp); lastGoodPositionReal--; - if(ids.isEmpty()) + if(ids.empty()) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"stop with return"); return; @@ -1389,17 +1400,17 @@ void ListThread::forceMode(const Ultracopier::CopyMode &mode) setRsync(false); #endif if(mode==Ultracopier::Copy) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("Force mode to copy")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Force mode to copy"); else - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("Force mode to move")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"Force mode to move"); this->mode=mode; forcedMode=true; } -void ListThread::exportTransferList(const QString &fileName) +void ListThread::exportTransferList(const std::string &fileName) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); - QFile transferFile(fileName); + QFile transferFile(QString::fromStdString(fileName)); if(transferFile.open(QIODevice::WriteOnly|QIODevice::Truncate)) { transferFile.write(QStringLiteral("Ultracopier;Transfer-list;").toUtf8()); @@ -1443,38 +1454,38 @@ void ListThread::exportTransferList(const QString &fileName) } if(haveError) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Unable do to move or copy item into wrong forced mode: %1").arg(transferFile.errorString())); - emit errorTransferList(tr("Unable do to move or copy item into wrong forced mode: %1").arg(transferFile.errorString())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Unable do to move or copy item into wrong forced mode: %1").arg(transferFile.errorString()).toStdString()); + emit errorTransferList(tr("Unable do to move or copy item into wrong forced mode: %1").arg(transferFile.errorString()).toStdString()); } transferFile.close(); } else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Unable to save the transfer list: %1").arg(transferFile.errorString())); - emit errorTransferList(tr("Unable to save the transfer list: %1").arg(transferFile.errorString())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Unable to save the transfer list: %1").arg(transferFile.errorString()).toStdString()); + emit errorTransferList(tr("Unable to save the transfer list: %1").arg(transferFile.errorString()).toStdString()); return; } } -void ListThread::importTransferList(const QString &fileName) +void ListThread::importTransferList(const std::string &fileName) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); - QFile transferFile(fileName); + QFile transferFile(QString::fromStdString(fileName)); if(transferFile.open(QIODevice::ReadOnly)) { - QString content; + std::string content; QByteArray data=transferFile.readLine(64); if(data.size()<=0) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Problem reading file, or file-size is 0")); - emit errorTransferList(tr("Problem reading file, or file-size is 0")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Problem reading file, or file-size is 0"); + emit errorTransferList(tr("Problem reading file, or file-size is 0").toStdString()); return; } - content=QString::fromUtf8(data); + content=QString::fromUtf8(data).toStdString(); if(content!="Ultracopier;Transfer-list;Transfer;Ultracopier\n" && content!="Ultracopier;Transfer-list;Copy;Ultracopier\n" && content!="Ultracopier;Transfer-list;Move;Ultracopier\n") { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Wrong header: \"%1\"").arg(content)); - emit errorTransferList(tr("Wrong header: \"%1\"").arg(content)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Wrong header: "+content); + emit errorTransferList(tr("Wrong header: \"%1\"").arg(QString::fromStdString(content)).toStdString()); return; } bool transferListMixedMode=false; @@ -1482,8 +1493,8 @@ void ListThread::importTransferList(const QString &fileName) { if(forcedMode) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("The transfer list is in mixed mode, but this instance is not")); - emit errorTransferList(tr("The transfer list is in mixed mode, but this instance is not in this mode")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"The transfer list is in mixed mode, but this instance is not"); + emit errorTransferList(tr("The transfer list is in mixed mode, but this instance is not in this mode").toStdString()); return; } else @@ -1491,14 +1502,14 @@ void ListThread::importTransferList(const QString &fileName) } if(content=="Ultracopier;Transfer-list;Copy;Ultracopier\n" && (forcedMode && mode==Ultracopier::Move)) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("The transfer list is in copy mode, but this instance is not: forcedMode: %1, mode: %2").arg(forcedMode).arg(mode)); - emit errorTransferList(tr("The transfer list is in copy mode, but this instance is not in this mode")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("The transfer list is in copy mode, but this instance is not: forcedMode: %1, mode: %2").arg(forcedMode).arg(mode).toStdString()); + emit errorTransferList(tr("The transfer list is in copy mode, but this instance is not in this mode").toStdString()); return; } if(content=="Ultracopier;Transfer-list;Move;Ultracopier\n" && (forcedMode && mode==Ultracopier::Copy)) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("The transfer list is in move mode, but this instance is not: forcedMode: %1, mode: %2").arg(forcedMode).arg(mode)); - emit errorTransferList(tr("The transfer list is in move mode, but this instance is not in this mode")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("The transfer list is in move mode, but this instance is not: forcedMode: %1, mode: %2").arg(forcedMode).arg(mode).toStdString()); + emit errorTransferList(tr("The transfer list is in move mode, but this instance is not in this mode").toStdString()); return; } @@ -1511,42 +1522,49 @@ void ListThread::importTransferList(const QString &fileName) emit actionInProgess(updateTheStatus_action_in_progress); bool errorFound=false; - QRegularExpression correctLine; + std::regex correctLine; if(transferListMixedMode) - correctLine=QRegularExpression(QStringLiteral("^(Copy|Move);[^;]+;[^;]+[\n\r]*$")); + correctLine=std::regex("^(Copy|Move);[^;]+;[^;]+[\n\r]*$"); else - correctLine=QRegularExpression(QStringLiteral("^[^;]+;[^;]+[\n\r]*$")); - QStringList args; + correctLine=std::regex("^[^;]+;[^;]+[\n\r]*$"); + std::vector<std::string> args; Ultracopier::CopyMode tempMode; do { data=transferFile.readLine(65535*2); if(data.size()>0) { - content=QString::fromUtf8(data); + content=std::string(data.constData(),data.size()); //do the import here - if(content.contains(correctLine)) + if(std::regex_match(content,correctLine)) { - content.remove(QStringLiteral("\n")); - args=content.split(QStringLiteral(";")); + stringreplaceAll(content,"\n",""); + args=stringsplit(content,';'); if(forcedMode) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("New data to import in forced mode: %2,%3").arg(args.at(0)).arg(args.at(1))); - addToTransfer(QFileInfo(args.at(0)),QFileInfo(args.at(1)),mode); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("New data to import in forced mode: %2,%3") + .arg(QString::fromStdString(args.at(0))) + .arg(QString::fromStdString(args.at(1))) + .toStdString()); + addToTransfer(QFileInfo(QString::fromStdString(args.at(0))),QFileInfo(QString::fromStdString(args.at(1))),mode); } else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("New data to import: %1,%2,%3").arg(args.at(0)).arg(args.at(1)).arg(args.at(2))); - if(args.at(0)==QStringLiteral("Copy")) + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("New data to import: %1,%2,%3") + .arg(QString::fromStdString(args.at(0))) + .arg(QString::fromStdString(args.at(1))) + .arg(QString::fromStdString(args.at(2))) + .toStdString()); + if(args.at(0)=="Copy") tempMode=Ultracopier::Copy; else tempMode=Ultracopier::Move; - addToTransfer(QFileInfo(args.at(1)),QFileInfo(args.at(2)),tempMode); + addToTransfer(QFileInfo(QString::fromStdString(args.at(1))),QFileInfo(QString::fromStdString(args.at(2))),tempMode); } } else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Wrong line syntax: %1").arg(content)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Wrong line syntax: "+content); errorFound=true; } } @@ -1554,15 +1572,15 @@ void ListThread::importTransferList(const QString &fileName) while(data.size()>0); transferFile.close(); if(errorFound) - emit warningTransferList(tr("Some errors have been found during the line parsing")); + emit warningTransferList(tr("Some errors have been found during the line parsing").toStdString()); updateTheStatus();//->sendActionDone(); into this autoStartAndCheckSpace(); } else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Unable to open the transfer list: %1").arg(transferFile.errorString())); - emit errorTransferList(tr("Unable to open the transfer list: %1").arg(transferFile.errorString())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Unable to open the transfer list: %1").arg(transferFile.errorString()).toStdString()); + emit errorTransferList(tr("Unable to open the transfer list: %1").arg(transferFile.errorString()).toStdString()); return; } } @@ -1587,15 +1605,14 @@ bool ListThread::needMoreSpace() const { if(!checkDiskSpace) return false; - QList<Diskspace> diskspace_list; - QHashIterator<QString,quint64> i(requiredSpace); - while (i.hasNext()) { - i.next(); + std::vector<Diskspace> diskspace_list; + for( auto& spaceDrive : requiredSpace ) { + const QString &drive=QString::fromStdString(spaceDrive.first); #ifdef Q_OS_WIN32 - if(i.key()!="A:\\" && i.key()!="A:/" && i.key()!="A:" && i.key()!="A" && i.key()!="a:\\" && i.key()!="a:/" && i.key()!="a:" && i.key()!="a") + if(spaceDrive.first!="A:\\" && spaceDrive.first!="A:/" && spaceDrive.first!="A:" && spaceDrive.first!="A" && spaceDrive.first!="a:\\" && spaceDrive.first!="a:/" && spaceDrive.first!="a:" && spaceDrive.first!="a") { #endif - QStorageInfo storageInfo(i.key()); + QStorageInfo storageInfo(drive); storageInfo.refresh(); const qint64 &availableSpace=storageInfo.bytesAvailable(); #ifdef ULTRACOPIER_PLUGIN_DEBUG @@ -1607,40 +1624,40 @@ bool ListThread::needMoreSpace() const (availableSpace==0 && storageInfo.bytesTotal()==0) ) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("availableSpace: %1, space needed: %2, on: %3, bytesFree: %4").arg(availableSpace).arg(i.value()).arg(i.key()).arg(bytesFree)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("availableSpace: %1, space needed: %2, on: %3, bytesFree: %4").arg(availableSpace).arg(spaceDrive.second).arg(drive).arg(bytesFree).toStdString()); } - else if(i.value()>(quint64)availableSpace) + else if(spaceDrive.second>(quint64)availableSpace) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("availableSpace: %1, space needed: %2, on: %3, bytesFree: %4").arg(availableSpace).arg(i.value()).arg(i.key()).arg(bytesFree)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("availableSpace: %1, space needed: %2, on: %3, bytesFree: %4").arg(availableSpace).arg(spaceDrive.second).arg(drive).arg(bytesFree).toStdString()); #ifdef Q_OS_WIN32 - //if(i.key().contains(QRegularExpression("^[a-zA-Z]:[\\\\/]"))) - if(i.key().contains(QRegularExpression("^[a-zA-Z]:"))) + //if(drive.contains(QRegularExpression("^[a-zA-Z]:[\\\\/]"))) + if(drive.contains(QRegularExpression("^[a-zA-Z]:"))) #endif { Diskspace diskspace; - diskspace.drive=i.key(); + diskspace.drive=spaceDrive.first; diskspace.freeSpace=availableSpace; - diskspace.requiredSpace=i.value(); - diskspace_list << diskspace; + diskspace.requiredSpace=spaceDrive.second; + diskspace_list.push_back(diskspace); } #ifdef Q_OS_WIN32 else - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("not local drive")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"not local drive"); #endif } #ifdef Q_OS_WIN32 } #endif } - if(!diskspace_list.isEmpty()) + if(!diskspace_list.empty()) emit missingDiskSpace(diskspace_list); - return ! diskspace_list.isEmpty(); + return ! diskspace_list.empty(); } //do new actions void ListThread::doNewActions_start_transfer() { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, numberOfTranferRuning: %2").arg(actionToDoListTransfer.size()).arg(getNumberOfTranferRuning())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, numberOfTranferRuning: %2").arg(actionToDoListTransfer.size()).arg(getNumberOfTranferRuning()).toStdString()); if(stopIt || putInPause) return; int numberOfTranferRuning=getNumberOfTranferRuning(); @@ -1682,7 +1699,7 @@ void ListThread::doNewActions_start_transfer() } int_for_loop++; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("numberOfTranferRuning: ")+QString::number(numberOfTranferRuning)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"numberOfTranferRuning: "+std::to_string(numberOfTranferRuning)); } /** \brief lunch the pre-op or inode op @@ -1694,7 +1711,7 @@ void ListThread::doNewActions_start_transfer() void ListThread::doNewActions_inode_manipulation() { #ifdef ULTRACOPIER_PLUGIN_DEBUG_SCHEDULER - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoList.size(): %1").arg(actionToDoListTransfer.size())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"actionToDoList.size(): "+std::to_string(actionToDoListTransfer.size())); #endif if(stopIt) checkIfReadyToCancel(); @@ -1746,11 +1763,11 @@ void ListThread::doNewActions_inode_manipulation() currentTransferThread=transferThreadList.at(int_for_transfer_thread_search); if(currentTransferThread->getStat()==TransferStat_Idle && currentTransferThread->transferId==0) // /!\ important! { - QString drive=driveManagement.getDrive(actionToDoListTransfer.at(int_for_internal_loop).destination.absoluteFilePath()); - if(requiredSpace.contains(drive) && (actionToDoListTransfer.at(int_for_internal_loop).mode!=Ultracopier::Move || drive!=driveManagement.getDrive(actionToDoListTransfer.at(int_for_internal_loop).source.absoluteFilePath()))) + std::string drive=driveManagement.getDrive(actionToDoListTransfer.at(int_for_internal_loop).destination.absoluteFilePath().toStdString()); + if(requiredSpace.find(drive)!=requiredSpace.cend() && (actionToDoListTransfer.at(int_for_internal_loop).mode!=Ultracopier::Move || drive!=driveManagement.getDrive(actionToDoListTransfer.at(int_for_internal_loop).source.absoluteFilePath().toStdString()))) { requiredSpace[drive]-=actionToDoListTransfer.at(int_for_internal_loop).size; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("space needed removed: %1, space needed: %2, on: %3").arg(actionToDoListTransfer.at(int_for_internal_loop).size).arg(requiredSpace.value(drive)).arg(drive)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("space needed removed: %1, space needed: %2, on: %3").arg(actionToDoListTransfer.at(int_for_internal_loop).size).arg(requiredSpace.at(drive)).arg(QString::fromStdString(drive)).toStdString()); } currentTransferThread->transferId=currentActionToDoTransfer.id; currentTransferThread->transferSize=currentActionToDoTransfer.size; @@ -1761,28 +1778,28 @@ void ListThread::doNewActions_inode_manipulation() currentActionToDoTransfer.mode )) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[%1] id: %2 is idle, but seam busy at set name: %3").arg(int_for_loop).arg(currentTransferThread->transferId).arg(currentActionToDoTransfer.destination.absoluteFilePath())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[%1] id: %2 is idle, but seam busy at set name: %3").arg(int_for_loop).arg(currentTransferThread->transferId).arg(currentActionToDoTransfer.destination.absoluteFilePath()).toStdString()); break; } currentActionToDoTransfer.isRunning=true; - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[%1] id: %2 is idle, use it for %3").arg(int_for_loop).arg(currentTransferThread->transferId).arg(currentActionToDoTransfer.destination.absoluteFilePath())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[%1] id: %2 is idle, use it for %3").arg(int_for_loop).arg(currentTransferThread->transferId).arg(currentActionToDoTransfer.destination.absoluteFilePath()).toStdString()); /// \note wrong position? Else write why it's here Ultracopier::ReturnActionOnCopyList newAction; newAction.type = Ultracopier::PreOperation; newAction.addAction.id = currentActionToDoTransfer.id; - newAction.addAction.sourceFullPath = currentActionToDoTransfer.source.absoluteFilePath(); - newAction.addAction.sourceFileName = currentActionToDoTransfer.source.fileName(); - newAction.addAction.destinationFullPath = currentActionToDoTransfer.destination.absoluteFilePath(); - newAction.addAction.destinationFileName = currentActionToDoTransfer.destination.fileName(); + newAction.addAction.sourceFullPath = currentActionToDoTransfer.source.absoluteFilePath().toStdString(); + newAction.addAction.sourceFileName = currentActionToDoTransfer.source.fileName().toStdString(); + newAction.addAction.destinationFullPath = currentActionToDoTransfer.destination.absoluteFilePath().toStdString(); + newAction.addAction.destinationFileName = currentActionToDoTransfer.destination.fileName().toStdString(); newAction.addAction.size = currentActionToDoTransfer.size; newAction.addAction.mode = currentActionToDoTransfer.mode; - actionDone << newAction; + actionDone.push_back(newAction); int_for_transfer_thread_search++; numberOfInodeOperation++; #ifdef ULTRACOPIER_PLUGIN_DEBUG_SCHEDULER - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("numberOfInodeOperation: %1").arg(numberOfInodeOperation)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"numberOfInodeOperation: "+std::to_string(numberOfInodeOperation)); #endif break; } @@ -1797,7 +1814,7 @@ void ListThread::doNewActions_inode_manipulation() break; } #ifdef ULTRACOPIER_PLUGIN_DEBUG_SCHEDULER - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("numberOfInodeOperation: %1").arg(numberOfInodeOperation)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"numberOfInodeOperation: "+std::to_string(numberOfInodeOperation)); #endif if(numberOfInodeOperation>=inodeThreads) break; @@ -1820,7 +1837,7 @@ void ListThread::doNewActions_inode_manipulation() //error checking if(actionToDoListInode_count>inodeThreads) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("The index have been detected as out of max range: %1>%2").arg(actionToDoListInode_count).arg(inodeThreads)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("The index have been detected as out of max range: %1>%2").arg(actionToDoListInode_count).arg(inodeThreads).toStdString()); return; } } @@ -1832,7 +1849,7 @@ void ListThread::restartTransferIfItCan() TransferThread *transfer=qobject_cast<TransferThread *>(QObject::sender()); if(transfer==NULL) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("transfer thread not located!")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"transfer thread not located!"); return; } int numberOfTranferRuning=getNumberOfTranferRuning(); @@ -1844,7 +1861,7 @@ void ListThread::restartTransferIfItCan() /// \brief update the transfer stat void ListThread::newTransferStat(const TransferStat &stat,const quint64 &id) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("TransferStat: %1").arg(stat)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"TransferStat: "+std::to_string(stat)); Ultracopier::ReturnActionOnCopyList newAction; switch(stat) { @@ -1872,7 +1889,7 @@ void ListThread::newTransferStat(const TransferStat &stat,const quint64 &id) break; } newAction.addAction.id = id; - actionDone << newAction; + actionDone.push_back(newAction); } void ListThread::set_osBufferLimit(const unsigned int &osBufferLimit) @@ -1887,12 +1904,12 @@ void ListThread::set_osBufferLimit(const unsigned int &osBufferLimit) } } -void ListThread::set_setFilters(const QList<Filters_rules> &include,const QList<Filters_rules> &exclude) +void ListThread::set_setFilters(const std::vector<Filters_rules> &include,const std::vector<Filters_rules> &exclude) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("include.size(): %1, exclude.size(): %2").arg(include.size()).arg(exclude.size())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("include.size(): %1, exclude.size(): %2").arg(include.size()).arg(exclude.size()).toStdString()); this->include=include; this->exclude=exclude; - int index=0; + unsigned int index=0; while(index<scanFileOrFolderThreadsPool.size()) { scanFileOrFolderThreadsPool.at(index)->setFilters(include,exclude); @@ -1900,7 +1917,7 @@ void ListThread::set_setFilters(const QList<Filters_rules> &include,const QList< } } -void ListThread::set_sendNewRenamingRules(const QString &firstRenamingRule,const QString &otherRenamingRule) +void ListThread::set_sendNewRenamingRules(const std::string &firstRenamingRule,const std::string &otherRenamingRule) { this->firstRenamingRule=firstRenamingRule; this->otherRenamingRule=otherRenamingRule; @@ -1924,15 +1941,15 @@ void ListThread::mkPathFirstFolderFinish() if(actionToDoListInode.at(int_for_loop).type==ActionType_MkPath) { //to send to the log - emit mkPath(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath()); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("stop mkpath: %1").arg(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath())); - actionToDoListInode.removeAt(int_for_loop); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, actionToDoListInode: %2, actionToDoListInode_afterTheTransfer: %3").arg(actionToDoListTransfer.size()).arg(actionToDoListInode.size()).arg(actionToDoListInode_afterTheTransfer.size())); - if(actionToDoListTransfer.isEmpty() && actionToDoListInode.isEmpty() && actionToDoListInode_afterTheTransfer.isEmpty()) + emit mkPath(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath().toStdString()); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("stop mkpath: %1").arg(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath()).toStdString()); + actionToDoListInode.erase(actionToDoListInode.cbegin()+int_for_loop); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, actionToDoListInode: %2, actionToDoListInode_afterTheTransfer: %3").arg(actionToDoListTransfer.size()).arg(actionToDoListInode.size()).arg(actionToDoListInode_afterTheTransfer.size()).toStdString()); + if(actionToDoListTransfer.empty() && actionToDoListInode.empty() && actionToDoListInode_afterTheTransfer.empty()) updateTheStatus(); numberOfInodeOperation--; #ifdef ULTRACOPIER_PLUGIN_DEBUG_SCHEDULER - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("numberOfInodeOperation: %1").arg(numberOfInodeOperation)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"numberOfInodeOperation: "+std::to_string(numberOfInodeOperation)); #endif doNewActions_inode_manipulation(); return; @@ -1946,19 +1963,19 @@ void ListThread::mkPathFirstFolderFinish() //to send to the log #ifdef ULTRACOPIER_PLUGIN_RSYNC if(actionToDoListInode.at(int_for_loop).type!=ActionType_RmSync) - emit mkPath(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath()); + emit mkPath(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath().toStdString()); #else - emit mkPath(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath()); + emit mkPath(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath().toStdString()); #endif - emit rmPath(actionToDoListInode.at(int_for_loop).source.absoluteFilePath()); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("stop mkpath: %1").arg(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath())); - actionToDoListInode.removeAt(int_for_loop); - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, actionToDoListInode: %2, actionToDoListInode_afterTheTransfer: %3").arg(actionToDoListTransfer.size()).arg(actionToDoListInode.size()).arg(actionToDoListInode_afterTheTransfer.size())); - if(actionToDoListTransfer.isEmpty() && actionToDoListInode.isEmpty() && actionToDoListInode_afterTheTransfer.isEmpty()) + emit rmPath(actionToDoListInode.at(int_for_loop).source.absoluteFilePath().toStdString()); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("stop mkpath: %1").arg(actionToDoListInode.at(int_for_loop).destination.absoluteFilePath()).toStdString()); + actionToDoListInode.erase(actionToDoListInode.cbegin()+int_for_loop); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("actionToDoListTransfer.size(): %1, actionToDoListInode: %2, actionToDoListInode_afterTheTransfer: %3").arg(actionToDoListTransfer.size()).arg(actionToDoListInode.size()).arg(actionToDoListInode_afterTheTransfer.size()).toStdString()); + if(actionToDoListTransfer.empty() && actionToDoListInode.empty() && actionToDoListInode_afterTheTransfer.empty()) updateTheStatus(); numberOfInodeOperation--; #ifdef ULTRACOPIER_PLUGIN_DEBUG_SCHEDULER - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("numberOfInodeOperation: %1").arg(numberOfInodeOperation)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"numberOfInodeOperation: "+std::to_string(numberOfInodeOperation)); #endif doNewActions_inode_manipulation(); return; @@ -1974,7 +1991,7 @@ void ListThread::mkPathFirstFolderFinish() void ListThread::timedUpdateDebugDialog() { - QStringList newList; + std::vector<std::string> newList; int index=0; int loop_sub_size_transfer_thread_search=transferThreadList.size(); while(index<loop_sub_size_transfer_thread_search) @@ -2007,25 +2024,29 @@ void ListThread::timedUpdateDebugDialog() stat=QStringLiteral("??? (%1)").arg(transferThreadList.at(index)->getStat()); break; } - newList << QStringLiteral("%1) (%3,%4) %2") + newList.push_back(QStringLiteral("%1) (%3,%4) %2") .arg(index) .arg(stat) .arg(transferThreadList.at(index)->readingLetter()) - .arg(transferThreadList.at(index)->writingLetter()); + .arg(transferThreadList.at(index)->writingLetter()) + .toStdString() + ); index++; } - QStringList newList2; + std::vector<std::string> newList2; index=0; const int &loop_size=actionToDoListTransfer.size(); while(index<loop_size) { - newList2 << QStringLiteral("%1 %2 %3") + newList2.push_back(QStringLiteral("%1 %2 %3") .arg(actionToDoListTransfer.at(index).source.absoluteFilePath()) .arg(actionToDoListTransfer.at(index).size) - .arg(actionToDoListTransfer.at(index).destination.absoluteFilePath()); + .arg(actionToDoListTransfer.at(index).destination.absoluteFilePath()) + .toStdString() + ); if(index>((inodeThreads+ULTRACOPIER_PLUGIN_MAXPARALLELTRANFER)*2+1)) { - newList2 << QStringLiteral("..."); + newList2.push_back("..."); break; } index++; @@ -2042,7 +2063,7 @@ void ListThread::fileAlreadyExists(const QFileInfo &source,const QFileInfo &dest } /// \note Can be call without queue because all call will be serialized -void ListThread::errorOnFile(const QFileInfo &fileInfo, const QString &errorString, const ErrorType &errorType) +void ListThread::errorOnFile(const QFileInfo &fileInfo, const std::string &errorString, const ErrorType &errorType) { TransferThread * transferThread=qobject_cast<TransferThread *>(sender()); if(transferThread==NULL) @@ -2055,7 +2076,7 @@ void ListThread::errorOnFile(const QFileInfo &fileInfo, const QString &errorStri errorLogEntry.destination=transferThread->getDestinationInode(); errorLogEntry.mode=transferThread->getMode(); errorLogEntry.error=errorString; - errorLog << errorLogEntry; + errorLog.push_back(errorLogEntry); emit errorToRetry(transferThread->getSourcePath(),transferThread->getDestinationPath(),errorString); emit send_errorOnFile(fileInfo,errorString,transferThread,errorType); } @@ -2068,7 +2089,7 @@ void ListThread::folderAlreadyExists(const QFileInfo &source,const QFileInfo &de /// \note Can be call without queue because all call will be serialized /// \todo all this part -void ListThread::errorOnFolder(const QFileInfo &fileInfo,const QString &errorString,const ErrorType &errorType) +void ListThread::errorOnFolder(const QFileInfo &fileInfo,const std::string &errorString,const ErrorType &errorType) { emit send_errorOnFolder(fileInfo,errorString,qobject_cast<ScanFileOrFolder *>(sender()),errorType); } @@ -2083,7 +2104,7 @@ void ListThread::run() exec(); } -void ListThread::getNeedPutAtBottom(const QFileInfo &fileInfo, const QString &errorString, TransferThread *thread, const ErrorType &errorType) +void ListThread::getNeedPutAtBottom(const QFileInfo &fileInfo, const std::string &errorString, TransferThread *thread, const ErrorType &errorType) { if(actionToDoListTransfer.empty()) { @@ -2115,25 +2136,25 @@ void ListThread::createTransferThread() { if(stopIt) return; - if(transferThreadList.size()>=inodeThreads) + if(transferThreadList.size()>=(unsigned int)inodeThreads) return; - transferThreadList << new TransferThread(); - TransferThread * last=transferThreadList.last(); + transferThreadList.push_back(new TransferThread()); + TransferThread * last=transferThreadList.back(); last->transferId=0; last->transferSize=0; last->setRightTransfer(doRightTransfer); last->setKeepDate(keepDate); #ifdef ULTRACOPIER_PLUGIN_SPEED_SUPPORT if(!last->setBlockSize(blockSizeAfterSpeedLimitation)) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unable to set the block size: ")+QString::number(blockSizeAfterSpeedLimitation)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to set the block size: "+std::to_string(blockSizeAfterSpeedLimitation)); #else if(!last->setBlockSize(blockSize)) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unable to set the block size: ")+QString::number(blockSize)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to set the block size: "+std::to_string(blockSize)); #endif if(!last->setSequentialBuffer(sequentialBuffer)) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unable to set the sequentialBuffer: ")+QString::number(sequentialBuffer)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to set the sequentialBuffer: "+std::to_string(sequentialBuffer)); if(!last->setBlockSize(parallelBuffer)) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("unable to set the parallelBuffer: ")+QString::number(parallelBuffer)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to set the parallelBuffer: "+std::to_string(parallelBuffer)); last->setAlwaysFileExistsAction(alwaysDoThisActionForFileExists); #ifdef ULTRACOPIER_PLUGIN_SPEED_SUPPORT last->setMultiForBigSpeed(multiForBigSpeed); @@ -2180,9 +2201,9 @@ void ListThread::createTransferThread() #ifdef ULTRACOPIER_PLUGIN_DEBUG last->setId(transferThreadList.size()-1); #endif - if(transferThreadList.size()>=inodeThreads) + if(transferThreadList.size()>=(unsigned int)inodeThreads) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("create the last of the ")+QString::number(inodeThreads)+QStringLiteral(" transferThread")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"create the last of the "+std::to_string(inodeThreads)+" transferThread"); return; } if(stopIt) @@ -2204,25 +2225,25 @@ void ListThread::deleteTransferThread() transferThreadList.at(index)->stop(); delete transferThreadList.at(index);//->deleteLayer(); transferThreadList[index]=NULL; - transferThreadList.removeAt(index); + transferThreadList.erase(transferThreadList.cbegin()+index); loop_size--; } else index++; } if(loop_size==inodeThreads) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("inodeThreads is lowered to the right value: ")+QString::number(inodeThreads)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"inodeThreads is lowered to the right value: "+std::to_string(inodeThreads)); } } void ListThread::setTransferAlgorithm(const TransferAlgorithm &transferAlgorithm) { if(transferAlgorithm==TransferAlgorithm_Sequential) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("transferAlgorithm==TransferAlgorithm_Sequential")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"transferAlgorithm==TransferAlgorithm_Sequential"); else if(transferAlgorithm==TransferAlgorithm_Automatic) - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("transferAlgorithm==TransferAlgorithm_Automatic")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"transferAlgorithm==TransferAlgorithm_Automatic"); else - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("transferAlgorithm==TransferAlgorithm_Parallel")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"transferAlgorithm==TransferAlgorithm_Parallel"); emit send_setTransferAlgorithm(transferAlgorithm); } @@ -2230,10 +2251,10 @@ void ListThread::setParallelBuffer(int parallelBuffer) { if(parallelBuffer<1 || parallelBuffer>ULTRACOPIER_PLUGIN_MAX_PARALLEL_NUMBER_OF_BLOCK) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("wrong number of block: ")+QString::number(parallelBuffer)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"wrong number of block: "+std::to_string(parallelBuffer)); return; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("in number of block: ")+QString::number(parallelBuffer)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"in number of block: "+std::to_string(parallelBuffer)); this->parallelBuffer=parallelBuffer; emit send_parallelBuffer(parallelBuffer); } @@ -2242,23 +2263,23 @@ void ListThread::setSequentialBuffer(int sequentialBuffer) { if(sequentialBuffer<1 || sequentialBuffer>ULTRACOPIER_PLUGIN_MAX_SEQUENTIAL_NUMBER_OF_BLOCK) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,QStringLiteral("wrong number of block: ")+QString::number(sequentialBuffer)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Critical,"wrong number of block: "+std::to_string(sequentialBuffer)); return; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("in number of block: ")+QString::number(sequentialBuffer)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"in number of block: "+std::to_string(sequentialBuffer)); this->sequentialBuffer=sequentialBuffer; emit send_sequentialBuffer(sequentialBuffer); } void ListThread::setParallelizeIfSmallerThan(const unsigned int ¶llelizeIfSmallerThan) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("parallelizeIfSmallerThan in Bytes: ")+QString::number(parallelizeIfSmallerThan)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"parallelizeIfSmallerThan in Bytes: "+std::to_string(parallelizeIfSmallerThan)); this->parallelizeIfSmallerThan=parallelizeIfSmallerThan; } void ListThread::setMoveTheWholeFolder(const bool &moveTheWholeFolder) { - for(int i=0;i<scanFileOrFolderThreadsPool.size();i++) + for(unsigned int i=0;i<scanFileOrFolderThreadsPool.size();i++) scanFileOrFolderThreadsPool.at(i)->setMoveTheWholeFolder(moveTheWholeFolder); this->moveTheWholeFolder=moveTheWholeFolder; } @@ -2284,10 +2305,10 @@ void ListThread::setInodeThreads(const int &inodeThreads) { if(inodeThreads<1 || inodeThreads>32) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("inodeThreads is out of ranges: ")+QString::number(inodeThreads)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"inodeThreads is out of ranges: "+std::to_string(inodeThreads)); return; } - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("inodeThreads: ")+QString::number(inodeThreads)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"inodeThreads: "+std::to_string(inodeThreads)); this->inodeThreads=inodeThreads; createTransferThread(); deleteTransferThread(); @@ -2295,7 +2316,7 @@ void ListThread::setInodeThreads(const int &inodeThreads) void ListThread::setRenameTheOriginalDestination(const bool &renameTheOriginalDestination) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("renameTheOriginalDestination: ")+QString::number(renameTheOriginalDestination)); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"renameTheOriginalDestination: "+std::to_string(renameTheOriginalDestination)); this->renameTheOriginalDestination=renameTheOriginalDestination; int index=0; int loop_sub_size_transfer_thread_search=transferThreadList.size(); @@ -2314,14 +2335,14 @@ void ListThread::setCheckDiskSpace(const bool &checkDiskSpace) void ListThread::setCopyListOrder(const bool &order) { this->copyListOrder=order; - for(int i=0;i<scanFileOrFolderThreadsPool.size();i++) + for(unsigned int i=0;i<scanFileOrFolderThreadsPool.size();i++) scanFileOrFolderThreadsPool.at(i)->setCopyListOrder(this->copyListOrder); } -void ListThread::exportErrorIntoTransferList(const QString &fileName) +void ListThread::exportErrorIntoTransferList(const std::string &fileName) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); - QFile transferFile(fileName); + QFile transferFile(QString::fromStdString(fileName)); if(transferFile.open(QIODevice::WriteOnly|QIODevice::Truncate)) { transferFile.write(QStringLiteral("Ultracopier;Transfer-list;").toUtf8()); @@ -2365,15 +2386,15 @@ void ListThread::exportErrorIntoTransferList(const QString &fileName) } if(haveError) { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Unable do to move or copy item into wrong forced mode: %1").arg(transferFile.errorString())); - emit errorTransferList(tr("Unable do to move or copy item into wrong forced mode: %1").arg(transferFile.errorString())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Unable do to move or copy item into wrong forced mode: "+transferFile.errorString().toStdString()); + emit errorTransferList(tr("Unable do to move or copy item into wrong forced mode: %1").arg(transferFile.errorString()).toStdString()); } transferFile.close(); } else { - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,QStringLiteral("Unable to save the transfer list: %1").arg(transferFile.errorString())); - emit errorTransferList(tr("Unable to save the transfer list: %1").arg(transferFile.errorString())); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Unable to save the transfer list: "+transferFile.errorString().toStdString()); + emit errorTransferList(tr("Unable to save the transfer list: %1").arg(transferFile.errorString()).toStdString()); return; } } |