##// END OF EJS Templates
added missing GPL headers...
added missing GPL headers fixed move/zoom issue on plot with log scale

File last commit:

r11:f1a4e3a7ca04 default
r11:f1a4e3a7ca04 default
Show More
filedownloadertask.cpp
75 lines | 2.8 KiB | text/x-c | CppLexer
/ src / Core / filedownloadertask.cpp
/*------------------------------------------------------------------------------
-- This file is a part of the QLop Software
-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------*/
/*-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@member.fsf.org
----------------------------------------------------------------------------*/
#include "filedownloadertask.h"
FileDownloaderTask::FileDownloaderTask(QNetworkReply *reply, int ID, const QString &fileName, QObject *parent) : QObject(parent)
{
this->m_Reply = reply;
this->m_downloadComplete = false;
this->m_FileName = fileName;
this->m_taskId = ID;
this->m_file = new QFile(fileName+".part");
this->m_file->open(QIODevice::WriteOnly|QIODevice::Truncate);
this->m_startDateTime = QDateTime::currentDateTime();
this->m_URL = m_Reply->url().toString();
connect(this->m_Reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadProgress(qint64,qint64)));
connect(this->m_Reply,SIGNAL(downloadProgress(qint64,qint64)),this,SIGNAL(updateProgress(qint64,qint64)));
connect(this->m_Reply,SIGNAL(readyRead()),this,SLOT(readReady()));
connect(this->m_Reply,SIGNAL(finished()),this,SLOT(downloadFinished()));
}
FileDownloaderTask::~FileDownloaderTask()
{
delete m_file;
delete m_Reply;
}
int FileDownloaderTask::ID(){return m_taskId;}
const QString &FileDownloaderTask::fileName(){return m_FileName;}
const QString &FileDownloaderTask::url(){return m_URL;}
const QDateTime &FileDownloaderTask::startDateTime(){return m_startDateTime;}
bool FileDownloaderTask::downloadComplete(){return m_downloadComplete;}
void FileDownloaderTask::downloadProgress(qint64 bytesSent, qint64 bytesTotal)
{
if(bytesTotal!=0)
emit updateProgress((100*bytesSent)/bytesTotal);
}
void FileDownloaderTask::readReady()
{
this->m_file->write(this->m_Reply->readAll());
}
void FileDownloaderTask::downloadFinished()
{
this->m_downloadComplete = true;
this->m_file->write(this->m_Reply->readAll());
this->m_file->close();
this->m_file->rename(this->m_FileName);
}