Logo Search packages:      
Sourcecode: ultracopier version File versions  Download package

void AddFolderThread::run (  ) [protected]

Start the listing thread.

Warning:
The param of the listing need be already set
See also:
setDir(), setFileListDropped() and stop()

Note:
Important code

Definition at line 74 of file AddFolder.cpp.

References actionNum, addToCopyList(), dirDest, dirSource, FolderSourceAndDestAreSame(), putToSourceDirList(), scandir(), sourceDirList, stop(), translationOfCopyOf, and urlList.

{
      stopped = false;
      stopIt = false;
      DEBUGCONSOLE(30,"AddFolderThread::run","start");
      //maybe list query
      if(!dirSource.path().isEmpty())
      {
            DEBUGCONSOLE(30,"AddFolderThread::run","!dirSource.path().isEmpty(): "+dirSource.path());
            urlList.append(QUrl().fromLocalFile(dirSource.path()));
            DEBUGCONSOLE(30,"AddFolderThread::run","urlList.append(QUrl().fromLocalFile(dirSource.path())): done");
      }
      DEBUGCONSOLE(30,"AddFolderThread::run","dirSource.path().isEmpty()==true");
      if(urlList.isEmpty())
      {
            DEBUGCONSOLE(10,"AddFolderThread::run","Internal error, the copy and the source folder is empty!");
            DEBUGCONSOLE(10,"AddFolderThread::run","dirSource.path(): "+dirSource.path());
      }
      else
      {
            //if given file and folder is list
            DEBUGCONSOLE(50,"AddFolderThread::run","Listed url");
            for (int i = 0; i < urlList.size() && !stopIt; ++i)
            {
                  DEBUGCONSOLE(90,"AddFolderThread::run","urlList.at(i).toLocalFile(): "+urlList.at(i).toLocalFile());
                  DEBUGCONSOLE(90,"AddFolderThread::run","dirDest.path(): "+dirDest.path());
                  if(QFileInfo(urlList.at(i).toLocalFile()).isFile() ||
                  #ifdef Q_OS_UNIX
                  QFileInfo(urlList.at(i).toLocalFile()).isSymLink() ||
                  #endif
                  (!QFileInfo(urlList.at(i).toLocalFile()).isDir() && !urlList.at(i).toLocalFile().endsWith('\\')  && !urlList.at(i).toLocalFile().endsWith('/')))
                  {
                        DEBUGCONSOLE(90,"AddFolderThread::run","Source=\""+urlList.at(i).toLocalFile()+"\", dirDest="+dirDest.path());
                        emit addToCopyList(QFileInfo(urlList.at(i).toLocalFile()),QFileInfo(dirDest.path()));
                  }
                  else
                  {
                        DEBUGCONSOLE(90,"AddFolderThread::run","if("+QString::number(QFileInfo(urlList.at(i).toLocalFile()).isFile())+" || (!"+QString::number(QFileInfo(urlList.at(i).toLocalFile()).isDir())+" && !"+QString::number(urlList.at(i).toLocalFile().endsWith('\\'))+"  && !"+QString::number(urlList.at(i).toLocalFile().endsWith('/'))+"))");
                        dirSource=urlList.at(i).toLocalFile();
                        if(dirSource.absolutePath()=="" && !urlList.at(i).isEmpty())
                        {
                              DEBUGCONSOLE(10,"AddFolderThread::run",QString("dirSource is empty and urlList.at(")+QString::number(i)+"): \""+urlList.at(i).path()+"\" and \""+urlList.at(i).toString()+"\"");
                              dirSource=urlList.at(i).toString();
                        }
                        else
                        {
                              DEBUGCONSOLE(90,"AddFolderThread::run","dirDest: "+dirDest.path()+", dirSource: "+dirSource.path());
                              QDir dirDestTemp=dirDest;
                              /// \note Important code
                              //add of destination the last directory in the sources
                              //if source is /home/user/sources/
                              //add destination /home/user/
                              //final destination should by: /home/user/sources/, ... renaming...
                              DEBUGCONSOLE(90,"AddFolderThread::run","dirSource.dirName(): \""+dirSource.dirName()+"\"");
                              //add here folder source name to destination
                              if(!dirDest.path().endsWith('\\') && !dirDest.path().endsWith('/'))
                              {
                                    DEBUGCONSOLE(90,"AddFolderThread::run","dirDest.setPath(\""+dirDest.path()+QDir::separator()+dirSource.dirName()+QDir::separator()+"\")");
                                    dirDest.setPath(dirDest.path()+QDir::separator()+dirSource.dirName()+QDir::separator());
                              }
                              else
                              {
                                    DEBUGCONSOLE(90,"AddFolderThread::run","dirDest.setPath(\""+dirDest.path()+dirSource.dirName()+QDir::separator()+"\")");
                                    dirDest.setPath(dirDest.path()+dirSource.dirName()+QDir::separator());
                              }
                              actionNum=0;
                              DEBUGCONSOLE(90,"AddFolderThread::run","dirDest: "+dirDest.path()+", dirSource: "+dirSource.path());
                              //only manager same folder, same file is managed in the copy thread
                              if(dirDest==dirSource)
                              {
                                    DEBUGCONSOLE(50,"AddFolderThread::run","dirDest==dirSource, emit FolderSourceAndDestAreSame(\""+dirDest.path()+"\")");
                                    emit FolderSourceAndDestAreSame(dirDest.path());
                                    waitOneAction.acquire();
                                    if(stopIt || actionNum==FILEEXIST_ACTION_CANCEL)
                                    {
                                          stopIt=true;
                                          goto skipTheListing;
                                    }
                                    if(actionNum==FILEEXIST_ACTION_SKIP)
                                          goto skipTheListing;
                                    if(actionNum==FILEEXIST_ACTION_RENAME)
                                    {
                                          DEBUGCONSOLE(50,"AddFolderThread::run","Rename, multiple shot");
                                          DEBUGCONSOLE(90,"AddFolderThread::run","dirDest: "+dirDest.dirName()+", dirSource: "+dirSource.dirName());
                                          QString NewName=translationOfCopyOf+dirDest.dirName();
                                          dirDest.cdUp();
                                          if(dirDest.path().endsWith('\\') || dirDest.path().endsWith('/'))
                                                dirDest.setPath(dirDest.path()+NewName);
                                          else
                                                dirDest.setPath(dirDest.path()+'/'+NewName);
                                          DEBUGCONSOLE(90,"AddFolderThread::run","dirDest: "+dirDest.dirName()+", dirSource: "+dirSource.dirName());
                                    }
                              }
                              DEBUGCONSOLE(90,"AddFolderThread::run","dirDest="+dirDest.path()+", Source=\""+dirSource.path()+"\"");
                              DEBUGCONSOLE(90,"AddFolderThread::run","emit putToSourceDirList(\""+dirSource.path()+"\")");
                              emit putToSourceDirList(QDir(dirSource));
                              scandir();
                              dirDest=dirDestTemp;
                        }
                  }
            }
      }
      skipTheListing:
      //reset the dirSource
      dirSource="";
      sourceDirList.clear();
      stop();
      stopIt=true;
      DEBUGCONSOLE(70,"AddFolderThread::run","Stop and emit runTheCopy()");
      stopped = true;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index