Clang-format (#3028)

* 1/3 Add .clang-format file and travis compilation check

* 2/3 Run clang-format

* 3/3 Fix compilation problems due to include reordering

* 3bis/3 AfterControlStatement: false
This commit is contained in:
ctrlaltca 2018-01-27 10:41:32 +01:00 committed by GitHub
parent 8dbdd24c8e
commit b29bd9e070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
272 changed files with 13378 additions and 9535 deletions

View file

@ -1,14 +1,16 @@
#include <QUrl>
#include <QDebug>
#include <QUrl>
#include "update_downloader.h"
UpdateDownloader::UpdateDownloader(QObject *parent) : QObject(parent) {
UpdateDownloader::UpdateDownloader(QObject *parent) : QObject(parent)
{
netMan = new QNetworkAccessManager(this);
}
void UpdateDownloader::beginDownload(QUrl downloadUrl) {
//Save the original URL because we need it for the filename
void UpdateDownloader::beginDownload(QUrl downloadUrl)
{
// Save the original URL because we need it for the filename
if (originalUrl.isEmpty())
originalUrl = downloadUrl;
@ -18,33 +20,33 @@ void UpdateDownloader::beginDownload(QUrl downloadUrl) {
connect(this, SIGNAL(stopDownload()), response, SLOT(abort()));
}
void UpdateDownloader::downloadError(QNetworkReply::NetworkError) {
void UpdateDownloader::downloadError(QNetworkReply::NetworkError)
{
if (response == nullptr)
return;
emit error(response->errorString().toUtf8());
}
void UpdateDownloader::fileFinished() {
//If we finished but there's a redirect, follow it
void UpdateDownloader::fileFinished()
{
// If we finished but there's a redirect, follow it
QVariant redirect = response->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (!redirect.isNull())
{
if (!redirect.isNull()) {
beginDownload(redirect.toUrl());
return;
}
//Handle any errors we had
if (response->error())
{
// Handle any errors we had
if (response->error()) {
emit error(response->errorString());
return;
}
//Work out the file name of the download
// Work out the file name of the download
QString fileName = QDir::temp().path() + QDir::separator() + originalUrl.toString().section('/', -1);
//Save the build in a temporary directory
// Save the build in a temporary directory
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly)) {
emit error(tr("Could not open the file for reading."));
@ -54,11 +56,11 @@ void UpdateDownloader::fileFinished() {
file.write(response->readAll());
file.close();
//Emit the success signal with a URL to the download file
// Emit the success signal with a URL to the download file
emit downloadSuccessful(QUrl::fromLocalFile(fileName));
}
void UpdateDownloader::downloadProgress(qint64 bytesRead, qint64 totalBytes) {
void UpdateDownloader::downloadProgress(qint64 bytesRead, qint64 totalBytes)
{
emit progressMade(bytesRead, totalBytes);
}