Browse Source

refactoring iaw coding style guidelines

Refactored all class names iaw new naming guidelines. Adjusted includes and some member variables, improved folder layout. Deprecated classes still have their old names since they will be removed anyway once experimental matures.
Felix Turowsky 4 years ago
parent
commit
95854584a0
66 changed files with 925 additions and 945 deletions
  1. 4 4
      main.cpp
  2. 1 1
      mainwindow.cpp
  3. 2 2
      mainwindow.h
  4. 26 26
      openPilotLog.pro
  5. 13 15
      src/classes/adownload.cpp
  6. 7 7
      src/classes/adownload.h
  7. 1 1
      src/classes/aircraft.cpp
  8. 2 2
      src/classes/aircraft.h
  9. 97 0
      src/classes/arunguard.cpp
  10. 25 17
      src/classes/arunguard.h
  11. 3 3
      src/classes/asettings.cpp
  12. 6 6
      src/classes/asettings.h
  13. 2 2
      src/classes/astrictrxvalidator.cpp
  14. 2 2
      src/classes/astrictrxvalidator.h
  15. 0 78
      src/classes/calc.h
  16. 0 63
      src/classes/completionlist.cpp
  17. 0 14
      src/classes/csv.h
  18. 1 1
      src/classes/flight.cpp
  19. 2 2
      src/classes/flight.h
  20. 1 1
      src/classes/pilot.cpp
  21. 2 2
      src/classes/pilot.h
  22. 0 80
      src/classes/runguard.cpp
  23. 0 35
      src/classes/runguard.h
  24. 43 41
      src/database/adatabasesetup.cpp
  25. 4 5
      src/database/adatabasesetup.h
  26. 1 1
      src/database/db.cpp
  27. 1 1
      src/database/dbinfo.cpp
  28. 13 13
      src/database/entry_deprecated.cpp
  29. 4 4
      src/database/entry_deprecated.h
  30. 0 44
      src/experimental/Entry.cpp
  31. 101 37
      src/experimental/adatabase.cpp
  32. 40 20
      src/experimental/adatabase.h
  33. 32 0
      src/experimental/aentry.cpp
  34. 8 17
      src/experimental/aentry.h
  35. 17 0
      src/experimental/apilotentry.cpp
  36. 20 0
      src/experimental/apilotentry.h
  37. 0 0
      src/experimental/decl.h
  38. 108 134
      src/functions/acalc.cpp
  39. 58 0
      src/functions/acalc.h
  40. 3 3
      src/functions/adebug.h
  41. 3 7
      src/functions/areadcsv.cpp
  42. 8 0
      src/functions/areadcsv.h
  43. 41 33
      src/functions/astat.cpp
  44. 15 13
      src/functions/astat.h
  45. 17 16
      src/gui/dialogues/firstrundialog.cpp
  46. 1 1
      src/gui/dialogues/firstrundialog.h
  47. 78 77
      src/gui/dialogues/newflightdialog.cpp
  48. 4 4
      src/gui/dialogues/newflightdialog.h
  49. 7 10
      src/gui/dialogues/newpilotdialog.cpp
  50. 5 5
      src/gui/dialogues/newpilotdialog.h
  51. 7 8
      src/gui/dialogues/newtaildialog.cpp
  52. 6 6
      src/gui/dialogues/newtaildialog.h
  53. 2 2
      src/gui/widgets/aircraftwidget.cpp
  54. 1 1
      src/gui/widgets/aircraftwidget.h
  55. 11 10
      src/gui/widgets/debugwidget.cpp
  56. 4 2
      src/gui/widgets/debugwidget.h
  57. 1 1
      src/gui/widgets/homewidget.cpp
  58. 5 6
      src/gui/widgets/homewidget.h
  59. 7 7
      src/gui/widgets/logbookwidget.cpp
  60. 1 1
      src/gui/widgets/logbookwidget.h
  61. 5 5
      src/gui/widgets/pilotswidget.cpp
  62. 1 1
      src/gui/widgets/pilotswidget.h
  63. 41 41
      src/gui/widgets/settingswidget.cpp
  64. 1 1
      src/gui/widgets/settingswidget.h
  65. 2 2
      src/gui/widgets/totalswidget.cpp
  66. 1 1
      src/gui/widgets/totalswidget.h

+ 4 - 4
main.cpp

@@ -17,12 +17,12 @@
  */
 #include "mainwindow.h"
 #include "src/gui/dialogues/firstrundialog.h"
-#include "src/classes/runguard.h"
+#include "src/classes/arunguard.h"
 #include <QApplication>
 #include <QProcess>
 #include <QSettings>
 #include <QFileInfo>
-#include "src/experimental/DataBase.h"
+#include "src/experimental/adatabase.h"
 
 const auto DATA_DIR = QLatin1String("data");
 /*!
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
     QSettings settings;
 
 //    Db::connect();
-    experimental::DB()->connect();
+    experimental::aDB()->connect();
 
     QApplication openPilotLog(argc, argv);
     if(!setup()){
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
 
 
     //sqlite does not deal well with multiple connections, ensure only one instance is running
-    RunGuard guard("opl_single_key");
+    ARunGuard guard("opl_single_key");
         if ( !guard.tryToRun() ){
             qDebug() << "Another Instance is already running. Exiting.";
             return 0;

+ 1 - 1
mainwindow.cpp

@@ -17,7 +17,7 @@
  */
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)

+ 2 - 2
mainwindow.h

@@ -35,8 +35,8 @@
 #include "src/gui/widgets/debugwidget.h"
 #include "src/gui/dialogues/newtaildialog.h"
 #include "src/gui/dialogues/newpilotdialog.h"
-#include "src/classes/runguard.h"
-#include "src/experimental/DataBase.h"
+#include "src/classes/arunguard.h"
+#include "src/experimental/adatabase.h"
 
 QT_BEGIN_NAMESPACE
 namespace Ui {

+ 26 - 26
openPilotLog.pro

@@ -18,23 +18,23 @@ DEFINES += QT_DEPRECATED_WARNINGS
 SOURCES += \
     main.cpp \
     mainwindow.cpp \
+    src/classes/adownload.cpp \
     src/classes/aircraft.cpp \
-    src/classes/calc.cpp \
-    src/classes/completionlist.cpp \
-    src/classes/csv.cpp \
-    src/classes/download.cpp \
+    src/classes/arunguard.cpp \
+    src/classes/asettings.cpp \
+    src/classes/astrictrxvalidator.cpp \
     src/classes/flight.cpp \
     src/classes/pilot.cpp \
-    src/classes/runguard.cpp \
-    src/classes/settings.cpp \
-    src/classes/stat.cpp \
-    src/classes/strictrxvalidator.cpp \
+    src/database/adatabasesetup.cpp \
     src/database/db.cpp \
     src/database/dbinfo.cpp \
-    src/database/dbsetup.cpp \
-    src/database/entry.cpp \
-    src/experimental/DataBase.cpp \
-    src/experimental/Entry.cpp \
+    src/database/entry_deprecated.cpp \
+    src/experimental/adatabase.cpp \
+    src/experimental/aentry.cpp \
+    src/experimental/apilotentry.cpp \
+    src/functions/acalc.cpp \
+    src/functions/areadcsv.cpp \
+    src/functions/astat.cpp \
     src/gui/dialogues/firstrundialog.cpp \
     src/gui/dialogues/newflightdialog.cpp \
     src/gui/dialogues/newpilotdialog.cpp \
@@ -48,27 +48,27 @@ SOURCES += \
     src/gui/widgets/totalswidget.cpp
 
 HEADERS += \
-    debug.h \
     mainwindow.h \
+    src/classes/adownload.h \
     src/classes/aircraft.h \
-    src/classes/calc.h \
-    src/classes/completionlist.h \
-    src/classes/csv.h \
-    src/classes/download.h \
+    src/classes/arunguard.h \
+    src/classes/asettings.h \
+    src/classes/astrictrxvalidator.h \
     src/classes/flight.h \
     src/classes/pilot.h \
-    src/classes/runguard.h \
-    src/classes/settings.h \
-    src/classes/stat.h \
-    src/classes/strictrxvalidator.h \
+    src/database/adatabasesetup.h \
     src/database/db.h \
     src/database/dbinfo.h \
-    src/database/dbsetup.h \
-    src/database/entry.h \
-    src/experimental/DataBase.h \
-    src/experimental/Decl.h \
-    src/experimental/Entry.h \
+    src/database/entry_deprecated.h \
     src/experimental/UserInput.h \
+    src/experimental/adatabase.h \
+    src/experimental/aentry.h \
+    src/experimental/apilotentry.h \
+    src/experimental/decl.h \
+    src/functions/acalc.h \
+    src/functions/src/functions/adebug.h \
+    src/functions/areadcsv.h \
+    src/functions/astat.h \
     src/gui/dialogues/firstrundialog.h \
     src/gui/dialogues/newflightdialog.h \
     src/gui/dialogues/newpilotdialog.h \

+ 13 - 15
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 "debug.h"
+#include "adownload.h"
+#include "src/functions/adebug.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

+ 1 - 1
src/classes/aircraft.cpp

@@ -16,7 +16,7 @@
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 #include "aircraft.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 
 Aircraft::Aircraft()

+ 2 - 2
src/classes/aircraft.h

@@ -18,13 +18,13 @@
 #ifndef AIRCRAFT_H
 #define AIRCRAFT_H
 #include <QCoreApplication>
-#include "src/database/entry.h"
+#include "src/database/entry_deprecated.h"
 
 /*!
  * \brief The aircraft class
  *
  */
-class Aircraft : public Entry
+class Aircraft : public Entry_deprecated
 {
 //    using Entry::Entry;
 public:

+ 97 - 0
src/classes/arunguard.cpp

@@ -0,0 +1,97 @@
+/*
+ *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>
+
+
+namespace
+{
+
+QString generateKeyHash(const QString &key, const QString &salt)
+{
+    QByteArray data;
+
+    data.append(key.toUtf8());
+    data.append(salt.toUtf8());
+    data = QCryptographicHash::hash(data, QCryptographicHash::Sha1).toHex();
+
+    return data;
+}
+
+}
+
+
+ARunGuard::ARunGuard(const QString &key )
+    : key(key )
+    , memLockKey(generateKeyHash(key, "_memLockKey" ))
+    , sharedmemKey(generateKeyHash(key, "_sharedmemKey" ))
+    , sharedMem(sharedmemKey )
+    , memLock(memLockKey, 1 )
+{
+    memLock.acquire();
+    {
+        QSharedMemory fix(sharedmemKey );    // Fix for *nix: http://habrahabr.ru/post/173281/
+        fix.attach();
+    }
+    memLock.release();
+}
+
+ARunGuard::~ARunGuard()
+{
+    release();
+}
+
+bool ARunGuard::isAnotherRunning()
+{
+    if (sharedMem.isAttached())
+        return false;
+
+    memLock.acquire();
+    const bool isRunning = sharedMem.attach();
+    if (isRunning )
+        sharedMem.detach();
+    memLock.release();
+
+    return isRunning;
+}
+
+bool ARunGuard::tryToRun()
+{
+    if (isAnotherRunning())  // Extra check
+        return false;
+
+    memLock.acquire();
+    const bool result = sharedMem.create(sizeof(quint64 ));
+    memLock.release();
+    if (!result )
+    {
+        release();
+        return false;
+    }
+
+    return true;
+}
+
+void ARunGuard::release()
+{
+    memLock.acquire();
+    if (sharedMem.isAttached())
+        sharedMem.detach();
+    memLock.release();
+}

+ 25 - 17
src/classes/completionlist.h → src/classes/arunguard.h

@@ -15,30 +15,38 @@
  *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 COMPLETIONLIST_H
-#define COMPLETIONLIST_H
-
-#include <QCoreApplication>
-#include "src/database/db.h"
-
-class CompleterTarget
-{
-public:
-    enum targets {airports, pilots, registrations, aircraft, companies};
-};
+#ifndef ARUNGUARD_H
+#define ARUNGUARD_H
 
+#include <QObject>
+#include <QSharedMemory>
+#include <QSystemSemaphore>
 
 /*!
- * \brief The completionList class provides QStringLists to be used by a QCompleter
+ * \brief The RunGuard class ensures only a single instance of the application
+ * is running simultaneously.
  */
-class CompletionList
+class ARunGuard
 {
+
 public:
-    QStringList list;
+    ARunGuard(const QString &key);
+    ~ARunGuard();
+
+    bool isAnotherRunning();
+    bool tryToRun();
+    void release();
 
-    CompletionList();
+private:
+    const QString key;
+    const QString memLockKey;
+    const QString sharedmemKey;
 
-    CompletionList(CompleterTarget::targets);
+    QSharedMemory sharedMem;
+    QSystemSemaphore memLock;
+
+    Q_DISABLE_COPY(ARunGuard)
 };
 
-#endif // COMPLETIONLIST_H
+
+#endif // ARUNGUARD_H

+ 3 - 3
src/classes/settings.cpp → src/classes/asettings.cpp

@@ -15,15 +15,15 @@
  *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 "settings.h"
+#include "asettings.h"
 
-QVariant Settings::read(const QString &key)
+QVariant ASettings::read(const QString &key)
 {
     QSettings settings;
     return settings.value(key);
 }
 
-void Settings::write(const QString& key, const QVariant& val)
+void ASettings::write(const QString &key, const QVariant &val)
 {
     QSettings settings;
     settings.setValue(key, val);

+ 6 - 6
src/classes/settings.h → 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>
 
@@ -24,12 +24,12 @@
  * \brief The Settings class is a thin wrapper for the QSettings class,
  * simplifying reading and writing of settings.
  */
-class Settings
+class ASettings
 {
 public:
-    static QVariant read(const QString& key);
+    static QVariant read(const QString &key);
 
-    static void write(const QString& key, const QVariant& val);
+    static void write(const QString &key, const QVariant &val);
 };
 
-#endif // SETTINGS_H
+#endif // ASETTINGS_H

+ 2 - 2
src/classes/strictrxvalidator.cpp → src/classes/astrictrxvalidator.cpp

@@ -15,9 +15,9 @@
  *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 "strictrxvalidator.h"
+#include "astrictrxvalidator.h"
 
-QValidator::State StrictRxValidator::validate(QString &txt, int &pos) const
+QValidator::State AStrictRxValidator::validate(QString &txt, int &pos) const
 {
     auto validation = QRegularExpressionValidator::validate(txt, pos);
     if (validation == QValidator::Intermediate) {

+ 2 - 2
src/classes/strictrxvalidator.h → src/classes/astrictrxvalidator.h

@@ -22,9 +22,9 @@
 #include <QValidator>
 
 /*!
- * \brief The StrictRegularExpressionValidator class only returns Invalid or Acceptable
+ * \brief The AStrictRxValidator class only returns Invalid or Acceptable
  */
-class StrictRxValidator : public QRegularExpressionValidator
+class AStrictRxValidator : public QRegularExpressionValidator
 {
     using QRegularExpressionValidator::QRegularExpressionValidator;
 public:

+ 0 - 78
src/classes/calc.h

@@ -1,78 +0,0 @@
-/*
- *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 CALC_H
-#define CALC_H
-
-#include "src/database/db.h"
-#include "src/classes/aircraft.h"
-#include "src/classes/flight.h"
-#include "src/classes/settings.h"
-#include <QDateTime>
-#include <cmath>
-#include <QDebug>
-/*!
- * \brief The calc class provides functionality for various calculations that are performed
- * outside of the database. This includes tasks like converting different units and formats,
- * or functions calculating block time or night time.
- */
-class Calc
-{
-public:
-
-    static QTime blocktime(QTime tofb, QTime tonb);
-
-    static QString minutesToString(QString blockminutes);
-
-    static int stringToMinutes(QString time);
-
-    static int qTimeToMinutes(QTime time);
-
-    static double radToDeg(double rad);
-
-    static double degToRad(double deg);
-
-    static double radToNauticalMiles(double rad);
-
-    static double greatCircleDistance(double lat1, double lon1, double lat2, double lon2);
-
-    static double greatCircleDistanceBetweenAirports(QString dept, QString dest);
-
-    static QVector<QVector<double>> intermediatePointsOnGreatCircle(double lat1,
-                                                                    double lon1,
-                                                                    double lat2,
-                                                                    double lon2,
-                                                                    int tblk);
-
-    static double solarElevation(QDateTime utc_time_point, double lat, double lon);
-
-    static int calculateNightTime(QString dept, QString dest, QDateTime departureTime, int tblk, int nightAngle);
-
-    static bool isNight(QString icao, QDateTime eventTime, int nightAngle);
-
-    static QString formatTimeInput(QString userinput);
-
-    static void updateAutoTimes(int acft_id);
-
-    static void autoTimes(Flight, Aircraft);
-
-    static void updateNightTimes();
-};
-
-
-#endif // CALC_H

+ 0 - 63
src/classes/completionlist.cpp

@@ -1,63 +0,0 @@
-/*
- *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 "completionlist.h"
-
-CompletionList::CompletionList()
-{
-
-}
-
-/*!
- * \brief completionList::completionList construcs a completionList object.
- * Access object->list for the list.
- * \param type see enum completerTarget::targets
- */
-CompletionList::CompletionList(CompleterTarget::targets type)
-{
-    QString query;
-    QVector<QString> columns;
-    QVector<QString> result;
-
-    switch (type) {
-    case CompleterTarget::airports:
-        columns.append("icao");
-        columns.append("iata");
-        result = Db::multiSelect(columns, "airports");
-        break;
-    case CompleterTarget::registrations:
-        columns.append("registration");
-        result = Db::multiSelect(columns, "tails");
-        break;
-    case CompleterTarget::companies:
-        columns.append("company");
-        result = Db::multiSelect(columns, "pilots");
-        break;
-    case CompleterTarget::pilots:
-        query.append("SELECT piclastname||','||picfirstname FROM pilots");
-        result = Db::customQuery(query, 1);
-        break;
-    case CompleterTarget::aircraft:
-        query.append("SELECT make||' '||model||'-'||variant FROM aircraft");
-        result = Db::customQuery(query, 1);
-        break;
-    }
-
-    list = result.toList();
-    list.removeAll(QString(""));
-    list.removeDuplicates();
-}

+ 0 - 14
src/classes/csv.h

@@ -1,14 +0,0 @@
-#ifndef CSV_H
-#define CSV_H
-#include <QtCore>
-
-class Csv
-{
-public:
-    Csv();
-
-    static QVector<QStringList> read(QString filename);
-
-};
-
-#endif // CSV_H

+ 1 - 1
src/classes/flight.cpp

@@ -16,7 +16,7 @@
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 #include "flight.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 Flight::Flight()
 {

+ 2 - 2
src/classes/flight.h

@@ -21,10 +21,10 @@
 #include <QCoreApplication>
 #include <QDateTime>
 #include <QDebug>
-#include "src/database/entry.h"
+#include "src/database/entry_deprecated.h"
 
 
-class Flight : public Entry
+class Flight : public Entry_deprecated
 {
 //    using Entry::Entry;
 public:

+ 1 - 1
src/classes/pilot.cpp

@@ -16,7 +16,7 @@
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 #include "pilot.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 
 

+ 2 - 2
src/classes/pilot.h

@@ -17,10 +17,10 @@
  */
 #ifndef PILOT_H
 #define PILOT_H
-#include "src/database/entry.h"
+#include "src/database/entry_deprecated.h"
 
 
-class Pilot : public Entry
+class Pilot : public Entry_deprecated
 {
 //    using Entry::Entry;
 public:

+ 0 - 80
src/classes/runguard.cpp

@@ -1,80 +0,0 @@
-#include "runguard.h"
-
-#include <QCryptographicHash>
-
-
-namespace
-{
-
-QString generateKeyHash( const QString& key, const QString& salt )
-{
-    QByteArray data;
-
-    data.append( key.toUtf8() );
-    data.append( salt.toUtf8() );
-    data = QCryptographicHash::hash( data, QCryptographicHash::Sha1 ).toHex();
-
-    return data;
-}
-
-}
-
-
-RunGuard::RunGuard( const QString& key )
-    : key( key )
-    , memLockKey( generateKeyHash( key, "_memLockKey" ) )
-    , sharedmemKey( generateKeyHash( key, "_sharedmemKey" ) )
-    , sharedMem( sharedmemKey )
-    , memLock( memLockKey, 1 )
-{
-    memLock.acquire();
-    {
-        QSharedMemory fix( sharedmemKey );    // Fix for *nix: http://habrahabr.ru/post/173281/
-        fix.attach();
-    }
-    memLock.release();
-}
-
-RunGuard::~RunGuard()
-{
-    release();
-}
-
-bool RunGuard::isAnotherRunning()
-{
-    if ( sharedMem.isAttached() )
-        return false;
-
-    memLock.acquire();
-    const bool isRunning = sharedMem.attach();
-    if ( isRunning )
-        sharedMem.detach();
-    memLock.release();
-
-    return isRunning;
-}
-
-bool RunGuard::tryToRun()
-{
-    if ( isAnotherRunning() )   // Extra check
-        return false;
-
-    memLock.acquire();
-    const bool result = sharedMem.create( sizeof( quint64 ) );
-    memLock.release();
-    if ( !result )
-    {
-        release();
-        return false;
-    }
-
-    return true;
-}
-
-void RunGuard::release()
-{
-    memLock.acquire();
-    if ( sharedMem.isAttached() )
-        sharedMem.detach();
-    memLock.release();
-}

+ 0 - 35
src/classes/runguard.h

@@ -1,35 +0,0 @@
-#ifndef RUNGUARD_H
-#define RUNGUARD_H
-
-#include <QObject>
-#include <QSharedMemory>
-#include <QSystemSemaphore>
-
-/*!
- * \brief The RunGuard class ensures only a single instance of the application
- * is running simultaneously.
- */
-class RunGuard
-{
-
-public:
-    RunGuard( const QString& key );
-    ~RunGuard();
-
-    bool isAnotherRunning();
-    bool tryToRun();
-    void release();
-
-private:
-    const QString key;
-    const QString memLockKey;
-    const QString sharedmemKey;
-
-    QSharedMemory sharedMem;
-    QSystemSemaphore memLock;
-
-    Q_DISABLE_COPY( RunGuard )
-};
-
-
-#endif // RUNGUARD_H

+ 43 - 41
src/database/dbsetup.cpp → src/database/adatabasesetup.cpp

@@ -15,15 +15,16 @@
  *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 "dbsetup.h"
-#include "debug.h"
+#include "adatabasesetup.h"
+#include "src/functions/adebug.h"
 
-// Statements for creation of database tables, Revision 10
+
+// Statements for creation of database tables, Revision 12
 
 const QString createTablePilots = "CREATE TABLE \"pilots\" ( "
             "\"pilot_id\"       INTEGER NOT NULL, "
-            "\"piclastname\"	TEXT    NOT NULL, "
-            "\"picfirstname\"	TEXT, "
+            "\"piclastname\"    TEXT    NOT NULL, "
+            "\"picfirstname\"   TEXT, "
             "\"alias\"          TEXT, "
             "\"company\"        TEXT, "
             "\"employeeid\"     TEXT, "
@@ -34,15 +35,15 @@ const QString createTablePilots = "CREATE TABLE \"pilots\" ( "
 
 const QString createTableTails = "CREATE TABLE \"tails\" ( "
             "\"tail_id\"        INTEGER NOT NULL, "
-            "\"registration\"	TEXT NOT NULL, "
+            "\"registration\"   TEXT NOT NULL, "
             "\"company\"        TEXT, "
             "\"make\"           TEXT, "
             "\"model\"          TEXT, "
             "\"variant\"        TEXT, "
-            "\"singlepilot\"	INTEGER, "
+            "\"singlepilot\"    INTEGER, "
             "\"multipilot\"     INTEGER, "
-            "\"singleengine\"	INTEGER, "
-            "\"multiengine\"	INTEGER, "
+            "\"singleengine\"   INTEGER, "
+            "\"multiengine\"    INTEGER, "
             "\"unpowered\"      INTEGER, "
             "\"piston\"         INTEGER, "
             "\"turboprop\"      INTEGER, "
@@ -75,16 +76,16 @@ const QString createTableFlights = "CREATE TABLE \"flights\" ("
             "\"tDUAL\"          INTEGER, "
             "\"tFI\"            INTEGER, "
             "\"tSIM\"           INTEGER, "
-            "\"pilotFlying\"	INTEGER, "
+            "\"pilotFlying\"    INTEGER, "
             "\"toDay\"          INTEGER, "
             "\"toNight\"        INTEGER, "
             "\"ldgDay\"         INTEGER, "
             "\"ldgNight\"       INTEGER, "
             "\"autoland\"       INTEGER, "
-            "\"secondPilot\"	INTEGER, "
+            "\"secondPilot\"    INTEGER, "
             "\"thirdPilot\"     INTEGER, "
-            "\"ApproachType\"	TEXT, "
-            "\"FlightNumber\"	TEXT, "
+            "\"ApproachType\"   TEXT, "
+            "\"FlightNumber\"   TEXT, "
             "\"Remarks\"        TEXT, "
             "FOREIGN KEY(\"pic\")  REFERENCES \"pilots\"(\"pilot_id\") ON DELETE RESTRICT, "
             "FOREIGN KEY(\"acft\") REFERENCES \"tails\"(\"tail_id\")   ON DELETE RESTRICT, "
@@ -106,17 +107,17 @@ const QString createTableAirports = "CREATE TABLE \"airports\" ( "
             ")";
 
 const QString createTableAircraft = "CREATE TABLE \"aircraft\" ( "
-            "\"aircraft_id\"	INTEGER NOT NULL, "
+            "\"aircraft_id\"    INTEGER NOT NULL, "
             "\"make\"           TEXT, "
             "\"model\"          TEXT, "
             "\"variant\"        TEXT, "
             "\"name\"           TEXT, "
             "\"iata\"           TEXT, "
             "\"icao\"           TEXT, "
-            "\"singlepilot\"	INTEGER, "
+            "\"singlepilot\"    INTEGER, "
             "\"multipilot\"     INTEGER, "
-            "\"singleengine\"	INTEGER, "
-            "\"multiengine\"	INTEGER, "
+            "\"singleengine\"   INTEGER, "
+            "\"multiengine\"    INTEGER, "
             "\"unpowered\"      INTEGER, "
             "\"piston\"         INTEGER, "
             "\"turboprop\"      INTEGER, "
@@ -129,9 +130,9 @@ const QString createTableAircraft = "CREATE TABLE \"aircraft\" ( "
             ")";
 
 const QString createTableChangelog = "CREATE TABLE \"changelog\" ( "
-            "\"revision\"	INTEGER NOT NULL, "
-            "\"comment\"	TEXT, "
-            "\"date\"	NUMERIC, "
+            "\"revision\"   INTEGER NOT NULL, "
+            "\"comment\"    TEXT, "
+            "\"date\"       NUMERIC, "
             "PRIMARY KEY(\"revision\") "
             ")";
 
@@ -141,7 +142,7 @@ const QString createViewDefault = "CREATE VIEW viewDefault AS "
         "dept AS 'Dept', "
         "printf('%02d',(tofb/60))||':'||printf('%02d',(tofb%60)) AS 'Time', "
         "dest AS 'Dest', printf('%02d',(tonb/60))||':'||printf('%02d',(tonb%60)) AS 'Time ', "
-        "printf('%02d',(tblk/60))||':'||printf('%02d',(tblk%60)) AS 'Total', " 
+        "printf('%02d',(tblk/60))||':'||printf('%02d',(tblk%60)) AS 'Total', "
         "CASE "
         "WHEN pilot_id = 1 THEN alias "
         "ELSE piclastname||', '||substr(picfirstname, 1, 1)||'.' "
@@ -255,31 +256,32 @@ const QStringList templateTables= {
 };
 
 
-bool DbSetup::createDatabase()
+bool ADataBaseSetup::createDatabase()
 {
-    /// [George]: Not necessary to heap allocate for such a trivial task
-    /// TODO: Since you want to be fancy well do it with some cheeky bit operations
-    /// for the lolz.
-    QVector<bool> returnValues;
-
     DEB("Creating tables...");
-    returnValues << createSchemata(tables);
+    if (!createSchemata(tables)) {
+        DEB("Creating tables has failed.");
+        return false;
+    }
+
     DEB("Creating views...");
-    returnValues << createSchemata(views);
-    DEB("Populating tables...");
-    returnValues << importDefaultData();
+    if (!createSchemata(views)) {
+        DEB("Creating views failed.");
+        return false;
+    }
 
-    for (const auto& allGood : returnValues) {
-        if (!allGood){
-            return false;
-        }
+    DEB("Populating tables...");
+    if (!importDefaultData()) {
+        DEB("Populating tables failed.");
+        return false;
     }
+
     DEB("Database successfully created!");
     return true;
 }
 
 
-bool DbSetup::importDefaultData()
+bool ADataBaseSetup::importDefaultData()
 {
     QSqlQuery query;
     // reset template tables
@@ -290,7 +292,7 @@ bool DbSetup::importDefaultData()
             DEB("Error: " << query.lastError().text());
         }
         //fill with data from csv
-        if (!commitData(Csv::read("data/templates/" + table + ".csv"), table)) {
+        if (!commitData(aReadCsv("data/templates/" + table + ".csv"), table)) {
             DEB("Error importing data.");
             return false;
         }
@@ -302,7 +304,7 @@ bool DbSetup::importDefaultData()
  * \brief DbSetup::resetToDefault Empties all user-generated content in the database.
  * \return true on success
  */
-bool DbSetup::resetToDefault()
+bool ADataBaseSetup::resetToDefault()
 {
     QSqlQuery query;
 
@@ -319,7 +321,7 @@ bool DbSetup::resetToDefault()
 /*!
  * \brief dbSetup::debug prints Database Layout
  */
-void DbSetup::debug()
+void ADataBaseSetup::debug()
 {
     DEB("Database tables and views: ");
     QSqlQuery query;
@@ -341,7 +343,7 @@ void DbSetup::debug()
  * \brief dbSetup::createTables Create the required tables for the database
  * \return true on success
  */
-bool DbSetup::createSchemata(const QStringList &statements)
+bool ADataBaseSetup::createSchemata(const QStringList &statements)
 {
     QSqlQuery query;
     QStringList errors;
@@ -375,7 +377,7 @@ bool DbSetup::createSchemata(const QStringList &statements)
  * \param tableName as in the database
  * \return
  */
-bool DbSetup::commitData(QVector<QStringList> fromCSV, const QString &tableName)
+bool ADataBaseSetup::commitData(QVector<QStringList> fromCSV, const QString &tableName)
 {
     DEB("Importing Data to" << tableName);
     auto dbLayout = DbInfo();

+ 4 - 5
src/database/dbsetup.h → src/database/adatabasesetup.h

@@ -21,18 +21,17 @@
 #include <QCoreApplication>
 #include "src/database/db.h"
 #include "src/database/dbinfo.h"
-#include "src/classes/csv.h"
-
+#include "src/functions/areadcsv.h"
 
 /*!
- * \brief The DbSetup class is responsible for the inital setup of the database when
+ * \brief The ADataBaseSetup class is responsible for the inital setup of the database when
  * the application is first launched. It creates the database in the specified default
  * location and creates all required tables and views. It can also be used to reset the
  * database currently used
  */
-class DbSetup
+class ADataBaseSetup
 {
-public: 
+public:
     static void debug();
 
     static bool createDatabase();

+ 1 - 1
src/database/db.cpp

@@ -17,7 +17,7 @@
  */
 #include "db.h"
 #include "dbinfo.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 /*!
  * \brief Db::iconnect - see Db::connect

+ 1 - 1
src/database/dbinfo.cpp

@@ -16,7 +16,7 @@
  *along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 #include "dbinfo.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 DbInfo::DbInfo()
 {

+ 13 - 13
src/database/entry.cpp → src/database/entry_deprecated.cpp

@@ -15,15 +15,15 @@
  *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 "entry.h"
-#include "debug.h"
+#include "entry_deprecated.h"
+#include "src/functions/adebug.h"
 #include "db.h"
 
-Entry::Entry()
+Entry_deprecated::Entry_deprecated()
 {
 }
 
-Entry::Entry(QString table, int row)
+Entry_deprecated::Entry_deprecated(QString table, int row)
 {
     //retreive database layout
     const auto dbContent = DbInfo();
@@ -65,7 +65,7 @@ Entry::Entry(QString table, int row)
     }
 }
 
-Entry::Entry(QString table, QMap<QString, QString> newData)
+Entry_deprecated::Entry_deprecated(QString table, QMap<QString, QString> newData)
 {
     //retreive database layout
     const auto dbContent = DbInfo();
@@ -93,7 +93,7 @@ Entry::Entry(QString table, QMap<QString, QString> newData)
     data = newData;
 }
 
-void Entry::setData(QMap<QString, QString> &value)
+void Entry_deprecated::setData(QMap<QString, QString> &value)
 {
     //retreive database layout
     const auto dbContent = DbInfo();
@@ -114,7 +114,7 @@ void Entry::setData(QMap<QString, QString> &value)
     data = value;
 }
 
-bool Entry::commit()
+bool Entry_deprecated::commit()
 {
     if (exists()) {
         return update();
@@ -123,7 +123,7 @@ bool Entry::commit()
     }
 }
 
-bool Entry::remove()
+bool Entry_deprecated::remove()
 {
     if (exists()) {
         QString statement = "DELETE FROM " + position.first +
@@ -143,7 +143,7 @@ bool Entry::remove()
     }
 }
 
-bool Entry::exists()
+bool Entry_deprecated::exists()
 {
     //Check database for row id
     QString statement = "SELECT COUNT(*) FROM " + position.first +
@@ -160,7 +160,7 @@ bool Entry::exists()
     }
 }
 
-bool Entry::insert()
+bool Entry_deprecated::insert()
 {
     DEB("Inserting...");
     //check prerequisites
@@ -193,7 +193,7 @@ bool Entry::insert()
     }
 }
 
-bool Entry::update()
+bool Entry_deprecated::update()
 {
     //create query
     QString statement = "UPDATE " + position.first + " SET ";
@@ -224,7 +224,7 @@ bool Entry::update()
 }
 
 //Debug
-void Entry::print()
+void Entry_deprecated::print()
 {
     QString v = "Object status:\t\033[38;2;0;255;0;48;2;0;0;0m VALID \033[0m\n";
     QString nv = "Object status:\t\033[38;2;255;0;0;48;2;0;0;0m INVALID \033[0m\n";
@@ -240,7 +240,7 @@ void Entry::print()
     }
 }
 
-QString Entry::debug()
+QString Entry_deprecated::debug()
 {
     print();
     return QString();

+ 4 - 4
src/database/entry.h → src/database/entry_deprecated.h

@@ -26,12 +26,12 @@
  * It can be seen as a row in a table within the database.
  *
  */
-class Entry
+class Entry_deprecated
 {
 public:
-    Entry();
-    Entry(QString table, int row);
-    Entry(QString table, QMap<QString, QString> newData);
+    Entry_deprecated();
+    Entry_deprecated(QString table, int row);
+    Entry_deprecated(QString table, QMap<QString, QString> newData);
 
     QPair   <QString, int>       position = QPair<QString, int>();    // Position within the database, i.e. <table,row>
     QVector <QString>            columns  = QVector<QString>();       // The columns within the table

+ 0 - 44
src/experimental/Entry.cpp

@@ -1,44 +0,0 @@
-#include "Entry.h"
-
-namespace experimental {
-
-Entry::Entry(DataPosition position_)
-    : position(position_)
-{}
-
-Entry::Entry(TableData table_data)
-    : tableData(table_data)
-{}
-
-Entry::Entry(DataPosition position_, TableData table_data)
-    : position(position_), tableData(table_data)
-{}
-
-void Entry::setData(TableData table_data)
-{
-    tableData = table_data;
-}
-
-const DataPosition& Entry::getPosition()
-{
-    return position;
-}
-
-const TableData& Entry::getData()
-{
-    return tableData;
-}
-
-PilotEntry::PilotEntry()
-    : Entry::Entry(DEFAULT_PILOT_POSITION)
-{}
-
-PilotEntry::PilotEntry(int row_id)
-    : Entry::Entry(DataPosition("pilots", row_id))
-{}
-
-PilotEntry::PilotEntry(TableData table_data)
-    : Entry::Entry(DEFAULT_PILOT_POSITION, table_data)
-{}
-
-}  // namespace experimental

+ 101 - 37
src/experimental/DataBase.cpp → src/experimental/adatabase.cpp

@@ -1,17 +1,17 @@
-#include "DataBase.h"
+#include "adatabase.h"
 
 namespace experimental {
 
-DataBase* DataBase::instance = nullptr;
+ADataBase* ADataBase::instance = nullptr;
 
-DataBase* DataBase::getInstance()
+ADataBase* ADataBase::getInstance()
 {
     if(!instance)
-        instance = new DataBase();
+        instance = new ADataBase();
     return instance;
 }
 
-bool DataBase::connect()
+bool ADataBase::connect()
 {
     const QString driver("QSQLITE");
 
@@ -44,20 +44,20 @@ bool DataBase::connect()
     return true;
 }
 
-void DataBase::disconnect()
+void ADataBase::disconnect()
 {
-    auto db = DataBase::database();
+    auto db = ADataBase::database();
     db.close();
     db.removeDatabase(db.connectionName());
     DEB("Database connection closed.");
 }
 
-QSqlDatabase DataBase::database()
+QSqlDatabase ADataBase::database()
 {
     return QSqlDatabase::database("qt_sql_default_connection");
 }
 
-bool DataBase::commit(Entry entry)
+bool ADataBase::commit(AEntry entry)
 {
     if (exists(entry)) {
         return update(entry);
@@ -66,7 +66,7 @@ bool DataBase::commit(Entry entry)
     }
 }
 
-bool DataBase::remove(Entry entry)
+bool ADataBase::remove(AEntry entry)
 {
     if (!exists(entry)) {
         DEB("Error: Entry does not exist.");
@@ -75,23 +75,23 @@ bool DataBase::remove(Entry entry)
 
     QString statement = "DELETE FROM " + entry.getPosition().tableName +
             " WHERE ROWID=" + QString::number(entry.getPosition().rowId);
-    QSqlQuery q(statement);
+    QSqlQuery query(statement);
 
-    if (q.lastError().type() == QSqlError::NoError)
+    if (query.lastError().type() == QSqlError::NoError)
     {
         DEB("Entry " << entry.getPosition().tableName << entry.getPosition().rowId << " removed.");
-        emit commitSuccessful();
+        emit sqlSuccessful();
         return true;
     } else {
         DEB("Unable to delete.");
         DEB("Query: " << statement);
-        DEB("Query Error: " << q.lastError().text());
-        emit sqlError(q.lastError(), statement);
+        DEB("Query Error: " << query.lastError().text());
+        emit sqlError(query.lastError(), statement);
         return false;
     }
 }
 
-bool DataBase::exists(Entry entry)
+bool ADataBase::exists(AEntry entry)
 {
     if(entry.getPosition() == DEFAULT_PILOT_POSITION)
         return false;
@@ -100,9 +100,9 @@ bool DataBase::exists(Entry entry)
     QString statement = "SELECT COUNT(*) FROM " + entry.getPosition().tableName +
             " WHERE ROWID=" + QString::number(entry.getPosition().rowId);
     //this returns either 1 or 0 since row ids are unique
-    QSqlQuery q(statement);
-    q.next();
-    int rowId = q.value(0).toInt();
+    QSqlQuery query(statement);
+    query.next();
+    int rowId = query.value(0).toInt();
     if (rowId) {
         DEB("Entry " << entry.getPosition() << " exists.");
         return true;
@@ -113,7 +113,7 @@ bool DataBase::exists(Entry entry)
 }
 
 
-bool DataBase::update(Entry updated_entry)
+bool ADataBase::update(AEntry updated_entry)
 {
     auto data = updated_entry.getData();
     QString statement = "UPDATE " + updated_entry.getPosition().tableName + " SET ";
@@ -128,23 +128,23 @@ bool DataBase::update(Entry updated_entry)
     statement.append(QLatin1String(" WHERE ROWID=") + QString::number(updated_entry.getPosition().rowId));
 
     DEB("UPDATE QUERY: " << statement);
-    QSqlQuery q(statement);
+    QSqlQuery query(statement);
 
-    if (q.lastError().type() == QSqlError::NoError)
+    if (query.lastError().type() == QSqlError::NoError)
     {
         DEB("Entry successfully committed.");
-        emit commitSuccessful();
+        emit sqlSuccessful();
         return true;
     } else {
         DEB("Unable to commit.");
         DEB("Query: " << statement);
-        DEB("Query Error: " << q.lastError().text());
-        emit sqlError(q.lastError(), statement);
+        DEB("Query Error: " << query.lastError().text());
+        emit sqlError(query.lastError(), statement);
         return false;
     }
 }
 
-bool DataBase::insert(Entry new_entry)
+bool ADataBase::insert(AEntry new_entry)
 {
     auto data = new_entry.getData();
     DEB("Inserting...");
@@ -161,24 +161,24 @@ bool DataBase::insert(Entry new_entry)
     statement.chop(2);
     statement += QLatin1String(")");
 
-    QSqlQuery q(statement);
+    QSqlQuery query(statement);
     //check result.
-    if (q.lastError().type() == QSqlError::NoError)
+    if (query.lastError().type() == QSqlError::NoError)
     {
         DEB("Entry successfully committed.");
-        emit commitSuccessful();
+        emit sqlSuccessful();
         return true;
     } else {
         DEB("Unable to commit.");
         DEB("Query: " << statement);
-        DEB("Query Error: " << q.lastError().text());
-        emit sqlError(q.lastError(), statement);
+        DEB("Query Error: " << query.lastError().text());
+        emit sqlError(query.lastError(), statement);
         return false;
     }
 
 }
 
-TableData DataBase::getEntryData(DataPosition data_position)
+TableData ADataBase::getEntryData(DataPosition data_position)
 {
     // check table exists
     if (!tableNames.contains(data_position.first)) {
@@ -224,20 +224,84 @@ TableData DataBase::getEntryData(DataPosition data_position)
     return entry_data;
 }
 
-Entry DataBase::getEntry(DataPosition data_position)
+AEntry ADataBase::getEntry(DataPosition data_position)
 {
-    Entry entry(data_position);
+    AEntry entry(data_position);
     entry.setData(getEntryData(data_position));
     return entry;
 }
 
-PilotEntry DataBase::getPilotEntry(RowId row_id)
+APilotEntry ADataBase::getPilotEntry(RowId row_id)
 {
-    PilotEntry pilotEntry(row_id);
+    APilotEntry pilotEntry(row_id);
     pilotEntry.setData(getEntryData(pilotEntry.getPosition()));
     return pilotEntry;
 }
 
-DataBase* DB() { return DataBase::getInstance(); }
+QStringList ADataBase::getCompletionList(ADataBase::CompleterTarget target)
+{
+    QString statement;
+
+    switch (target) {
+    case pilots:
+        statement.append("SELECT piclastname||\",\"||picfirstname FROM pilots");
+        break;
+    case aircraft:
+        statement.append("SELECT make||\" \"||model FROM aircraft WHERE model IS NOT NULL "
+                         "UNION "
+                         "SELECT make||\" \"||model||\"-\"||variant FROM aircraft WHERE variant IS NOT NULL");
+        break;
+    case airports:
+        statement.append("SELECT icao FROM airports UNION SELECT iata FROM airports");
+        break;
+    case registrations:
+        statement.append("SELECT registration FROM tails");
+        break;
+    case companies:
+        statement.append("SELECT company FROM pilots");
+        break;
+    }
+
+    QSqlQuery query(statement);
+    if(!query.first())
+        emit sqlError(query.lastError(), statement);
+
+    query.previous();
+    QStringList completer_list;
+    while (query.next())
+        completer_list.append(query.value(0).toString());
+
+    completer_list.sort();
+    completer_list.removeAll(QString(""));
+    completer_list.removeDuplicates();
+
+    return completer_list;
+}
+
+QVector<QString> ADataBase::customQuery(QString statement, int return_values)
+{
+    QSqlQuery query(statement);
+    query.exec();
+
+    if (!query.first()) {
+        DEB("No result found. Check Query and Error.");
+        DEB("Error: " << query.lastError().text());
+        emit sqlError(query.lastError(), statement);
+        return QVector<QString>();
+    } else {
+        query.first();
+        query.previous();
+        QVector<QString> result;
+        while (query.next()) {
+            for (int i = 0; i < return_values ; i++) {
+                result.append(query.value(i).toString());
+            }
+        }
+        emit sqlSuccessful();
+        return result;
+    }
+}
+
+ADataBase* aDB() { return ADataBase::getInstance(); }
 
 }

+ 40 - 20
src/experimental/DataBase.h → src/experimental/adatabase.h

@@ -8,9 +8,10 @@
 #include <QSqlError>
 #include <QSqlTableModel>
 #include "src/database/dbinfo.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
-#include "Entry.h"
+#include "aentry.h"
+#include "apilotentry.h"
 
 namespace experimental {
 
@@ -18,18 +19,24 @@ namespace experimental {
  * \brief The DB class encapsulates the SQL database by providing fast access
  * to hot database data.
  */
-class DataBase : public QObject {
+class ADataBase : public QObject {
     Q_OBJECT
 private:
     TableNames tableNames;
     TableColumns tableColumns;
-    static DataBase* instance;
-    DataBase() = default;
+    static ADataBase* instance;
+    ADataBase() = default;
 public:
     // Ensure DB is not copiable or assignable
-    DataBase(const DataBase&) = delete;
-    void operator=(const DataBase&) = delete;
-    static DataBase* getInstance();
+    ADataBase(const ADataBase&) = delete;
+    void operator=(const ADataBase&) = delete;
+    static ADataBase* getInstance();
+
+    /*!
+     * \brief The CompleterTarget enum provides the items for which QCompleter
+     * completion lists are provided from the database.
+     */
+    enum CompleterTarget {airports, pilots, registrations, aircraft, companies};
 
     /*!
      * \brief Connect to the database and populate database information.
@@ -45,34 +52,40 @@ public:
      * \brief Can be used to access the database connection.
      * \return The QSqlDatabase object pertaining to the connection.
      */
-    static
-    QSqlDatabase database();
+    static QSqlDatabase database();
+
+    /*!
+     * \brief Can be used to send a complex query to the database.
+     * \param query - the full sql query statement
+     * \param returnValues - the number of return values
+     */
+    QVector<QString> customQuery(QString statement, int return_values);
 
     /*!
      * \brief Checks if an entry exists in the database, based on position data
      */
-    bool exists(Entry entry);
+    bool exists(AEntry entry);
 
     /*!
      * \brief commits an entry to the database, calls either insert or update,
      * based on position data
      */
-    bool commit(Entry entry);
+    bool commit(AEntry entry);
 
     /*!
      * \brief Create new entry in the databse based on UserInput
      */
-    bool insert(Entry new_entry);
+    bool insert(AEntry new_entry);
 
     /*!
      * \brief Updates entry in database from existing entry tweaked by the user.
      */
-    bool update(Entry updated_entry);
+    bool update(AEntry updated_entry);
 
     /*!
      * \brief deletes an entry from the database.
      */
-    bool remove(Entry entry);
+    bool remove(AEntry entry);
 
     /*!
      * \brief retreive entry data from the database to create an entry object
@@ -82,7 +95,7 @@ public:
     /*!
      * \brief retreive an Entry from the database.
      */
-    Entry getEntry(DataPosition data_position);
+    AEntry getEntry(DataPosition data_position);
 
     /*!
      * \brief retreives a PilotEntry from the database.
@@ -92,11 +105,18 @@ public:
      * instead of an Entry. It allows for easy access to a pilot entry
      * with only the RowId required as input.
      */
-    PilotEntry getPilotEntry(RowId row_id);
+    APilotEntry getPilotEntry(RowId row_id);
     // [G] TODO: Ensure PilotDialog works great and slowly move to
     // other dialogs
+
+    /*!
+     * \brief getCompletionList returns a QStringList of values for a
+     * QCompleter based on database values
+     * \return
+     */
+    QStringList getCompletionList(CompleterTarget);
 signals:
-    void commitSuccessful();
+    void sqlSuccessful();
 
     void sqlError(const QSqlError &sqlError, const QString &sqlStatement);
 
@@ -107,9 +127,9 @@ signals:
  * Instead of this:
  * DataBase::getInstance().commit(...)
  * Write this:
- * DB()->commit(...)
+ * aDB()->commit(...)
  */
-DataBase* DB();
+ADataBase* aDB();
 
 }  // namespace experimental
 

+ 32 - 0
src/experimental/aentry.cpp

@@ -0,0 +1,32 @@
+#include "aentry.h"
+
+namespace experimental {
+
+AEntry::AEntry(DataPosition position_)
+    : position(position_)
+{}
+
+AEntry::AEntry(TableData table_data)
+    : tableData(table_data)
+{}
+
+AEntry::AEntry(DataPosition position_, TableData table_data)
+    : position(position_), tableData(table_data)
+{}
+
+void AEntry::setData(TableData table_data)
+{
+    tableData = table_data;
+}
+
+const DataPosition& AEntry::getPosition()
+{
+    return position;
+}
+
+const TableData& AEntry::getData()
+{
+    return tableData;
+}
+
+}  // namespace experimental

+ 8 - 17
src/experimental/Entry.h → src/experimental/aentry.h

@@ -6,7 +6,7 @@
 #include <QMap>
 #include <QPair>
 
-#include "Decl.h"
+#include "decl.h"
 
 namespace experimental {
 
@@ -17,17 +17,17 @@ namespace experimental {
  * \brief The Entry class encapsulates table metadata(table name, row id)
  *  and data for new and existing entries in the database to operate on.
  */
-class Entry {
+class AEntry {
 protected:
     DataPosition position;
     TableData tableData;
 public:
-    Entry() = delete; // Demand specificity from default constructor
-    Entry(const Entry&) = default;
-    Entry& operator=(const Entry&) = default;
-    Entry(DataPosition position_);
-    Entry(TableData table_data);
-    Entry(DataPosition position_, TableData table_data);
+    AEntry() = delete; // Demand specificity from default constructor
+    AEntry(const AEntry&) = default;
+    AEntry& operator=(const AEntry&) = default;
+    AEntry(DataPosition position_);
+    AEntry(TableData table_data);
+    AEntry(DataPosition position_, TableData table_data);
 
     void setData(TableData table_data);
     void setPosition(DataPosition position_);
@@ -37,15 +37,6 @@ public:
 
 };
 
-struct PilotEntry : public Entry {
-public:
-    PilotEntry();
-    PilotEntry(const PilotEntry& pe) = default;
-    PilotEntry& operator=(const PilotEntry& pe) = default;
-    PilotEntry(int row_id);
-    PilotEntry(TableData table_data);
-};
-
 }
 
 #endif // ENTRY_H

+ 17 - 0
src/experimental/apilotentry.cpp

@@ -0,0 +1,17 @@
+#include "apilotentry.h"
+
+namespace experimental {
+
+APilotEntry::APilotEntry()
+    : AEntry::AEntry(DEFAULT_PILOT_POSITION)
+{}
+
+APilotEntry::APilotEntry(int row_id)
+    : AEntry::AEntry(DataPosition("pilots", row_id))
+{}
+
+APilotEntry::APilotEntry(TableData table_data)
+    : AEntry::AEntry(DEFAULT_PILOT_POSITION, table_data)
+{}
+
+} // namespace experimental

+ 20 - 0
src/experimental/apilotentry.h

@@ -0,0 +1,20 @@
+#ifndef APILOTENTRY_H
+#define APILOTENTRY_H
+
+#include "src/experimental/aentry.h"
+#include "src/experimental/decl.h"
+
+namespace experimental {
+
+struct APilotEntry : public AEntry {
+public:
+    APilotEntry();
+    APilotEntry(const APilotEntry& pe) = default;
+    APilotEntry& operator=(const APilotEntry& pe) = default;
+    APilotEntry(int row_id);
+    APilotEntry(TableData table_data);
+};
+
+} // namespace experimental
+
+#endif // APILOTENTRY_H

+ 0 - 0
src/experimental/Decl.h → src/experimental/decl.h


+ 108 - 134
src/classes/calc.cpp → src/functions/acalc.cpp

@@ -1,55 +1,38 @@
-/*
- *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 "calc.h"
-#include "debug.h"
+#include "acalc.h"
+#include "src/functions/adebug.h"
+
+using namespace ACalc;
 
 /*!
- * \brief Calc::blocktime Calculates Block Time for a given departure and arrival time
+ * \brief ACalc::blocktime Calculates Block Time for a given departure and arrival time
  * \param tofb QTime Time Off Blocks
  * \param tonb QTime Time On Blocks
  * \return Block Time in minutes
  */
-QTime Calc::blocktime(QTime tofb, QTime tonb)
+QTime ACalc::blocktime(QTime tofb, QTime tonb)
 {
-    if (tonb > tofb) { // landing same day
-        QTime blocktimeout(0, 0); // initialise return value at midnight
-        int blockseconds = tofb.secsTo(tonb); // returns seconds between 2 time objects
-        blocktimeout = blocktimeout.addSecs(blockseconds);
-        return blocktimeout;
+    QTime blocktime_out(0, 0); // initialise return value at midnight
 
+    if (tonb > tofb) { // landing same day
+        int blockseconds = tofb.secsTo(tonb);
+        blocktime_out = blocktime_out.addSecs(blockseconds);
     } else { // landing next day
         QTime midnight(0, 0);
-        QTime blocktimeout(0, 0); // initialise return value at midnight
-        int blockseconds = tofb.secsTo(midnight); // returns seconds passed until midnight
-        blocktimeout = blocktimeout.addSecs(blockseconds);
-        blockseconds = midnight.secsTo(tonb); // returns seconds passed after midnight
-        blocktimeout = blocktimeout.addSecs(blockseconds);
-        return blocktimeout;
+        int blockseconds = tofb.secsTo(midnight);
+        blocktime_out = blocktime_out.addSecs(blockseconds);
+        blockseconds = midnight.secsTo(tonb);
+        blocktime_out = blocktime_out.addSecs(blockseconds);
     }
+    return blocktime_out;
 }
 
 
 /*!
- * \brief Calc::minutes_to_string Converts database time to String Time
- * \param blockminutes int from database
+ * \brief ACalc::minutes_to_string Converts database time to String Time
+ * \param blockminutes from database
  * \return String hh:mm
  */
-QString Calc::minutesToString(QString blockminutes)
+QString ACalc::minutesToString(QString blockminutes)
 {
     int minutes = blockminutes.toInt();
     QString hour = QString::number(minutes / 60);
@@ -65,11 +48,11 @@ QString Calc::minutesToString(QString blockminutes)
 };
 
 /*!
- * \brief Calc::time_to_minutes converts QTime to int minutes
+ * \brief ACalc::time_to_minutes converts QTime to int minutes
  * \param time QTime
  * \return int time as number of minutes
  */
-int Calc::qTimeToMinutes(QTime time)
+int ACalc::QTimeToMinutes(QTime time)
 {
     QString timestring = time.toString("hh:mm");
     int minutes = (timestring.left(2).toInt()) * 60;
@@ -78,11 +61,11 @@ int Calc::qTimeToMinutes(QTime time)
 }
 
 /*!
- * \brief Calc::string_to_minutes Converts String Time to String Number of Minutes
+ * \brief ACalc::string_to_minutes Converts String Time to String Number of Minutes
  * \param timestring "hh:mm"
  * \return String number of minutes
  */
-int Calc::stringToMinutes(QString timestring)
+int ACalc::stringToMinutes(QString timestring)
 {
     int minutes = (timestring.left(2).toInt()) * 60;
     minutes += timestring.right(2).toInt();
@@ -120,7 +103,7 @@ int Calc::stringToMinutes(QString timestring)
  * \param rad
  * \return degrees
  */
-double Calc::radToDeg(double rad)
+double ACalc::radToDeg(double rad)
 {
     double deg = rad * (180 / M_PI);
     return deg;
@@ -131,7 +114,7 @@ double Calc::radToDeg(double rad)
  * \param deg
  * \return radians
  */
-double Calc::degToRad(double deg)
+double ACalc::degToRad(double deg)
 {
     double rad = deg * (M_PI / 180);
     return rad;
@@ -142,7 +125,7 @@ double Calc::degToRad(double deg)
  * \param rad
  * \return nautical miles
  */
-double Calc::radToNauticalMiles(double rad)
+double ACalc::radToNauticalMiles(double rad)
 {
     double nm = rad * 3440.06479482;
     return nm;
@@ -156,7 +139,7 @@ double Calc::radToNauticalMiles(double rad)
  * \param lon2 Location Longitude in degrees -180:180 W(-) E(+)
  * \return
  */
-double Calc::greatCircleDistance(double lat1, double lon1, double lat2, double lon2)
+double ACalc::greatCircleDistance(double lat1, double lon1, double lat2, double lon2)
 {
     // Converting Latitude and Longitude to Radians
     lat1 = degToRad(lat1);
@@ -165,53 +148,46 @@ double Calc::greatCircleDistance(double lat1, double lon1, double lat2, double l
     lon2 = degToRad(lon2);
 
     // Haversine Formula
-    double deltalon = lon2 - lon1;
-    double deltalat = lat2 - lat1;
+    double delta_lon = lon2 - lon1;
+    double delta_lat = lat2 - lat1;
 
-    double result = pow(sin(deltalat / 2), 2) +
-                    cos(lat1) * cos(lat2) * pow(sin(deltalon / 2), 2);
+    double result = pow(sin(delta_lat / 2), 2) +
+                    cos(lat1) * cos(lat2) * pow(sin(delta_lon / 2), 2);
     result = 2 * asin(sqrt(result));
     return result;
 }
 
 /*!
- * \brief Calc::greatCircleDistanceBetweenAirports Calculates Great
+ * \brief ACalc::greatCircleDistanceBetweenAirports Calculates Great
  * Circle distance between two coordinates, return in nautical miles.
  * \param dept ICAO 4-letter Airport Identifier
  * \param dest ICAO 4-letter Airport Identifier
  * \return Nautical Miles From Departure to Destination
  */
-double Calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
+double ACalc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
 {
-    //db::multiSelect("airports", columns, "EDDF", "icao", db::exactMatch);
-    /*if(dbAirport::retreiveIcaoCoordinates(dept).isEmpty() || dbAirport::retreiveIcaoCoordinates(dest).isEmpty()){
-        qWarning() << "greatCircleDistance - invalid input. aborting.";
-        return 0;
-    }*/
-
-    QVector<QString> columns = {"lat", "long"};
-    QVector<QString> deptCoordinates = Db::multiSelect(columns, "airports", "icao", dept,
+    QVector<QString> dept_coordinates = Db::multiSelect({"lat", "long"}, "airports", "icao", dept,
                                                        Db::exactMatch);
-    QVector<QString> destCoordinates = Db::multiSelect(columns, "airports", "icao", dest,
+    QVector<QString> dest_coordinates = Db::multiSelect({"lat", "long"}, "airports", "icao", dest,
                                                        Db::exactMatch);
 
-    if (deptCoordinates.isEmpty() || destCoordinates.isEmpty()
+    if (dept_coordinates.isEmpty() || dest_coordinates.isEmpty()
        ) {
-        qDebug() << "greatCircleDistance - invalid input. aborting.";
+        DEB("invalid input. aborting.");
         return 0;
     }
 
-    double lat1 = degToRad(deptCoordinates[0].toDouble());
-    double lon1 = degToRad(deptCoordinates[1].toDouble());
-    double lat2 = degToRad(destCoordinates[0].toDouble());
-    double lon2 = degToRad(destCoordinates[1].toDouble());
+    double lat1 = degToRad(dept_coordinates[0].toDouble());
+    double lon1 = degToRad(dept_coordinates[1].toDouble());
+    double lat2 = degToRad(dest_coordinates[0].toDouble());
+    double lon2 = degToRad(dest_coordinates[1].toDouble());
 
     // Haversine Formula
-    double deltalon = lon2 - lon1;
-    double deltalat = lat2 - lat1;
+    double delta_lon = lon2 - lon1;
+    double delta_lat = lat2 - lat1;
 
-    double result = pow(sin(deltalat / 2), 2) +
-                    cos(lat1) * cos(lat2) * pow(sin(deltalon / 2), 2);
+    double result = pow(sin(delta_lat / 2), 2) +
+                    cos(lat1) * cos(lat2) * pow(sin(delta_lon / 2), 2);
     result = 2 * asin(sqrt(result));
     return radToNauticalMiles(result);
 }
@@ -226,7 +202,7 @@ double Calc::greatCircleDistanceBetweenAirports(QString dept, QString dest)
  * \param tblk Total Blocktime in minutes
  * \return coordinates {lat,lon} along the Great Circle Track
  */
-QVector<QVector<double>> Calc::intermediatePointsOnGreatCircle(double lat1, double lon1,
+QVector<QVector<double>> ACalc::intermediatePointsOnGreatCircle(double lat1, double lon1,
                                                                double lat2, double lon2, int tblk)
 {
     double d = greatCircleDistance(lat1, lon1, lat2, lon2); //Calculate distance (radians)
@@ -272,7 +248,7 @@ QVector<QVector<double>> Calc::intermediatePointsOnGreatCircle(double lat1, doub
  * \param lon - Location Longitude in degrees -180:180 W(-) E(+)
  * \return elevation - double of solar elevation in degrees.
  */
-double Calc::solarElevation(QDateTime utc_time_point, double lat, double lon)
+double ACalc::solarElevation(QDateTime utc_time_point, double lat, double lon)
 {
     double Alt =
         11; // I am taking 11 kilometers as an average cruising height for a commercial passenger airplane.
@@ -296,29 +272,29 @@ double Calc::solarElevation(QDateTime utc_time_point, double lat, double lon)
     double r = sqrt(pow(x, 2) + pow(y, 2));
     double v = atan2(y, x) * (180 / M_PI);
     // find the longitude of the sun
-    double solarlongitude = v + w;
+    double solar_longitude = v + w;
     // compute the ecliptic rectangular coordinates
-    double xeclip = r * cos(solarlongitude * (M_PI / 180));
-    double yeclip = r * sin(solarlongitude * (M_PI / 180));
-    double zeclip = 0.0;
+    double x_eclip = r * cos(solar_longitude * (M_PI / 180));
+    double y_eclip = r * sin(solar_longitude * (M_PI / 180));
+    double z_eclip = 0.0;
     //rotate these coordinates to equitorial rectangular coordinates
-    double xequat = xeclip;
-    double yequat = yeclip * cos(oblecl * (M_PI / 180)) + zeclip * sin(oblecl * (M_PI / 180));
-    double zequat = yeclip * sin(23.4406 * (M_PI / 180)) + zeclip * cos(oblecl * (M_PI / 180));
+    double x_equat = x_eclip;
+    double y_equat = y_eclip * cos(oblecl * (M_PI / 180)) + z_eclip * sin(oblecl * (M_PI / 180));
+    double z_equat = y_eclip * sin(23.4406 * (M_PI / 180)) + z_eclip * cos(oblecl * (M_PI / 180));
     // convert equatorial rectangular coordinates to RA and Decl:
-    r = sqrt(pow(xequat, 2) + pow(yequat, 2) + pow(zequat,
+    r = sqrt(pow(x_equat, 2) + pow(y_equat, 2) + pow(z_equat,
                                                    2)) - (Alt / 149598000); //roll up the altitude correction
-    double RA = atan2(yequat, xequat) * (180 / M_PI);
-    double delta = asin(zequat / r) * (180 / M_PI);
+    double RA = atan2(y_equat, x_equat) * (180 / M_PI);
+    double delta = asin(z_equat / r) * (180 / M_PI);
 
-    // GET UTH time
-    double UTH = utc_time_point.time().hour() + utc_time_point.time().minute() / 60.0 +
+    // GET UT in hours time
+    double uth = utc_time_point.time().hour() + utc_time_point.time().minute() / 60.0 +
                  utc_time_point.time().second() / 3600.0;
     // Calculate local siderial time
-    double GMST0 = fmod(L + 180, 360.0) / 15;
-    double SIDTIME = GMST0 + UTH + lon / 15;
+    double gmst0 = fmod(L + 180, 360.0) / 15;
+    double sid_time = gmst0 + uth + lon / 15;
     // Replace RA with hour angle HA
-    double HA = (SIDTIME * 15 - RA);
+    double HA = (sid_time * 15 - RA);
     // convert to rectangular coordinate system
     x = cos(HA * (M_PI / 180)) * cos(delta * (M_PI / 180));
     y = sin(HA * (M_PI / 180)) * cos(delta * (M_PI / 180));
@@ -341,49 +317,47 @@ double Calc::solarElevation(QDateTime utc_time_point, double lat, double lon)
  * Default -6 (end of civil evening twilight)
  * \return Total number of minutes under night flying conditions
  */
-int Calc::calculateNightTime(QString dept, QString dest, QDateTime departureTime, int tblk, int nightAngle)
+int ACalc::calculateNightTime(const QString &dept, const QString &dest, QDateTime departureTime, int tblk, int nightAngle)
 {
-    QVector<QString> columns = {"lat", "long"};
-    QVector<QString> deptCoordinates = Db::multiSelect(columns, "airports", "icao", dept,
+    QVector<QString> dept_coordinates = Db::multiSelect({"lat", "long"}, "airports", "icao", dept,
                                                        Db::exactMatch);
-    QVector<QString> destCoordinates = Db::multiSelect(columns, "airports", "icao", dest,
+    QVector<QString> dest_coordinates = Db::multiSelect({"lat", "long"}, "airports", "icao", dest,
                                                        Db::exactMatch);
 
-    if (deptCoordinates.isEmpty() || destCoordinates.isEmpty()
+    if (dept_coordinates.isEmpty() || dest_coordinates.isEmpty()
        ) {
-        qDebug() << "Calc::CalculateNightTime - invalid input. aborting.";
+        DEB("invalid input. aborting.");
         return 0;
     }
 
-    double deptLat = degToRad(deptCoordinates[0].toDouble());
-    double deptLon = degToRad(deptCoordinates[1].toDouble());
-    double destLat = degToRad(destCoordinates[0].toDouble());
-    double destLon = degToRad(destCoordinates[1].toDouble());
+    double dept_lat = degToRad(dept_coordinates[0].toDouble());
+    double dept_lon = degToRad(dept_coordinates[1].toDouble());
+    double dest_lat = degToRad(dest_coordinates[0].toDouble());
+    double dest_lon = degToRad(dest_coordinates[1].toDouble());
 /*
-    qDebug() << "Calc::CalculateNightTime deptLat = " << deptLat;
-    qDebug() << "Calc::CalculateNightTime deptLon = " << deptLon;
-    qDebug() << "Calc::CalculateNightTime destLat = " << destLat;
-    qDebug() << "Calc::CalculateNightTime destLon = " << destLon;
+    qDebug() << "ACalc::CalculateNightTime deptLat = " << deptLat;
+    qDebug() << "ACalc::CalculateNightTime deptLon = " << deptLon;
+    qDebug() << "ACalc::CalculateNightTime destLat = " << destLat;
+    qDebug() << "ACalc::CalculateNightTime destLon = " << destLon;
 */
-    QVector<QVector<double>> route = intermediatePointsOnGreatCircle(deptLat, deptLon, destLat, destLon,
+    QVector<QVector<double>> route = intermediatePointsOnGreatCircle(dept_lat, dept_lon, dest_lat, dest_lon,
                                                                      tblk);
 
-    int nightTime = 0;
+    int night_time = 0;
     for (int i = 0; i < tblk ; i++) {
         if (solarElevation(departureTime.addSecs(60 * i), radToDeg(route[i][0]),
                            radToDeg(route[i][1])) < nightAngle) {
-            nightTime ++;
+            night_time ++;
         }
     }
-    //qDebug() << "Calc::CalculateNightTime result for angle: "<< nightAngle
+    //qDebug() << "ACalc::CalculateNightTime result for angle: "<< nightAngle
     //         << " :" << nightTime << " minutes night flying time.";
-    return nightTime;
+    return night_time;
 }
 
-bool Calc::isNight(QString icao, QDateTime eventTime, int nightAngle)
+bool ACalc::isNight(QString icao, QDateTime event_time, int nightAngle)
 {
-    QVector<QString> columns = {"lat", "long"};
-    QVector<QString> coordinates = Db::multiSelect(columns, "airports", "icao", icao,
+    QVector<QString> coordinates = Db::multiSelect({"lat", "long"}, "airports", "icao", icao,
                                                        Db::exactMatch);
     if (coordinates.isEmpty()) {
         DEB("invalid input. aborting.");
@@ -393,7 +367,7 @@ bool Calc::isNight(QString icao, QDateTime eventTime, int nightAngle)
     double lat = degToRad(coordinates[0].toDouble());
     double lon = degToRad(coordinates[1].toDouble());
 
-    if(solarElevation(eventTime, lat, lon) < nightAngle){
+    if(solarElevation(event_time, lat, lon) < nightAngle){
         return true;
     } else {
         return false;
@@ -401,34 +375,34 @@ bool Calc::isNight(QString icao, QDateTime eventTime, int nightAngle)
 }
 
 /*!
- * \brief Calc::formatTimeInput verifies user input and formats to hh:mm
+ * \brief ACalc::formatTimeInput verifies user input and formats to hh:mm
  * if the output is not a valid time, an empty string is returned. Accepts
  * input as hh:mm, h:mm, hhmm or hmm.
  * \param userinput from a QLineEdit
  * \return formatted QString "hh:mm" or Empty String
  */
-QString Calc::formatTimeInput(QString userinput)
+QString ACalc::formatTimeInput(QString user_input)
 {
     QString output; //
-    QTime temptime; //empty time object is invalid by default
-
-    bool containsSeperator = userinput.contains(":");
-    if (userinput.length() == 4 && !containsSeperator) {
-        temptime = QTime::fromString(userinput, "hhmm");
-    } else if (userinput.length() == 3 && !containsSeperator) {
-        if (userinput.toInt() < 240) { //Qtime is invalid if time is between 000 and 240 for this case
-            QString tempstring = userinput.prepend("0");
-            temptime = QTime::fromString(tempstring, "hhmm");
+    QTime temp_time; //empty time object is invalid by default
+
+    bool contains_seperator = user_input.contains(":");
+    if (user_input.length() == 4 && !contains_seperator) {
+        temp_time = QTime::fromString(user_input, "hhmm");
+    } else if (user_input.length() == 3 && !contains_seperator) {
+        if (user_input.toInt() < 240) { //Qtime is invalid if time is between 000 and 240 for this case
+            QString tempstring = user_input.prepend("0");
+            temp_time = QTime::fromString(tempstring, "hhmm");
         } else {
-            temptime = QTime::fromString(userinput, "Hmm");
+            temp_time = QTime::fromString(user_input, "Hmm");
         }
-    } else if (userinput.length() == 4 && containsSeperator) {
-        temptime = QTime::fromString(userinput, "h:mm");
-    } else if (userinput.length() == 5 && containsSeperator) {
-        temptime = QTime::fromString(userinput, "hh:mm");
+    } else if (user_input.length() == 4 && contains_seperator) {
+        temp_time = QTime::fromString(user_input, "h:mm");
+    } else if (user_input.length() == 5 && contains_seperator) {
+        temp_time = QTime::fromString(user_input, "hh:mm");
     }
 
-    output = temptime.toString("hh:mm");
+    output = temp_time.toString("hh:mm");
     if (output.isEmpty()) {
         qDebug() << "Time input is invalid.";
     }
@@ -436,19 +410,19 @@ QString Calc::formatTimeInput(QString userinput)
 }
 
 /*!
- * \brief Calc::updateAutoTimes When the details of an aircraft are changed,
+ * \brief ACalc::updateAutoTimes When the details of an aircraft are changed,
  * this function recalculates deductable times for this aircraft and updates
  * the database accordingly.
  * \param acft An aircraft object.
  * \return
  */
-void Calc::updateAutoTimes(int acft_id)
+void ACalc::updateAutoTimes(int acft_id)
 {
     //find all flights for aircraft
-    auto flightList = Db::multiSelect(QVector<QString>{"flight_id"},"flights","acft",
+    auto flight_list = Db::multiSelect({"flight_id"},"flights","acft",
                                       QString::number(acft_id),Db::exactMatch);
     auto acft = Aircraft(acft_id);
-    for (const auto& item : flightList) {
+    for (const auto& item : flight_list) {
         auto flt = Flight(item.toInt());
 
         if(acft.data.value("singlepilot") == "1" && acft.data.value("singleengine") == "1") {
@@ -471,13 +445,12 @@ void Calc::updateAutoTimes(int acft_id)
     }
 }
 /*!
- * \brief Calc::updateNightTimes updates the night times in the database
+ * \brief ACalc::updateNightTimes updates the night times in the database
  */
-void Calc::updateNightTimes()
+void ACalc::updateNightTimes()
 {
-    const int nightAngle = Settings::read("flightlogging/nightangle").toInt();
-    const QVector<QString> columns = {"flight_id"};
-    auto flights = Db::multiSelect(columns,"flights");
+    const int nightAngle = ASettings::read("flightlogging/nightangle").toInt();
+    auto flights = Db::multiSelect({"flight_id"}, "flights");
     for (const auto& item : flights) {
         auto flt = new Flight(item.toInt());
         auto dateTime = QDateTime(QDate::fromString(flt->data.value("doft"),Qt::ISODate),
@@ -492,3 +465,4 @@ void Calc::updateNightTimes()
         flt->commit();
     }
 }
+

+ 58 - 0
src/functions/acalc.h

@@ -0,0 +1,58 @@
+#ifndef ACALC_H
+#define ACALC_H
+
+#include "src/database/db.h"
+#include "src/classes/aircraft.h"
+#include "src/classes/flight.h"
+#include "src/classes/asettings.h"
+#include <QDateTime>
+#include <cmath>
+#include <QDebug>
+/*!
+ * \brief The ACalc namespace provides various functions for calculations that are performed
+ * outside of the database. This includes tasks like converting different units and formats,
+ * or functions calculating block time or night time.
+ */
+
+namespace ACalc {
+
+QTime blocktime(QTime tofb, QTime tonb);
+
+QString minutesToString(QString blockminutes);
+
+int stringToMinutes(QString time);
+
+int QTimeToMinutes(QTime time);
+
+double radToDeg(double rad);
+
+double degToRad(double deg);
+
+double radToNauticalMiles(double rad);
+
+double greatCircleDistance(double lat1, double lon1, double lat2, double lon2);
+
+double greatCircleDistanceBetweenAirports(QString dept, QString dest);
+
+QVector<QVector<double>> intermediatePointsOnGreatCircle(double lat1,
+                                                         double lon1,
+                                                         double lat2,
+                                                         double lon2,
+                                                         int tblk);
+
+double solarElevation(QDateTime utc_time_point, double lat, double lon);
+
+int calculateNightTime(const QString &dept, const QString &dest, QDateTime departureTime, int tblk, int nightAngle);
+
+bool isNight(QString icao, QDateTime event_time, int nightAngle);
+
+QString formatTimeInput(QString user_input);
+
+void updateAutoTimes(int acft_id);
+
+void autoTimes(Flight, Aircraft);
+
+void updateNightTimes();
+} // namespace ACalc
+
+#endif // ACALC_H

+ 3 - 3
debug.h → src/functions/adebug.h

@@ -1,5 +1,5 @@
-#ifndef DEBUG_H
-#define DEBUG_H
+#ifndef ADEBUG_H
+#define ADEBUG_H
 
 #include <QDebug>
 
@@ -7,4 +7,4 @@
 #define DEB(expr) \
     qDebug() << __PRETTY_FUNCTION__ << "\t" << expr
 
-#endif // DEBUG_H
+#endif // ADEBUG_H

+ 3 - 7
src/classes/csv.cpp → src/functions/areadcsv.cpp

@@ -1,15 +1,11 @@
-#include "csv.h"
+#include "areadcsv.h"
 
-Csv::Csv()
-{
-
-}
 /*!
- * \brief Csv::read reads from a CSV file
+ * \brief aReadCSV reads from a CSV file
  * \param filename - QString to csv file.
  * \return QVector<QStringList> of the CSV data, where each QStringList is one column of the input file
  */
-QVector<QStringList> Csv::read(QString filename)
+QVector<QStringList> aReadCsv(QString filename)
 {
     QFile csvfile(filename);
     csvfile.open(QIODevice::ReadOnly);

+ 8 - 0
src/functions/areadcsv.h

@@ -0,0 +1,8 @@
+#ifndef AREADCSV_H
+#define AREADCSV_H
+
+#include<QtCore>
+
+QVector<QStringList> aReadCsv(QString filename);
+
+#endif // AREADCSV_H

+ 41 - 33
src/classes/stat.cpp → src/functions/astat.cpp

@@ -15,57 +15,63 @@
  *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 "stat.h"
+#include "astat.h"
+#include "src/functions/adebug.h"
 
+using namespace experimental;
 
 /*!
- * \brief Stat::totalTime Looks up Total Blocktime in the flights database
+ * \brief AStat::totalTime Looks up Total Blocktime in the flights database
  * \param yearType - Whether the calculation is based on total time, last
  * calendar year or the last rolling year
  * \return Amount of Total Block Time in minutes
  */
-QString Stat::totalTime(yearType yt)
+QString AStat::totalTime(yearType year_type)
 {
-    QString query;
+    QString statement;
     QDate start;
-    QString startdate;
+    QString start_date;
 
-    switch (yt) {
-    case Stat::allYears:
-        query = "SELECT SUM(tblk) FROM flights";
+    switch (year_type) {
+    case AStat::allYears:
+        statement = "SELECT SUM(tblk) FROM flights";
         break;
-    case Stat::calendarYear:
+    case AStat::calendarYear:
         start.setDate(QDate::currentDate().year(), 1, 1);
-        startdate = start.toString(Qt::ISODate);
-        startdate.append(QLatin1Char('\''));
-        startdate.prepend(QLatin1Char('\''));
-        query = "SELECT SUM(tblk) FROM flights WHERE doft >= " + startdate;
+        start_date = start.toString(Qt::ISODate);
+        start_date.append(QLatin1Char('\''));
+        start_date.prepend(QLatin1Char('\''));
+        statement = "SELECT SUM(tblk) FROM flights WHERE doft >= " + start_date;
         break;
-    case Stat::rollingYear:
+    case AStat::rollingYear:
         start = QDate::fromJulianDay(QDate::currentDate().toJulianDay() - 365);
-        startdate = start.toString(Qt::ISODate);
-        startdate.append(QLatin1Char('\''));
-        startdate.prepend(QLatin1Char('\''));
-        query = "SELECT SUM(tblk) FROM flights WHERE doft >= " + startdate;
+        start_date = start.toString(Qt::ISODate);
+        start_date.append(QLatin1Char('\''));
+        start_date.prepend(QLatin1Char('\''));
+        statement = "SELECT SUM(tblk) FROM flights WHERE doft >= " + start_date;
         break;
     }
 
-    QVector<QString> result = Db::customQuery(query, 1);
+    //QVector<QString> result = Db::customQuery(query, 1);
+    QSqlQuery query(statement);
 
-    if (!result.isEmpty()) {
-        return result[0];
+    if (!query.first()) {
+        DEB("No result found. Check Query and Error.");
+        DEB("Error: " << query.lastError().text());
+        return "00:00";
     } else {
-        return QString();
+        query.previous();
+        return query.value(0).toString();
     }
 }
 
 /*!
- * \brief Stat::currencyTakeOffLanding Returns the amount of Take Offs and
+ * \brief AStat::currencyTakeOffLanding Returns the amount of Take Offs and
  * Landings performed in the last x days. Normally, 90 would be used. (EASA)
  * \param days Number of days to check
  * \return {TO,LDG}
  */
-QVector<QString> Stat::currencyTakeOffLanding(int days)
+QVector<QString> AStat::currencyTakeOffLanding(int days)
 {
     QDate start = QDate::fromJulianDay(QDate::currentDate().toJulianDay() - days);
     QString startdate = start.toString(Qt::ISODate);
@@ -73,11 +79,13 @@ QVector<QString> Stat::currencyTakeOffLanding(int days)
     startdate.prepend(QLatin1Char('\''));
 
 
-    QString query = "SELECT SUM(flights.TOday) + SUM(flights.TOnight) AS 'TO', "
-                    "SUM(flights.LDGday) + SUM(flights.LDGnight) AS 'LDG' "
-                    "FROM flights "
-                    "WHERE doft >= " + startdate;
-    QVector<QString> result = Db::customQuery(query, 2);
+    QString statement = "SELECT "
+            "CAST(SUM(flights.TOday) + SUM(flights.TOnight) AS INTEGER) 'TO', "
+            "CAST(SUM(flights.LDGday) + SUM(flights.LDGnight) AS INTEGER) AS 'LDG' "
+            "FROM flights "
+            "WHERE doft >= \"" + startdate + "\"";
+
+    QVector<QString> result = aDB()->customQuery(statement, 2);
 
     if (!result.isEmpty()) {
         return result;
@@ -87,7 +95,7 @@ QVector<QString> Stat::currencyTakeOffLanding(int days)
 
 }
 
-QVector<QPair<QString, QString>> Stat::totals()
+QVector<QPair<QString, QString>> AStat::totals()
 {
     QString statement = "SELECT "
             "printf('%02d',CAST(SUM(tblk) AS INT)/60)||':'||printf('%02d',CAST(SUM(tblk) AS INT)%60) AS 'TOTAL', "
@@ -109,12 +117,12 @@ QVector<QPair<QString, QString>> Stat::totals()
                                 "pic", "picus", "sic", "dual", "fi", "sim", "multipilot",
                                 "today", "tonight", "ldgday", "ldgnight"
                                };
-    QSqlQuery q(statement);
+    QSqlQuery query(statement);
     QVector<QPair<QString, QString>> output;
     QString value;
-    q.next();
+    query.next();
     for (const auto &column : columns) {
-        value = q.value(columns.indexOf(column)).toString();
+        value = query.value(columns.indexOf(column)).toString();
         if (!value.isEmpty()) {
             output << QPair{column, value};
         } else {

+ 15 - 13
src/classes/stat.h → src/functions/astat.h

@@ -15,29 +15,31 @@
  *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 STAT_H
-#define STAT_H
+#ifndef ASTAT_H
+#define ASTAT_H
+#include <QtCore>
+#include <QSqlQuery>
+#include <QSqlError>
+#include "src/experimental/adatabase.h"
+
+namespace AStat {
 
-#include "src/database/db.h"
-#include <QDateTime>
 
 /*!
- * \brief The stat class provides functionality for retreiving various statistics
+ * \brief The AStat namespace provides functionality for retreiving various statistics
  * from the database, such as total times or recency. In general, most values are
  * provided as either QString or QVector<QString>.
  */
-class Stat
-{
-public:
+
 
     enum yearType {allYears, calendarYear, rollingYear};
 
-    static QString totalTime(yearType);
+    QString totalTime(yearType);
 
-    static QVector<QString> currencyTakeOffLanding(int days);
+    QVector<QString> currencyTakeOffLanding(int days);
 
-    static QVector<QPair<QString, QString>> totals();
+    QVector<QPair<QString, QString>> totals();
 
-};
+} // namespace AStat
 
-#endif // STAT_H
+#endif // ASTAT_H

+ 17 - 16
src/gui/dialogues/firstrundialog.cpp

@@ -40,7 +40,7 @@ void FirstRunDialog::on_nextPushButton_clicked()
 
 void FirstRunDialog::themeGroup_toggled(int id)
 {
-    Settings::write("main/theme", id);
+    ASettings::write("main/theme", id);
 }
 
 void FirstRunDialog::on_finishButton_clicked()
@@ -50,30 +50,30 @@ void FirstRunDialog::on_finishButton_clicked()
         mb->setText("You have to enter a valid first and last name for the logbook.");
         mb->show();
     } else {
-        Settings::write("userdata/piclastname",ui->piclastnameLineEdit->text());
-        Settings::write("userdata/picfirstname",ui->picfirstnameLineEdit->text());
-        Settings::write("userdata/employeeid",ui->employeeidLineEdit->text());
-        Settings::write("userdata/phone",ui->phoneLineEdit->text());
-        Settings::write("userdata/email",ui->emailLineEdit->text());
+        ASettings::write("userdata/piclastname",ui->piclastnameLineEdit->text());
+        ASettings::write("userdata/picfirstname",ui->picfirstnameLineEdit->text());
+        ASettings::write("userdata/employeeid",ui->employeeidLineEdit->text());
+        ASettings::write("userdata/phone",ui->phoneLineEdit->text());
+        ASettings::write("userdata/email",ui->emailLineEdit->text());
 
-        Settings::write("flightlogging/function", ui->functionComboBox->currentText());
-        Settings::write("flightlogging/rules", ui->rulesComboBox->currentText());
-        Settings::write("flightlogging/approach", ui->approachComboBox->currentText());
-        Settings::write("flightlogging/nightlogging", ui->nightComboBox->currentIndex());
-        Settings::write("flightlogging/flightnumberPrefix", ui->prefixLineEdit->text());
+        ASettings::write("flightlogging/function", ui->functionComboBox->currentText());
+        ASettings::write("flightlogging/rules", ui->rulesComboBox->currentText());
+        ASettings::write("flightlogging/approach", ui->approachComboBox->currentText());
+        ASettings::write("flightlogging/nightlogging", ui->nightComboBox->currentIndex());
+        ASettings::write("flightlogging/flightnumberPrefix", ui->prefixLineEdit->text());
 
         QMap<QString,QString> data;
         switch (ui->aliasComboBox->currentIndex()) {
         case 0:
-            Settings::write("userdata/displayselfas",ui->aliasComboBox->currentIndex());
+            ASettings::write("userdata/displayselfas",ui->aliasComboBox->currentIndex());
             data.insert("displayname","self");
             break;
         case 1:
-            Settings::write("userdata/displayselfas",ui->aliasComboBox->currentIndex());
+            ASettings::write("userdata/displayselfas",ui->aliasComboBox->currentIndex());
             data.insert("displayname","SELF");
             break;
         case 2:{
-            Settings::write("userdata/displayselfas",ui->aliasComboBox->currentIndex());
+            ASettings::write("userdata/displayselfas",ui->aliasComboBox->currentIndex());
             QString name;
             name.append(ui->piclastnameLineEdit->text());
             name.append(QLatin1String(", "));
@@ -87,6 +87,7 @@ void FirstRunDialog::on_finishButton_clicked()
         }
         data.insert("piclastname",ui->piclastnameLineEdit->text());
         data.insert("picfirstname",ui->picfirstnameLineEdit->text());
+        data.insert("alias", ASettings::read("userdata/displayselfas").toString());
         data.insert("employeeid",ui->employeeidLineEdit->text());
         data.insert("phone",ui->phoneLineEdit->text());
         data.insert("email",ui->emailLineEdit->text());
@@ -95,7 +96,7 @@ void FirstRunDialog::on_finishButton_clicked()
         pic.setData(data);
         pic.commit();
 
-        switch(Settings::read("main/theme").toInt()){
+        switch(ASettings::read("main/theme").toInt()){
         case 0:
             accept();
             break;
@@ -108,7 +109,7 @@ void FirstRunDialog::on_finishButton_clicked()
             QProcess::startDetached(qApp->arguments()[0], qApp->arguments());
             break;
         default:
-            Settings::write("main/theme", 0);
+            ASettings::write("main/theme", 0);
             accept();
         }
     }

+ 1 - 1
src/gui/dialogues/firstrundialog.h

@@ -5,7 +5,7 @@
 #include <QButtonGroup>
 #include <QMessageBox>
 #include <QRegularExpressionValidator>
-#include "src/classes/settings.h"
+#include "src/classes/asettings.h"
 #include "src/classes/pilot.h"
 
 namespace Ui {

+ 78 - 77
src/gui/dialogues/newflightdialog.cpp

@@ -17,7 +17,7 @@
  */
 #include "newflightdialog.h"
 #include "ui_newflight.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 
 
@@ -183,9 +183,10 @@ void NewFlightDialog::setup(){
         }
     }
     //fill Lists
-    pilots = CompletionList(CompleterTarget::pilots).list;
-    tails = CompletionList(CompleterTarget::registrations).list;
-    airports = CompletionList(CompleterTarget::airports).list;
+    pilots   = experimental::aDB()->getCompletionList(experimental::ADataBase::pilots);
+    tails    = experimental::aDB()->getCompletionList(experimental::ADataBase::registrations);
+    airports = experimental::aDB()->getCompletionList(experimental::ADataBase::airports);
+
     QString statement = "SELECT iata, icao FROM airports";
     auto result = Db::customQuery(statement,2);
     for(int i=0; i<result.length()-2; i += 2){
@@ -265,8 +266,8 @@ void NewFlightDialog::formFiller(Flight oldFlight)
                 //DEB("Time Match found: " << key << " - " << leName);
                 auto le = parent()->findChild<QLineEdit *>(leName);
                 if(le != nullptr){
-                    DEB("Setting " << le->objectName() << " to " << Calc::minutesToString(oldFlight.data.value(key)));
-                    le->setText(Calc::minutesToString(
+                    DEB("Setting " << le->objectName() << " to " << ACalc::minutesToString(oldFlight.data.value(key)));
+                    le->setText(ACalc::minutesToString(
                                 oldFlight.data.value(key)));
                     filled << leName;
                     line_edits_names.removeOne(leName);
@@ -368,7 +369,7 @@ inline void NewFlightDialog::setupLineEdit(QLineEdit* line_edit, LineEditSetting
     DEB("Setting validators for " << line_edit_objectName);
     auto [valid_rgx, invalid_rgx, sql_col] = settings.getAll();
 
-    auto validator = new StrictRxValidator(valid_rgx, line_edit);
+    auto validator = new AStrictRxValidator(valid_rgx, line_edit);
 
     auto comp_model = new QSqlRelationalTableModel(line_edit, db);
     comp_model->database().open();
@@ -395,18 +396,18 @@ void NewFlightDialog::writeSettings()
 {
     DEB("Writing Settings...");
 
-    Settings::write("NewFlight/FunctionComboBox",ui->FunctionComboBox->currentText());
-    Settings::write("NewFlight/ApproachComboBox",ui->ApproachComboBox->currentText());
-    Settings::write("NewFlight/PilotFlyingCheckBox",ui->PilotFlyingCheckBox->isChecked());
-    Settings::write("NewFlight/PilotMonitoringCheckBox",ui->PilotMonitoringCheckBox->isChecked());
-    Settings::write("NewFlight/TakeoffSpinBox",ui->TakeoffSpinBox->value());
-    Settings::write("NewFlight/TakeoffCheckBox",ui->TakeoffCheckBox->isChecked());
-    Settings::write("NewFlight/LandingSpinBox",ui->LandingSpinBox->value());
-    Settings::write("NewFlight/LandingCheckBox",ui->LandingCheckBox->isChecked());
-    Settings::write("NewFlight/AutolandSpinBox",ui->AutolandSpinBox->value());
-    Settings::write("NewFlight/AutolandCheckBox",ui->AutolandCheckBox->isChecked());
-    Settings::write("NewFlight/IfrCheckBox",ui->IfrCheckBox->isChecked());
-    Settings::write("NewFlight/VfrCheckBox",ui->VfrCheckBox->isChecked());
+    ASettings::write("NewFlight/FunctionComboBox",ui->FunctionComboBox->currentText());
+    ASettings::write("NewFlight/ApproachComboBox",ui->ApproachComboBox->currentText());
+    ASettings::write("NewFlight/PilotFlyingCheckBox",ui->PilotFlyingCheckBox->isChecked());
+    ASettings::write("NewFlight/PilotMonitoringCheckBox",ui->PilotMonitoringCheckBox->isChecked());
+    ASettings::write("NewFlight/TakeoffSpinBox",ui->TakeoffSpinBox->value());
+    ASettings::write("NewFlight/TakeoffCheckBox",ui->TakeoffCheckBox->isChecked());
+    ASettings::write("NewFlight/LandingSpinBox",ui->LandingSpinBox->value());
+    ASettings::write("NewFlight/LandingCheckBox",ui->LandingCheckBox->isChecked());
+    ASettings::write("NewFlight/AutolandSpinBox",ui->AutolandSpinBox->value());
+    ASettings::write("NewFlight/AutolandCheckBox",ui->AutolandCheckBox->isChecked());
+    ASettings::write("NewFlight/IfrCheckBox",ui->IfrCheckBox->isChecked());
+    ASettings::write("NewFlight/VfrCheckBox",ui->VfrCheckBox->isChecked());
 }
 
 /*!
@@ -418,24 +419,24 @@ void NewFlightDialog::readSettings()
     DEB("Reading Settings...");
     QSettings settings;
 
-    ui->FunctionComboBox->setCurrentText(Settings::read("NewFlight/FunctionComboBox").toString());
-    ui->ApproachComboBox->setCurrentText(Settings::read("NewFlight/ApproachComboBox").toString());
-    ui->PilotFlyingCheckBox->setChecked(Settings::read("NewFlight/PilotFlyingCheckBox").toBool());
-    ui->PilotMonitoringCheckBox->setChecked(Settings::read("NewFlight/PilotMonitoringCheckBox").toBool());
-    ui->TakeoffSpinBox->setValue(Settings::read("NewFlight/TakeoffSpinBox").toInt());
-    ui->TakeoffCheckBox->setChecked(Settings::read("NewFlight/TakeoffCheckBox").toBool());
-    ui->LandingSpinBox->setValue(Settings::read("NewFlight/LandingSpinBox").toInt());
-    ui->LandingCheckBox->setChecked(Settings::read("NewFlight/LandingCheckBox").toBool());
-    ui->AutolandSpinBox->setValue(Settings::read("NewFlight/AutolandSpinBox").toInt());
-    ui->AutolandCheckBox->setChecked(Settings::read("NewFlight/AutolandCheckBox").toBool());
-    ui->IfrCheckBox->setChecked(Settings::read("NewFlight/IfrCheckBox").toBool());
-    ui->VfrCheckBox->setChecked(Settings::read("NewFlight/VfrCheckBox").toBool());
-    ui->FlightNumberLineEdit->setText(Settings::read("flightlogging/flightnumberPrefix").toString());
-
-    if(Settings::read("NewFlight/FunctionComboBox").toString() == "PIC"){
+    ui->FunctionComboBox->setCurrentText(ASettings::read("NewFlight/FunctionComboBox").toString());
+    ui->ApproachComboBox->setCurrentText(ASettings::read("NewFlight/ApproachComboBox").toString());
+    ui->PilotFlyingCheckBox->setChecked(ASettings::read("NewFlight/PilotFlyingCheckBox").toBool());
+    ui->PilotMonitoringCheckBox->setChecked(ASettings::read("NewFlight/PilotMonitoringCheckBox").toBool());
+    ui->TakeoffSpinBox->setValue(ASettings::read("NewFlight/TakeoffSpinBox").toInt());
+    ui->TakeoffCheckBox->setChecked(ASettings::read("NewFlight/TakeoffCheckBox").toBool());
+    ui->LandingSpinBox->setValue(ASettings::read("NewFlight/LandingSpinBox").toInt());
+    ui->LandingCheckBox->setChecked(ASettings::read("NewFlight/LandingCheckBox").toBool());
+    ui->AutolandSpinBox->setValue(ASettings::read("NewFlight/AutolandSpinBox").toInt());
+    ui->AutolandCheckBox->setChecked(ASettings::read("NewFlight/AutolandCheckBox").toBool());
+    ui->IfrCheckBox->setChecked(ASettings::read("NewFlight/IfrCheckBox").toBool());
+    ui->VfrCheckBox->setChecked(ASettings::read("NewFlight/VfrCheckBox").toBool());
+    ui->FlightNumberLineEdit->setText(ASettings::read("flightlogging/flightnumberPrefix").toString());
+
+    if(ASettings::read("NewFlight/FunctionComboBox").toString() == "PIC"){
         ui->picNameLineEdit->setText("self");
         ui->secondPilotNameLineEdit->setText("");
-    }else if (Settings::read("NewFlight/FunctionComboBox").toString() == "Co-Pilot") {
+    }else if (ASettings::read("NewFlight/FunctionComboBox").toString() == "Co-Pilot") {
         ui->picNameLineEdit->setText("");
         ui->secondPilotNameLineEdit->setText("self");
     }
@@ -551,8 +552,8 @@ void NewFlightDialog::collectBasicData()
     //Block Time
     auto tofb = QTime::fromString(ui->tofbTimeLineEdit->text(),"hh:mm");
     auto tonb = QTime::fromString(ui->tonbTimeLineEdit->text(),"hh:mm");
-    QString blockTime = Calc::blocktime(tofb, tonb).toString("hh:mm");
-    QString blockMinutes = QString::number(Calc::stringToMinutes(blockTime));
+    QString blockTime = ACalc::blocktime(tofb, tonb).toString("hh:mm");
+    QString blockMinutes = QString::number(ACalc::stringToMinutes(blockTime));
     newData.insert("tblk",blockMinutes);
 
     // Aircraft
@@ -633,8 +634,8 @@ void NewFlightDialog::collectAdditionalData()
     // Extra Times
     auto tofb = QTime::fromString(ui->tofbTimeLineEdit->text(),"hh:mm");
     auto tonb = QTime::fromString(ui->tonbTimeLineEdit->text(),"hh:mm");
-    QString blockTime = Calc::blocktime(tofb, tonb).toString("hh:mm");
-    QString blockMinutes = QString::number(Calc::stringToMinutes(blockTime));
+    QString blockTime = ACalc::blocktime(tofb, tonb).toString("hh:mm");
+    QString blockMinutes = QString::number(ACalc::stringToMinutes(blockTime));
 
     auto acft = Aircraft(newData.value("acft").toInt());
 
@@ -669,10 +670,10 @@ void NewFlightDialog::collectAdditionalData()
     QString deptDate = ui->doftLineEdit->text() + 'T' + tofb.toString("hh:mm");
     QDateTime deptDateTime = QDateTime::fromString(deptDate,"yyyy-MM-ddThh:mm");
     int tblk = blockMinutes.toInt();
-    const int nightAngle = Settings::read("flightlogging/nightangle").toInt();
+    const int nightAngle = ASettings::read("flightlogging/nightangle").toInt();
 
     QString nightTime = QString::number(
-                        Calc::calculateNightTime(
+                        ACalc::calculateNightTime(
                         newData.value("dept"), newData.value("dest"),
                         deptDateTime, tblk, nightAngle));
     newData.insert("tNIGHT", nightTime);
@@ -724,7 +725,7 @@ void NewFlightDialog::collectAdditionalData()
             newData.insert("toDay", "0");
             newData.insert("toNight", QString::number(ui->TakeoffSpinBox->value()));
         } else { //check
-            if(Calc::isNight(ui->deptLocLineEdit->text(), deptDateTime,  nightAngle)){
+            if(ACalc::isNight(ui->deptLocLineEdit->text(), deptDateTime,  nightAngle)){
                 newData.insert("toDay", "0");
                 newData.insert("toNight", QString::number(ui->TakeoffSpinBox->value()));
             }else{
@@ -747,7 +748,7 @@ void NewFlightDialog::collectAdditionalData()
         } else { //check
             QString destDate = ui->doftLineEdit->text() + 'T' + tonb.toString("hh:mm");
             QDateTime destDateTime = QDateTime::fromString(destDate,"yyyy-MM-ddThh:mm");
-            if(Calc::isNight(ui->destLocLineEdit->text(), destDateTime,  nightAngle)){
+            if(ACalc::isNight(ui->destLocLineEdit->text(), destDateTime,  nightAngle)){
                 newData.insert("ldgDay", "0");
                 newData.insert("ldgNight", QString::number(ui->LandingSpinBox->value()));
             }else{
@@ -784,8 +785,8 @@ void NewFlightDialog::fillExtras()
     //Times
     auto tofb = QTime::fromString(ui->tofbTimeLineEdit->text(),"hh:mm");
     auto tonb = QTime::fromString(ui->tonbTimeLineEdit->text(),"hh:mm");
-    QString blockTime = Calc::blocktime(tofb, tonb).toString("hh:mm");
-    QString blockMinutes = QString::number(Calc::stringToMinutes(blockTime));
+    QString blockTime = ACalc::blocktime(tofb, tonb).toString("hh:mm");
+    QString blockMinutes = QString::number(ACalc::stringToMinutes(blockTime));
     ui->tblkTimeLineEdit->setText(blockTime);
     auto acft = Aircraft(newData.value("acft").toInt());
 
@@ -819,14 +820,14 @@ void NewFlightDialog::fillExtras()
     QString deptDate = ui->doftLineEdit->text() + 'T' + tofb.toString("hh:mm");
     QDateTime deptDateTime = QDateTime::fromString(deptDate,"yyyy-MM-ddThh:mm");
     int tblk = blockMinutes.toInt();
-    const int nightAngle = Settings::read("flightlogging/nightangle").toInt();
+    const int nightAngle = ASettings::read("flightlogging/nightangle").toInt();
 
     QString nightTime = QString::number(
-                        Calc::calculateNightTime(
+                        ACalc::calculateNightTime(
                         newData.value("dept"), newData.value("dest"),
                         deptDateTime, tblk, nightAngle));
-    ui->tNIGHTTimeLineEdit->setText(Calc::minutesToString(nightTime));
-    ui->tNIGHTLabel->setText(Calc::minutesToString(nightTime));
+    ui->tNIGHTTimeLineEdit->setText(ACalc::minutesToString(nightTime));
+    ui->tNIGHTLabel->setText(ACalc::minutesToString(nightTime));
     // Function times
     switch (ui->FunctionComboBox->currentIndex()) {
     case 0://PIC
@@ -1116,7 +1117,7 @@ void NewFlightDialog::on_tofbTimeLineEdit_inputRejected()
 
 void NewFlightDialog::on_tofbTimeLineEdit_editingFinished()
 {
-    ui->tofbTimeLineEdit->setText(Calc::formatTimeInput(ui->tofbTimeLineEdit->text()));
+    ui->tofbTimeLineEdit->setText(ACalc::formatTimeInput(ui->tofbTimeLineEdit->text()));
     const auto time = QTime::fromString(ui->tofbTimeLineEdit->text(),"hh:mm");
 
     auto line_edit = ui->tofbTimeLineEdit;
@@ -1177,7 +1178,7 @@ void NewFlightDialog::on_tonbTimeLineEdit_inputRejected()
 
 void NewFlightDialog::on_tonbTimeLineEdit_editingFinished()
 {
-    ui->tonbTimeLineEdit->setText(Calc::formatTimeInput(ui->tonbTimeLineEdit->text()));
+    ui->tonbTimeLineEdit->setText(ACalc::formatTimeInput(ui->tonbTimeLineEdit->text()));
     auto line_edit = ui->tonbTimeLineEdit;
     const auto time = QTime::fromString(ui->tonbTimeLineEdit->text(),"hh:mm");
     if(time.isValid()){
@@ -1209,7 +1210,7 @@ void NewFlightDialog::on_acftLineEdit_inputRejected()
 
 void NewFlightDialog::on_acftLineEdit_editingFinished()
 {
-    auto registrationList = CompletionList(CompleterTarget::registrations).list;
+    auto registrationList = experimental::aDB()->getCompletionList(experimental::ADataBase::registrations);
     auto line_edit = ui->acftLineEdit;
     auto text = ui->acftLineEdit->text();
 
@@ -1249,7 +1250,7 @@ void NewFlightDialog::on_picNameLineEdit_editingFinished()
         return;
     }else //check if entry is in pilotList
     {
-        QStringList pilotList = CompletionList(CompleterTarget::pilots).list;
+        QStringList pilotList = experimental::aDB()->getCompletionList(experimental::ADataBase::pilots);
         QStringList match = pilotList.filter(line_edit->text().remove(" "), Qt::CaseInsensitive);
 
         if(match.length()!= 0)
@@ -1294,7 +1295,7 @@ void NewFlightDialog::on_secondPilotNameLineEdit_editingFinished()
         return;
     }else //check if entry is in pilotList
     {
-        QStringList pilotList = CompletionList(CompleterTarget::pilots).list;
+        QStringList pilotList = experimental::aDB()->getCompletionList(experimental::ADataBase::pilots);
         QStringList match = pilotList.filter(line_edit->text().remove(" "), Qt::CaseInsensitive);
 
         if(match.length()!= 0)
@@ -1328,7 +1329,7 @@ void NewFlightDialog::on_thirdPilotNameLineEdit_editingFinished()
         return;
     }else //check if entry is in pilotList
     {
-        QStringList pilotList = CompletionList(CompleterTarget::pilots).list;
+        QStringList pilotList = experimental::aDB()->getCompletionList(experimental::ADataBase::pilots);
         QStringList match = pilotList.filter(line_edit->text().remove(" "), Qt::CaseInsensitive);
 
         if(match.length()!= 0)
@@ -1451,13 +1452,13 @@ inline bool NewFlightDialog::isLessOrEqualToTotalTime(QString timeString)
         mb->show();
         return false;
     } else {
-        int minutes = Calc::stringToMinutes(timeString);
+        int minutes = ACalc::stringToMinutes(timeString);
         if (minutes <= newData.value("tblk").toInt()) {
             return true;
         } else {
             auto mb = new QMessageBox(this);
             mb->setText("Cannot be more than Total Time of Flight:<br><br><center><b>"
-                        + Calc::minutesToString(newData.value("tblk"))
+                        + ACalc::minutesToString(newData.value("tblk"))
                         + "</b></center><br>");
             mb->show();
             return false;
@@ -1469,21 +1470,21 @@ inline bool NewFlightDialog::isLessOrEqualToTotalTime(QString timeString)
 void NewFlightDialog::on_tblkTimeLineEdit_editingFinished()
 {
     const auto &le = ui->tblkTimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
-    newData.insert("tblk",QString::number(Calc::stringToMinutes(text)));
+    newData.insert("tblk",QString::number(ACalc::stringToMinutes(text)));
     le->setText(QString());
 }
 
 void NewFlightDialog::on_tSPSETimeLineEdit_editingFinished()
 {
     const auto &le = ui->tSPSETimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
     if(isLessOrEqualToTotalTime(text)){
-        newData.insert("tSPSE",QString::number(Calc::stringToMinutes(text)));
+        newData.insert("tSPSE",QString::number(ACalc::stringToMinutes(text)));
     } else {
         le->setText(QString());
     }
@@ -1492,11 +1493,11 @@ void NewFlightDialog::on_tSPSETimeLineEdit_editingFinished()
 void NewFlightDialog::on_tSPMETimeLineEdit_editingFinished()
 {
     const auto &le = ui->tSPMETimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
     if(isLessOrEqualToTotalTime(text)){
-        newData.insert("tSPME",QString::number(Calc::stringToMinutes(text)));
+        newData.insert("tSPME",QString::number(ACalc::stringToMinutes(text)));
     } else {
         le->setText(QString());
     }
@@ -1505,11 +1506,11 @@ void NewFlightDialog::on_tSPMETimeLineEdit_editingFinished()
 void NewFlightDialog::on_tMPTimeLineEdit_editingFinished()
 {
     const auto &le = ui->tMPTimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
     if(isLessOrEqualToTotalTime(text)){
-        newData.insert("tMP",QString::number(Calc::stringToMinutes(text)));
+        newData.insert("tMP",QString::number(ACalc::stringToMinutes(text)));
     } else {
         le->setText(QString());
     }
@@ -1517,11 +1518,11 @@ void NewFlightDialog::on_tMPTimeLineEdit_editingFinished()
 void NewFlightDialog::on_tIFRTimeLineEdit_editingFinished()
 {
     const auto &le = ui->tIFRTimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
     if(isLessOrEqualToTotalTime(text)){
-        newData.insert("tIFR",QString::number(Calc::stringToMinutes(text)));
+        newData.insert("tIFR",QString::number(ACalc::stringToMinutes(text)));
     } else {
         le->setText(QString());
     }
@@ -1530,11 +1531,11 @@ void NewFlightDialog::on_tIFRTimeLineEdit_editingFinished()
 void NewFlightDialog::on_tNIGHTTimeLineEdit_editingFinished()
 {
     const auto &le = ui->tNIGHTTimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
     if(isLessOrEqualToTotalTime(text)){
-        newData.insert("tNIGHT",QString::number(Calc::stringToMinutes(text)));
+        newData.insert("tNIGHT",QString::number(ACalc::stringToMinutes(text)));
     } else {
         le->setText(QString());
     }
@@ -1543,11 +1544,11 @@ void NewFlightDialog::on_tNIGHTTimeLineEdit_editingFinished()
 void NewFlightDialog::on_tPICTimeLineEdit_editingFinished()
 {
     const auto &le = ui->tPICTimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
     if(isLessOrEqualToTotalTime(text)){
-        newData.insert("tPIC",QString::number(Calc::stringToMinutes(text)));
+        newData.insert("tPIC",QString::number(ACalc::stringToMinutes(text)));
     } else {
         le->setText(QString());
     }
@@ -1556,11 +1557,11 @@ void NewFlightDialog::on_tPICTimeLineEdit_editingFinished()
 void NewFlightDialog::on_tSICTimeLineEdit_editingFinished()
 {
     const auto &le = ui->tSICTimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
     if(isLessOrEqualToTotalTime(text)){
-        newData.insert("tSIC",QString::number(Calc::stringToMinutes(text)));
+        newData.insert("tSIC",QString::number(ACalc::stringToMinutes(text)));
     } else {
         le->setText(QString());
     }
@@ -1569,11 +1570,11 @@ void NewFlightDialog::on_tSICTimeLineEdit_editingFinished()
 void NewFlightDialog::on_tDUALTimeLineEdit_editingFinished()
 {
     const auto &le = ui->tDUALTimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
     if(isLessOrEqualToTotalTime(text)){
-        newData.insert("tDUAL",QString::number(Calc::stringToMinutes(text)));
+        newData.insert("tDUAL",QString::number(ACalc::stringToMinutes(text)));
     } else {
         le->setText(QString());
     }
@@ -1582,11 +1583,11 @@ void NewFlightDialog::on_tDUALTimeLineEdit_editingFinished()
 void NewFlightDialog::on_tFITimeLineEdit_editingFinished()
 {
     const auto &le = ui->tFITimeLineEdit;
-    le->setText(Calc::formatTimeInput(le->text()));
+    le->setText(ACalc::formatTimeInput(le->text()));
     const auto &text = le->text();
 
     if(isLessOrEqualToTotalTime(text)){
-        newData.insert("tFI",QString::number(Calc::stringToMinutes(text)));
+        newData.insert("tFI",QString::number(ACalc::stringToMinutes(text)));
     } else {
         le->setText(QString());
     }

+ 4 - 4
src/gui/dialogues/newflightdialog.h

@@ -38,10 +38,10 @@
 #include "src/database/db.h"
 #include "src/classes/flight.h"
 #include "src/classes/aircraft.h"
-#include "src/classes/strictrxvalidator.h"
-#include "src/classes/settings.h"
-#include "src/classes/completionlist.h"
-#include "src/classes/calc.h"
+#include "src/classes/astrictrxvalidator.h"
+#include "src/classes/asettings.h"
+#include "src/functions/acalc.h"
+#include "src/experimental/adatabase.h"
 
 #include "src/gui/dialogues/newpilotdialog.h"
 #include "src/gui/dialogues/newtaildialog.h"

+ 7 - 10
src/gui/dialogues/newpilotdialog.cpp

@@ -17,10 +17,8 @@
  */
 #include "newpilotdialog.h"
 #include "ui_newpilot.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
-#include "src/experimental/DataBase.h"
-#include "src/experimental/Entry.h"
 /* Examples for names around the world:
  * José Eduardo Santos Tavares Melo Silva
  * María José Carreño Quiñones
@@ -71,7 +69,7 @@ NewPilotDialog::NewPilotDialog(QWidget *parent) :
     DEB("New NewPilotDialog (newEntry)");
     setup();
 
-    pilotEntry = PilotEntry();
+    pilotEntry = APilotEntry();
     ui->piclastnameLineEdit->setFocus();
 }
 
@@ -82,7 +80,7 @@ NewPilotDialog::NewPilotDialog(int rowId, QWidget *parent) :
     DEB("New NewPilotDialog (editEntry)");
     setup();
 
-    pilotEntry = DB()->getPilotEntry(rowId);
+    pilotEntry = aDB()->getPilotEntry(rowId);
     DEB("Pilot Entry position: " << pilotEntry.getPosition());
     formFiller();
     ui->piclastnameLineEdit->setFocus();
@@ -110,8 +108,7 @@ void NewPilotDialog::setup()
     }
 
     DEB("Setting up completer...");
-    auto companies = new CompletionList(CompleterTarget::companies);
-    auto completer = new QCompleter(companies->list, ui->companyLineEdit);
+    auto completer = new QCompleter(aDB()->getCompletionList(ADataBase::companies), ui->companyLineEdit);
     completer->setCompletionMode(QCompleter::InlineCompletion);
     completer->setCaseSensitivity(Qt::CaseSensitive);
     ui->companyLineEdit->setCompleter(completer);
@@ -122,9 +119,9 @@ void NewPilotDialog::setup()
     ///   makes it easier to maintain.
     /// - these signals and slots are specific to this dialog, for communication with
     ///   other widgets we have the QDialog::accepted() and QDialog::rejected signals.
-    QObject::connect(DB(), &DataBase::commitSuccessful,
+    QObject::connect(aDB(), &ADataBase::sqlSuccessful,
                      this, &NewPilotDialog::onCommitSuccessful);
-    QObject::connect(DB(), &DataBase::sqlError,
+    QObject::connect(aDB(), &ADataBase::sqlError,
                      this, &NewPilotDialog::onCommitUnsuccessful);
 }
 
@@ -181,5 +178,5 @@ void NewPilotDialog::submitForm()
     pilotEntry.setData(new_data);
     DEB("Pilot entry position: " << pilotEntry.getPosition());
     DEB("Pilot entry data: " << pilotEntry.getData());
-    DB()->commit(pilotEntry);
+    aDB()->commit(pilotEntry);
 }

+ 5 - 5
src/gui/dialogues/newpilotdialog.h

@@ -24,11 +24,11 @@
 #include <QRegularExpressionValidator>
 #include <QCompleter>
 #include "src/classes/pilot.h"
-#include "src/classes/completionlist.h"
 
-#include "src/experimental/DataBase.h"
-#include "src/experimental/Entry.h"
-#include "src/experimental/Decl.h"
+#include "src/experimental/adatabase.h"
+#include "src/experimental/aentry.h"
+#include "src/experimental/apilotentry.h"
+#include "src/experimental/decl.h"
 
 namespace Ui {
 class NewPilot;
@@ -53,7 +53,7 @@ private slots:
 private:
     Ui::NewPilot *ui;
 
-    experimental::PilotEntry pilotEntry;
+    experimental::APilotEntry pilotEntry;
 
     inline void setup();
 

+ 7 - 8
src/gui/dialogues/newtaildialog.cpp

@@ -17,7 +17,7 @@
  */
 #include "newtaildialog.h"
 #include "ui_newtail.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 static const auto REG_VALID = QPair<QString, QRegularExpression> {
     "registrationLineEdit", QRegularExpression("\\w+-\\w+")};
@@ -88,11 +88,10 @@ void NewTailDialog::setupCompleter()
     }
     //creating QStringlist for QCompleter. This list is identical to a list of map<key>,
     //but creating it like this is faster.
-    auto cl = new CompletionList(CompleterTarget::aircraft);
 
-    aircraftlist = cl->list;
-    idMap = map;
 
+    auto aircraftlist = experimental::aDB()->getCompletionList(experimental::ADataBase::aircraft);
+    idMap = map;
     QCompleter *completer = new QCompleter(aircraftlist, ui->searchLineEdit);
     completer->setCaseSensitivity(Qt::CaseInsensitive);
     completer->setCompletionMode(QCompleter::PopupCompletion);
@@ -113,7 +112,7 @@ void NewTailDialog::setupValidators()
  * information contained in an aircraft object.
  * \param db - entry retreived from database
  */
-void NewTailDialog::formFiller(Entry entry)
+void NewTailDialog::formFiller(Entry_deprecated entry)
 {
     DEB("Filling Form for a/c" << entry);
     //fill Line Edits
@@ -234,7 +233,7 @@ void NewTailDialog::submitForm(Db::editRole edRole)
     case Db::editExisting:
         oldEntry.setData(newData);
         oldEntry.commit();
-        Calc::updateAutoTimes(oldEntry.position.second);
+        ACalc::updateAutoTimes(oldEntry.position.second);
         break;
     }
 }
@@ -248,7 +247,7 @@ void NewTailDialog::on_searchLineEdit_textChanged(const QString &arg1)
 
         DEB("Template Selected. aircraft_id is: " << idMap.value(arg1));
         //call autofiller for dialog
-        formFiller(Entry("aircraft",idMap.value(arg1)));
+        formFiller(Entry_deprecated("aircraft",idMap.value(arg1)));
         ui->searchLineEdit->setStyleSheet("border: 1px solid green");
     } else {
         //for example, editing finished without selecting a result from Qcompleter
@@ -297,7 +296,7 @@ void NewTailDialog::on_buttonBox_accepted()
             submitForm(role);
             accept();
         } else {
-            if (!Settings::read("userdata/acAllowIncomplete").toInt()) {
+            if (!ASettings::read("userdata/acAllowIncomplete").toInt()) {
                 auto nope = QMessageBox(this);
                 nope.setText("Some or all fields are empty.\nPlease go back and "
                               "complete the form.\n\nYou can allow logging incomplete entries on the settings page.");

+ 6 - 6
src/gui/dialogues/newtaildialog.h

@@ -23,12 +23,12 @@
 #include <QMessageBox>
 #include <QRegularExpression>
 
-#include "src/classes/settings.h"
-#include "src/classes/completionlist.h"
+#include "src/classes/asettings.h"
 #include "src/classes/aircraft.h"
-#include "src/classes/strictrxvalidator.h"
-#include "src/classes/calc.h"
-#include "src/database/entry.h"
+#include "src/classes/astrictrxvalidator.h"
+#include "src/functions/acalc.h"
+#include "src/database/entry_deprecated.h"
+#include "src/experimental/adatabase.h"
 
 namespace Ui {
 class NewTail;
@@ -85,7 +85,7 @@ private:
 
     void setupValidators();
 
-    void formFiller(Entry);
+    void formFiller(Entry_deprecated);
 
     bool verify();
 };

+ 2 - 2
src/gui/widgets/aircraftwidget.cpp

@@ -28,7 +28,7 @@ AircraftWidget::AircraftWidget(QWidget *parent) :
 {
     DEB("New AircraftWidet");
     ui->setupUi(this);
-    sortColumn = Settings::read("userdata/acSortColumn").toInt();
+    sortColumn = ASettings::read("userdata/acSortColumn").toInt();
     refreshModelAndView();
 }
 
@@ -163,7 +163,7 @@ void AircraftWidget::tableView_selectionChanged()
 void AircraftWidget::tableView_headerClicked(int column)
 {
     sortColumn = column;
-    Settings::write("userdata/acSortColumn", column);
+    ASettings::write("userdata/acSortColumn", column);
 }
 
 void AircraftWidget::acft_editing_finished()

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

@@ -25,7 +25,7 @@
 #include <QLabel>
 #include <QHBoxLayout>
 
-#include "src/classes/settings.h"
+#include "src/classes/asettings.h"
 #include "src/gui/dialogues/newtaildialog.h"
 #include "src/classes/aircraft.h"
 #include "src/database/db.h"

+ 11 - 10
src/gui/widgets/debugwidget.cpp

@@ -1,6 +1,7 @@
 #include "debugwidget.h"
 #include "ui_debugwidget.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
+
 
 DebugWidget::DebugWidget(QWidget *parent) :
     QWidget(parent),
@@ -23,7 +24,7 @@ DebugWidget::~DebugWidget()
 void DebugWidget::on_resetUserTablesPushButton_clicked()
 {
     QMessageBox result;
-    if (DbSetup::resetToDefault()){
+    if (ADataBaseSetup::resetToDefault()){
         result.setText("Database successfully reset.\n\nRestarting app.");
         result.exec();
         qApp->quit();
@@ -48,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();
@@ -71,7 +72,7 @@ void DebugWidget::on_resetDatabasePushButton_clicked()
     // re-connct and create new database
     Db::connect();
 
-    if (DbSetup::createDatabase()) {
+    if (ADataBaseSetup::createDatabase()) {
         mb.setText("Database has been successfully reset.\n\nRestarting application.");
         mb.exec();
         qApp->quit();
@@ -99,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();
@@ -109,8 +110,8 @@ void DebugWidget::on_fillUserDataPushButton_clicked()
     }
     QVector<bool> allGood;
     for (const auto& table : userTables) {
-        auto data = Csv::read("data/templates/sample_" + table + ".csv");
-        allGood.append(DbSetup::commitData(data, table));
+        auto data = aReadCsv("data/templates/sample_" + table + ".csv");
+        allGood.append(ADataBaseSetup::commitData(data, table));
     }
 
     for (const auto& item : allGood) {
@@ -142,7 +143,7 @@ void DebugWidget::on_importCsvPushButton_clicked()
 
     if (file.exists() && file.isFile()) {
 
-        if (DbSetup::commitData(Csv::read(file.absoluteFilePath()), ui->tableComboBox->currentText())) {
+        if (ADataBaseSetup::commitData(aReadCsv(file.absoluteFilePath()), ui->tableComboBox->currentText())) {
             auto mb = QMessageBox(this);
             mb.setText("Data inserted successfully.");
             mb.exec();

+ 4 - 2
src/gui/widgets/debugwidget.h

@@ -7,10 +7,12 @@
 #include <QFile>
 #include <QFileDialog>
 #include <QMessageBox>
+#include <QProcess>
 #include "src/database/db.h"
-#include "src/database/dbsetup.h"
+#include "src/database/adatabasesetup.h"
 #include "src/database/dbinfo.h"
-#include "src/classes/download.h"
+#include "src/classes/adownload.h"
+#include "src/functions/areadcsv.h"
 
 namespace Ui {
 class DebugWidget;

+ 1 - 1
src/gui/widgets/homewidget.cpp

@@ -17,7 +17,7 @@
  */
 #include "homewidget.h"
 #include "ui_homewidget.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 
 HomeWidget::HomeWidget(QWidget *parent) :

+ 5 - 6
src/gui/widgets/homewidget.h

@@ -23,19 +23,18 @@
 #include <QLabel>
 #include <QLineEdit>
 #include "src/database/db.h"
-#include "src/classes/stat.h"
-#include "src/classes/calc.h"
-#include "src/classes/completionlist.h"
+#include "src/functions/astat.h"
+#include "src/functions/acalc.h"
 #include "src/gui/dialogues/newtaildialog.h"
 #include "src/classes/aircraft.h"
 #include "src/gui/dialogues/newpilotdialog.h"
-#include "src/database/entry.h"
+#include "src/database/entry_deprecated.h"
 #include "src/gui/widgets/totalswidget.h"
 #include "src/gui/dialogues/firstrundialog.h"
 #include "src/gui/dialogues/newflightdialog.h"
 
-#include "src/experimental/DataBase.h"
-#include "src/experimental/Decl.h"
+#include "src/experimental/adatabase.h"
+#include "src/experimental/decl.h"
 
 namespace Ui {
 class HomeWidget;

+ 7 - 7
src/gui/widgets/logbookwidget.cpp

@@ -17,7 +17,7 @@
  */
 #include "logbookwidget.h"
 #include "ui_logbookwidget.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 LogbookWidget::LogbookWidget(QWidget *parent) :
     QWidget(parent),
@@ -36,7 +36,7 @@ LogbookWidget::LogbookWidget(QWidget *parent) :
     //message Box
     nope = new QMessageBox(this);
 
-    refreshView(Settings::read("logbook/view").toInt());
+    refreshView(ASettings::read("logbook/view").toInt());
 }
 
 LogbookWidget::~LogbookWidget()
@@ -152,7 +152,7 @@ void LogbookWidget::on_newFlightButton_clicked()
     auto nf = new NewFlightDialog(this, Db::createNew);
     nf->setAttribute(Qt::WA_DeleteOnClose);
     nf->exec();
-    refreshView(Settings::read("logbook/view").toInt());
+    refreshView(ASettings::read("logbook/view").toInt());
 }
 
 void LogbookWidget::on_editFlightButton_clicked()
@@ -161,7 +161,7 @@ void LogbookWidget::on_editFlightButton_clicked()
         auto ef = new NewFlightDialog(this,Flight(selectedFlights.first()), Db::editExisting);
         ef->setAttribute(Qt::WA_DeleteOnClose);
         ef->exec();
-        refreshView(Settings::read("logbook/view").toInt());
+        refreshView(ASettings::read("logbook/view").toInt());
     } else if (selectedFlights.isEmpty()) {
         nope->setText("No flight selected.\n");
         nope->exec();
@@ -205,7 +205,7 @@ void LogbookWidget::on_deleteFlightPushButton_clicked()
                 auto entry = Flight(selectedFlight);
                 entry.remove();
             }
-            refreshView(Settings::read("logbook/view").toInt());
+            refreshView(ASettings::read("logbook/view").toInt());
         }
     } else if (selectedFlights.length() == 0) {
         nope->setIcon(QMessageBox::Information);
@@ -228,7 +228,7 @@ void LogbookWidget::on_deleteFlightPushButton_clicked()
                 auto entry = Flight(selectedFlight);
                 entry.remove();
             }
-            refreshView(Settings::read("logbook/view").toInt());
+            refreshView(ASettings::read("logbook/view").toInt());
         }
     }
 }
@@ -251,7 +251,7 @@ void LogbookWidget::on_filterFlightsByDateButton_clicked()
 
 void LogbookWidget::on_showAllButton_clicked()
 {
-    refreshView(Settings::read("logbook/view").toInt());
+    refreshView(ASettings::read("logbook/view").toInt());
 }
 
 void LogbookWidget::on_tableView_customContextMenuRequested(const QPoint &pos)

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

@@ -26,7 +26,7 @@
 #include <QDebug>
 #include <QMenu>
 
-#include "src/classes/settings.h"
+#include "src/classes/asettings.h"
 #include "src/database/db.h"
 #include "src/classes/flight.h"
 #include "src/gui/dialogues/newflightdialog.h"

+ 5 - 5
src/gui/widgets/pilotswidget.cpp

@@ -17,7 +17,7 @@
  */
 #include "pilotswidget.h"
 #include "ui_pilotswidget.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 using namespace experimental;
 PilotsWidget::PilotsWidget(QWidget *parent) :
@@ -25,7 +25,7 @@ PilotsWidget::PilotsWidget(QWidget *parent) :
     ui(new Ui::PilotsWidget)
 {
     ui->setupUi(this);
-    sortColumn = Settings::read("userdata/pilSortColumn").toInt();
+    sortColumn = ASettings::read("userdata/pilSortColumn").toInt();
 
     setupModelAndView();
     refreshModelAndView();
@@ -110,7 +110,7 @@ void PilotsWidget::tableView_selectionChanged()//const QItemSelection &index, co
 void PilotsWidget::tableView_headerClicked(int column)
 {
     sortColumn = column;
-    Settings::write("userdata/pilSortColumn", column);
+    ASettings::write("userdata/pilSortColumn", column);
 }
 
 void PilotsWidget::on_newButton_clicked()
@@ -142,8 +142,8 @@ void PilotsWidget::on_deletePushButton_clicked()
         /// flights table (see on_delete_unsuccessful) below
 
     } else if (selectedPilots.length() == 1) {
-        auto entry = DB()->getPilotEntry(selectedPilots.first());
-        DB()->remove(entry);
+        auto entry = aDB()->getPilotEntry(selectedPilots.first());
+        aDB()->remove(entry);
         }
     refreshModelAndView();
 

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

@@ -24,7 +24,7 @@
 #include <QDebug>
 #include <QLabel>
 #include <QTableView>
-#include "src/classes/settings.h"
+#include "src/classes/asettings.h"
 #include "src/classes/pilot.h"
 #include "src/gui/dialogues/newpilotdialog.h"
 

+ 41 - 41
src/gui/widgets/settingswidget.cpp

@@ -18,7 +18,7 @@
 #include "settingswidget.h"
 #include "ui_settingswidget.h"
 #include "src/database/dbinfo.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 static const auto FIRSTNAME_VALID = QPair<QString, QRegularExpression> {
     "picfirstnameLineEdit", QRegularExpression("[a-zA-Z]+")};
@@ -68,25 +68,25 @@ void SettingsWidget::fillSettings()
     /*
      * Personal Tab
      */
-    ui->piclastnameLineEdit->setText(Settings::read("userdata/piclastname").toString());
-    ui->picfirstnameLineEdit->setText(Settings::read("userdata/picfirstname").toString());
-    ui->companyLineEdit->setText(Settings::read("userdata/company").toString());
-    ui->employeeidLineEdit->setText(Settings::read("userdata/employeeid").toString());
-    ui->phoneLineEdit->setText(Settings::read("userdata/phone").toString());
-    ui->emailLineEdit->setText(Settings::read("userdata/email").toString());
+    ui->piclastnameLineEdit->setText(ASettings::read("userdata/piclastname").toString());
+    ui->picfirstnameLineEdit->setText(ASettings::read("userdata/picfirstname").toString());
+    ui->companyLineEdit->setText(ASettings::read("userdata/company").toString());
+    ui->employeeidLineEdit->setText(ASettings::read("userdata/employeeid").toString());
+    ui->phoneLineEdit->setText(ASettings::read("userdata/phone").toString());
+    ui->emailLineEdit->setText(ASettings::read("userdata/email").toString());
     /*
      * Flight Logging Tab
      */
-    ui->aliasComboBox->setCurrentIndex(Settings::read("userdata/displayselfas").toInt());
-    ui->functionComboBox->setCurrentText(Settings::read("flightlogging/function").toString());
-    ui->rulesComboBox->setCurrentText(Settings::read("flightlogging/rules").toString());
-    ui->approachComboBox->setCurrentText(Settings::read("flightlogging/approach").toString());
-    ui->nightComboBox->setCurrentIndex(Settings::read("flightlogging/nightlogging").toInt());
-    ui->prefixLineEdit->setText(Settings::read("flightlogging/flightnumberPrefix").toString());
+    ui->aliasComboBox->setCurrentIndex(ASettings::read("userdata/displayselfas").toInt());
+    ui->functionComboBox->setCurrentText(ASettings::read("flightlogging/function").toString());
+    ui->rulesComboBox->setCurrentText(ASettings::read("flightlogging/rules").toString());
+    ui->approachComboBox->setCurrentText(ASettings::read("flightlogging/approach").toString());
+    ui->nightComboBox->setCurrentIndex(ASettings::read("flightlogging/nightlogging").toInt());
+    ui->prefixLineEdit->setText(ASettings::read("flightlogging/flightnumberPrefix").toString());
     /*
      * Misc Tab
      */
-    switch (Settings::read("main/theme").toInt()) {
+    switch (ASettings::read("main/theme").toInt()) {
     case 0:
         ui->systemThemeCheckBox->setChecked(true);
         break;
@@ -96,13 +96,13 @@ void SettingsWidget::fillSettings()
     case 2:
         ui->darkThemeCheckBox->setChecked(true);
     }
-    ui->logbookViewComboBox->setCurrentIndex(Settings::read("logbook/view").toInt());
+    ui->logbookViewComboBox->setCurrentIndex(ASettings::read("logbook/view").toInt());
     /*
      * Aircraft Tab
      */
-    ui->acSortComboBox->setCurrentIndex(Settings::read("userdata/acSortColumn").toInt());
-    ui->pilotSortComboBox->setCurrentIndex(Settings::read("userdata/pilSortColumn").toInt());
-    ui->acAllowIncompleteComboBox->setCurrentIndex(Settings::read("userdata/acAllowIncomplete").toInt());
+    ui->acSortComboBox->setCurrentIndex(ASettings::read("userdata/acSortColumn").toInt());
+    ui->pilotSortComboBox->setCurrentIndex(ASettings::read("userdata/pilSortColumn").toInt());
+    ui->acAllowIncompleteComboBox->setCurrentIndex(ASettings::read("userdata/acAllowIncomplete").toInt());
 }
 
 void SettingsWidget::setupValidators()
@@ -166,10 +166,10 @@ void SettingsWidget::updatePersonalDetails()
 void SettingsWidget::on_piclastnameLineEdit_editingFinished()
 {
     if(ui->piclastnameLineEdit->text().isEmpty()){
-        ui->piclastnameLineEdit->setText(Settings::read("userdata/piclastname").toString());
+        ui->piclastnameLineEdit->setText(ASettings::read("userdata/piclastname").toString());
         ui->piclastnameLineEdit->setFocus();
     } else {
-        Settings::write("userdata/piclastname",ui->piclastnameLineEdit->text());
+        ASettings::write("userdata/piclastname",ui->piclastnameLineEdit->text());
         updatePersonalDetails();
     }
 }
@@ -177,35 +177,35 @@ void SettingsWidget::on_piclastnameLineEdit_editingFinished()
 void SettingsWidget::on_picfirstnameLineEdit_editingFinished()
 {
     if(ui->picfirstnameLineEdit->text().isEmpty()){
-        ui->picfirstnameLineEdit->setText(Settings::read("userdata/picfirstname").toString());
+        ui->picfirstnameLineEdit->setText(ASettings::read("userdata/picfirstname").toString());
         ui->picfirstnameLineEdit->setFocus();
     } else {
-        Settings::write("userdata/picfirstname",ui->picfirstnameLineEdit->text());
+        ASettings::write("userdata/picfirstname",ui->picfirstnameLineEdit->text());
         updatePersonalDetails();
     }
 }
 
 void SettingsWidget::on_companyLineEdit_editingFinished()
 {
-    Settings::write("userdata/company",ui->companyLineEdit->text());
+    ASettings::write("userdata/company",ui->companyLineEdit->text());
     updatePersonalDetails();
 }
 
 void SettingsWidget::on_employeeidLineEdit_editingFinished()
 {
-    Settings::write("userdata/employeeid",ui->employeeidLineEdit->text());
+    ASettings::write("userdata/employeeid",ui->employeeidLineEdit->text());
     updatePersonalDetails();
 }
 
 void SettingsWidget::on_emailLineEdit_editingFinished()
 {
-    Settings::write("userdata/email",ui->emailLineEdit->text());
+    ASettings::write("userdata/email",ui->emailLineEdit->text());
     updatePersonalDetails();
 }
 
 void SettingsWidget::on_phoneLineEdit_editingFinished()
 {
-    Settings::write("userdata/phone",ui->phoneLineEdit->text());
+    ASettings::write("userdata/phone",ui->phoneLineEdit->text());
     updatePersonalDetails();
 }
 
@@ -215,43 +215,43 @@ void SettingsWidget::on_phoneLineEdit_editingFinished()
 
 void SettingsWidget::on_aliasComboBox_currentIndexChanged(int index)
 {
-    Settings::write("userdata/displayselfas",index);
+    ASettings::write("userdata/displayselfas",index);
     updatePersonalDetails();
 }
 
 void SettingsWidget::on_functionComboBox_currentIndexChanged(const QString &arg1)
 {
-    Settings::write("flightlogging/function", arg1);
+    ASettings::write("flightlogging/function", arg1);
 }
 
 void SettingsWidget::on_rulesComboBox_currentIndexChanged(const QString &arg1)
 {
-    Settings::write("flightlogging/rules", arg1);
+    ASettings::write("flightlogging/rules", arg1);
 }
 
 void SettingsWidget::on_approachComboBox_currentIndexChanged(const QString &arg1)
 {
-    Settings::write("flightlogging/approach", arg1);
+    ASettings::write("flightlogging/approach", arg1);
 }
 
 void SettingsWidget::on_nightComboBox_currentIndexChanged(int index)
 {
-    Settings::write("flightlogging/nightlogging", index);
+    ASettings::write("flightlogging/nightlogging", index);
     switch (index) {
     case 1:
-        Settings::write("flightlogging/nightangle",-6);
+        ASettings::write("flightlogging/nightangle",-6);
         break;
     case 2:
-        Settings::write("flightlogging/nightangle",0);
+        ASettings::write("flightlogging/nightangle",0);
         break;
     default:
-        Settings::write("flightlogging/nightangle",-6);
+        ASettings::write("flightlogging/nightangle",-6);
     }
 }
 
 void SettingsWidget::on_prefixLineEdit_textChanged(const QString &arg1)
 {
-    Settings::write("flightlogging/flightnumberPrefix", arg1);
+    ASettings::write("flightlogging/flightnumberPrefix", arg1);
 
 }
 
@@ -260,7 +260,7 @@ void SettingsWidget::on_prefixLineEdit_textChanged(const QString &arg1)
  */
 void SettingsWidget::themeGroup_toggled(int id)
 {
-    Settings::write("main/theme", id);
+    ASettings::write("main/theme", id);
 
     QMessageBox::StandardButton reply;
     reply = QMessageBox::question(this, "Changing Themes",
@@ -278,21 +278,21 @@ void SettingsWidget::themeGroup_toggled(int id)
 }
 void SettingsWidget::on_logbookViewComboBox_currentIndexChanged(int index)
 {
-    Settings::write("logbook/view", index);
+    ASettings::write("logbook/view", index);
 }
 void SettingsWidget::on_pilotSortComboBox_currentIndexChanged(int index)
 {
-    Settings::write("userdata/pilSortColumn", index);
+    ASettings::write("userdata/pilSortColumn", index);
 }
 
 void SettingsWidget::on_acSortComboBox_currentIndexChanged(int index)
 {
-    Settings::write("userdata/acSortColumn", index);
+    ASettings::write("userdata/acSortColumn", index);
 }
 
 void SettingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
 {
-    Settings::write("userdata/acAllowIncomplete", index);
+    ASettings::write("userdata/acAllowIncomplete", index);
     if (index) {
         QMessageBox::StandardButton reply;
         reply = QMessageBox::warning(this, "Warning",
@@ -304,7 +304,7 @@ void SettingsWidget::on_acAllowIncompleteComboBox_currentIndexChanged(int index)
                                       "Are you sure you want to proceed?",
                                       QMessageBox::Yes | QMessageBox::No);
         if (reply == QMessageBox::Yes) {
-            Settings::write("userdata/acAllowIncomplete", index);
+            ASettings::write("userdata/acAllowIncomplete", index);
         } else {
             ui->acAllowIncompleteComboBox->setCurrentIndex(0);
         }

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

@@ -25,7 +25,7 @@
 #include <QMessageBox>
 #include <QProcess>
 #include <QDebug>
-#include "src/classes/settings.h"
+#include "src/classes/asettings.h"
 #include "src/database/db.h"
 #include "src/classes/pilot.h"
 

+ 2 - 2
src/gui/widgets/totalswidget.cpp

@@ -1,13 +1,13 @@
 #include "totalswidget.h"
 #include "ui_totalswidget.h"
-#include "debug.h"
+#include "src/functions/adebug.h"
 
 TotalsWidget::TotalsWidget(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::TotalsWidget)
 {
     ui->setupUi(this);
-    auto data = Stat::totals();
+    auto data = AStat::totals();
     DEB("Filling Totals Line Edits...");
     //DEB("data: " << data);
     for (const auto &field : data) {

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

@@ -7,7 +7,7 @@
 #include <QLineEdit>
 #include <QSettings>
 #include "src/database/db.h"
-#include "src/classes/stat.h"
+#include "src/functions/astat.h"
 
 namespace Ui {
 class TotalsWidget;