예제 #1
0
void Downloader::_readAvailableBytes()
{
    qint64 bytesAvailable = data->reply->bytesAvailable();
    if (bytesAvailable < DownloaderData::BUFFERSIZE)
        return;

    if (!data->file) {
        data->file = new QFile(data->destinationFolder + QDir::separator() + data->fileName);
        if (data->file->exists()) {
            if (!data->file->remove()) {
                setErrorString(QString("Could not remove existing file '%1': %2")
                               .arg(data->file->fileName())
                               .arg(data->file->errorString()));
                abortDownload();
                return;
            }
        }

        if (!data->file->open(QIODevice::WriteOnly)) {
            setErrorString(QString("Could not write to file '%1': %2")
                           .arg(data->file->fileName())
                           .arg(data->file->errorString()));
            abortDownload();
            return;
        }
    }

    if (!data->buffer)
        data->buffer = new char[DownloaderData::BUFFERSIZE];

    qint64 read = data->reply->read(data->buffer, DownloaderData::BUFFERSIZE);
    if (read == -1) {
        setErrorString(QString("Could not read from network: %2")
                       .arg(data->reply->errorString()));
        abortDownload();
        return;
    }

    qint64 write = data->file->write(data->buffer, read);
    if (write == -1) {
        setErrorString(QString("Could not write to file '%1': %2")
                       .arg(data->file->fileName())
                       .arg(data->file->errorString()));
        abortDownload();
        return;
    }
    Q_ASSERT(read == write);

    data->bytesWritten += write;
    emit bytesWritten(write);
}
예제 #2
0
void MpcImportWindow::createDialogContent()
{
	ui->setupUi(dialog);

	//Signals
	connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
	connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
	connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));

	connect(ui->pushButtonAcquire, SIGNAL(clicked()),
	        this, SLOT(acquireObjectData()));
	connect(ui->pushButtonAbortDownload, SIGNAL(clicked()),
	        this, SLOT(abortDownload()));
	connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(addObjects()));
	connect(ui->pushButtonDiscard, SIGNAL(clicked()),
	        this, SLOT(discardObjects()));

	connect(ui->pushButtonBrowse, SIGNAL(clicked()), this, SLOT(selectFile()));
	connect(ui->comboBoxBookmarks, SIGNAL(currentIndexChanged(QString)),
	        this, SLOT(bookmarkSelected(QString)));

	connect(ui->radioButtonFile, SIGNAL(toggled(bool)),
	        ui->frameFile, SLOT(setVisible(bool)));
	connect(ui->radioButtonURL, SIGNAL(toggled(bool)),
	        ui->frameURL, SLOT(setVisible(bool)));

	connect(ui->radioButtonAsteroids, SIGNAL(toggled(bool)),
	        this, SLOT(switchImportType(bool)));
	connect(ui->radioButtonComets, SIGNAL(toggled(bool)),
	        this, SLOT(switchImportType(bool)));

	connect(ui->pushButtonMarkAll, SIGNAL(clicked()),
	        this, SLOT(markAll()));
	connect(ui->pushButtonMarkNone, SIGNAL(clicked()),
	        this, SLOT(unmarkAll()));

	connect(ui->pushButtonSendQuery, SIGNAL(clicked()),
	        this, SLOT(sendQuery()));
	connect(ui->lineEditQuery, SIGNAL(returnPressed()),
		this, SLOT(sendQuery()));
	connect(ui->pushButtonAbortQuery, SIGNAL(clicked()),
	        this, SLOT(abortQuery()));
	connect(ui->lineEditQuery, SIGNAL(textEdited(QString)),
	        this, SLOT(resetNotFound()));
	//connect(ui->lineEditQuery, SIGNAL(editingFinished()), this, SLOT(sendQuery()));
	connect(countdownTimer, SIGNAL(timeout()), this, SLOT(updateCountdown()));

	QSortFilterProxyModel * filterProxyModel = new QSortFilterProxyModel(this);
	filterProxyModel->setSourceModel(candidateObjectsModel);
	filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
	ui->listViewObjects->setModel(filterProxyModel);
	connect(ui->lineEditSearch, SIGNAL(textChanged(const QString&)),
	        filterProxyModel, SLOT(setFilterFixedString(const QString&)));

	loadBookmarks();
	updateTexts();

	resetCountdown();
	resetDialog();
}
/// PRIVATE
void UImageConvertationForm::init()
{
    connect(ui->tButtonSelectFile, SIGNAL(clicked()), this, SLOT(selectFilePicture()));
    connect(ui->tButtonDownloadPicture, SIGNAL(clicked()), this, SLOT(downloadUrlImage()));
    connect(ui->tButtonAbortDownloadPicture, SIGNAL(clicked()), this, SLOT(abortDownload()));
    connect(ui->lEditUrlPicture, SIGNAL(textChanged(QString)), this, SLOT(testingEditUrlPicture(QString)));
    connect(ui->tButtonSaveAs, SIGNAL(clicked()), this, SLOT(saveAs()));
    connect(ui->tButtonQuit, SIGNAL(clicked()), qApp, SLOT(quit()));

    connect(ui->actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(ui->actionSelectFile, SIGNAL(triggered()), this, SLOT(selectFilePicture()));
    connect(ui->actionSelectFolder, SIGNAL(triggered()), this, SLOT(selectFolder()));
    connect(ui->actionDownloadPicture, SIGNAL(triggered()), this, SLOT(downloadUrlImage()));
    connect(ui->actionAbortDownloadPicture, SIGNAL(triggered()), this, SLOT(abortDownload()));
    connect(ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()));
    connect(ui->actionAboutProgram, SIGNAL(triggered()), this, SLOT(about()));
}
예제 #4
0
파일: IO.cpp 프로젝트: nocylah/libwfut
/**
 * Abort all current and pending downloads.
 */
void IO::abortAll() {

  while (!m_files.empty()) {
    DataStruct *ds = (m_files.begin())->second;
    abortDownload(ds);
    delete ds;
    m_files.erase(m_files.begin());
  }
}
예제 #5
0
파일: IO.cpp 프로젝트: nocylah/libwfut
/**
 * Abort all current and pending downloads.
 */
void IO::abortDownload(const std::string &filename) {
  std::map<std::string, DataStruct*>::iterator I = m_files.find(filename);

  if (I != m_files.end()) {
    DataStruct *ds = I->second;
    abortDownload(ds);
    delete ds;
    m_files.erase(I);
  }
}
예제 #6
0
bool Downloader::handleDownloadRequest(QNetworkAccessManager *manager, QNetworkReply *r)
{
    reply = r;
    QUrl url = reply->url();
    fileName = QFileInfo(url.path()).fileName();
	if(QMessageBox::question(this,tr("Download the file?"),tr("Do you really wish to download ") + fileName) != QMessageBox::Ok)
		return false;
    absFileName = downloadsDir.absoluteFilePath(fileName);
    if(absFileName.isEmpty())
        return false;
    file = new QFile(absFileName);
    file->open(QIODevice::WriteOnly);
    label->setText(tr("Downloading ") + fileName);
    setTitle(tr("Downloading"));
    cancelButton->setText(tr("Cancel"));
    connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(setProgress(qint64,qint64)));
    connect(cancelButton,SIGNAL(clicked()),this,SLOT(abortDownload()));
    connect(reply,SIGNAL(finished()),this,SLOT(finished()));
    connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
    return true;
}
예제 #7
0
Downloader::~Downloader()
{
    if (data->reply)
        data->reply->disconnect();
    abortDownload();
}
예제 #8
0
파일: mainwindow.cpp 프로젝트: gt945/gov
void MainWindow::on_Quit_clicked()
{
    emit abortFetch();
    emit abortDownload();
    this->close();
}