Manager::Manager( QObject * parent ) : QObject( parent ), worker_( interruptRequested_ ) { // initialize internal fields interruptRequested_ = false; hasPendingInput_ = false; workerBusy_ = false; // connect worker and manager connect( & worker_, SIGNAL( progress( ResultsG1dFit ) ), this, SLOT( onProgress( ResultsG1dFit ) ) ); connect( & worker_, SIGNAL( done( ResultsG1dFit ) ), this, SLOT( onDone( ResultsG1dFit ) ) ); connect( & worker_, SIGNAL( error( QString ) ), this, SLOT( onError( QString ) ) ); connect( & worker_, SIGNAL( interrupt() ), this, SLOT( onInterrupt() ) ); connect( this, SIGNAL( privateGo( InputParametersG1dFit ) ), & worker_, SLOT( onGoFromService( InputParametersG1dFit ) ) ); // move the worker to a separate thread worker_.moveToThread( & workerThread_ ); workerThread_.start(); }
void VerifyServiceTask::setTier(uint8 tier) { m_iTier = tier; MCFCore::Misc::ProgressInfo prog; onProgress(prog); }
bool PGNImporter::importFromFile(const QString& fileName) { pgn::GameCollection games; std::ifstream pgnfile(fileName.toStdString().c_str()); std::cout << "\"" << fileName.toStdString() << "\"" << std::endl; std::cout << "Called: " << pgnfile.is_open() << std::endl; emit onProgress(1); try { pgnfile >> games; } catch(pgn::ParseException& ex) { std::clog << "Parse error: " << ex.what() << std::endl; QMessageBox msg; msg.setIcon(QMessageBox::Critical); msg.setText(QString("Parse error: \"%1\" - document can not be imported").arg(ex.what())); msg.exec(); return false; } return import(games); }
void DownloadListModel::addDownload(QUrl url, QString outFileName) { AbstractDownload *d = createDownload(url); beginInsertRows(QModelIndex(), 0, 0); downloads.prepend(d); d->downloadToFile(outFileName); endInsertRows(); connect(d, SIGNAL(progress()), this, SLOT(onProgress())); connect(d, SIGNAL(statusChanged()), this, SLOT(onStatusChanged())); }
void ViewFileManager::on(QueueManagerListener::ItemStatusUpdated, const QueueItemPtr& aQI) noexcept { if (!isViewedItem(aQI)) { return; } auto file = getFile(aQI->getTTH()); if (file) { file->onProgress(aQI->getTarget(), aQI->getDownloadedBytes()); } }
SlothCopier::SlothCopier(QObject *parent) : QObject(parent) { copier = new QFileCopier(this); connect(copier, SIGNAL(stateChanged(QFileCopier::State)), SLOT(onStateChanged(QFileCopier::State))); connect(copier, SIGNAL(started(int)), SLOT(onStarted(int))); connect(copier, SIGNAL(finished(int,bool)), SLOT(onFinished(int))); connect(copier, SIGNAL(progress(qint64,qint64)), SLOT(onProgress(qint64,qint64))); connect(copier, SIGNAL(error(int, QFileCopier::Error,bool)), SLOT(onError(int, QFileCopier::Error,bool))); }
void GWSession::onSipReply(const AmSipReply& reply, AmSipDialog::Status old_dlg_status) { int status = dlg.getStatus(); DBG("GWSession::onSipReply: code = %i, reason = %s\n, status = %i\n", reply.code,reply.reason.c_str(),dlg.getStatus()); if((dlg.getStatus()==AmSipDialog::Pending)&&(reply.code==183)) { onProgress(reply); } if((dlg.getStatus()==AmSipDialog::Pending)&&(reply.code>=300)) { int ret=((mISDNChannel*)m_OtherLeg)->hangup(); } DBG("GWSession::onSipReply calling parent\n"); AmSession::onSipReply(reply, old_dlg_status); }
void Editor::onCreateMap() { myEngine->scheduler()->schedule([&] { myGame->createMap(); emit mapReady(); }); myStatusProgress->show(); myStatusLabel->setText("Preprocessing map, please wait.."); if (myProgressTimer) delete myProgressTimer; myProgressTimer = new QTimer; QObject::connect(myProgressTimer, SIGNAL(timeout()), this, SLOT(onProgress())); myProgressTimer->start(100); }
void Download::downloadToFile(QString outFileName) { AbstractDownload::downloadToFile(outFileName); reply = nam->get(QNetworkRequest(url)); outFile = new QFile(this->outFileName, this); outFile->open(QIODevice::WriteOnly); connect(reply, SIGNAL(finished()), this, SLOT(onFinished())); connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(onProgress(qint64,qint64))); connect(reply, SIGNAL(readyRead()), this, SLOT(writeData())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onNetworkError(QNetworkReply::NetworkError))); }
void CrashReporter::send() { // TODO: check if dump file actually exists ... // add minidump file setReportData( "upload_file_minidump", contents( m_minidump_file_path ), "application/octet-stream", QFileInfo( m_minidump_file_path ).fileName().toUtf8() ); QByteArray body; foreach (const QByteArray& name, m_formContents.keys() ) { body += "--thkboundary\r\n"; body += "Content-Disposition: form-data; name=\"" + name + "\""; if ( !m_formFileNames.value( name ).isEmpty() && !m_formContentTypes.value( name ).isEmpty() ) { body += "; filename=\"" + m_formFileNames.value( name ) + "\"\r\n"; body += "Content-Type: " + m_formContentTypes.value( name ) + "\r\n"; } else { body += "\r\n"; } body += "\r\n"; body += m_formContents.value( name ) + "\r\n"; } body += "--thkboundary\r\n"; QNetworkAccessManager* nam = new QNetworkAccessManager( this ); m_request->setHeader( QNetworkRequest::ContentTypeHeader, "multipart/form-data; boundary=thkboundary" ); m_reply = nam->post( *m_request, body ); #if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) connect( m_reply, SIGNAL( finished() ), SLOT( onDone() ), Qt::QueuedConnection ); connect( m_reply, SIGNAL( uploadProgress( qint64, qint64 ) ), SLOT( onProgress( qint64, qint64 ) ) ); #else connect( m_reply, &QNetworkReply::finished, this, &CrashReporter::onDone, Qt::QueuedConnection ); connect( m_reply, &QNetworkReply::uploadProgress, this, &CrashReporter::onProgress ); #endif }
void split(){ //1.读取大文件 //2.分批次向小文件中写入 for (int i = 0; i < m_fileNumber; i++){ //... float progressValue = m_fileNumber; progressValue = (i + 1) / progressValue; onProgress(progressValue);//发送通知 } }
FileUploader::FileUploader(MtpObjectsModel * model, QObject *parent) : QObject(parent), _model(model), _aborted(false) { _worker = new CommandQueue(_model); _worker->moveToThread(&_workerThread); connect(&_workerThread, SIGNAL(finished()), SLOT(deleteLater())); connect(this, SIGNAL(executeCommand(Command*)), _worker, SLOT(execute(Command*))); connect(_worker, SIGNAL(progress(qint64)), SLOT(onProgress(qint64))); connect(_worker, SIGNAL(started(QString)), SLOT(onStarted(QString))); connect(_worker, SIGNAL(finished()), SLOT(onFinished())); _workerThread.start(); }
void WebLoadManager::sendRequest(webFileLoaderPrivate *loader, const QString &redirect) { Replies::iterator j = _replies.find(loader->reply()); if (j != _replies.cend()) { QNetworkReply *r = j.key(); _replies.erase(j); r->abort(); r->deleteLater(); } QNetworkReply *r = loader->request(_manager, redirect); connect(r, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(onProgress(qint64, qint64))); connect(r, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onFailed(QNetworkReply::NetworkError))); connect(r, SIGNAL(metaDataChanged()), this, SLOT(onMeta())); _replies.insert(r, loader); }
void HGTController::onWriteMemory(WriteMem_s& ws) { ws.handled = true; ws.wrote = ws.size; ws.stop = isStopped(); try { ws.stop = saveData((const char*)ws.data, ws.size); } catch (gcException) { ws.stop = true; } m_uiDownloaded += ws.size; onProgress(); }
void Tasks::exec(Task* t, bool foreground) { // setup signals connect(t, SIGNAL(onStart()), this, SLOT(onTaskStart()), Qt::AutoConnection); connect(t, SIGNAL(onProgress(TaskStatus)), this, SLOT(onTaskProgress(TaskStatus)), Qt::AutoConnection); connect(t, SIGNAL(onDone()), this, SLOT(onTaskDone()), Qt::AutoConnection); connect(t, SIGNAL(onError(QString)), this, SLOT(onTaskError(QString)), Qt::AutoConnection); // run (will trigger start, progress, done) t->run(); // done //TaskStatus ts("", 1); //emit onTaskProgress(ts); // the task will be deleted, after he sent the onDone() signal // AND this signal has been processed by the event loop. // see "Tasks::onTaskDone()" below. }
void CDownloadPackage::downloadVersionByIndex() { if(m_pAssetManager) //保证Asstmanage是最新的 { CC_SAFE_DELETE(m_pAssetManager); } m_iPackageIndex++; onProgress(0); CCString* strPackageName = CCString::createWithFormat(PACKAGE_NAME, m_iPackageIndex); std::string sUpdateServer = CCUserDefault::sharedUserDefault()->getStringForKey(SERVER_FOR_UPDATE); m_pAssetManager = new AssetsManager(CCString::createWithFormat("%s%s/%s?r=%ld", sUpdateServer.c_str(), m_versionNeedData.sVersion.c_str(), strPackageName->getCString(), getCurrentTime())->getCString() , m_pathToSave.c_str()); m_pAssetManager->setZipFileName(CCString::createWithFormat("%s", strPackageName->getCString())->getCString()); m_pAssetManager->setDelegate(this); //m_pAssetManager->setConnectionTimeout(3); //3S内没有回调则报错调用 onError m_pAssetManager->update(); }
void QtTestApp::initUpdater() { createUpdaterWindow(); FvUpdater::sharedUpdater()->SetFeedURL("https://raw.github.com/ershovdz/WebMounter_Builds/master/Appcast.xml"); // signals from WINDOW connect(m_updaterWindow, SIGNAL(installRequested()), FvUpdater::sharedUpdater(), SLOT(InstallUpdate())); connect(m_updaterWindow, SIGNAL(skipInstallRequested()), FvUpdater::sharedUpdater(), SLOT(SkipUpdate())); connect(m_updaterWindow, SIGNAL(remindLaterRequested()), FvUpdater::sharedUpdater(), SLOT(RemindMeLater())); connect(m_updaterWindow, SIGNAL(cancelRequested()), FvUpdater::sharedUpdater(), SLOT(CancelUpdate())); // signals from UPDATER connect(FvUpdater::sharedUpdater(), SIGNAL(finished()), m_updaterWindow, SLOT(onFinished())); connect(FvUpdater::sharedUpdater(), SIGNAL(failed(QString)), m_updaterWindow, SLOT(onFailed(QString))); connect(FvUpdater::sharedUpdater(), SIGNAL(progress(uint)), m_updaterWindow, SLOT(onProgress(uint))); connect(FvUpdater::sharedUpdater(), SIGNAL(updateAvailable(FvAvailableUpdate*)), this, SLOT(onUpdates(FvAvailableUpdate*))); connect(FvUpdater::sharedUpdater(), SIGNAL(noUpdates()), this, SLOT(onNoUpdates())); connect(FvUpdater::sharedUpdater(), SIGNAL(closeAppToRunInstaller()), this, SLOT(onCloseApp())); }
bool PGNImporter::import(pgn::GameCollection& games) { int currentGame = 0; QSqlDatabase db = QSqlDatabase::database(); db.driver()->beginTransaction(); try { FENForm fenForm; pgn::GameCollection::iterator gameIter; for (gameIter = games.begin(); gameIter != games.end(); gameIter++) { GameGateway gameGateway; gameGateway.insertGame(*gameIter); emit onProgress((++currentGame) * 100 / games.size()); } cout << "Count: " << currentGame << endl; } catch(...) { db.driver()->rollbackTransaction(); return false; } if(!db.driver()->commitTransaction()) { std::cerr << "ERROR: !Commit" << db.lastError().driverText().toStdString() << endl; } return true; }
void Task::setProgress(const std::string& msg) { status.msg = msg; emit onProgress(status); }
void Task::setProgress(float val) { status.val = val; emit onProgress(status); }
void Task::setProgress(const std::string& msg, float val) { status.val = val; status.msg = msg; emit onProgress(status); }
void QBrotliDecoder::decode() { if (m_pInputDevice == nullptr || m_pOutputDevice == nullptr) { emit onError("IO devices not set."); return; } if (!m_pInputDevice->isReadable()) { emit onError("Input not readable."); return; } if (!m_pOutputDevice->isWritable()) { emit onError("Output not writeable."); return; } BrotliState state; qint64 totalsize=-1; if (!m_pInputDevice->isSequential()) totalsize = m_pInputDevice->size(); BrotliStateInit(&state); int finish = 0; BrotliResult r; BrotliInput input = initInput(m_pInputDevice); BrotliOutput output = initOutput(m_pOutputDevice); for (;;) { r = BrotliDecompressStreaming(input,output,finish,&state); if (r==0) { //error emit onError("Decoding error."); break; } else if (r==1) { //done break; } if (totalsize!=-1) emit onProgress((double)m_pInputDevice->pos()/(double)totalsize); if (m_pInputDevice->atEnd()) finish=1; } emit onProgress(1.0); emit onDone(); BrotliStateCleanup(&state); }