#include "scdlmgr.h" #include "scdlthread.h" #include "scpaths.h" #include #include #include #include #include #include ScDLThread::ScDLThread(QObject *parent) : QThread(parent), downloadedCount(0), totalCount(0) { connect(this, SIGNAL(runSignal()), this, SLOT(runSlot())); } ScDLThread::~ScDLThread() { } void ScDLThread::run() { emit(runSignal()); } void ScDLThread::addURL(const QUrl &url, bool overwrite, const QString& location) { qDebug()<<"ScDLThread::addURL:"< urlPair=downloadQueue.dequeue(); QString filename = saveFileName(urlPair.first, urlPair.second, true); if (filename.isEmpty()) { qDebug()<<"File name empty for url:"<error()) qDebug()<<"Failed: "<errorString()); else { printf("Succeeded.\n"); qDebug()<<"Saving file:"<deleteLater(); startNextDownload(); } void ScDLThread::downloadReadyRead() { output.write(currentDownload->readAll()); } void ScDLThread::runSlot() { startNextDownload(); } bool ScDLThread::urlOK(QUrl url) { //TODO: Add some more URL checks if (!url.isValid() || url.isEmpty() || url.host().isEmpty()) { qDebug()<<"URL invalid:"<