Example #1
0
void FormatWidget::loadFormat()
{
    FormatsDialog fd(this->_hexedit->data()->length(), (this->_hexedit->selectionLength() ? this->_hexedit->cursorPos() : 0), this->topLevelWidget());
    int res = fd.exec();

    if(res == FormatsDialog::Accepted)
    {
        this->_formatview = nullptr;
        this->_logwidget->clear();
        this->_formatdefinition = fd.selectedFormat();

        Logger* logger = new Logger(this->_logwidget);
        bool validated = this->_formatdefinition->callValidate(this->_hexedit->data(), logger, fd.offset());

        if(!validated)
        {
            emit parsingFailed();
            logger->deleteLater();
            return;
        }

        this->_worker = new FormatWorker(this->_formatdefinition, logger, this->_hexedit->data(), fd.offset(), this);
        connect(this->_worker, SIGNAL(started()), this, SIGNAL(workStarted()));
        connect(this->_worker, SIGNAL(started()), this, SIGNAL(parsingStarted()));
        connect(this->_worker, SIGNAL(finished()), this, SIGNAL(workFinished()));
        connect(this->_worker, SIGNAL(finished()), this, SIGNAL(parsingCompleted()));
        connect(this->_worker, SIGNAL(parsingFailed()), this, SIGNAL(parsingFailed()));
        connect(this->_worker, SIGNAL(parsingCompleted()), this, SLOT(onParseCompleted()));
        this->_worker->start();
    }
}
void TripPlanner::connectionClosedByServer()
{
  if (nextBlockSize != 0xFFFF)
  qDebug() << "Connection closed by server";
  closeConnection();
  if (finished == true) workFinished();
}
Example #3
0
void MainWindow::connectSignalSlot()
{
    connect(mStartResumeButton.data(), SIGNAL (clicked()), this, SLOT (pressedStartResumeButton()));
    connect(mStopButton.data(), SIGNAL (clicked()), this, SLOT (pressedStopButton()));
    connect(&_core, SIGNAL (workFinished()), this, SLOT (pressedStopButton()));
    connect(this, SIGNAL(processStarted(const ProcessData&)), &_core, SLOT(init(const ProcessData&)));
    connect(this, SIGNAL(processPaused()), &_core, SLOT(pause()), Qt::ConnectionType::DirectConnection);
    connect(this, SIGNAL(processResumed()), &_core, SLOT(resume()), Qt::ConnectionType::DirectConnection);
    connect(this, SIGNAL(procesStoped()), &_core, SLOT(stop()), Qt::ConnectionType::DirectConnection);
    connect(&_core, SIGNAL(processing(UrlInfo*)), this, SLOT(processUrl(UrlInfo*)));
}
Example #4
0
void DataBase::setSettings(QString userID, QStringList settings)
{
    connect();
    QSqlQuery setSettingsQuery;    
    setSettingsQuery.exec("UPDATE settings SET timelineTweetsByPage="+settings.value(0)\
                          +", searchTweetsByPage="+settings.value(1)\
                          +", searchUsersByPage="+settings.value(2) \                          
                          + ", refreshTime="+settings.value(3)+" WHERE userID="+userID);

    disconnect();
    emit workFinished();
}
Example #5
0
void UpdateWindow::startUpdate()
{
    // try to download new update
    mUpdateDownloader = new UpdateDownloader(this);
    connect(mUpdateDownloader, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(workProgress(qint64, qint64)));
    connect(mUpdateDownloader, SIGNAL(started()), this, SLOT(workStarted()));
    connect(mUpdateDownloader, SIGNAL(failed()), this, SLOT(workFailed()));
    connect(mUpdateDownloader, SIGNAL(finished()), this, SLOT(workFinished()));

    mLabel->setText(tr("Download updates list"));
    mUpdateDownloader->doDownload(UPDATE_LIST, "_updates.xml");
}
Example #6
0
ChartWidget::ChartWidget(QWidget *parent): WorkerTab(parent), ui(new Ui::ChartWidget), _histogrammodel(nullptr), _hexeditdata(nullptr)
{
    this->_xycharticon = QIcon(":/misc_icons/res/xychart.png");
    this->_histogramicon = QIcon(":/misc_icons/res/histogram.png");

    ui->setupUi(this);
    ui->splitter->setStretchFactor(0, 1);
    ui->tbSwitchChart->setIcon(this->_xycharticon);

    connect(&this->_worker, SIGNAL(started()), this, SIGNAL(workStarted()));
    connect(&this->_worker, SIGNAL(occurrencesListCompleted()), this, SLOT(onOccurrencesListCompleted()));
    connect(&this->_worker, SIGNAL(dataEntropyCompleted()), this, SLOT(onDataEntropyCompleted()));
    connect(&this->_worker, SIGNAL(finished()), this, SIGNAL(workFinished()));
}
Example #7
0
void SerialPortWorker::runQueue()
{
//    qDebug() << "Method name";

    while (working) {
        if (!workingQueue.empty()) {
            queueLock.lockForRead();
            Command command = workingQueue.dequeue();
            queueLock.unlock();
            processCommand(command);
        }
        else {
            QThread::msleep(1);
        }
    }
    emit workFinished();
}
void MainWindow::fnInitThread()
{
	prs = new clsProcess();
	thrd = new QThread();
    dlg = new Dialog(this);
	prs->moveToThread(thrd);
	connect( thrd, SIGNAL(started()), prs, SLOT(doWork()) );
    connect( prs, SIGNAL(workFinished()), this, SLOT(fnStop()) );
	//gui update
    connect( prs, SIGNAL(fnUpdateGUI(int)), this, SLOT(fnUpdateGUINow(int)) );
	//automatically delete thrd and prs object when work is done:
	connect( thrd, SIGNAL(finished()), prs, SLOT(deleteLater()) );
	connect( thrd, SIGNAL(finished()), thrd, SLOT(deleteLater()) );

	thrd->start();
    dlg->show();
}
Example #9
0
Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    on_create();

    QThread *thread = new QThread( );
    Task    *task   = new Task();
    task->moveToThread(thread);
    connect( thread, SIGNAL(started()), task, SLOT(doWork()) );
    connect( task, SIGNAL(event_hotplug()), this, SLOT(event_hotplug()) );
    connect( task, SIGNAL(workFinished()), thread, SLOT(quit()) );
    //automatically delete thread and task object when work is done:
    connect( thread, SIGNAL(finished()), task, SLOT(deleteLater()) );
    connect( thread, SIGNAL(finished()), thread, SLOT(deleteLater()) );
    thread->start();
}
Example #10
0
void UpdateWindow::readUpdate()
{
    mCurrentWork = WT_READCONTENT;

    mLabel->setText(tr("Reading update..."));
    workStarted();

    // TODO: compare checksum

    // unpack
    UpdateExtractor extractor;
    if (!extractor.extract(UPDATE_FILE_PATH, "_update_files"))
        workFailed();



    workFinished();
}
Example #11
0
void DataBase::updateNewUserData(QString id, Twitter::userData *data )
{
    connect();
    QSqlQuery updateUserDataQuery;
    QString queryString = "UPDATE users SET userName=\""+data->name\
            +"\", twitterID="+data->twitterID\
            +", desription=\""+data->description \
            +"\", tweets="+data->statuses_count \
            +", friends="+data->friends_count \
            +", followers="+data->followers_count \
            +", image=:image" \
            +", imageUrl=\""+data->profile_image_url +"\" WHERE userID="+id;    
    updateUserDataQuery.prepare(queryString);
    updateUserDataQuery.addBindValue(data->profile_image_data);
    updateUserDataQuery.exec();
    updateUserDataQuery.finish();
    queryString = "INSERT INTO settings (userID, timelineTweetsByPage," \
                  "searchTweetsByPage, searchUsersByPage, "\
                  "tweetsToDatabase, refreshTime) VALUES ("+id+",5,10,5,100,1)";
    updateUserDataQuery.prepare(queryString);
    updateUserDataQuery.exec();
    disconnect();
    emit workFinished();
}
Example #12
0
processMultireads::processMultireads(QWidget *parent) :
    QWidget(parent),
    progressView(new analysisProgressView(this)),
    multireadsView(new processMultireadsView(this))
{
    // set a window title
    setWindowTitle(tr("Rcount-multireads"));

    // initialize all the other widgets
    // get and set the minimal sizes
    int minWidth = multireadsView->sizeHint().width();
    int minHeight = multireadsView->sizeHint().height()+progressView->sizeHint().height()*1.5;
    this->setMinimumHeight(minHeight);
    this->setMinimumWidth(minWidth);

    // layout
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(multireadsView);
    layout->addWidget(progressView);
    setLayout(layout);

    // hide the progressView
    //! progressView->hide();

    // connections
    connect(&processor, SIGNAL(processStatus(QString)), progressView, SLOT(updateStatus(QString)));
    connect(&processor, SIGNAL(processProgress(int)), progressView, SLOT(updateProgress(int)));
    connect(&processor, SIGNAL(errorMessage(QString)), progressView, SLOT(updateStatus(QString)));
    //! connect(&processor, SIGNAL(idleAgain()), this, SLOT(hideProgress()));
    connect(&processor, SIGNAL(workFinished(QString)), multireadsView, SLOT(removeFromQueue(QString)));
    connect(progressView, SIGNAL(analysisCanceled()), &processor, SLOT(cancelProcessing()));
    connect(multireadsView, SIGNAL(closeAll()), &processor, SLOT(cancelProcessing()));
    connect(multireadsView, SIGNAL(closeAll()), this, SLOT(close()));
    connect(multireadsView, SIGNAL(processReads(QString)), this, SLOT(runProcessor(QString)));

}
Example #13
0
bool EpisodeConverterWorker::runJob()
{
    m_jobRunning = true;
    m_isFine = false;

    QString BackupDirectory = QString("pge_maintainer_backup-%1-%2-%3_%4-%5-%6")
            .arg(QDate().currentDate().year())
            .arg(QDate().currentDate().month())
            .arg(QDate().currentDate().day())
            .arg(QTime().currentTime().hour())
            .arg(QTime().currentTime().minute())
            .arg(QTime().currentTime().second());
    m_currentValue = 0;

    try
    {
        for(int i=0; i<m_episodeBox.d.size(); i++)
        {
            EpisodeBox_level& lvl = m_episodeBox.d[i];
            QString relDirPath;
            QString oldPath = lvl.fPath;
            if(preparePath(m_episode, relDirPath, lvl.fPath, BackupDirectory, m_doBackup))
                continue;
            switch(m_targetFormat)
            {
            case 0://PGE-X
                qDebug() << "Make LVLX";
                lvl.ftype = EpisodeBox_level::F_LVLX;
                renameExtension(lvl.fPath, ".lvlx");
                if(!FileFormats::SaveLevelFile(lvl.d, lvl.fPath, FileFormats::LVL_PGEX))
                    throw(FileFormats::errorString);
                break;
            case 1://SMBX 1...64
                qDebug() << "Make LVL SMBX" << lvl.ftypeVer;
                lvl.ftype = EpisodeBox_level::F_LVL;
                lvl.ftypeVer = m_targetFormatVer;
                renameExtension(lvl.fPath, ".lvl");
                if(!FileFormats::SaveLevelFile(lvl.d, lvl.fPath, FileFormats::LVL_SMBX64, m_targetFormatVer))
                    throw(FileFormats::errorString);
                break;
            case 2://SMBX-38A
                qDebug() << "Make LVL SMBX-38a";
                lvl.ftype = EpisodeBox_level::F_LVL38A;
                renameExtension(lvl.fPath, ".lvl");
                if(!FileFormats::SaveLevelFile(lvl.d, lvl.fPath, FileFormats::LVL_SMBX38A))
                    throw(FileFormats::errorString);
                break;
            }

            if(oldPath != lvl.fPath)
            {
                m_episodeBox.renameLevel(oldPath, lvl.fPath);
                QFile::remove(oldPath);
            }
            qDebug() << "Successfully!";
            m_currentValue++;
        }

        for(int i=0; i<m_episodeBox.dw.size(); i++)
        {
            EpisodeBox_world& wld = m_episodeBox.dw[i];
            qDebug() << "Open world map" << wld.fPath;
            QString relDirPath;
            if(preparePath(m_episode, relDirPath, wld.fPath, BackupDirectory, m_doBackup))
                continue;

            qDebug() << "Will be processed";

            if(m_doBackup)
            {
                qDebug() << "Make backup";
                QFileInfo oldFile(wld.fPath);
                m_episode.mkpath(BackupDirectory + "/" + relDirPath);
                QFile::copy(wld.fPath, BackupDirectory+"/" + relDirPath + "/" + oldFile.fileName() );
            }
            QString oldPath = wld.fPath;

            switch(m_targetFormat)
            {
            case 0://PGE-X
                qDebug() << "Make WLDX";
                wld.ftype = EpisodeBox_world::F_WLDX;
                renameExtension(wld.fPath, ".wldx");
                if(!FileFormats::SaveWorldFile(wld.d, wld.fPath, FileFormats::WLD_PGEX))
                    throw(FileFormats::errorString);
                break;
            case 1://SMBX 1...64
                qDebug() << "Make WLD SMBX "<<wld.ftypeVer;
                wld.ftype = EpisodeBox_world::F_WLD;
                wld.ftypeVer = m_targetFormatVer;
                renameExtension(wld.fPath, ".wld");
                if(!FileFormats::SaveWorldFile(wld.d, wld.fPath, FileFormats::WLD_SMBX64, m_targetFormatVer))
                    throw(FileFormats::errorString);
                break;
            case 2://SMBX-38A
                qDebug() << "Make WLD SMBX-38a";
                wld.ftype = EpisodeBox_world::F_WLD38A;
                renameExtension(wld.fPath, ".wld");
                if(!FileFormats::SaveWorldFile(wld.d, wld.fPath, FileFormats::WLD_SMBX38A))
                    throw(FileFormats::errorString);
                break;
            }

            if(oldPath != wld.fPath)
            {
                qDebug() << "Delete old file";
                //m_episodeBox.renameLevel(oldPath, wld.fPath);
                QFile::remove(oldPath);
            }
            qDebug() << "Successfully!";
            m_currentValue++;
        }

        m_isFine=true;
    }
    catch(QString err)
    {
        m_errorString = "Error ocouped while conversion process: " + err;
        emit workFinished(false);
        m_isFine = false;
    }
    m_jobRunning = false;

    qDebug() << "Work done, exiting";
    emit workFinished(true);
    return m_isFine;
}