long Controller::downloadPodcastFile(std::string url, std::string filePath, long fileSize) { if (fileSize == 0) { HTTPFileDownload::downloadBinaryFile(url, filePath, nullptr, 4096); } else { setupProgress(fileSize); HTTPFileDownload::downloadBinaryFile(url, filePath, &fileProgress, 4096); } return getFileSize(filePath); }
/*! Takes the \a helpData and generates a new documentation set from it. The Qt compressed help file is written to \a outputFileName. Returns true on success, otherwise false. */ bool QHelpGenerator::generate(QHelpDataInterface *helpData, const QString &outputFileName) { emit progressChanged(0); d->error.clear(); if (!helpData || helpData->namespaceName().isEmpty()) { d->error = tr("Invalid help data!"); return false; } QString outFileName = outputFileName; if (outFileName.isEmpty()) { d->error = tr("No output file name specified!"); return false; } QFileInfo fi(outFileName); if (fi.exists()) { if (!fi.dir().remove(fi.fileName())) { d->error = tr("The file %1 cannot be overwritten!").arg(outFileName); return false; } } setupProgress(helpData); emit statusChanged(tr("Building up file structure...")); bool openingOk = true; { QSqlDatabase db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), QLatin1String("builder")); db.setDatabaseName(outFileName); openingOk = db.open(); if (openingOk) d->query = new QSqlQuery(db); } if (!openingOk) { d->error = tr("Cannot open data base file %1!").arg(outFileName); cleanupDB(); return false; } d->query->exec(QLatin1String("PRAGMA synchronous=OFF")); d->query->exec(QLatin1String("PRAGMA cache_size=3000")); addProgress(1.0); createTables(); insertFileNotFoundFile(); insertMetaData(helpData->metaData()); if (!registerVirtualFolder(helpData->virtualFolder(), helpData->namespaceName())) { d->error = tr("Cannot register namespace %1!").arg(helpData->namespaceName()); cleanupDB(); return false; } addProgress(1.0); emit statusChanged(tr("Insert custom filters...")); foreach (const QHelpDataCustomFilter &f, helpData->customFilters()) { if (!registerCustomFilter(f.name, f.filterAttributes, true)) { cleanupDB(); return false; } } addProgress(1.0); int i = 1; QList<QHelpDataFilterSection>::const_iterator it = helpData->filterSections().constBegin(); while (it != helpData->filterSections().constEnd()) { emit statusChanged(tr("Insert help data for filter section (%1 of %2)...") .arg(i++).arg(helpData->filterSections().count())); insertFilterAttributes((*it).filterAttributes()); QByteArray ba; QDataStream s(&ba, QIODevice::WriteOnly); foreach (QHelpDataContentItem *itm, (*it).contents()) writeTree(s, itm, 0); if (!insertFiles((*it).files(), helpData->rootPath(), (*it).filterAttributes()) || !insertContents(ba, (*it).filterAttributes()) || !insertKeywords((*it).indices(), (*it).filterAttributes())) { cleanupDB(); return false; } ++it; } cleanupDB(); emit progressChanged(100); emit statusChanged(tr("Documentation successfully generated.")); return true; }
/** * this is the real workhorse. * maybe we should not call this directly, but instead from doWork ? */ void RenderTask_sV::slotContinueRendering() { qDebug()<<"Starting rendering process in Thread "<<thread()->currentThreadId(); /* real workhorse, need to account for exporting */ setupProgress(trUtf8("Rendering Slow-Mo …"), 2* int(m_prefs.fps().fps() * (m_timeEnd-m_timeStart))); //TODO: initialize m_stopwatch.start(); m_nextFrameTime=m_timeStart; int framesBefore; qreal snapped = m_project->snapToOutFrame(m_nextFrameTime, false, m_prefs.fps(), &framesBefore); qDebug() << "Frame snapping in from " << m_nextFrameTime << " to " << snapped; m_nextFrameTime = snapped; Q_ASSERT(int((m_nextFrameTime - m_project->nodes()->startTime()) * m_prefs.fps().fps() + .5) == framesBefore); try { m_renderTarget->openRenderTarget(); } catch (Error_sV &err) { m_stopRendering = true; emit signalRenderingAborted(tr("Rendering aborted.") + " " + err.message()); return; } // render loop // TODO: add more threading here while(m_nextFrameTime<m_timeEnd) { QCoreApplication::processEvents(); // Checks if the process should be aborted mutex.lock(); bool abort = m_stopRendering; mutex.unlock(); if (abort) { // user stop the process qDebug()<<"Aborting Rendering process in Thread "<<thread()->currentThreadId(); m_renderTimeElapsed = m_stopwatch.elapsed(); emit signalRenderingStopped(QTime().addMSecs(m_renderTimeElapsed).toString("hh:mm:ss")); qDebug() << "Rendering stopped after " << QTime().addMSecs(m_renderTimeElapsed).toString("hh:mm:ss"); break; } // do the work int outputFrame = (m_nextFrameTime - m_project->nodes()->startTime()) * m_prefs.fps().fps() + .5; qreal srcTime = m_project->nodes()->sourceTime(m_nextFrameTime); qDebug() << "Rendering frame number " << outputFrame << " @" << m_nextFrameTime << " from source time " << srcTime; updateMessage(tr("Rendering frame %1 @ %2 s from input position: %3 s (frame %4)") .arg( QString::number(outputFrame),QString::number(m_nextFrameTime), QString::number(srcTime), QString::number(srcTime*m_project->frameSource()->fps()->fps()) ) ); try { QImage rendered = m_project->render(m_nextFrameTime, m_prefs); m_renderTarget->slotConsumeFrame(rendered, outputFrame); m_nextFrameTime = m_nextFrameTime + 1/m_prefs.fps().fps(); updateProgress( (m_nextFrameTime-m_timeStart) * m_prefs.fps().fps() ); } catch (FlowBuildingError &err) { m_stopRendering = true; emit signalRenderingAborted(err.message()); } catch (InterpolationError &err) { updateMessage(err.message()); } } /* while */ // Checks if the process should be aborted mutex.lock(); bool abort = m_stopRendering; mutex.unlock(); if (abort) { qDebug() << "Rendering : aborting"; updateMessage(tr("Rendering : aborting")); } else { //TODO: closing rendering project qDebug() << "Rendering : exporting"; updateMessage(tr("Rendering : exporting")); m_renderTarget->closeRenderTarget(); } m_renderTimeElapsed = m_stopwatch.elapsed(); qDebug() << "time : " << m_renderTimeElapsed; emit signalRenderingFinished(QTime(0,0).addMSecs(m_renderTimeElapsed).toString("hh:mm:ss")); qDebug() << "Rendering stopped after " << QTime(0,0).addMSecs(m_renderTimeElapsed).toString("hh:mm:ss"); qDebug()<<"Rendering process finished in Thread "<<thread()->currentThreadId(); // Set _working to false, meaning the process can't be aborted anymore. mutex.lock(); _working = false; mutex.unlock(); }