Prechádzať zdrojové kódy

Refactored ADownload

Renamed Download to ADownload, filenames and includes adjusted

cleanup in include guards, added some gpl blocks to source files.
Felix Turo 4 rokov pred
rodič
commit
bff25bf07d

+ 2 - 2
openPilotLog.pro

@@ -18,10 +18,10 @@ DEFINES += QT_DEPRECATED_WARNINGS
 SOURCES += \
     main.cpp \
     mainwindow.cpp \
+    src/classes/adownload.cpp \
     src/classes/aircraft.cpp \
     src/classes/arunguard.cpp \
     src/classes/asettings.cpp \
-    src/classes/download.cpp \
     src/classes/flight.cpp \
     src/classes/pilot.cpp \
     src/classes/stat.cpp \
@@ -49,10 +49,10 @@ SOURCES += \
 HEADERS += \
     debug.h \
     mainwindow.h \
+    src/classes/adownload.h \
     src/classes/aircraft.h \
     src/classes/arunguard.h \
     src/classes/asettings.h \
-    src/classes/download.h \
     src/classes/flight.h \
     src/classes/pilot.h \
     src/classes/stat.h \

+ 12 - 14
src/classes/download.cpp → src/classes/adownload.cpp

@@ -15,49 +15,47 @@
  *You should have received a copy of the GNU General Public License
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-#include "download.h"
+#include "adownload.h"
 #include "debug.h"
 
 
 
 
-Download::Download() : QObject(nullptr)
+ADownload::ADownload() : QObject(nullptr)
 {
     QObject::connect(&manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(downloadFinished(QNetworkReply*)));
 }
 
-Download::~Download()
+ADownload::~ADownload()
 {
     DEB("Deleting Download object");
 }
 
-void Download::setTarget(const QUrl &value)
+void ADownload::setTarget(const QUrl &value)
 {
     this->target = value;
 }
 
-void Download::setFileName(const QString &value)
+void ADownload::setFileName(const QString &value)
 {
     this->fileName = value;
 }
 
-void Download::download()
+void ADownload::download()
 {
     QNetworkRequest request(target);
     DEB("Downloading from: " << target.toString());
 
-    QObject::connect(manager.get(request), SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));
+    //QObject::connect(manager.get(request), SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));
 }
 
+/* not needed for now
+ * void ADownload::downloadProgress(qint64 received, qint64 total)
+ * {}
+ */
 
-void Download::downloadProgress(qint64 received, qint64 total)
-{
-    auto shutupcompilerwarning = received;
-    shutupcompilerwarning += total;
-    //qDebug() << "Received " << received << " out of " << total;
-}
 
-void Download::downloadFinished(QNetworkReply *data)
+void ADownload::downloadFinished(QNetworkReply *data)
 {
     QFile localFile(fileName);
     if (!localFile.open(QIODevice::WriteOnly))

+ 7 - 7
src/classes/download.h → src/classes/adownload.h

@@ -15,8 +15,8 @@
  *You should have received a copy of the GNU General Public License
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-#ifndef DOWNLOAD_H
-#define DOWNLOAD_H
+#ifndef ADOWNLOAD_H
+#define ADOWNLOAD_H
 
 #include <QObject>
 #include <QNetworkAccessManager>
@@ -27,12 +27,12 @@
 #include <QDebug>
 
 
-class Download : public QObject {
+class ADownload : public QObject {
     Q_OBJECT
 public:
-    explicit Download();
+    explicit ADownload();
 
-    ~Download();
+    ~ADownload();
 
     void setTarget(const QUrl &value);
 
@@ -51,7 +51,7 @@ signals:
 
 public slots:
     void downloadFinished(QNetworkReply* data);
-    void downloadProgress(qint64 recieved, qint64 total);
+    //void downloadProgress(qint64 received, qint64 total); //not needed for now
 };
 
-#endif // DOWNLOAD_H
+#endif // ADOWNLOAD_H

+ 17 - 0
src/classes/arunguard.cpp

@@ -1,3 +1,20 @@
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *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 3 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, see <https://www.gnu.org/licenses/>.
+ */
 #include "arunguard.h"
 
 #include <QCryptographicHash>

+ 20 - 3
src/classes/arunguard.h

@@ -1,5 +1,22 @@
-#ifndef RUNGUARD_H
-#define RUNGUARD_H
+/*
+ *openPilot Log - A FOSS Pilot Logbook Application
+ *Copyright (C) 2020  Felix Turowsky
+ *
+ *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 3 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, see <https://www.gnu.org/licenses/>.
+ */
+#ifndef ARUNGUARD_H
+#define ARUNGUARD_H
 
 #include <QObject>
 #include <QSharedMemory>
@@ -32,4 +49,4 @@ private:
 };
 
 
-#endif // RUNGUARD_H
+#endif // ARUNGUARD_H

+ 3 - 3
src/classes/asettings.h

@@ -15,8 +15,8 @@
  *You should have received a copy of the GNU General Public License
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
-#ifndef SETTINGS_H
-#define SETTINGS_H
+#ifndef ASETTINGS_H
+#define ASETTINGS_H
 #include <QtCore>
 #include <QSettings>
 
@@ -32,4 +32,4 @@ public:
     static void write(const QString &key, const QVariant &val);
 };
 
-#endif // SETTINGS_H
+#endif // ASETTINGS_H

+ 4 - 4
src/gui/widgets/debugwidget.cpp

@@ -49,8 +49,8 @@ void DebugWidget::on_resetDatabasePushButton_clicked()
     const auto& linkStub = "https://raw.githubusercontent.com/fiffty-50/openpilotlog/develop/assets/database/templates/";
     for (const auto& table : templateTables) {
         QEventLoop loop;
-        Download* dl = new Download;
-        connect(dl, &Download::done, &loop, &QEventLoop::quit );
+        ADownload* dl = new ADownload;
+        connect(dl, &ADownload::done, &loop, &QEventLoop::quit );
         dl->setTarget(QUrl(linkStub + table + ".csv"));
         dl->setFileName("data/templates/" + table + ".csv");
         dl->download();
@@ -100,8 +100,8 @@ void DebugWidget::on_fillUserDataPushButton_clicked()
     const auto& linkStub = "https://raw.githubusercontent.com/fiffty-50/openpilotlog/develop/assets/database/templates/sample_";
     for (const auto& table : userTables) {
         QEventLoop loop;
-        Download* dl = new Download;
-        connect(dl, &Download::done, &loop, &QEventLoop::quit );
+        ADownload* dl = new ADownload;
+        connect(dl, &ADownload::done, &loop, &QEventLoop::quit );
         dl->setTarget(QUrl(linkStub + table + ".csv"));
         dl->setFileName("data/templates/sample_" + table + ".csv");
         dl->download();

+ 1 - 1
src/gui/widgets/debugwidget.h

@@ -11,7 +11,7 @@
 #include "src/database/db.h"
 #include "src/database/dbsetup.h"
 #include "src/database/dbinfo.h"
-#include "src/classes/download.h"
+#include "src/classes/adownload.h"
 #include "src/functions/areadcsv.h"
 
 namespace Ui {