importfile.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include "importfile.h"
  2. ImportFile::ImportFile(NumberListModel *oldModel)
  3. {
  4. this->stop =false;
  5. this->oldModel = oldModel;
  6. this->all_file_size = 0;
  7. this->current_file_size = 0;
  8. this->step1Progress = 30;
  9. this->step2Progress = 70;
  10. }
  11. ImportFile::~ImportFile()
  12. {
  13. qDebug()<<"ImportProxy dead";
  14. LogHelper::writeLog("ipy trs ex");
  15. }
  16. void ImportFile::setFileList(QStringList list)
  17. {
  18. this->fileList = list;
  19. }
  20. void ImportFile::abort()
  21. {
  22. this->stop = true;
  23. }
  24. void ImportFile::setBuildType(NumberBuildType buildType)
  25. {
  26. //this->buildType = buildType;
  27. }
  28. void ImportFile::run()
  29. {
  30. this->all_file_size = 0;
  31. for(int i=0;i<this->fileList.size();i++)
  32. {
  33. QFileInfo fileInfo(this->fileList.at(i));
  34. int filesize = fileInfo.size();
  35. this->all_file_size += filesize;
  36. }
  37. /*emit progressMaxUpdated(all_file_size);
  38. for(int i=0;i<this->fileList.size();i++)
  39. {
  40. QFile file(this->fileList.at(i));
  41. if (file.open(QIODevice::ReadOnly))
  42. {
  43. QTextStream in(&file);
  44. QStringList readList;
  45. int current_file_size=0;
  46. while (!in.atEnd())
  47. {
  48. QString line = in.readLine();
  49. if(checkline(line))
  50. current_file_size +=line.size();
  51. readList.append(line);
  52. this->readnothing = false;
  53. if((readList.size()%pers==0 && readList.size()/pers>0) ||in.atEnd())
  54. {
  55. emit produced(current_file_size);
  56. //qDebug()<<"emit ";
  57. current_file_size = 0;
  58. free->acquire();
  59. mutex->lock();
  60. buffer->append(readList);
  61. mutex->unlock();
  62. used->release();
  63. readList.clear();
  64. }
  65. }
  66. }
  67. }
  68. }
  69. bool ImportFile::checkLine(QString line)
  70. {
  71. if(line.length()!=11 || line<"13000000000" || line>"18999999999")
  72. {
  73. return false;
  74. }
  75. else
  76. {
  77. return true;
  78. }*/
  79. }