Пример #1
0
void DownloadManager::downloadRequested(const QNetworkRequest& request) {
    std::cout << "DownloadManager::DownloadRequested()\n";
    QString src = request.url().toString();
    QString dest = request.attribute(QNetworkRequest::User, "~").toString();

    QFile* fileDestination = new QFile(dest);
    fileDestination->open(QIODevice::ReadWrite);
    QNetworkReply* reply = mNetworkAccess.get(request);
    reply->setReadBufferSize(0);
    mActiveDownloads.insert(reply, fileDestination);

    connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished()));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
    connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
    connect(reply, SIGNAL(readyRead()), this, SLOT(downloadReadyRead()));

    DownloadData* data = new DownloadData();
    data->mRemotePath = src;
    data->mLocalPath = dest;

    connect(reply, SIGNAL(finished()), data, SLOT(finished()));

    connect(reply, SIGNAL(downloadProgress(qint64, qint64)), data, SLOT(catchProgress(qint64, qint64)));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), data, SIGNAL(error(QNetworkReply::NetworkError)));
    connect(data, SIGNAL(stopMe()), this, SLOT(stopDownload()));
    connect(data, SIGNAL(removeMe()), this, SLOT(removeDownload()));
    //connect(data, SIGNAL(reloadMe()), this, SLOT(reloadDownload()));

    emit downloadStarted(data);
    emit controller_showSystemTrayMessage("", "Download Started: " + data->localName());
    mModel.addDownload(data);
    mDownloads.insert(data, reply);
}
Пример #2
0
void importDialog::on_btnImportar_clicked()
{
    if(ui->btnImportar->text() != "Importar")
    {
        ui->btnImportar->setEnabled(false);
        switch (ui->stackedWidget->currentIndex()) {
        case 3:
            _createNewGroup();
            break;
        case 4:
        case 5:
            ui->stackedWidget->setCurrentIndex(ui->stackedWidget->currentIndex()+1);
            ui->btnImportar->setEnabled(true);
            break;
        case 6:
            _getRelations();
            break;
        default:
            ui->stackedWidget->setCurrentIndex(ui->stackedWidget->currentIndex()+1);
            break;
        }
    }
    else
    {
        QString s = _empDir+"/Fpago.dbf";
        MainWindow* mainWin = new MainWindow(s);
        ui->btnImportar->setEnabled(false);
        importThread * Thread = new importThread(mainWin , this);
        Thread->setPath(_empDir);
        Thread->setPathConta(_contaDir);

        Thread->setIvaRelation(_ivas);
        Thread->setPaisRelation(_paises);
        Thread->setMonedaPais(_MonedaPais);

        connect(Thread,SIGNAL(finished()),Thread,SLOT(deleteLater()));
        connect(Thread,SIGNAL(finished()),this,SLOT(reEnableImportar()));
        connect(Thread,SIGNAL(Error(QString)),this,SLOT(threadError(QString)));

        progressDialog * d = new progressDialog (this);
        d->setModal(true);
        connect(Thread,SIGNAL(Error(QString)),d,SLOT(error(QString)));
        connect(Thread,SIGNAL(Progress(QString,int)),d,SLOT(Progress(QString,int)));
        connect(Thread,SIGNAL(sizeOfTask(int)),d,SLOT(sizeOfTask(int)));
        connect(Thread,SIGNAL(finished()),d,SLOT(end()));
        connect(d,SIGNAL(stop()),Thread,SLOT(stopMe()));
        d->show();

        Thread->setEmpresa(_empresaFp);
        Thread->setDivisas(_divisas);
        Thread->start();
    }
}