Window::Window(QWidget *parent) :
    QWidget(parent), _working(false)
{
    _label = new QLabel("Номера страниц через пробелы", this);
    _text = new QLineEdit(this);
    _button = new QPushButton("Начать", this);
    _edit = new QTextEdit(this);
    _from = new QDateEdit(QDate::currentDate(), this);
    _to = new QDateEdit(QDate::currentDate(), this);

    _from->setDisplayFormat("MM.yyyy");
    _to->setDisplayFormat("MM.yyyy");


    auto line = new QHBoxLayout();
    line->addWidget(_label);
    line->addWidget(_text);

    auto grid = new QGridLayout();
    grid->addLayout(line, 0, 0, 1, 4);

    grid->addWidget(new QLabel("Начало", this), 1, 0, 1, 1);
    grid->addWidget(_from, 1, 1, 1, 1);
    grid->addWidget(new QLabel("Конец", this), 1, 2, 1, 1);
    grid->addWidget(_to, 1, 3, 1, 1);

    grid->addWidget(_button, 2, 3, 1, 1);
    grid->addWidget(_edit, 3, 0, 1, 4);

    this->setLayout(grid);

    connect(_button, SIGNAL(clicked()), this, SLOT(startParsing()));
}
Exemple #2
0
ResponseHdr scanCimXmlResponse(const char *xmlData, CMPIObjectPath *cop)
{

   pthread_mutex_lock(&scan_mutex);
   ParserControl control;
#if DEBUG
   extern int do_debug;

   if (do_debug)
       fprintf(stderr,"*** CIMOM response: %s\n", xmlData);
#endif

   memset(&control,0,sizeof(control));

   XmlBuffer *xmb = newXmlBuffer(xmlData);
   control.xmb = xmb;
   control.respHdr.xmlBuffer = xmb;

   control.respHdr.rvArray=newCMPIArray(0,0,NULL);

   control.requestObjectPath = cop;

   control.heap = parser_heap_init();

   control.respHdr.rc = startParsing(&control);

   parser_heap_term(control.heap);

   releaseXmlBuffer(xmb);

   pthread_mutex_unlock(&scan_mutex);

   return control.respHdr;
}
Exemple #3
0
void UnTiny::slotAddNewPostWidget(Choqok::UI::PostWidget* newWidget)
{
    postsQueue.enqueue(newWidget);
    if(state == Stopped){
        state = Running;
        QTimer::singleShot(1000, this, SLOT(startParsing()));
    }
}
void Window::finished()
{
    _button->setText("Начать");

    disconnect(_button, SIGNAL(clicked()), this, SLOT(stopParsing()));
    connect(_button, SIGNAL(clicked()), this, SLOT(startParsing()));

}
Exemple #5
0
void UnTiny::startParsing()
{
    int i = 8;
    while( !postsQueue.isEmpty() && i>0 ){
        parse(postsQueue.dequeue());
        --i;
    }

    if(postsQueue.isEmpty())
        state = Stopped;
    else
        QTimer::singleShot(500, this, SLOT(startParsing()));
}
Exemple #6
0
/*=============================UNIT-TEST*/
int main(int argc, char** argv) {
	startParsing("ut.dat");
	listItem *p = buildOperationList();
	while((*p).next != NULL) {
		openOperation *t = (openOperation*) (*p).item;
		printf(">%s", (*t).operation);
		if (strcmp((*t).operation, "open") == 0) {
			printf("[%s]", (*t).fileName);
		}
		printf("\n");
		p = (*p).next;
	}
}
Exemple #7
0
void ParserManager::parse(EditorSource *source, QuantaXmlInputSource *inputSource, ParseResult *base, const DTDStruct *dtd, bool detailed)
{
  emit startParsing(source);
  ParserStatus *parser = new ParserStatus(inputSource->newLocator(), xmlStateMachine());
  DomBuilder *builder = new DomBuilder();
  parser->setContentHandler(builder);
  parser->setLexicalHandler(builder);
  parser->setErrorHandler(builder);
  parser->setQuantaHandler(builder);
  parser->parse(inputSource);
  base->model = builder->model();
  delete parser;
  delete builder;
  //   m_parser->parse(source, base, dtd, detailed);
  emit finishedParsing(source, base);
}
Exemple #8
0
		void parseFile_start(const std::string & fname) {
			incfile_f.exceptions(std::ifstream::failbit | std::ifstream::badbit);
			incfile_f.open(fname.c_str(), std::ifstream::in);
			file_pos = 0;
			file_size = 0;
			incfile_f.exceptions();
			incfile_f.seekg(0, std::ifstream::end);
			if(!incfile_f.bad() && !incfile_f.fail()) {
				long long int siz = incfile_f.tellg();
				if(siz > 0) file_size = siz;
			}
			incfile_f.seekg(0, std::ifstream::beg);
			incfile_f.exceptions(std::ifstream::badbit);
			startParsing();
			incfile_finished = false;
		}
void Window::startParsing()
{
    if(_text->text().isEmpty())
        return;

    _edit->setPlainText("");
    _button->setText("Отменить");

    disconnect(_button, SIGNAL(clicked()), this, SLOT(startParsing()));
    connect(_button, SIGNAL(clicked()), this, SLOT(stopParsing()));

    auto list = _text->text().split(" ", QString::SkipEmptyParts);

    for(int i = 0; i < _tasks.size(); i++)
    {
        _threads[i]->deleteLater();
        _tasks[i]->deleteLater();
    }

    _tasks.clear();
    _threads.clear();

    for(int i = 0; i < list.size(); i++)
    {
        int index = list[i].toInt();
        log(index, "Начало");
        _threads.append(new QThread());
        _tasks.append(new Task(index, qMakePair(_to->date().month(), _to->date().year()),
                                      qMakePair(_from->date().month(), _from->date().year())));

        connect(_threads.back(), SIGNAL(started()), _tasks.back(), SLOT(start()));
        connect(_tasks.back(), SIGNAL(finished()), _threads.back(), SLOT(quit()));
        connect(_tasks.back(), SIGNAL(finished()), this, SLOT(finished()));
        connect(_tasks.back(), SIGNAL(log(int,QString)), this, SLOT(log(int,QString)));

       _tasks.back()->moveToThread(_threads.back());
    }

    for(int i = 0; i < list.size(); i++)
    {
        _threads[i]->start();
    }
}
Exemple #10
0
		void parseFile(const std::string & fname) {
			std::ifstream f;
			f.exceptions(std::ifstream::failbit | std::ifstream::badbit);
			f.open(fname.c_str(), std::ifstream::in);
			f.exceptions(std::ifstream::badbit);
			startParsing();
			char buf[1024];
			try {
				while(!f.fail() && !f.eof()) {
					f.read(buf, sizeof(buf));
					submitData(buf, f.gcount());
				}
			} catch(...) {
				f.close();
				std::cout << "Exception around line " << XML_GetCurrentLineNumber(exp_parser) << "\n";
				endParsing();
				throw;
			}
			f.close();
			endParsing();
		}
Exemple #11
0
CFormulaParser::CFormulaParser(std::string formula)
{
	startParsing(formula);
}
Exemple #12
0
void ParserManager::rebuild(EditorSource *source, ParseResult *base, const DTDStruct *dtd, bool detailed)
{
  emit startParsing(source);
//   m_parser->rebuild(source, base, dtd, detailed);
  emit finishedParsing(source, base);
}
Exemple #13
0
void * enumScanThrd(struct native_enum *NatEnum)
{
   CMCIConnection * con = NatEnum->econ ; /* enumeration */
   CMPIObjectPath * cop = NatEnum->ecop ; /* enumeration */ 
   
   struct          timespec tp ;
	 int             rc = 0 ;
   
   ParserControl control;
   struct native_enum  *local_enmp ;
   
   memset(&control,0,sizeof(control));
  
   /* 
    * get the data array and save a copy of address in enumeration 
    */
    
   XmlBuffer *xmb = newXmlBuffer(NULL);
   control.xmb = xmb;
   control.respHdr.xmlBuffer = xmb;
    
   control.respHdr.rvArray=newCMPIArray(0,0,NULL);

   local_enmp = con->asynRCntl.enmp ;
   
   local_enmp->data = control.respHdr.rvArray ;
   
   control.requestObjectPath = cop;

   control.heap = parser_heap_init();

   control.econ = con ;
     
   if(rc = setjmp(save_env)) {
      printf(" we had a timeout , we are going to exit from here \n") ;
      con->asynRCntl.escanInfo.parsestate = PARSTATE_SERVER_TIMEOUT ;
      con->asynRCntl.xfer_state = XFER_ERROR ;
      return ;
   }
   
   /*
    * wait for first data block received or xfer complete
    * we need to have some data before starting
    */
   while((con->asynRCntl.xfer_state != XFER_DATA_RECVD )&&
         (con->asynRCntl.xfer_state != XFER_COMPLETE)){
    	usleep(100000) ;
   }
       
   control.respHdr.rc = startParsing(&control);
     
   /*
    * releaseXmlBuffer free's that last con->asynRCntl.escanInfo.section 
    * we clear out that pointer just to be safe
    */
   releaseXmlBuffer(xmb);
   
   con->asynRCntl.escanInfo.section = 0 ;
   
   parser_heap_term(control.heap);
   
   con->asynRCntl.escanInfo.parsestate = PARSTATE_COMPLETE ;
    
}