| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- #include "numberbuild.h"
- NumberBuild::NumberBuild()
- {
- this->stop =false;
- this->relation = 0;//0:and 1:or
- }
- NumberBuild::~NumberBuild()
- {
- qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
- <<"NumberBuild Destroyed.";
- }
- void NumberBuild::setList(QStringList list)
- {
- this->segments = list;
- }
- void NumberBuild::setRelation(int relation)
- {
- this->relation = relation;
- }
- void NumberBuild::setRegList(QStringList regList)
- {
- this->regList = regList;
- }
- void NumberBuild::abort()
- {
- this->stop = true;
- }
- void NumberBuild::run()
- {
- switch(relation)
- {
- case 0:
- buildByAnd();
- break;
- case 1:
- buildByOr();
- break;
- default:
- break;
- }
- }
- //void NumberBuild::run()
- //{
- // QStringList tails;
- // emit progressMaxUpdated(9999);
- // for(int j=0; j<10000; j++)
- // {
- // QString tail = "000"+QString::number(j);
- // bool allmatch = true;
- // for(int k=0;k<this->regList.size();k++)
- // {
- // QRegExp rx(regList.at(k));
- // if(!rx.exactMatch(tail.right(4)))
- // {
- // allmatch = false;
- // break;
- // }
- // }
- // if(allmatch)
- // tails << tail.right(4);
- // emit progressUpdated(j);
- // }
- // int howmany = segments.size();
- // for(int i=0;i < howmany ; i++)
- // {
- // this->numbers.append(tails);
- // }
- // appendModel();
- // emit numberBuilt(newModel);
- //}
- void NumberBuild::appendModel()
- {
- newModel = new NumberListModel();
- newModel->setNumberList(segments,numbers);
- }
- void NumberBuild::buildByOr()
- {
- QStringList tails;
- emit progressMaxUpdated(9999);
- for(int j=0; j<10000; j++)
- {
- QString tail = "000"+QString::number(j);
- bool allmatch = false;
- for(int k=0;k<this->regList.size();k++)
- {
- QRegExp rx(regList.at(k));
- if(rx.exactMatch(tail.right(4)))
- {
- allmatch = true;
- break;
- }
- else
- {
- continue;
- }
- }
- if(allmatch)
- tails << tail.right(4);
- emit progressUpdated(j);
- }
- int howmany = segments.size();
- for(int i=0;i < howmany ; i++)
- {
- this->numbers.append(tails);
- }
- appendModel();
- emit numberBuilt(newModel);
- }
- void NumberBuild::buildByAnd()
- {
- QStringList tails;
- emit progressMaxUpdated(9999);
- for(int j=0; j<10000; j++)
- {
- QString tail = "000"+QString::number(j);
- bool allmatch = true;
- for(int k=0;k<this->regList.size();k++)
- {
- QRegExp rx(regList.at(k));
- if(!rx.exactMatch(tail.right(4)))
- {
- allmatch = false;
- break;
- }
- }
- if(allmatch)
- tails << tail.right(4);
- emit progressUpdated(j);
- }
- int howmany = segments.size();
- for(int i=0;i < howmany ; i++)
- {
- this->numbers.append(tails);
- }
- appendModel();
- emit numberBuilt(newModel);
- }
|