Browse Source

Mandatory Line Edits working

Completers and Validators on mandatory line edits implemented.
Bit Map for mandatory line edits implemented and working as well.
Felix Turo 4 years ago
parent
commit
58cd092aeb

+ 13 - 12
src/experimental/adatabase.cpp

@@ -97,7 +97,7 @@ bool ADataBase::remove(AEntry entry)
     if (query.lastError().type() == QSqlError::NoError)
     {
         DEB("Entry " << entry.getPosition().tableName << entry.getPosition().rowId << " removed.");
-        emit sqlSuccessful();
+        emit deleteSuccessful();
         return true;
     } else {
         DEB("Unable to delete.");
@@ -134,7 +134,7 @@ bool ADataBase::removeMany(QList<DataPosition> data_position_list)
         query.prepare("COMMIT");
         query.exec();
         if(query.lastError().type() == QSqlError::NoError) {
-            emit sqlSuccessful();
+            emit deleteSuccessful();
             return true;
         } else {
             emit sqlError(query.lastError(), "Transaction unsuccessful. Error count: " + QString::number(errorCount));
@@ -225,7 +225,7 @@ bool ADataBase::update(AEntry updated_entry)
     if (query.lastError().type() == QSqlError::NoError)
     {
         DEB("Entry successfully committed.");
-        emit sqlSuccessful();
+        emit commitSuccessful();
         return true;
     } else {
         DEB("Unable to commit.");
@@ -263,7 +263,7 @@ bool ADataBase::insert(AEntry new_entry)
     if (query.lastError().type() == QSqlError::NoError)
     {
         DEB("Entry successfully committed.");
-        emit sqlSuccessful();
+        emit commitSuccessful();
         return true;
     } else {
         DEB("Unable to commit.");
@@ -369,14 +369,14 @@ const QStringList ADataBase::getCompletionList(ADataBase::DatabaseTarget target)
 
     switch (target) {
     case pilots:
-        statement.append("SELECT piclastname||\",\"||picfirstname FROM 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 airport_identifier:
+    case airport_identifier_all:
         statement.append("SELECT icao FROM airports UNION SELECT iata FROM airports");
         break;
     case registrations:
@@ -415,17 +415,18 @@ const QMap<QString, int> ADataBase::getIdMap(ADataBase::DatabaseTarget target)
 
     switch (target) {
     case pilots:
-        statement.append("SELECT ROWID, piclastname||\",\"||picfirstname FROM pilots");
+        statement.append("SELECT ROWID, piclastname||\", \"||picfirstname FROM pilots");
         break;
     case aircraft:
         statement.append("SELECT ROWID, make||\" \"||model FROM aircraft WHERE model IS NOT NULL "
                          "UNION "
                          "SELECT ROWID, make||\" \"||model||\"-\"||variant FROM aircraft WHERE variant IS NOT NULL");
         break;
-    case airport_identifier:
-        statement.append("SELECT ROWID, icao FROM airports "
-                         "UNION "
-                         "SELECT ROWID, iata FROM airports WHERE iata IS NOT NULL");
+    case airport_identifier_icao:
+        statement.append("SELECT ROWID, icao FROM airports");
+        break;
+    case airport_identifier_iata:
+        statement.append("SELECT ROWID, iata FROM airports WHERE iata NOT NULL");
         break;
     case airport_names:
         statement.append("SELECT ROWID, name FROM airports");
@@ -475,7 +476,7 @@ QVector<QString> ADataBase::customQuery(QString statement, int return_values)
                 result.append(query.value(i).toString());
             }
         }
-        emit sqlSuccessful();
+        emit commitSuccessful();
         return result;
     }
 }

+ 4 - 2
src/experimental/adatabase.h

@@ -56,7 +56,7 @@ public:
      * \brief The CompleterTarget enum provides the items for which QCompleter
      * completion lists are provided from the database.
      */
-    enum DatabaseTarget {airport_identifier, airport_names, pilots, registrations, aircraft, companies, tails};
+    enum DatabaseTarget {airport_identifier_icao, airport_identifier_iata, airport_identifier_all, airport_names, pilots, registrations, aircraft, companies, tails};
 
     /*!
      * \brief Connect to the database and populate database information.
@@ -178,7 +178,9 @@ public:
      */
     const QMap<QString, int> getIdMap(DatabaseTarget);
 signals:
-    void sqlSuccessful();
+    void commitSuccessful();
+
+    void deleteSuccessful();
 
     void sqlError(const QSqlError &sqlError, const QString &sqlStatement);
 

+ 176 - 59
src/experimental/expnewflightdialog.cpp

@@ -5,20 +5,45 @@ using namespace experimental;
 
 static const auto IATA_RX = QLatin1String("[a-zA-Z0-9]{3}");
 static const auto ICAO_RX = QLatin1String("[a-zA-Z0-9]{4}");
-static const auto NAME_RX = QLatin1String("(\\p{L}+('|\\-)?)");//(\\p{L}+(\\s|'|\\-)?\\s?(\\p{L}+)?\\s?)
-static const auto ADD_NAME_RX = QLatin1String("(\\s?(\\p{L}+('|\\-)?))?");
+//static const auto NAME_RX = QLatin1String("(\\p{L}+('|\\-)?)");//(\\p{L}+(\\s|'|\\-)?\\s?(\\p{L}+)?\\s?)
+static const auto NAME_RX = QLatin1String("(\\p{L}+('|\\-|,)?\\p{L}+?)");
+static const auto ADD_NAME_RX = QLatin1String("(\\s?(\\p{L}+('|\\-|,)?\\p{L}+?))?");
+//static const auto ADD_NAME_RX = QLatin1String("(\\s?(\\p{L}+('|\\-)?))?");
 static const auto SELF_RX = QLatin1String("(self|SELF)");
+//static const auto NON_WORD_CHAR = QLatin1String("\\W");
 
 /// Raw Input validation
 static const auto TIME_VALID_RGX       = QRegularExpression("([01]?[0-9]|2[0-3]):?[0-5][0-9]?");// We only want to allow inputs that make sense as a time, e.g. 99:99 is not a valid time
 static const auto LOC_VALID_RGX        = QRegularExpression(IATA_RX + "|" + ICAO_RX);
-static const auto AIRCRAFT_VALID_RGX   = QRegularExpression("[A-Z0-9]+\\-?[A-Z0-9]+");
+static const auto AIRCRAFT_VALID_RGX   = QRegularExpression("\\w+\\-?(\\w+)?");
 static const auto NAME_VALID_RGX = QRegularExpression(SELF_RX + QLatin1Char('|')
-                                                     + NAME_RX + ADD_NAME_RX + ADD_NAME_RX + ADD_NAME_RX + ",?\\s?" // up to 4 first names
-                                                     + NAME_RX + ADD_NAME_RX + ADD_NAME_RX + ADD_NAME_RX );// up to 4 last names
+                                                      + NAME_RX + ADD_NAME_RX + ADD_NAME_RX + ADD_NAME_RX + ",?\\s?" // up to 4 first names
+                                                      + NAME_RX + ADD_NAME_RX + ADD_NAME_RX + ADD_NAME_RX );// up to 4 last names
+//static const auto NAME_VALID_RGX = QRegularExpression("(\\p{L}+('|\\-|,)?\\p{L}+?)");
 static const auto DATE_VALID_RGX       = QRegularExpression("^([1-9][0-9]{3}).?(1[0-2]|0[1-9]).?(3[01]|0[1-9]|[12][0-9])?$");// . allows all seperators, still allows for 2020-02-31, additional verification via QDate::isValid()
 
 
+/// [F] The general idea for this dialog is this:
+/// - line edits have validators and completers.
+/// - mandatory line edits only emit editing finished if their content is
+/// valid. This means mapping user inputs to database keys where required.
+/// - A QBitArray is mainained with the state of the mandatory line edits
+/// - The deducted entries are automatically filled if all mandatory entries
+/// are valid.
+///
+/// if the user presses "OK", check if all mandatory inputs are valid,
+/// check if optional user inputs are valid and commit.
+///
+/// For the completion and mapping, I have settled on a more low-level approach using
+/// Completers based on QStringLists and mapping with QMaps.
+///
+/// I implemented the Completers and mapping based on a QSqlTableModel which would
+/// have been quite nice, since it would keep all data in one place, but as we have
+/// seen before with the more high-level qt classes, they are quite slow on execution.
+/// Mapping a registration to an ID for example took around 300ms, which is very
+/// noticeable in the UI and not an acceptable user experience. Using QStringLists and QMaps
+/// this goes down to around 5ms.
+
 ExpNewFlightDialog::ExpNewFlightDialog(QWidget *parent) :
     QDialog(parent),
     ui(new Ui::ExpNewFlightDialog)
@@ -26,7 +51,7 @@ ExpNewFlightDialog::ExpNewFlightDialog(QWidget *parent) :
     ui->setupUi(this);
     flightEntry = AFlightEntry();
     setupRawInputValidation();
-    setupMandatoryLineEdits();
+    setupLineEditSignalsAndSlots();
 }
 
 ExpNewFlightDialog::ExpNewFlightDialog(int row_id, QWidget *parent) :
@@ -36,7 +61,7 @@ ExpNewFlightDialog::ExpNewFlightDialog(int row_id, QWidget *parent) :
     ui->setupUi(this);
     flightEntry = aDB()->getFlightEntry(row_id);
     setupRawInputValidation();
-    setupMandatoryLineEdits();
+    setupLineEditSignalsAndSlots();
 }
 
 ExpNewFlightDialog::~ExpNewFlightDialog()
@@ -47,23 +72,40 @@ ExpNewFlightDialog::~ExpNewFlightDialog()
 void ExpNewFlightDialog::onGoodInputReceived(QLineEdit *line_edit)
 {
     DEB(line_edit->objectName() << " - Good input received - " << line_edit->text());
-    mandatoryLineEditsGood.setBit(mandatoryLineEdits.indexOf(line_edit), true);
-    DEB("Mandatory Good: " << mandatoryLineEditsGood);
+    if (mandatoryLineEdits.contains(line_edit)) {
+        mandatoryLineEditsGood.setBit(mandatoryLineEdits.indexOf(line_edit), true);
+        DEB("Mandatory Good: " << mandatoryLineEditsGood.count(true) << " out of "
+            << mandatoryLineEditsGood.size() << ". Array: " << mandatoryLineEditsGood);
+    }
 }
 
 void ExpNewFlightDialog::onBadInputReceived(QLineEdit *line_edit)
 {
     DEB(line_edit->objectName() << " - Bad input received - " << line_edit->text());
-    mandatoryLineEditsGood.setBit(mandatoryLineEdits.indexOf(line_edit), false);
-    DEB("Mandatory Good: " << mandatoryLineEditsGood);
+
+    if (mandatoryLineEdits.contains(line_edit)) {
+        mandatoryLineEditsGood.setBit(mandatoryLineEdits.indexOf(line_edit), false);
+        DEB("Mandatory Good: " << mandatoryLineEditsGood.count(true) << " out of "
+            << mandatoryLineEditsGood.size() << ". Array: " << mandatoryLineEditsGood);
+    }
 }
 
 void ExpNewFlightDialog::setupRawInputValidation()
 {
+    /////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
+    ui->doftLineEdit_2->setText(QDate::currentDate().toString(Qt::ISODate)); // deal with date input later...
+    /////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
+    // get Maps
+    pilotsIdMap      = aDB()->getIdMap(ADataBase::pilots);
+    tailsIdMap       = aDB()->getIdMap(ADataBase::tails);
+    airportIcaoIdMap = aDB()->getIdMap(ADataBase::airport_identifier_icao);
+    airportIataIdMap = aDB()->getIdMap(ADataBase::airport_identifier_iata);
+    airportNameIdMap = aDB()->getIdMap(ADataBase::airport_names);
     //get Completer Lists
     pilotList   = aDB()->getCompletionList(ADataBase::pilots);
     tailsList   = aDB()->getCompletionList(ADataBase::registrations);
-    airportList = aDB()->getCompletionList(ADataBase::airport_identifier);
+    airportList = aDB()->getCompletionList(ADataBase::airport_identifier_all);
+    auto tempList = QStringList();
     // define tuples
     const std::tuple<QString, QStringList*, QRegularExpression>
             location_line_edit_settings = {"Loc", &airportList, LOC_VALID_RGX};
@@ -71,12 +113,14 @@ void ExpNewFlightDialog::setupRawInputValidation()
             name_line_edit_settings = {"Name", &pilotList, NAME_VALID_RGX};
     const std::tuple<QString, QStringList*, QRegularExpression>
             acft_line_edit_settings = {"acft", &tailsList, AIRCRAFT_VALID_RGX};
+    const std::tuple<QString, QStringList*, QRegularExpression>
+            time_line_edit_settings = {"Time", &tempList, TIME_VALID_RGX};
     const QList<std::tuple<QString, QStringList*, QRegularExpression>> line_edit_settings = {
         location_line_edit_settings,
         name_line_edit_settings,
-        acft_line_edit_settings
+        acft_line_edit_settings,
+        time_line_edit_settings
     };
-
     //get line edits, set up completers and validators
     auto line_edits = ui->flightDataTab_2->findChildren<QLineEdit*>();
 
@@ -84,30 +128,20 @@ void ExpNewFlightDialog::setupRawInputValidation()
         for (const auto &line_edit : line_edits) {
             if(line_edit->objectName().contains(std::get<0>(item))) {
                 DEB("Setting up: " << line_edit->objectName());
+                // Set Validator
+                auto validator = new QRegularExpressionValidator(std::get<2>(item), line_edit);
+                line_edit->setValidator(validator);
+                // Set Completer
                 auto completer = new QCompleter(*std::get<1>(item), line_edit);
                 completer->setCaseSensitivity(Qt::CaseInsensitive);
                 completer->setCompletionMode(QCompleter::PopupCompletion);
                 completer->setFilterMode(Qt::MatchContains);
-                auto validator = new AStrictRxValidator(std::get<2>(item), line_edit);
                 line_edit->setCompleter(completer);
-                line_edit->setValidator(validator);
             }
         }
     }
-    // get Maps
-    pilotsIdMap = aDB()->getIdMap(ADataBase::pilots);
-    tailsIdMap  = aDB()->getIdMap(ADataBase::tails);
-    airportIdentifierIdMap = aDB()->getIdMap(ADataBase::airport_identifier);
-    airportNameIdMap = aDB()->getIdMap(ADataBase::airport_names);
-}
-
-void ExpNewFlightDialog::setupMandatoryLineEdits()
-{
-    QObject::connect(this, &ExpNewFlightDialog::goodInputReceived,
-                     this, &ExpNewFlightDialog::onGoodInputReceived);
-    QObject::connect(this, &ExpNewFlightDialog::badInputReceived,
-                     this, &ExpNewFlightDialog::onBadInputReceived);
-    this->mandatoryLineEdits = {
+    // populate Mandatory Line Edits list and prepare QBitArray
+    mandatoryLineEdits = {
         ui->doftLineEdit_2,
         ui->deptLocLineEdit_2,
         ui->destLocLineEdit_2,
@@ -117,58 +151,104 @@ void ExpNewFlightDialog::setupMandatoryLineEdits()
         ui->acftLineEdit_2,
     };
     mandatoryLineEditsGood.resize(mandatoryLineEdits.size());
-    DEB("Mandatory Good: " << mandatoryLineEditsGood);
+    /////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
+    mandatoryLineEditsGood.setBit(0, true); // deal with date input later...
+    /////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
+}
+
+void ExpNewFlightDialog::setupLineEditSignalsAndSlots()
+{
+
+    auto line_edits = this->findChildren<QLineEdit*>();
 
-    for(const auto &line_edit : mandatoryLineEdits){
+    for(const auto &line_edit : line_edits){
+        /////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
         QObject::connect(line_edit, &QLineEdit::inputRejected,
                          this, &ExpNewFlightDialog::onInputRejected);
+        /////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
         if(line_edit->objectName().contains("Loc") || line_edit->objectName().contains("acft")){
             QObject::connect(line_edit, &QLineEdit::textChanged,
                              this, &ExpNewFlightDialog::onTextChangedToUpper);
         }
+        if(line_edit->objectName().contains("acft")){
+            QObject::connect(line_edit, &QLineEdit::textChanged,
+                             this, &ExpNewFlightDialog::onTextChangedToUpper);
+        }
+        if(line_edit->objectName().contains("Name")){
+            QObject::connect(line_edit, &QLineEdit::editingFinished,
+                             this, &ExpNewFlightDialog::onPilotLineEdit_editingFinished);
+        }
     }
+    QObject::connect(this, &ExpNewFlightDialog::goodInputReceived,
+                     this, &ExpNewFlightDialog::onGoodInputReceived);
+    QObject::connect(this, &ExpNewFlightDialog::badInputReceived,
+                     this, &ExpNewFlightDialog::onBadInputReceived);
+    QObject::connect(this, &ExpNewFlightDialog::locationEditingFinished,
+                     this, &ExpNewFlightDialog::onLocLineEdit_editingFinished);
+    QObject::connect(this, &ExpNewFlightDialog::timeEditingFinished,
+                     this, &ExpNewFlightDialog::onTimeLineEdit_editingFinished);
 }
 
+// Location Line Edits
+
 void ExpNewFlightDialog::on_deptLocLineEdit_2_editingFinished()
 {
-    auto line_edit = ui->deptLocLineEdit_2;
+    emit locationEditingFinished(ui->deptLocLineEdit_2, ui->deptNameLabel_2);
+}
+
+void ExpNewFlightDialog::on_destLocLineEdit_2_editingFinished()
+{
+    emit locationEditingFinished(ui->destLocLineEdit_2, ui->destNameLabel_2);
+}
+
+void ExpNewFlightDialog::onLocLineEdit_editingFinished(QLineEdit *line_edit, QLabel *name_label)
+{
     const auto &text = line_edit->text();
+    DEB(line_edit->objectName() << " Editing finished. " << text);
+    int airport_id = 0;
 
-    if (airportIdentifierIdMap.value(text) != 0) {
-        ui->deptNameLabel_2->setText(airportNameIdMap.key(airportIdentifierIdMap.value(text)));
-        emit goodInputReceived(line_edit);
+    // try to map iata or icao code to airport id;
+    if (text.length() == 3) {
+        airport_id = airportIataIdMap.value(text);
     } else {
+        airport_id = airportIcaoIdMap.value(text);
+    }
+    // check result
+    if (airport_id == 0) {
+        // to do: prompt user how to handle unknown airport
+        name_label->setText("Unknown airport identifier");
         emit badInputReceived(line_edit);
+        return;
     }
+    line_edit->setText(airportIcaoIdMap.key(airport_id));
+    name_label->setText(airportNameIdMap.key(airport_id));
+    emit goodInputReceived(line_edit);
 }
+// Time Line Edits
 
-void ExpNewFlightDialog::on_destLocLineEdit_2_editingFinished()
+void ExpNewFlightDialog::on_tofbTimeLineEdit_2_editingFinished()
 {
-    auto line_edit = ui->destLocLineEdit_2;
-    const auto &text = line_edit->text();
-    if (airportIdentifierIdMap.value(text) != 0) {
-        ui->destNameLabel_2->setText(airportNameIdMap.key(airportIdentifierIdMap.value(text)));
+    emit timeEditingFinished(ui->tofbTimeLineEdit_2);
+}
+
+void ExpNewFlightDialog::on_tonbTimeLineEdit_2_editingFinished()
+{
+    emit timeEditingFinished(ui->tonbTimeLineEdit_2);
+}
+
+void ExpNewFlightDialog::onTimeLineEdit_editingFinished(QLineEdit *line_edit)
+{
+    line_edit->setText(ACalc::formatTimeInput(line_edit->text()));
+    const auto time = QTime::fromString(line_edit->text(),"hh:mm");
+    if(time.isValid()){
         emit goodInputReceived(line_edit);
     } else {
         emit badInputReceived(line_edit);
     }
 }
 
-void ExpNewFlightDialog::onInputRejected()
-{
-    auto sender_object = sender();
-    auto line_edit = this->findChild<QLineEdit*>(sender_object->objectName());
-    DEB(line_edit->objectName() << "Input Rejected - " << line_edit->text());
-    {
-        const QSignalBlocker blocker(line_edit);
-        auto text = line_edit->text();
-        line_edit->setText(text);
-        if(line_edit->objectName().contains("Loc") || line_edit->objectName().contains("acft"))
-            line_edit->setText(text.toUpper());
-    }
-    emit badInputReceived(line_edit);
-}
 
+// capitalize input for dept, dest and registration input
 void ExpNewFlightDialog::onTextChangedToUpper(const QString &text)
 {
     auto sender_object = sender();
@@ -179,17 +259,54 @@ void ExpNewFlightDialog::onTextChangedToUpper(const QString &text)
         line_edit->setText(text.toUpper());
     }
 }
-
+// Aircraft Line Edit
 void ExpNewFlightDialog::on_acftLineEdit_2_editingFinished()
 {
-    DEB(sender()->objectName() << "Editing Finished!");
     auto line_edit = ui->acftLineEdit_2;
-    line_edit->setText(line_edit->completer()->currentCompletion());
+    DEB(line_edit->objectName() << "Editing Finished!" << line_edit->text());
+
+    if (!line_edit->completer()->currentCompletion().isEmpty()) {
+        DEB("Trying to fix input...");
+        line_edit->setText(line_edit->completer()->currentCompletion());
+    }
 
-    if(tailsIdMap.value(line_edit->text()) == 0) {
+    if (tailsIdMap.value(line_edit->text()) == 0) {
         emit badInputReceived(line_edit);
+        ui->acftTypeLabel_2->setText("Unknown Registration.");
         // to do: promp user to add new
     } else {
         emit goodInputReceived(line_edit);
     }
 }
+// Pilot Line Edits
+void ExpNewFlightDialog::onPilotLineEdit_editingFinished()
+{
+    auto sender_object = sender();
+    auto line_edit = this->findChild<QLineEdit*>(sender_object->objectName());
+    DEB(line_edit->objectName() << "Editing Finished -" << line_edit->text());
+
+    if (!line_edit->completer()->currentCompletion().isEmpty()) {
+        DEB("Trying to fix input...");
+        line_edit->setText(line_edit->completer()->currentCompletion());
+    }
+    if(pilotsIdMap.value(line_edit->text()) == 0) {
+        emit badInputReceived(line_edit);
+        // to do: prompt user to add new
+    } else {
+        emit goodInputReceived(line_edit);
+    }
+}
+
+
+
+
+/////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
+void ExpNewFlightDialog::onInputRejected()
+{
+    auto sender_object = sender();
+    auto line_edit = this->findChild<QLineEdit*>(sender_object->objectName());
+    DEB(line_edit->objectName() << "Input Rejected - " << line_edit->text());
+}
+/////////////////////////////////////// DEBUG /////////////////////////////////////////////////////
+
+

+ 21 - 9
src/experimental/expnewflightdialog.h

@@ -16,13 +16,15 @@
 #include <QCalendarWidget>
 #include <QTabWidget>
 
-#include "src/classes/astrictrxvalidator.h"
-
 #include "src/experimental/adatabase.h"
 #include "src/experimental/aflightentry.h"
 #include "src/experimental/apilotentry.h"
 #include "src/experimental/atailentry.h"
 
+#include "src/functions/acalc.h"
+
+#include "src/testing/atimer.h"
+
 namespace Ui {
 class ExpNewFlightDialog;
 }
@@ -39,21 +41,30 @@ public:
 signals:
     void goodInputReceived(QLineEdit*);
     void badInputReceived(QLineEdit*);
+    void locationEditingFinished(QLineEdit*, QLabel*);
+    void timeEditingFinished(QLineEdit*);
 
 private slots:
 
     void onGoodInputReceived(QLineEdit*);
-    void onBadInputReceived(QLineEdit*);
+    void onBadInputReceived(QLineEdit *);
+    void onTextChangedToUpper(const QString&);
+    void onPilotLineEdit_editingFinished();
+    void onLocLineEdit_editingFinished(QLineEdit*, QLabel*);
+    void onTimeLineEdit_editingFinished(QLineEdit*);
 
     void on_deptLocLineEdit_2_editingFinished();
+    void on_destLocLineEdit_2_editingFinished();
+    void on_acftLineEdit_2_editingFinished();
 
+
+/////// DEBUG
     void onInputRejected();
+/////// DEBUG
 
-    void onTextChangedToUpper(const QString&);
+    void on_tofbTimeLineEdit_2_editingFinished();
 
-    void on_acftLineEdit_2_editingFinished();
-
-    void on_destLocLineEdit_2_editingFinished();
+    void on_tonbTimeLineEdit_2_editingFinished();
 
 private:
     Ui::ExpNewFlightDialog *ui;
@@ -70,11 +81,12 @@ private:
 
     QMap<QString, int> pilotsIdMap;
     QMap<QString, int> tailsIdMap;
-    QMap<QString, int> airportIdentifierIdMap;
+    QMap<QString, int> airportIcaoIdMap;
+    QMap<QString, int> airportIataIdMap;
     QMap<QString, int> airportNameIdMap;
 
     void setupRawInputValidation();
-    void setupMandatoryLineEdits();
+    void setupLineEditSignalsAndSlots();
 
     void setupValidators();
 };

+ 33 - 0
src/experimental/expnewflightdialog.ui

@@ -1385,6 +1385,39 @@
    </item>
   </layout>
  </widget>
+ <tabstops>
+  <tabstop>doftLineEdit_2</tabstop>
+  <tabstop>deptLocLineEdit_2</tabstop>
+  <tabstop>tofbTimeLineEdit_2</tabstop>
+  <tabstop>destLocLineEdit_2</tabstop>
+  <tabstop>tonbTimeLineEdit_2</tabstop>
+  <tabstop>acftLineEdit_2</tabstop>
+  <tabstop>picNameLineEdit_2</tabstop>
+  <tabstop>secondPilotNameLineEdit_2</tabstop>
+  <tabstop>thirdPilotNameLineEdit_2</tabstop>
+  <tabstop>FlightNumberLineEdit_2</tabstop>
+  <tabstop>RemarksLineEdit_2</tabstop>
+  <tabstop>verifyButton</tabstop>
+  <tabstop>verifyEdit</tabstop>
+  <tabstop>flightDataTabWidget</tabstop>
+  <tabstop>FunctionComboBox_2</tabstop>
+  <tabstop>PilotFlyingCheckBox_2</tabstop>
+  <tabstop>ApproachComboBox_2</tabstop>
+  <tabstop>PilotMonitoringCheckBox_2</tabstop>
+  <tabstop>TakeoffCheckBox_2</tabstop>
+  <tabstop>TakeoffSpinBox_2</tabstop>
+  <tabstop>VfrCheckBox_2</tabstop>
+  <tabstop>LandingCheckBox_2</tabstop>
+  <tabstop>LandingSpinBox_2</tabstop>
+  <tabstop>IfrCheckBox_2</tabstop>
+  <tabstop>AutolandCheckBox_2</tabstop>
+  <tabstop>AutolandSpinBox_2</tabstop>
+  <tabstop>setAsDefaultButton_2</tabstop>
+  <tabstop>restoreDefaultButton_2</tabstop>
+  <tabstop>manualEditingCheckBox_2</tabstop>
+  <tabstop>tblkTimeLineEdit_2</tabstop>
+  <tabstop>calendarWidget_2</tabstop>
+ </tabstops>
  <resources/>
  <connections/>
 </ui>

+ 1 - 1
src/gui/dialogues/newflightdialog.cpp

@@ -199,7 +199,7 @@ void NewFlightDialog::setup(){
     //fill Lists
     pilots   = experimental::aDB()->getCompletionList(experimental::ADataBase::pilots);
     tails    = experimental::aDB()->getCompletionList(experimental::ADataBase::registrations);
-    airports = experimental::aDB()->getCompletionList(experimental::ADataBase::airport_identifier);
+    airports = experimental::aDB()->getCompletionList(experimental::ADataBase::airport_identifier_icao);
 
     QString statement = "SELECT iata, icao FROM airports";
     auto result = Db::customQuery(statement,2);

+ 1 - 1
src/gui/dialogues/newpilotdialog.cpp

@@ -119,7 +119,7 @@ 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(aDB(), &ADataBase::sqlSuccessful,
+    QObject::connect(aDB(), &ADataBase::commitSuccessful,
                      this, &NewPilotDialog::onCommitSuccessful);
     QObject::connect(aDB(), &ADataBase::sqlError,
                      this, &NewPilotDialog::onCommitUnsuccessful);

+ 1 - 1
src/gui/dialogues/newtaildialog.cpp

@@ -111,7 +111,7 @@ void NewTailDialog::setupValidators()
 void NewTailDialog::connectSignals()
 {
     using namespace experimental;
-    QObject::connect(aDB(), &ADataBase::sqlSuccessful,
+    QObject::connect(aDB(), &ADataBase::commitSuccessful,
                      this,  &NewTailDialog::onCommitSuccessful);
     QObject::connect(aDB(), &ADataBase::sqlError,
                      this,  &NewTailDialog::onCommitUnsuccessful);

+ 2 - 0
src/gui/widgets/debugwidget.cpp

@@ -167,6 +167,8 @@ void DebugWidget::on_debugPushButton_clicked()
     using namespace experimental;
     auto nf = new ExpNewFlightDialog(7, this);
     nf->exec();
+
+
 }
 
 /* //Comparing two functions template

+ 50 - 47
src/gui/widgets/debugwidget.ui

@@ -24,6 +24,13 @@
        <string>Database</string>
       </attribute>
       <layout class="QGridLayout" name="gridLayout_2">
+       <item row="2" column="3">
+        <widget class="QLabel" name="label_3">
+         <property name="text">
+          <string>Fill a new database with sample entries</string>
+         </property>
+        </widget>
+       </item>
        <item row="3" column="3">
         <widget class="QLineEdit" name="importCsvLineEdit">
          <property name="minimumSize">
@@ -37,8 +44,18 @@
          </property>
         </widget>
        </item>
-       <item row="3" column="4">
-        <widget class="QPushButton" name="selectCsvPushButton">
+       <item row="4" column="3">
+        <widget class="QLineEdit" name="debugLineEdit"/>
+       </item>
+       <item row="2" column="0">
+        <widget class="QPushButton" name="fillUserDataPushButton">
+         <property name="text">
+          <string>Fill User Table with test data</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0">
+        <widget class="QPushButton" name="importCsvPushButton">
          <property name="minimumSize">
           <size>
            <width>110</width>
@@ -46,27 +63,21 @@
           </size>
          </property>
          <property name="text">
-          <string>Select File</string>
+          <string>Import CSV</string>
          </property>
         </widget>
        </item>
-       <item row="0" column="0">
-        <widget class="QPushButton" name="resetDatabasePushButton">
-         <property name="minimumSize">
-          <size>
-           <width>220</width>
-           <height>0</height>
-          </size>
-         </property>
+       <item row="4" column="0">
+        <widget class="QPushButton" name="debugPushButton">
          <property name="text">
-          <string>Reset Database</string>
+          <string>Do Debug Stuff!</string>
          </property>
         </widget>
        </item>
-       <item row="2" column="0">
-        <widget class="QPushButton" name="fillUserDataPushButton">
+       <item row="1" column="3">
+        <widget class="QLabel" name="label_2">
          <property name="text">
-          <string>Fill User Table with test data</string>
+          <string>Keep current database but delete entries in pilots, aircraft and flights</string>
          </property>
         </widget>
        </item>
@@ -83,6 +94,19 @@
          </property>
         </widget>
        </item>
+       <item row="3" column="4">
+        <widget class="QPushButton" name="selectCsvPushButton">
+         <property name="minimumSize">
+          <size>
+           <width>110</width>
+           <height>0</height>
+          </size>
+         </property>
+         <property name="text">
+          <string>Select File</string>
+         </property>
+        </widget>
+       </item>
        <item row="0" column="3">
         <widget class="QLabel" name="label">
          <property name="text">
@@ -90,10 +114,16 @@
          </property>
         </widget>
        </item>
-       <item row="1" column="3">
-        <widget class="QLabel" name="label_2">
+       <item row="0" column="0">
+        <widget class="QPushButton" name="resetDatabasePushButton">
+         <property name="minimumSize">
+          <size>
+           <width>220</width>
+           <height>0</height>
+          </size>
+         </property>
          <property name="text">
-          <string>Keep current database but delete entries in pilots, aircraft and flights</string>
+          <string>Reset Database</string>
          </property>
         </widget>
        </item>
@@ -112,35 +142,8 @@
          </item>
         </widget>
        </item>
-       <item row="3" column="0">
-        <widget class="QPushButton" name="importCsvPushButton">
-         <property name="minimumSize">
-          <size>
-           <width>110</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="text">
-          <string>Import CSV</string>
-         </property>
-        </widget>
-       </item>
-       <item row="2" column="3">
-        <widget class="QLabel" name="label_3">
-         <property name="text">
-          <string>Fill a new database with sample entries</string>
-         </property>
-        </widget>
-       </item>
-       <item row="4" column="0">
-        <widget class="QPushButton" name="debugPushButton">
-         <property name="text">
-          <string>Do Debug Stuff!</string>
-         </property>
-        </widget>
-       </item>
-       <item row="4" column="3">
-        <widget class="QLineEdit" name="debugLineEdit"/>
+       <item row="5" column="3">
+        <widget class="QLineEdit" name="debug2LineEdit"/>
        </item>
       </layout>
      </widget>

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

@@ -76,7 +76,7 @@ void LogbookWidget::connectSignalsAndSlots()
     QObject::connect(view->selectionModel(), &QItemSelectionModel::selectionChanged,
                      this, &LogbookWidget::flightsTableView_selectionChanged);
     using namespace experimental;
-    QObject::connect(aDB(), &ADataBase::sqlSuccessful,
+    QObject::connect(aDB(), &ADataBase::deleteSuccessful,
                      this, &LogbookWidget::onDeletedSuccessfully);
     QObject::connect(aDB(), &ADataBase::sqlError,
                      this, &LogbookWidget::onDeleteUnsuccessful);
@@ -268,7 +268,7 @@ void LogbookWidget::on_actionDelete_Flight_triggered()
 
 void LogbookWidget::onDeletedSuccessfully()
 {
-    messageBox->setText(QString::number(selectedFlights.length()) + " flights have been deleted.");
+    messageBox->setText(QString::number(selectedFlights.length()) + " entries have been deleted.");
     messageBox->exec();
 }