123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- /*
- *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();
- }
|