浏览代码

Add files via upload

fiffty-50 4 年之前
父节点
当前提交
dd6e789785
共有 14 个文件被更改,包括 2790 次插入0 次删除
  1. 48 0
      main.cpp
  2. 231 0
      mainwindow.cpp
  3. 68 0
      mainwindow.h
  4. 193 0
      mainwindow.ui
  5. 190 0
      newacft.cpp
  6. 66 0
      newacft.h
  7. 113 0
      newacft.ui
  8. 720 0
      newflight.cpp
  9. 108 0
      newflight.h
  10. 867 0
      newflight.ui
  11. 56 0
      openLog.pro
  12. 57 0
      showaircraftlist.cpp
  13. 42 0
      showaircraftlist.h
  14. 31 0
      showaircraftlist.ui

+ 48 - 0
main.cpp

@@ -0,0 +1,48 @@
+/*
+ *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 "mainwindow.h"
+//#include <QCoreApplication>
+#include <QApplication>
+#include <QFile>
+#include <QTextStream>
+#include <QDir>
+#include <QPalette>
+#include <QColor>
+#include <QDebug>
+
+
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication::setOrganizationName("Fiffty50");
+    QCoreApplication::setOrganizationDomain("f-cloud.ch");
+    QCoreApplication::setApplicationName("openLog");
+    QApplication openLog(argc, argv);
+    //Theming with CSS inlcues QFile,QTextStream, QDir, themes folder and TARGET = flog, RESOURCES = themes/breeze.qrc in pro
+    // credit: https://github.com/Alexhuszagh/BreezeStyleSheets
+    QDir::setCurrent("/themes");
+    QFile file(":dark.qss");
+    file.open(QFile::ReadOnly | QFile::Text);
+    QTextStream stream(&file);
+    openLog.setStyleSheet(stream.readAll());
+
+
+    MainWindow w;
+    w.show();
+    return openLog.exec();
+}

+ 231 - 0
mainwindow.cpp

@@ -0,0 +1,231 @@
+/*
+ *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 "mainwindow.h"
+#include "ui_mainwindow.h"
+#include "newflight.h"
+#include "editflight.h"
+#include "newacft.h"
+#include "easaview.h"
+#include "dbman.cpp"
+#include "calc.h"
+#include <QTime>
+#include <QSqlDatabase>
+#include <QSqlDriver>
+#include <QSqlError>
+#include <QSqlQuery>
+#include <QSqlTableModel>
+#include <QTableView>
+#include <chrono>
+#include <QMessageBox>
+
+qlonglong SelectedFlight = -1;
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+
+    ui->setupUi(this);
+
+
+
+    db::connect();
+    ui->FilterDateEdit->setDate(QDate::currentDate());
+
+
+    auto start = std::chrono::high_resolution_clock::now();
+    QSqlTableModel *model = new QSqlTableModel;
+    model->setTable("Logbook");
+    model->select();
+
+
+    QTableView *view = ui->tableView;
+    view->setModel(model);
+    view->setSelectionBehavior(QAbstractItemView::SelectRows);
+    view->setSelectionMode(QAbstractItemView::SingleSelection);
+    view->setEditTriggers(QAbstractItemView::NoEditTriggers);
+
+
+    view->setColumnWidth(1,120);
+    view->setColumnWidth(2,60);
+    view->setColumnWidth(3,60);
+    view->setColumnWidth(4,60);
+    view->setColumnWidth(5,60);
+    view->setColumnWidth(6,60);
+    view->setColumnWidth(7,120);
+    view->setColumnWidth(8,180);
+    view->setColumnWidth(9,120);
+    view->setColumnWidth(10,90);
+    view->horizontalHeader()->setStretchLastSection(QHeaderView::Stretch);
+    //view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+    view->verticalHeader()->hide();
+    view->setAlternatingRowColors(true);
+    view->hideColumn(0); // don't show the ID
+    view->show();
+
+    auto stop = std::chrono::high_resolution_clock::now();
+    auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
+    qDebug() << "Time taken for lookup and rendering: " << duration.count() << " microseconds";
+
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+/*
+ * Functions
+ */
+
+void MainWindow::nope()
+{
+    QMessageBox nope; //error box
+    nope.setText("This feature is not yet available!");
+    nope.exec();
+}
+
+/*
+ * Slots
+ */
+
+void MainWindow::on_newflightButton_clicked()
+{
+    NewFlight nf(this);
+    nf.exec();
+}
+
+
+void MainWindow::on_actionNew_Flight_triggered()
+{
+    NewFlight nf(this);
+    nf.exec();
+}
+
+void MainWindow::on_actionQuit_triggered()
+{
+    QApplication::quit();
+}
+
+void MainWindow::on_quitButton_clicked()
+{
+    QApplication::quit();
+}
+
+
+void MainWindow::on_ShowAllButton_clicked()
+{
+    QSqlTableModel *ShowAllModel = new QSqlTableModel;
+    ShowAllModel->setTable("Logbook");
+    ShowAllModel->select();
+
+    ui->tableView->setModel(ShowAllModel);
+}
+
+void MainWindow::on_filterComboBox_activated(const QString &arg1)
+{
+    if (arg1 == "Pilot Name")
+    {
+        nope();
+    }else if (arg1 == "Aircraft Registration")
+    {
+        nope();
+    }else if (arg1 == "Airline")
+    {
+        nope();
+    }else if (arg1 == "Multi-Engine")
+    {
+        nope();
+    }
+}
+
+void MainWindow::on_editflightButton_clicked()
+{
+    QVector<QString> flight;
+    flight = db::SelectFlightById(QString::number(SelectedFlight));
+    if(flight.length() > 0)
+    {
+        qDebug() << "Valid Flight Selected";
+        db::CommitToScratchpad(flight); // commits flight to scratchpad
+        EditFlight ef(this);
+        ef.exec();
+    }
+
+}
+
+void MainWindow::on_deleteFlightPushButton_clicked()
+{
+    if(SelectedFlight > 0)
+    {
+        qDebug() << "Valid Flight Selected";
+        db::DeleteFlightById(QString::number(SelectedFlight));
+
+
+
+        QSqlTableModel *ShowAllModel = new QSqlTableModel; //refresh view
+        ShowAllModel->setTable("Logbook");
+        ShowAllModel->select();
+
+        ui->tableView->setModel(ShowAllModel);
+    }else
+    {
+        QMessageBox NoFlight;
+        NoFlight.setText("No flight selected.");
+        NoFlight.exec();
+    }
+}
+
+void MainWindow::on_FilterDateEdit_editingFinished()
+{
+
+}
+
+void MainWindow::on_filterFlightsByDateButton_clicked()
+{
+    QDate selection(ui->FilterDateEdit->date());
+    QString selecteddate = selection.toString("yyyy-MM-dd");
+    QString datefilter = "Date = '" + selecteddate +"'";
+
+    QSqlTableModel *DateFilteredModel = new QSqlTableModel;
+    DateFilteredModel ->setTable("Logbook");
+    DateFilteredModel ->setFilter(datefilter);
+    DateFilteredModel->select();
+
+    ui->tableView->setModel(DateFilteredModel);
+}
+
+
+
+void MainWindow::on_EasaViewButton_clicked()
+{
+    EasaView ev(this);
+    ev.exec();
+}
+
+void MainWindow::on_tableView_pressed(const QModelIndex &index)
+{
+    auto NewIndex = ui->tableView->model()->index(index.row(), 0);
+    SelectedFlight = ui->tableView->model()->data(NewIndex).toInt();
+    qDebug() << "Selected Flight with ID#:(presssed) " << SelectedFlight;
+}
+
+void MainWindow::on_tableView_entered(const QModelIndex &index)
+{
+    auto NewIndex = ui->tableView->model()->index(index.row(), 0);
+    SelectedFlight = ui->tableView->model()->data(NewIndex).toInt();
+    qDebug() << "Selected Flight with ID#(entered): " << SelectedFlight;
+}

+ 68 - 0
mainwindow.h

@@ -0,0 +1,68 @@
+/*
+ *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 MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class MainWindow; }
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow(QWidget *parent = nullptr);
+    ~MainWindow();
+
+private slots:
+
+    void nope();
+
+    void on_newflightButton_clicked();
+
+    void on_actionNew_Flight_triggered();
+
+    void on_actionQuit_triggered();
+
+    void on_quitButton_clicked();
+
+    void on_ShowAllButton_clicked();
+
+    void on_filterComboBox_activated(const QString &arg1);
+
+    void on_editflightButton_clicked();
+
+    void on_deleteFlightPushButton_clicked();
+
+    void on_FilterDateEdit_editingFinished();
+
+    void on_filterFlightsByDateButton_clicked();
+
+    void on_EasaViewButton_clicked();
+
+    void on_tableView_pressed(const QModelIndex &index);
+
+    void on_tableView_entered(const QModelIndex &index);
+
+private:
+    Ui::MainWindow *ui;
+};
+#endif // MAINWINDOW_H

+ 193 - 0
mainwindow.ui

@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1280</width>
+    <height>720</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>openLog v0.5</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="6" column="0">
+     <widget class="QPushButton" name="EasaViewButton">
+      <property name="text">
+       <string>View EASA FCL.050 Logbook</string>
+      </property>
+     </widget>
+    </item>
+    <item row="11" column="0">
+     <spacer name="verticalSpacer">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <property name="sizeType">
+       <enum>QSizePolicy::Fixed</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>20</width>
+        <height>20</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+    <item row="3" column="1">
+     <widget class="QPushButton" name="editflightButton">
+      <property name="text">
+       <string>Edit Flight</string>
+      </property>
+     </widget>
+    </item>
+    <item row="0" column="0" colspan="2">
+     <widget class="QTableView" name="tableView">
+      <property name="font">
+       <font>
+        <family>Cantarell</family>
+       </font>
+      </property>
+      <property name="selectionMode">
+       <enum>QAbstractItemView::SingleSelection</enum>
+      </property>
+      <property name="selectionBehavior">
+       <enum>QAbstractItemView::SelectRows</enum>
+      </property>
+     </widget>
+    </item>
+    <item row="9" column="0">
+     <widget class="QComboBox" name="filterComboBox">
+      <item>
+       <property name="text">
+        <string>Pilot Name</string>
+       </property>
+      </item>
+      <item>
+       <property name="text">
+        <string>Aircraft Registration</string>
+       </property>
+      </item>
+      <item>
+       <property name="text">
+        <string>Airline</string>
+       </property>
+      </item>
+      <item>
+       <property name="text">
+        <string>Multi-Engine</string>
+       </property>
+      </item>
+     </widget>
+    </item>
+    <item row="13" column="0" colspan="2">
+     <widget class="QPushButton" name="quitButton">
+      <property name="text">
+       <string>Quit</string>
+      </property>
+     </widget>
+    </item>
+    <item row="3" column="0">
+     <widget class="QPushButton" name="filterFlightsByDateButton">
+      <property name="text">
+       <string>Filter Flights by Date</string>
+      </property>
+     </widget>
+    </item>
+    <item row="9" column="1">
+     <widget class="QPushButton" name="ShowAllButton">
+      <property name="text">
+       <string>Show All Flights</string>
+      </property>
+     </widget>
+    </item>
+    <item row="8" column="0">
+     <widget class="QLabel" name="filterFlightsByLabel">
+      <property name="text">
+       <string>Filter Flights by</string>
+      </property>
+     </widget>
+    </item>
+    <item row="6" column="1">
+     <widget class="QPushButton" name="deleteFlightPushButton">
+      <property name="text">
+       <string>Delete Flight</string>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="0">
+     <widget class="QDateEdit" name="FilterDateEdit">
+      <property name="dateTime">
+       <datetime>
+        <hour>23</hour>
+        <minute>0</minute>
+        <second>0</second>
+        <year>2019</year>
+        <month>12</month>
+        <day>21</day>
+       </datetime>
+      </property>
+      <property name="displayFormat">
+       <string>yyyy-MM-dd</string>
+      </property>
+      <property name="calendarPopup">
+       <bool>true</bool>
+      </property>
+      <property name="timeSpec">
+       <enum>Qt::UTC</enum>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="1">
+     <widget class="QPushButton" name="newflightButton">
+      <property name="text">
+       <string>New Flight</string>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>1280</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>File</string>
+    </property>
+    <addaction name="actionNew_Flight"/>
+    <addaction name="separator"/>
+    <addaction name="actionQuit"/>
+   </widget>
+   <addaction name="menuFile"/>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionNew_Flight">
+   <property name="text">
+    <string>New Flight</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+N</string>
+   </property>
+  </action>
+  <action name="actionQuit">
+   <property name="text">
+    <string>Quit</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+Q</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 190 - 0
newacft.cpp

@@ -0,0 +1,190 @@
+/*
+ *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 "newacft.h"
+#include "ui_newacft.h"
+#include "dbman.cpp"
+#include "showaircraftlist.h"
+#include <QStringListModel>
+#include <QSortFilterProxyModel>
+#include <QCompleter>
+#include <QDebug>
+#include <QMessageBox>
+#include <QSqlQueryModel> // test
+
+QString registration = "invalid";
+QString make = "invalid";
+QString model = "invalid";
+QString variant = "invalid";
+QString aircraft_id = "0";
+
+
+NewAcft::NewAcft(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::NewAcft)
+{
+    ui->setupUi(this);
+}
+
+NewAcft::~NewAcft()
+{
+    delete ui;
+}
+
+
+
+
+
+void NewAcft::on_MakeLineEdit_textEdited(const QString &arg1)
+{
+    QStringList makeList = db::RetreiveAircraftMake(arg1);
+    makeList.removeDuplicates();
+    QCompleter *makeCompleter = new QCompleter(makeList, this);
+    makeCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+    makeCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
+    ui->MakeLineEdit->setCompleter(makeCompleter);
+
+}
+void NewAcft::on_MakeLineEdit_editingFinished()
+{
+    QStringList makeList = db::RetreiveAircraftMake(ui->MakeLineEdit->text());
+    if(makeList.length() != 0)
+    {
+        make = makeList.first();
+        ui->MakeLineEdit->setText(make);
+    }else
+    {
+        QMessageBox msgBox;
+        msgBox.setText("No Airplane Maker with that name found.");
+        msgBox.exec();
+        ui->MakeLineEdit->setText("");
+    }
+}
+
+
+void NewAcft::on_ModelLineEdit_textEdited(const QString &arg1)
+{
+    QStringList modelList = db::RetreiveAircraftModel(make, arg1);
+    modelList.removeDuplicates();
+    QCompleter *modelCompleter = new QCompleter(modelList, this);
+    modelCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+    modelCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
+    ui->ModelLineEdit->setCompleter(modelCompleter);
+}
+void NewAcft::on_ModelLineEdit_editingFinished()
+{
+    QStringList modelList = db::RetreiveAircraftModel(make, ui->ModelLineEdit->text());
+    if(modelList.length() != 0)
+    {
+        model = modelList.first();
+        ui->ModelLineEdit->setText(model);
+    }else
+    {
+        QMessageBox msgBox;
+        msgBox.setText("No Model (Type) with that name found.");
+        msgBox.exec();
+        ui->ModelLineEdit->setText("");
+    }
+}
+
+void NewAcft::on_VariantLineEdit_textEdited(const QString &arg1)
+{
+    QStringList variantList = db::RetreiveAircraftVariant(make, model, arg1);
+    variantList.removeDuplicates();
+    QCompleter *variantCompleter = new QCompleter(variantList, this);
+    variantCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+    variantCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
+    ui->VariantLineEdit->setCompleter(variantCompleter);
+}
+
+void NewAcft::on_VariantLineEdit_editingFinished()
+{
+    QStringList VariantList = db::RetreiveAircraftVariant(make, model, ui->VariantLineEdit->text());
+    if(VariantList.length() != 0)
+    {
+        variant = VariantList.first();
+        ui->VariantLineEdit->setText(variant);
+    }else
+    {
+        QMessageBox msgBox;
+        msgBox.setText("No Variant found. Are you sure you want to proceed?");
+        msgBox.exec();
+        ui->VariantLineEdit->setText("");
+    }
+}
+
+void NewAcft::on_buttonBox_accepted()
+{
+    qDebug() << "Accepted Button pressed";
+    aircraft_id = db::RetreiveAircraftIdFromMakeModelVariant(make, model, variant);
+    if(aircraft_id.contains("0") && aircraft_id.length() < 2)
+    {
+        QMessageBox nope;
+        nope.setText("EASA FCL.050 requires Pilots to record details of:\n\n"
+                     "Make\t e.g. Boeing\nModel\t e.g. 737\nVariant\t e.g. 800\n\nRegistration\n\n"
+                     "Please check or edit the aircraft database.");
+        nope.exec();
+    }else
+    {
+        db::CommitTailToDb(registration, aircraft_id, "");
+        NewAcft::reject();
+    }
+
+}
+
+void NewAcft::on_buttonBox_rejected()
+{
+    make = "xxx";
+    model = "xxx";
+    variant = "xxx";
+    aircraft_id = "0";
+    NewAcft::reject();
+}
+
+
+void NewAcft::on_VerifyButton_clicked()
+{
+    if(ui->EasaEnabledCheckBox->isChecked())
+    {
+        QString checkstring = "[ " + registration + " ]    " + make + " " + model + "-" + variant;
+        ui->VerifyLineEdit->setText(checkstring);
+    }else
+    {
+        ui->VerifyLineEdit->setText("EASA FCL.050 compliance checks disabled.");
+    }
+
+
+
+}
+
+void NewAcft::on_RegistrationLineEdit_editingFinished()
+{
+    registration = ui->RegistrationLineEdit->text();
+}
+
+void NewAcft::on_EasaEnabledCheckBox_stateChanged()
+{
+    QMessageBox nope;
+    nope.setText("Data Input without Format checking may corrupt the database.");
+    nope.exec();
+}
+
+void NewAcft::on_showAllPushButton_clicked()
+{
+    ShowAircraftList sa(this);
+    sa.exec();
+}

+ 66 - 0
newacft.h

@@ -0,0 +1,66 @@
+/*
+ *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 NEWACFT_H
+#define NEWACFT_H
+
+#include <QDialog>
+
+namespace Ui {
+class NewAcft;
+}
+
+class NewAcft : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit NewAcft(QWidget *parent = nullptr);
+    ~NewAcft();
+
+private slots:
+
+    void on_MakeLineEdit_textEdited(const QString &arg1);
+
+    void on_ModelLineEdit_textEdited(const QString &arg1);
+
+    void on_VariantLineEdit_textEdited(const QString &arg1);
+
+    void on_MakeLineEdit_editingFinished();
+
+    void on_ModelLineEdit_editingFinished();
+
+    void on_VariantLineEdit_editingFinished();
+
+    void on_buttonBox_accepted();
+
+    void on_buttonBox_rejected();
+
+    void on_VerifyButton_clicked();
+
+    void on_RegistrationLineEdit_editingFinished();
+
+
+    void on_EasaEnabledCheckBox_stateChanged();
+
+    void on_showAllPushButton_clicked();
+
+private:
+    Ui::NewAcft *ui;
+};
+
+#endif // NEWACFT_H

+ 113 - 0
newacft.ui

@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NewAcft</class>
+ <widget class="QDialog" name="NewAcft">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>337</width>
+    <height>474</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Add New Aircraft</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0" colspan="2">
+    <widget class="QLabel" name="RegistrationLabel">
+     <property name="text">
+      <string>Registration</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="2" colspan="2">
+    <widget class="QLineEdit" name="RegistrationLineEdit"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="TypeLabel">
+     <property name="text">
+      <string>Make</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="2" colspan="2">
+    <widget class="QLineEdit" name="MakeLineEdit"/>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="ModelLabel">
+     <property name="text">
+      <string>Model</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="2" colspan="2">
+    <widget class="QLineEdit" name="ModelLineEdit"/>
+   </item>
+   <item row="3" column="0">
+    <widget class="QLabel" name="VariantLabel">
+     <property name="text">
+      <string>Variant</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="2" colspan="2">
+    <widget class="QLineEdit" name="VariantLineEdit"/>
+   </item>
+   <item row="4" column="0" colspan="3">
+    <widget class="QLabel" name="EasaLoggingLabel">
+     <property name="text">
+      <string>FCL.050 compliant logging:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="3">
+    <widget class="QCheckBox" name="EasaEnabledCheckBox">
+     <property name="text">
+      <string>Enabled</string>
+     </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="1" colspan="2">
+    <widget class="QPushButton" name="showAllPushButton">
+     <property name="text">
+      <string>Show All </string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="0" colspan="2">
+    <widget class="QPushButton" name="VerifyButton">
+     <property name="text">
+      <string>Verify</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="2" colspan="2">
+    <widget class="QLineEdit" name="VerifyLineEdit">
+     <property name="readOnly">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="7" column="2" colspan="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>RegistrationLineEdit</tabstop>
+  <tabstop>MakeLineEdit</tabstop>
+  <tabstop>ModelLineEdit</tabstop>
+  <tabstop>VariantLineEdit</tabstop>
+  <tabstop>VerifyLineEdit</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>

+ 720 - 0
newflight.cpp

@@ -0,0 +1,720 @@
+/*
+ *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 "newflight.h"
+#include "ui_newflight.h"
+#include "newacft.h"
+#include "calc.h"
+#include "dbman.cpp"
+#include <QMessageBox>
+#include <QDebug>
+#include <QCompleter>
+#include <QStringList>
+#include <QStringListModel>
+#include <QSortFilterProxyModel>
+#include <QButtonGroup>
+
+
+void NewFlight::on_verifyButton_clicked()
+{
+    /*on_newDoft_editingFinished();// - activate slots in case user has been active in last input before clicking submit
+    on_newTonb_editingFinished();
+    on_newTofb_editingFinished();
+    on_newDept_editingFinished();
+    on_newDest_editingFinished();
+    on_newAcft_editingFinished();
+    on_newPic_editingFinished();
+    verifyInput();*/
+    fillExtrasLineEdits();
+
+}
+/*
+ * Initialise variables
+ */
+QDate date(QDate::currentDate());
+QString doft(QDate::currentDate().toString(Qt::ISODate));
+QString dept;
+QString dest;
+QTime tofb;
+QTime tonb;
+QTime tblk;
+QString pic;
+QString acft;
+QVector<QString> flight;
+// extras
+QString PilotFunction;
+QString PilotTask;
+QString TakeOff;
+QString Landing;
+QString Autoland;
+QString ApproachType;
+
+
+
+
+
+/*
+ * Window
+ */
+
+NewFlight::NewFlight(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::NewFlight)
+{
+    ui->setupUi(this);
+    ui->newDoft->setDate(QDate::currentDate());
+
+    bool hasoldinput = db::CheckScratchpad();
+    qDebug() << "Hasoldinput? = " << hasoldinput;
+    if(hasoldinput) // Re-populate the Form
+    {
+        flight = db::RetreiveScratchpad();
+        qDebug() << "Re-Filling Form from Scratchpad";
+        returnInput(flight);
+    }
+
+    // Validators for Line Edits
+    QRegExp icao_rx("[a-zA-Z]?[a-zA-Z]?[a-zA-Z]?[a-zA-Z]"); // allow only letters (upper and lower)
+    QValidator *ICAOvalidator = new QRegExpValidator(icao_rx, this);
+    ui->newDept->setValidator(ICAOvalidator);
+    ui->newDest->setValidator(ICAOvalidator);
+    QRegExp timehhmm("([01]?[0-9]|2[0-3]):?[0-5][0-9]"); //allows time in 24h format with optional leading 0 and with or without seperator
+    QValidator *timeInputValidator = new QRegExpValidator(timehhmm, this);
+    ui->newTofb->setValidator(timeInputValidator);
+    ui->newTonb->setValidator(timeInputValidator);
+    ui->spseTimeLineEdit->setValidator(timeInputValidator);
+    ui->spmeTimeLineEdit->setValidator(timeInputValidator);
+    ui->mpTimeLineEdit->setValidator(timeInputValidator);
+    ui->totalTimeLineEdit->setValidator(timeInputValidator);
+    ui->ifrTimeLineEdit->setValidator(timeInputValidator);
+    ui->vfrTimeLineEdit->setValidator(timeInputValidator);
+    ui->nightTimeLineEdit->setValidator(timeInputValidator);
+    ui->xcTimeLineEdit->setValidator(timeInputValidator);
+    ui->picTimeLineEdit->setValidator(timeInputValidator);
+    ui->copTimeLineEdit->setValidator(timeInputValidator);
+    ui->dualTimeLineEdit->setValidator(timeInputValidator);
+    ui->fiTimeLineEdit->setValidator(timeInputValidator);
+    ui->simTimeLineEdit->setValidator(timeInputValidator);
+    QRegExp picname("^[a-zA-Z_]+,?( [a-zA-Z_]+)*$");// allow only lastname, firstname or lastname firstname with one whitespace
+    QValidator *picNameValidator = new QRegExpValidator(picname, this);
+    ui->newPic->setValidator(picNameValidator);
+
+    // Groups for CheckBoxes
+    QButtonGroup *FlightRulesGroup = new QButtonGroup(this);
+    FlightRulesGroup->addButton(ui->IfrCheckBox);
+    FlightRulesGroup->addButton(ui->VfrCheckBox);
+
+    QButtonGroup *PilotTaskGroup = new QButtonGroup(this);
+    PilotTaskGroup->addButton(ui->PilotFlyingCheckBox);
+    PilotTaskGroup->addButton(ui->PilotMonitoringCheckBox);
+
+    restoreSettings();
+    ui->deptTZ->setFocusPolicy(Qt::NoFocus);
+    ui->destTZ->setFocusPolicy(Qt::NoFocus);
+    ui->newDept->setFocus();
+
+}
+
+NewFlight::~NewFlight()
+{
+    delete ui;
+}
+
+/*
+ * Functions
+ */
+
+void NewFlight::nope()
+{
+    QMessageBox nope(this); //error box
+    nope.setText("This feature is not yet available!");
+    nope.exec();
+}
+
+/*!
+ * \brief NewFlight::validateTimeInput verifies user input and formats to hh:mm
+ * \param userinput from a QLineEdit
+ * \return formatted QString "hh:mm"
+ */
+QString NewFlight::validateTimeInput(QString userinput)
+{
+    QString output;
+    QTime temptime;
+
+    if(userinput.length() <3)
+    {
+        QMessageBox timeformat(this);
+        timeformat.setText("Please enter a valid time. Any of these formats is valid:\n845 0845 8:45 08:45");
+        timeformat.exec();
+    }
+
+    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");
+            }else
+            {
+                temptime = QTime::fromString(userinput,"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");
+        }
+
+        return temptime.toString("hh:mm");
+}
+
+/*!
+ * \brief NewFlight::fillExtrasLineEdits Fills the flight time line edits according to ui selections
+ */
+void NewFlight::fillExtrasLineEdits()
+{
+    // SP SE
+    // SP ME
+    // MP
+    // TOTAL
+    if(tofb.isValid() && tonb.isValid()) {
+        ui->totalTimeLineEdit->setText(calc::blocktime(tofb,tonb).toString("hh:mm"));
+    }
+    // IFR
+    // VFR
+    // Night
+    if(ui->autoNightCheckBox->isChecked() && tofb.isValid() && tonb.isValid() && dept.length() == 4 && dest.length() == 4) {
+        QString deptDate = date.toString(Qt::ISODate) + 'T' + tofb.toString("hh:mm");
+        qDebug() << "Departure Date: " << deptDate;
+        QDateTime deptDateTime = QDateTime::fromString(deptDate,"yyyy-MM-ddThh:mm");
+        qDebug() << "Departure DateTime " << deptDateTime;
+        int blocktime = calc::time_to_minutes(calc::blocktime(tofb,tonb));
+        qDebug() << "Blocktime: " << blocktime;
+            //qDebug() << calc::calculateNightTime(dept, dest, deptDateTime, blocktime);
+            //qDebug() << calc::minutes_to_string(QString::number(calc::calculateNightTime(dept, dest, deptDateTime, blocktime)));
+            ui->nightTimeLineEdit->setText(calc::minutes_to_string(QString::number(calc::calculateNightTime(dept, dest, deptDateTime, blocktime))));
+    }else if(!ui->autoNightCheckBox->isChecked()) {
+        ui->nightTimeLineEdit->setText("");
+    }
+    // XC
+    // PIC
+    // Co-Pilot
+    // Dual
+    // FI
+    // SIM
+}
+
+
+QVector<QString> NewFlight::collectInput()
+{
+    // Collect input from the user fields and return a vector containing the flight information
+    QString doft = date.toString(Qt::ISODate); // Format Date
+    QTime tblk = calc::blocktime(tofb,tonb);   // Calculate Blocktime
+
+
+    // Prepare Vector for commit to database
+    flight = db::CreateFlightVectorFromInput(doft, dept, tofb, dest, tonb, tblk, pic, acft);
+    qDebug() << "Created flight vector:" << flight;
+
+    return flight;
+}
+
+bool NewFlight::verifyInput()
+    //check if the input is correctly formatted and all required fields are filled
+{
+
+    bool deptValid = false;
+    bool tofbValid = false;
+    bool destValid = false;
+    bool tonbValid = false;
+    bool tblkValid = false;
+    bool picValid = false;
+    bool acftValid = false;
+
+    QTime tblk = calc::blocktime(tofb,tonb);
+    int checktblk = calc::time_to_minutes(tblk);
+
+    bool doftValid = true; //doft assumed to be always valid due to QDateTimeEdit constraints
+    qDebug() << "NewFlight::verifyInput() says: Date:" << doft << " - Valid?\t" << doftValid;
+
+    deptValid = db::CheckICAOValid(dept);
+    qDebug() << "NewFlight::verifyInput() says: Departure is:\t" << dept << " - Valid?\t" << deptValid;
+
+    destValid = db::CheckICAOValid(dest);
+    qDebug() << "NewFlight::verifyInput() says: Destination is:\t" << dest << " - Valid?\t" << destValid;
+
+    tofbValid = (unsigned)(calc::time_to_minutes(tofb)-0) <= (1440-0) && tofb.toString("hh:mm") != ""; // Make sure time is within range, DB 1 day = 1440 minutes. 0 is allowed (midnight) & that it is not empty.
+    qDebug() << "NewFlight::verifyInput() says: tofb is:\t\t" << tofb.toString("hh:mm") << " - Valid?\t" << tofbValid;
+
+    tonbValid = (unsigned)(calc::time_to_minutes(tonb)-0) <= (1440-0) && tonb.toString("hh:mm") != ""; // Make sure time is within range, DB 1 day = 1440 minutes
+    qDebug() << "NewFlight::verifyInput() says: tonb is:\t\t" << tonb.toString("hh:mm")<< " - Valid?\t" << tonbValid;
+
+    picValid = (pic.toInt() > 0); // pic should be a pilot_id retreived from the database
+    qDebug() << "NewFlight::verifyInput() says: pic is pilotd_id:\t" << pic << " - Valid?\t" << picValid;
+    if(!picValid)
+    {
+        QMessageBox msgBox(this);
+        msgBox.setText("You cannot log a flight without a valid pilot");
+        msgBox.exec();
+    }
+
+    acftValid = (acft.toInt() > 0);
+    qDebug() << "NewFlight::verifyInput() says: acft is tail_id:\t" << acft << " - Valid?\t" << acftValid;
+    if(!acftValid)
+    {
+        QMessageBox msgBox(this);
+        msgBox.setText("You cannot log a flight without a valid aircraft");
+        msgBox.exec();
+    }
+
+
+    tblkValid = checktblk != 0;
+    qDebug() << "NewFlight::verifyInput() says: tblk is:\t\t" << tblk.toString("hh:mm") << " - Valid?\t" << tblkValid;
+
+
+
+    if(deptValid && tofbValid  && destValid && tonbValid
+             && tblkValid && picValid && acftValid)
+    {
+        qDebug() << "====================================================";
+        qDebug() << "NewFlight::verifyInput() says: All checks passed! Very impressive. ";
+        return 1;
+    }else
+    {
+        qDebug() << "====================================================";
+        qDebug() << "NewFlight::verifyInput() says: Flight is invalid.";
+        qDebug() << "NewFlight::verifyInput() says: I will call the cops.";
+        return 0;
+    }
+    return 0;
+
+}
+
+void NewFlight::returnInput(QVector<QString> flight)
+{
+    // Re-populates the input masks with the selected fields if input was erroneous to allow for corrections to be made
+    ui->newDoft->setDate(QDate::fromString(flight[1],Qt::ISODate));
+    ui->newDept->setText(flight[2]);
+    ui->newTofb->setText(flight[3]);
+    ui->newDest->setText(flight[4]);
+    ui->newTonb->setText(flight[5]);
+    // flight[6] is blocktime
+    ui->newPic->setText(db::RetreivePilotNameFromID(flight[7]));
+    ui->newAcft->setText(db::RetreiveRegistration(flight[8]));
+}
+
+void NewFlight::storeSettings()
+{
+    qDebug() << "Storing Settings...";
+    db::storesetting(100, ui->FunctionComboBox->currentText());
+    db::storesetting(101, ui->ApproachComboBox->currentText());
+    db::storesetting(102, QString::number(ui->PilotFlyingCheckBox->isChecked()));
+    db::storesetting(103, QString::number(ui->PilotMonitoringCheckBox->isChecked()));
+    db::storesetting(104, QString::number(ui->TakeoffSpinBox->value()));
+    db::storesetting(105, QString::number(ui->TakeoffCheckBox->isChecked()));
+    db::storesetting(106, QString::number(ui->LandingSpinBox->value()));
+    db::storesetting(107, QString::number(ui->LandingCheckBox->isChecked()));
+    db::storesetting(108, QString::number(ui->AutolandSpinBox->value()));
+    db::storesetting(109, QString::number(ui->AutolandCheckBox->isChecked()));
+    db::storesetting(110, QString::number(ui->IfrCheckBox->isChecked()));
+    db::storesetting(111, QString::number(ui->VfrCheckBox->isChecked()));
+    db::storesetting(112, QString::number(ui->autoNightCheckBox->isChecked()));
+}
+void NewFlight::restoreSettings()
+{
+    qDebug() << "Restoring Settings...";
+    ui->FunctionComboBox->setCurrentText(db::retreiveSetting("100")[1]);
+    ui->ApproachComboBox->setCurrentText(db::retreiveSetting("101")[1]);
+    ui->PilotFlyingCheckBox->setChecked(db::retreiveSetting("102")[1].toInt());
+    ui->PilotMonitoringCheckBox->setChecked(db::retreiveSetting("103")[1].toInt());
+    ui->TakeoffSpinBox->setValue(db::retreiveSetting("104")[1].toInt());
+    ui->TakeoffCheckBox->setChecked(db::retreiveSetting("105")[1].toInt());
+    ui->LandingSpinBox->setValue(db::retreiveSetting("106")[1].toInt());
+    ui->LandingCheckBox->setChecked(db::retreiveSetting("107")[1].toInt());
+    ui->AutolandSpinBox->setValue(db::retreiveSetting("108")[1].toInt());
+    ui->AutolandCheckBox->setChecked(db::retreiveSetting("109")[1].toInt());
+    ui->IfrCheckBox->setChecked(db::retreiveSetting("110")[1].toInt());
+    ui->VfrCheckBox->setChecked(db::retreiveSetting("111")[1].toInt());
+    ui->autoNightCheckBox->setChecked(db::retreiveSetting("112")[1].toInt());
+    //qDebug() << "restore Settings ifr to int: " << db::retreiveSetting("110")[1].toInt();
+
+/*
+ *
+ * QString PilotFunction;
+QString PilotTask;
+QString TakeOff;
+QString Landing;
+QString Autoland;
+QString ApproachType;
+100	PIC	NewFlight::FunctionComboBox
+101	ILS CAT I	NewFlight::ApproachComboBox
+102	Qt::Checked	NewFlight::PilotFlyingCheckBox
+103	Qt::Unchecked	NewFlight::PilotMonitoringCheckBox
+104	1	NewFlight::TakeoffSpinBox
+105	Qt::Checked	NewFlight::TakeoffCheckBox
+106	1	NewFlight::LandingSpinBox
+107	Qt::Checked	NewFlight::LandingCheckBox
+108	0	NewFlight::AutolandSpinBox
+109	Qt::Unchecked	NewFlight::AutolandCheckBox
+110	Qt::Checked	NewFlight::IfrCheckBox
+111	Qt::Unchecked	NewFlight::VfrCheckBox
+*/
+}
+/*
+ * Slots
+ */
+
+
+
+void NewFlight::on_deptTZ_currentTextChanged(const QString &arg1)
+{
+    if(arg1 == "Local"){nope();}
+    ui->deptTZ->setCurrentIndex(0);
+}
+
+void NewFlight::on_destTZ_currentIndexChanged(const QString &arg1)
+{
+    if(arg1 == "Local"){nope();}
+    ui->destTZ->setCurrentIndex(0);
+}
+
+
+void NewFlight::on_newDept_textEdited(const QString &arg1)
+{
+    ui->newDept->setText(arg1.toUpper());
+    if(arg1.length()>2)
+    {
+        QStringList deptList = db::CompleteIcaoOrIata(arg1);
+        qDebug() << "deptList = " << deptList;
+        QCompleter *deptCompleter = new QCompleter(deptList, this);
+        deptCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+        deptCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
+        ui->newDept->setCompleter(deptCompleter);
+    }
+}
+
+void NewFlight::on_newDept_editingFinished()
+{
+    if(ui->newDept->text().length()<3)
+    {
+        QMessageBox msgBox(this);
+        msgBox.setText("Please enter a 3- or 4-letter code.");
+        msgBox.exec();
+        ui->newDept->setText("");
+        ui->newDept->setFocus();
+    }
+
+    QStringList deptList;
+
+    if(ui->newDept->text().length()>1)
+    {
+        QStringList deptList = db::CompleteIcaoOrIata(ui->newDept->text());
+        if(deptList.length() != 0)
+        {
+            dept = deptList.first();
+            ui->newDept->setText(dept);
+
+        }else
+        {
+            QMessageBox msgBox(this);
+            msgBox.setText("No Airport with that name found.");
+            msgBox.exec();
+            ui->newDept->setText("");
+            ui->newDept->setFocus();
+        }
+    }
+
+
+
+}
+
+void NewFlight::on_newDest_textEdited(const QString &arg1)
+{
+    ui->newDest->setText(arg1.toUpper());
+    if(arg1.length()>2)
+    {
+        QStringList destList = db::CompleteIcaoOrIata(arg1);
+        QCompleter *destCompleter = new QCompleter(destList, this);
+        destCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+        destCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
+        ui->newDest->setCompleter(destCompleter);
+    }
+
+}
+
+void NewFlight::on_newDest_editingFinished()
+{
+    if(ui->newDest->text().length()<3)
+    {
+        QMessageBox msgBox(this);
+        msgBox.setText("Please enter a 3- or 4-letter code.");
+        msgBox.exec();
+        ui->newDest->setText("");
+        ui->newDest->setFocus();
+    }
+    QStringList destList;
+    if(ui->newDest->text().length()>1)
+    {
+        QStringList destList = db::CompleteIcaoOrIata(ui->newDest->text());
+        if(destList.length() != 0)
+        {
+            dest = destList.first();
+            ui->newDest->setText(dest);
+        }else
+        {
+            QMessageBox msgBox(this);
+            msgBox.setText("No Airport with that name found.");
+            msgBox.exec();
+            ui->newDest->setText("");
+            ui->newDest->setFocus();
+        }
+    }
+}
+
+
+void NewFlight::on_newDoft_editingFinished()
+{
+    date = ui->newDoft->date();
+    doft = date.toString(Qt::ISODate);
+}
+
+void NewFlight::on_newTofb_editingFinished()
+{
+    ui->newTofb->setText(validateTimeInput(ui->newTofb->text()));
+    tofb = QTime::fromString(ui->newTofb->text(),"hh:mm");
+    qDebug() << "New Time Off Blocks: " << tofb;
+}
+
+void NewFlight::on_newTonb_editingFinished()
+{
+    ui->newTonb->setText(validateTimeInput(ui->newTonb->text()));
+    tonb = QTime::fromString(ui->newTonb->text(),"hh:mm");
+    qDebug() << "New Time On Blocks: " << tonb;
+}
+
+
+void NewFlight::on_newAcft_textEdited(const QString &arg1)
+{
+    if(arg1.length()>1)
+    {
+        QStringList acftList = db::newAcftGetString(arg1);
+        QCompleter *acftCompleter = new QCompleter(acftList, this);
+        acftCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+        acftCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
+        ui->newAcft->setCompleter(acftCompleter);
+     }
+}
+
+void NewFlight::on_newAcft_editingFinished()
+{
+    acft = "-1";// set invalid
+
+    if(ui->newAcft->text().contains(" "))// is input from QCompleter
+    {
+        QStringList input = ui->newAcft->text().split(" ");
+        QString registration = input[0].trimmed();
+        QStringList result = db::newAcftGetString(registration);
+        if(result.length() > 0)
+        {
+            ui->newAcft->setText(result[0]);
+            acft = db::newAcftGetId(registration);
+        }else
+        {
+            acft = "-1";
+        }
+    }else // is input from user
+    {
+        QString input = ui->newAcft->text();
+        QStringList result = db::newAcftGetString(input);
+        if(result.length() > 0)
+        {
+            ui->newAcft->setText(result[0]);
+
+            QStringList input = ui->newAcft->text().split(" ");
+            QString registration = input[0].trimmed();
+            acft = db::newAcftGetId(registration);
+        }else
+        {
+            acft = "-1";
+        }
+    }
+
+
+    if(acft == "-1")
+    {
+        QMessageBox::StandardButton reply;
+        reply = QMessageBox::question(this, "No aircraft found", "No aircraft found.\n Would you like to add a new aircraft to the database?",
+                                      QMessageBox::Yes|QMessageBox::No);
+        if (reply == QMessageBox::Yes) {
+            NewAcft na(this);
+            na.exec();
+            ui->newAcft->setText("");
+            ui->newAcft->setFocus();
+        }
+
+    }
+
+    qDebug() << "Editing finished. Acft: " << acft;
+}
+
+
+void NewFlight::on_newPic_textEdited(const QString &arg1)
+{
+    if(arg1.length()>2)
+    {
+        QStringList picList = db::newPicGetString(arg1);
+        QCompleter *picCompleter = new QCompleter(picList, this);
+        picCompleter->setCaseSensitivity(Qt::CaseInsensitive);
+        picCompleter->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
+        ui->newPic->setCompleter(picCompleter);
+     }
+}
+void NewFlight::on_newPic_editingFinished()
+{
+    pic = "-1"; // set invalid
+    if(ui->newPic->text() == "self")
+    {
+        pic = "1";
+    }else
+    {
+        QString picname;
+        QStringList picList = db::newPicGetString(ui->newPic->text());
+        qDebug() << picList;
+        if(picList.length()!= 0)
+        {
+            picname = picList[0];
+            ui->newPic->setText(picname);
+            pic = db::newPicGetId(picname);
+        }else
+        {
+            QMessageBox::StandardButton reply;
+            reply = QMessageBox::question(this, "No Pilot found", "No pilot found.\n Would you like to add a new pilot to the database?",
+                                          QMessageBox::Yes|QMessageBox::No);
+            if (reply == QMessageBox::Yes)
+            {
+                qDebug() << "Add new pilot selected";
+                nope();
+            }
+        }
+    }
+
+}
+
+
+
+
+/*
+ * Extras
+ */
+
+void NewFlight::on_PilotFlyingCheckBox_stateChanged(int)//0, unchecked, 2 checked
+{
+    if(ui->PilotFlyingCheckBox->isChecked()){
+        ui->TakeoffSpinBox->setValue(1);
+        ui->TakeoffCheckBox->setCheckState(Qt::Checked);
+        ui->LandingSpinBox->setValue(1);
+        ui->LandingCheckBox->setCheckState(Qt::Checked);
+
+    }else if(!ui->PilotFlyingCheckBox->isChecked()){
+        ui->TakeoffSpinBox->setValue(0);
+        ui->TakeoffCheckBox->setCheckState(Qt::Unchecked);
+        ui->LandingSpinBox->setValue(0);
+        ui->LandingCheckBox->setCheckState(Qt::Unchecked);
+    }
+}
+
+
+
+void NewFlight::on_setAsDefaultButton_clicked()
+{
+    storeSettings();
+}
+
+void NewFlight::on_restoreDefaultButton_clicked()
+{
+    restoreSettings();
+}
+
+
+void NewFlight::on_buttonBox_accepted()
+{
+    on_newDoft_editingFinished();// - activate slots in case user has been active in last input before clicking submit
+    on_newTonb_editingFinished();
+    on_newTofb_editingFinished();
+    on_newDept_editingFinished();
+    on_newDest_editingFinished();
+    on_newAcft_editingFinished();
+    on_newPic_editingFinished();
+
+
+
+        QVector<QString> flight;
+        flight = collectInput();
+        if(verifyInput())
+        {
+            db::CommitFlight(flight);
+            qDebug() << flight << "Has been commited.";
+            QMessageBox msgBox(this);
+            msgBox.setText("Flight has been commited.");
+            msgBox.exec();
+        }else
+        {
+            qDebug() << "Invalid Input. No entry has been made in the database.";
+            db::CommitToScratchpad(flight);
+            QMessageBox msgBox(this);
+            msgBox.setText("Invalid entries detected. Please check your input.");
+            msgBox.exec();
+            NewFlight nf(this);
+            nf.exec();
+        }
+
+
+}
+
+void NewFlight::on_buttonBox_rejected()
+{
+    qDebug() << "NewFlight: Rejected\n";
+}
+
+
+void NewFlight::on_ApproachComboBox_currentTextChanged(const QString &arg1)
+{
+    if(arg1 == "ILS CAT III"){
+        ui->AutolandCheckBox->setCheckState(Qt::Checked);
+        ui->AutolandSpinBox->setValue(1);
+    }else{
+        ui->AutolandCheckBox->setCheckState(Qt::Unchecked);
+        ui->AutolandSpinBox->setValue(0);
+    }
+    ApproachType = arg1;
+    qDebug() << "Approach Type: " << ApproachType;
+}
+
+/*
+ * Times
+ */
+
+
+void NewFlight::on_nightTimeLineEdit_editingFinished()
+{
+    ui->nightTimeLineEdit->setText(validateTimeInput(ui->nightTimeLineEdit->text()));
+}

+ 108 - 0
newflight.h

@@ -0,0 +1,108 @@
+/*
+ *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 NEWFLIGHT_H
+#define NEWFLIGHT_H
+
+#include <QDialog>
+
+namespace Ui {
+class NewFlight;
+}
+
+class NewFlight : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit NewFlight(QWidget *parent = nullptr);
+    ~NewFlight();
+
+private slots:
+    void nope();//error box
+
+    QString validateTimeInput(QString userinput);
+
+    QVector<QString> collectInput();
+
+    void fillExtrasLineEdits();
+
+    void storeSettings();
+
+    void restoreSettings();
+
+    bool verifyInput();
+
+    void returnInput(QVector<QString> flight);
+
+    void on_deptTZ_currentTextChanged(const QString &arg1);
+
+    void on_destTZ_currentIndexChanged(const QString &arg1);
+
+    void on_newDept_textEdited(const QString &arg1);
+
+    void on_newDept_editingFinished();
+
+    void on_newDest_textEdited(const QString &arg1);
+
+    void on_newDest_editingFinished();
+
+    void on_newDoft_editingFinished();
+
+    void on_newTofb_editingFinished();
+
+    void on_newTonb_editingFinished();
+
+    void on_newAcft_textEdited(const QString &arg1);
+
+    void on_newAcft_editingFinished();
+
+    void on_newPic_textEdited(const QString &arg1);
+
+    void on_newPic_editingFinished();
+
+    void on_verifyButton_clicked();
+
+
+
+
+
+
+    void on_setAsDefaultButton_clicked();
+
+    void on_restoreDefaultButton_clicked();
+
+
+    void on_buttonBox_accepted();
+
+    void on_buttonBox_rejected();
+
+
+
+    void on_PilotFlyingCheckBox_stateChanged(int);
+
+    void on_ApproachComboBox_currentTextChanged(const QString &arg1);
+
+
+
+    void on_nightTimeLineEdit_editingFinished();
+
+private:
+    Ui::NewFlight *ui;
+};
+
+#endif // NEWFLIGHT_H

+ 867 - 0
newflight.ui

@@ -0,0 +1,867 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NewFlight</class>
+ <widget class="QDialog" name="NewFlight">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1287</width>
+    <height>720</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>New Flight</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout_4">
+   <item row="0" column="0" colspan="2">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>Flight Data</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="3" rowspan="7" colspan="2">
+    <widget class="Line" name="line_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="5">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>Auto-Logging</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="7" rowspan="7" colspan="2">
+    <widget class="Line" name="line_3">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="9" colspan="3">
+    <widget class="QLabel" name="label_4">
+     <property name="text">
+      <string>Times</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" rowspan="3" colspan="2">
+    <layout class="QGridLayout" name="gridLayout_3">
+     <item row="0" column="0">
+      <widget class="QLabel" name="doftLabel">
+       <property name="text">
+        <string>Date of Flight</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="2">
+      <widget class="QDateEdit" name="newDoft">
+       <property name="dateTime">
+        <datetime>
+         <hour>23</hour>
+         <minute>0</minute>
+         <second>0</second>
+         <year>2019</year>
+         <month>12</month>
+         <day>16</day>
+        </datetime>
+       </property>
+       <property name="displayFormat">
+        <string>yyyy/MM/dd</string>
+       </property>
+       <property name="calendarPopup">
+        <bool>true</bool>
+       </property>
+       <property name="timeSpec">
+        <enum>Qt::UTC</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="deptLabel">
+       <property name="text">
+        <string>Departure</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QLabel" name="placeLabel1">
+       <property name="text">
+        <string>Place</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="2">
+      <widget class="QLineEdit" name="newDept">
+       <property name="toolTip">
+        <string>Enter the ICAO 4-letter Identifier of the Airport</string>
+       </property>
+       <property name="inputMethodHints">
+        <set>Qt::ImhNone</set>
+       </property>
+       <property name="maxLength">
+        <number>4</number>
+       </property>
+       <property name="placeholderText">
+        <string>KJFK</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="0">
+      <widget class="QComboBox" name="deptTZ">
+       <item>
+        <property name="text">
+         <string>UTC</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Local</string>
+        </property>
+       </item>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QLabel" name="tofbLabel">
+       <property name="text">
+        <string>Time</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="2">
+      <widget class="QLineEdit" name="newTofb">
+       <property name="maxLength">
+        <number>5</number>
+       </property>
+       <property name="placeholderText">
+        <string>00:00</string>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="0">
+      <widget class="QLabel" name="destLabel">
+       <property name="text">
+        <string>Destination</string>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="1">
+      <widget class="QLabel" name="placeLabel2">
+       <property name="text">
+        <string>Place</string>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="2">
+      <widget class="QLineEdit" name="newDest">
+       <property name="toolTip">
+        <string>Enter the ICAO 4-letter Identifier of the Airport</string>
+       </property>
+       <property name="inputMethodHints">
+        <set>Qt::ImhNone</set>
+       </property>
+       <property name="maxLength">
+        <number>4</number>
+       </property>
+       <property name="placeholderText">
+        <string>EDDF</string>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="0">
+      <widget class="QComboBox" name="destTZ">
+       <item>
+        <property name="text">
+         <string>UTC</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Local</string>
+        </property>
+       </item>
+      </widget>
+     </item>
+     <item row="4" column="1">
+      <widget class="QLabel" name="tonbLabel">
+       <property name="text">
+        <string>Time</string>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="2">
+      <widget class="QLineEdit" name="newTonb">
+       <property name="placeholderText">
+        <string>00:00</string>
+       </property>
+      </widget>
+     </item>
+     <item row="5" column="0">
+      <widget class="QLabel" name="acftLabel">
+       <property name="text">
+        <string>Aircraft</string>
+       </property>
+      </widget>
+     </item>
+     <item row="5" column="2">
+      <widget class="QLineEdit" name="newAcft">
+       <property name="placeholderText">
+        <string>D-LMAO</string>
+       </property>
+      </widget>
+     </item>
+     <item row="6" column="0">
+      <widget class="QLabel" name="picLabel">
+       <property name="text">
+        <string>Name PIC</string>
+       </property>
+      </widget>
+     </item>
+     <item row="6" column="2">
+      <widget class="QLineEdit" name="newPic">
+       <property name="placeholderText">
+        <string>self</string>
+       </property>
+      </widget>
+     </item>
+     <item row="7" column="0">
+      <widget class="QLabel" name="picLabel_2">
+       <property name="text">
+        <string>Second Pilot</string>
+       </property>
+      </widget>
+     </item>
+     <item row="7" column="2">
+      <widget class="QLineEdit" name="secondPilotLineEdit">
+       <property name="text">
+        <string/>
+       </property>
+       <property name="placeholderText">
+        <string>optional</string>
+       </property>
+      </widget>
+     </item>
+     <item row="8" column="0">
+      <widget class="QLabel" name="thirdPilotLabel">
+       <property name="text">
+        <string>Third Pilot</string>
+       </property>
+      </widget>
+     </item>
+     <item row="8" column="2">
+      <widget class="QLineEdit" name="thirdPilotLineEdit">
+       <property name="placeholderText">
+        <string>optional</string>
+       </property>
+      </widget>
+     </item>
+     <item row="9" column="0">
+      <widget class="QLabel" name="FlightNumberLabel">
+       <property name="text">
+        <string>Flight number</string>
+       </property>
+      </widget>
+     </item>
+     <item row="9" column="2">
+      <widget class="QLineEdit" name="FlightNumberLineEdit">
+       <property name="placeholderText">
+        <string>optional</string>
+       </property>
+      </widget>
+     </item>
+     <item row="10" column="0">
+      <widget class="QLabel" name="RemarksLabel">
+       <property name="text">
+        <string>Remarks</string>
+       </property>
+      </widget>
+     </item>
+     <item row="10" column="2">
+      <widget class="QLineEdit" name="RemarksLineEdit">
+       <property name="placeholderText">
+        <string>optional</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="5" rowspan="2">
+    <layout class="QGridLayout" name="gridLayout">
+     <item row="0" column="0">
+      <widget class="QLabel" name="FunctionLabel">
+       <property name="text">
+        <string>Function</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QComboBox" name="FunctionComboBox">
+       <item>
+        <property name="text">
+         <string>PIC</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Co-Pilot</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Dual</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Instructor</string>
+        </property>
+       </item>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Approach </string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QComboBox" name="ApproachComboBox">
+       <property name="currentText">
+        <string>ILS CAT I</string>
+       </property>
+       <item>
+        <property name="text">
+         <string>ILS CAT I</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>ILS CAT II</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>ILS CAT III</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>Visual</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>RNAV</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>RNAV (RNP)</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>RNAV (RNP AR)</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>VOR</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>NDB</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>LOC</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>GLS</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>MLS</string>
+        </property>
+       </item>
+       <item>
+        <property name="text">
+         <string>SRA</string>
+        </property>
+       </item>
+      </widget>
+     </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="TaskLabel">
+       <property name="text">
+        <string>Task</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QCheckBox" name="PilotFlyingCheckBox">
+       <property name="toolTip">
+        <string>Assumes T/O and LDG performed. If not, edit details.</string>
+       </property>
+       <property name="text">
+        <string>PF</string>
+       </property>
+       <property name="checked">
+        <bool>true</bool>
+       </property>
+       <property name="autoExclusive">
+        <bool>false</bool>
+       </property>
+       <property name="tristate">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="1">
+      <widget class="QCheckBox" name="PilotMonitoringCheckBox">
+       <property name="text">
+        <string>PM</string>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="0">
+      <widget class="QSpinBox" name="TakeoffSpinBox">
+       <property name="value">
+        <number>1</number>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="1">
+      <widget class="QCheckBox" name="TakeoffCheckBox">
+       <property name="toolTip">
+        <string/>
+       </property>
+       <property name="text">
+        <string>Take Off</string>
+       </property>
+       <property name="checked">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item row="5" column="0">
+      <widget class="QSpinBox" name="LandingSpinBox">
+       <property name="value">
+        <number>1</number>
+       </property>
+      </widget>
+     </item>
+     <item row="5" column="1">
+      <widget class="QCheckBox" name="LandingCheckBox">
+       <property name="text">
+        <string>Landing</string>
+       </property>
+       <property name="checked">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item row="6" column="0">
+      <widget class="QSpinBox" name="AutolandSpinBox"/>
+     </item>
+     <item row="6" column="1">
+      <widget class="QCheckBox" name="AutolandCheckBox">
+       <property name="text">
+        <string>Autoland</string>
+       </property>
+      </widget>
+     </item>
+     <item row="7" column="0">
+      <widget class="QLabel" name="RulesLabel">
+       <property name="text">
+        <string>Rules</string>
+       </property>
+      </widget>
+     </item>
+     <item row="7" column="1">
+      <widget class="QCheckBox" name="IfrCheckBox">
+       <property name="toolTip">
+        <string/>
+       </property>
+       <property name="text">
+        <string>IFR</string>
+       </property>
+       <property name="checked">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+     <item row="8" column="1">
+      <widget class="QCheckBox" name="VfrCheckBox">
+       <property name="text">
+        <string>VFR</string>
+       </property>
+      </widget>
+     </item>
+     <item row="9" column="0">
+      <widget class="QLabel" name="autoNightLabel">
+       <property name="text">
+        <string>Auto</string>
+       </property>
+      </widget>
+     </item>
+     <item row="9" column="1">
+      <widget class="QCheckBox" name="autoNightCheckBox">
+       <property name="toolTip">
+        <string>Enable or disable automatic logging of night time</string>
+       </property>
+       <property name="text">
+        <string>Night</string>
+       </property>
+       <property name="checked">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="10" rowspan="3">
+    <layout class="QGridLayout" name="gridLayout_2">
+     <item row="0" column="0">
+      <widget class="QLabel" name="spse_Label">
+       <property name="text">
+        <string>SP SE</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QLineEdit" name="spseTimeLineEdit"/>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="spmeLabel">
+       <property name="text">
+        <string>SP ME</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QLineEdit" name="spmeTimeLineEdit"/>
+     </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="mpLabel">
+       <property name="text">
+        <string>MP</string>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QLineEdit" name="mpTimeLineEdit"/>
+     </item>
+     <item row="3" column="0">
+      <widget class="QLabel" name="totalTimeLabel">
+       <property name="text">
+        <string>TOTAL</string>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="1">
+      <widget class="QLineEdit" name="totalTimeLineEdit"/>
+     </item>
+     <item row="4" column="0">
+      <widget class="QLabel" name="ifrLabel">
+       <property name="text">
+        <string>IFR</string>
+       </property>
+      </widget>
+     </item>
+     <item row="4" column="1">
+      <widget class="QLineEdit" name="ifrTimeLineEdit"/>
+     </item>
+     <item row="5" column="0">
+      <widget class="QLabel" name="vfrLabel">
+       <property name="text">
+        <string>VFR</string>
+       </property>
+      </widget>
+     </item>
+     <item row="5" column="1">
+      <widget class="QLineEdit" name="vfrTimeLineEdit"/>
+     </item>
+     <item row="6" column="0">
+      <widget class="QLabel" name="nightLabel">
+       <property name="text">
+        <string>Night</string>
+       </property>
+      </widget>
+     </item>
+     <item row="6" column="1">
+      <widget class="QLineEdit" name="nightTimeLineEdit"/>
+     </item>
+     <item row="7" column="0">
+      <widget class="QLabel" name="xcLabel">
+       <property name="text">
+        <string>XC</string>
+       </property>
+      </widget>
+     </item>
+     <item row="7" column="1">
+      <widget class="QLineEdit" name="xcTimeLineEdit"/>
+     </item>
+     <item row="8" column="0">
+      <widget class="QLabel" name="picTimeLabel">
+       <property name="text">
+        <string>PIC</string>
+       </property>
+      </widget>
+     </item>
+     <item row="8" column="1">
+      <widget class="QLineEdit" name="picTimeLineEdit"/>
+     </item>
+     <item row="9" column="0">
+      <widget class="QLabel" name="coPilotTimeLabel">
+       <property name="text">
+        <string>Co-Pilot</string>
+       </property>
+      </widget>
+     </item>
+     <item row="9" column="1">
+      <widget class="QLineEdit" name="copTimeLineEdit"/>
+     </item>
+     <item row="10" column="0">
+      <widget class="QLabel" name="dualTimeLabel">
+       <property name="text">
+        <string>Dual</string>
+       </property>
+      </widget>
+     </item>
+     <item row="10" column="1">
+      <widget class="QLineEdit" name="dualTimeLineEdit"/>
+     </item>
+     <item row="11" column="0">
+      <widget class="QLabel" name="fiTimeLabel">
+       <property name="text">
+        <string>FI</string>
+       </property>
+      </widget>
+     </item>
+     <item row="11" column="1">
+      <widget class="QLineEdit" name="fiTimeLineEdit"/>
+     </item>
+     <item row="12" column="0">
+      <widget class="QLabel" name="simTimeLabel">
+       <property name="text">
+        <string>SIM</string>
+       </property>
+      </widget>
+     </item>
+     <item row="12" column="1">
+      <widget class="QLineEdit" name="simTimeLineEdit"/>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="11">
+    <spacer name="horizontalSpacer_5">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>73</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="6">
+    <spacer name="horizontalSpacer_6">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>96</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="8" colspan="2">
+    <spacer name="horizontalSpacer_7">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>95</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="3" column="2">
+    <spacer name="horizontalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>41</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="3" column="4">
+    <spacer name="horizontalSpacer">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>40</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="4" column="5">
+    <widget class="QPushButton" name="setAsDefaultButton">
+     <property name="toolTip">
+      <string>Set current selection as default</string>
+     </property>
+     <property name="text">
+      <string>Set As Default</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="5">
+    <widget class="QPushButton" name="restoreDefaultButton">
+     <property name="toolTip">
+      <string>Restore previously stored default selection</string>
+     </property>
+     <property name="text">
+      <string>Restore Default</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="0">
+    <widget class="QPushButton" name="verifyButton">
+     <property name="text">
+      <string>DebugButton</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="1">
+    <widget class="QLineEdit" name="verifyEdit">
+     <property name="placeholderText">
+      <string>Debug Text</string>
+     </property>
+    </widget>
+   </item>
+   <item row="6" column="10" colspan="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>newDoft</tabstop>
+  <tabstop>newDept</tabstop>
+  <tabstop>newTofb</tabstop>
+  <tabstop>newDest</tabstop>
+  <tabstop>newTonb</tabstop>
+  <tabstop>newAcft</tabstop>
+  <tabstop>newPic</tabstop>
+  <tabstop>secondPilotLineEdit</tabstop>
+  <tabstop>thirdPilotLineEdit</tabstop>
+  <tabstop>FlightNumberLineEdit</tabstop>
+  <tabstop>RemarksLineEdit</tabstop>
+  <tabstop>FunctionComboBox</tabstop>
+  <tabstop>ApproachComboBox</tabstop>
+  <tabstop>PilotFlyingCheckBox</tabstop>
+  <tabstop>PilotMonitoringCheckBox</tabstop>
+  <tabstop>TakeoffSpinBox</tabstop>
+  <tabstop>TakeoffCheckBox</tabstop>
+  <tabstop>LandingSpinBox</tabstop>
+  <tabstop>LandingCheckBox</tabstop>
+  <tabstop>AutolandSpinBox</tabstop>
+  <tabstop>AutolandCheckBox</tabstop>
+  <tabstop>IfrCheckBox</tabstop>
+  <tabstop>VfrCheckBox</tabstop>
+  <tabstop>autoNightCheckBox</tabstop>
+  <tabstop>setAsDefaultButton</tabstop>
+  <tabstop>restoreDefaultButton</tabstop>
+  <tabstop>spseTimeLineEdit</tabstop>
+  <tabstop>spmeTimeLineEdit</tabstop>
+  <tabstop>mpTimeLineEdit</tabstop>
+  <tabstop>totalTimeLineEdit</tabstop>
+  <tabstop>ifrTimeLineEdit</tabstop>
+  <tabstop>vfrTimeLineEdit</tabstop>
+  <tabstop>nightTimeLineEdit</tabstop>
+  <tabstop>xcTimeLineEdit</tabstop>
+  <tabstop>picTimeLineEdit</tabstop>
+  <tabstop>copTimeLineEdit</tabstop>
+  <tabstop>dualTimeLineEdit</tabstop>
+  <tabstop>fiTimeLineEdit</tabstop>
+  <tabstop>simTimeLineEdit</tabstop>
+  <tabstop>destTZ</tabstop>
+  <tabstop>verifyButton</tabstop>
+  <tabstop>verifyEdit</tabstop>
+  <tabstop>deptTZ</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>NewFlight</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>NewFlight</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

+ 56 - 0
openLog.pro

@@ -0,0 +1,56 @@
+QT       += core gui sql
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+CONFIG += c++11
+
+TARGET = openLog
+
+RESOURCES = themes/breeze.qrc
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+    calc.cpp \
+    dbman.cpp \
+    easaview.cpp \
+    editflight.cpp \
+    main.cpp \
+    mainwindow.cpp \
+    newacft.cpp \
+    newflight.cpp \
+    showaircraftlist.cpp \
+
+HEADERS += \
+    calc.h \
+    easaview.h \
+    editflight.h \
+    mainwindow.h \
+    newacft.h \
+    newflight.h \
+    showaircraftlist.h \
+
+FORMS += \
+    easaview.ui \
+    editflight.ui \
+    mainwindow.ui \
+    newacft.ui \
+    newflight.ui \
+    showaircraftlist.ui \
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+DISTFILES += \
+    Scratchpad

+ 57 - 0
showaircraftlist.cpp

@@ -0,0 +1,57 @@
+/*
+ *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 "dbman.cpp"
+#include "showaircraftlist.h"
+#include "ui_showaircraftlist.h"
+#include <QStringListModel>
+#include <QDebug>
+#include <QMessageBox>
+#include <QSqlQueryModel>
+#include <QSqlTableModel>
+
+ShowAircraftList::ShowAircraftList(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::ShowAircraftList)
+{
+    ui->setupUi(this);
+
+    QSqlTableModel *model = new QSqlTableModel;
+    model->setTable("ViewAircraftList");
+    model->select();
+
+
+    QTableView *view = ui->tableView;
+    view->setModel(model);
+    view->setSelectionBehavior(QAbstractItemView::SelectRows);
+    view->setSelectionMode(QAbstractItemView::SingleSelection);
+    view->setEditTriggers(QAbstractItemView::NoEditTriggers);
+    view->verticalHeader()->hide();
+    view->setAlternatingRowColors(true);
+    //view->hideColumn(0); // don't show the ID
+    view->show();
+}
+
+ShowAircraftList::~ShowAircraftList()
+{
+    delete ui;
+}
+
+void ShowAircraftList::on_closeButton_clicked()
+{
+    QDialog::close();
+}

+ 42 - 0
showaircraftlist.h

@@ -0,0 +1,42 @@
+/*
+ *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 SHOWAIRCRAFTLIST_H
+#define SHOWAIRCRAFTLIST_H
+
+#include <QDialog>
+
+namespace Ui {
+class ShowAircraftList;
+}
+
+class ShowAircraftList : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit ShowAircraftList(QWidget *parent = nullptr);
+    ~ShowAircraftList();
+
+private slots:
+    void on_closeButton_clicked();
+
+private:
+    Ui::ShowAircraftList *ui;
+};
+
+#endif // SHOWAIRCRAFTLIST_H

+ 31 - 0
showaircraftlist.ui

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ShowAircraftList</class>
+ <widget class="QDialog" name="ShowAircraftList">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>343</width>
+    <height>387</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QTableView" name="tableView"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QPushButton" name="closeButton">
+     <property name="text">
+      <string>Close</string>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>