Esempio n. 1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    ui->m_processorProgressBar->setVisible(false);

    m_processorThread = new Processor("probas.xml");
    connect(m_processorThread, SIGNAL(onProcessStart()), this, SLOT(onProcessorProcessStart()));
    connect(m_processorThread, SIGNAL(onCategoryStart(unsigned int)), this, SLOT(onProcessorCategoryStart(unsigned int)));
    connect(m_processorThread, SIGNAL(onHandStart(unsigned int,unsigned int)), this, SLOT(onProcessorHandStart(unsigned int, unsigned int)));
    connect(m_processorThread, SIGNAL(onHandEnd()), this, SLOT(onProcessorHandEnd()));
    connect(m_processorThread, SIGNAL(onCategoryEnd()), this, SLOT(onProcessorCategoryEnd()));
    connect(m_processorThread, SIGNAL(onProcessDone()), this, SLOT(onProcessorProcessDone()));
    connect(m_processorThread, SIGNAL(onPercentageChange(double)), this, SLOT(onProcessorPercentageChange(double)));
}
void StemmedFileProcessingDialog::processFiles(const QString &inFile, const QString &outFile)
{
    ui->cbxReading->setText(ui->cbxReading->text() + " " + inFile);
    ui->cbxWriting->setText(ui->cbxWriting->text() + " " + outFile);
    this->in = inFile;
    this->out = outFile;

    QThread* t = new QThread(this);
    StemmedFileParserController* controller = new StemmedFileParserController(this);
    controller->moveToThread(t);
    t->start();
    QObject::connect(this, SIGNAL(read(QString)), controller, SLOT(onRead(QString)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(process()), controller, SLOT(onProcess()), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(write(QString)), controller, SLOT(onWrite(QString)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(generateHistograms(QString)), controller, SLOT(onGenerateHistograms(QString)), Qt::QueuedConnection);
    QObject::connect(controller, SIGNAL(readDone(bool)), this, SLOT(onReadDone(bool)), Qt::QueuedConnection);
    QObject::connect(controller, SIGNAL(processDone()), this, SLOT(onProcessDone()), Qt::QueuedConnection);
    QObject::connect(controller, SIGNAL(writeDone(bool)), this, SLOT(onWriteDone(bool)), Qt::QueuedConnection);
    QObject::connect(controller, SIGNAL(generateHistogramsDone(bool, QString)), this, SLOT(onGenerateHistogramsDone(bool, QString)), Qt::QueuedConnection);
    emit read(this->in);

    this->show();
}