Browse Source

Merge pull request #30 from fiffty-50/develop-cleanup

Less signals, more functions
Felix Turowsky 4 years ago
parent
commit
21aa47113a

+ 9 - 8
mainwindow.cpp

@@ -132,14 +132,15 @@ void MainWindow::on_actionDebug_triggered()
 
 void MainWindow::connectWidgets()
 {
-    QObject::connect(experimental::aDB(), &experimental::ADataBase::updated,
-                     logbookWidget, &LogbookWidget::onDatabaseChanged);
-    QObject::connect(settingsWidget, &SettingsWidget::logbookviewSelectionChanged,
-                     logbookWidget, &LogbookWidget::onLogbookviewSelectionChanged);
-    QObject::connect(experimental::aDB(), &experimental::ADataBase::updated,
-                     pilotsWidget, &PilotsWidget::onDatabaseChanged);
-    QObject::connect(experimental::aDB(), &experimental::ADataBase::updated,
-                     aircraftWidget, &AircraftWidget::onDatabaseChanged);
+    QObject::connect(experimental::aDB(), &experimental::ADataBase::dataBaseUpdated,
+                     logbookWidget, &LogbookWidget::onDisplayModel_dataBaseUpdated);
+    QObject::connect(experimental::aDB(), &experimental::ADataBase::dataBaseUpdated,
+                     pilotsWidget, &PilotsWidget::onDisplayModel_dataBaseUpdated);
+    QObject::connect(experimental::aDB(), &experimental::ADataBase::dataBaseUpdated,
+                     aircraftWidget, &AircraftWidget::onDisplayModel_dataBaseUpdated);
+
+    QObject::connect(settingsWidget, &SettingsWidget::logbookViewSelectionChanged,
+                     logbookWidget, &LogbookWidget::on_logbookViewSelectionChanged);
 }
 
 void MainWindow::on_actionSettings_triggered()

+ 5 - 5
src/experimental/adatabase.cpp

@@ -98,7 +98,7 @@ bool ADataBase::remove(AEntry entry)
     if (query.lastError().type() == QSqlError::NoError)
     {
         DEB("Entry " << entry.getPosition().tableName << entry.getPosition().rowId << " removed.");
-        emit updated();
+        emit dataBaseUpdated();
         lastError = QString();
         return true;
     } else {
@@ -136,7 +136,7 @@ bool ADataBase::removeMany(QList<DataPosition> data_position_list)
         query.prepare("COMMIT");
         query.exec();
         if(query.lastError().type() == QSqlError::NoError) {
-            emit updated();
+            emit dataBaseUpdated();
             lastError = QString();
             return true;
         } else {
@@ -231,7 +231,7 @@ bool ADataBase::update(AEntry updated_entry)
     if (query.lastError().type() == QSqlError::NoError)
     {
         DEB("Entry successfully committed.");
-        emit updated();
+        emit dataBaseUpdated();
         lastError = QString();
         return true;
     } else {
@@ -270,7 +270,7 @@ bool ADataBase::insert(AEntry new_entry)
     if (query.lastError().type() == QSqlError::NoError)
     {
         DEB("Entry successfully committed.");
-        emit updated();
+        emit dataBaseUpdated();
         lastError = QString();
         return true;
     } else {
@@ -517,7 +517,7 @@ QVector<QString> ADataBase::customQuery(QString statement, int return_values)
                 result.append(query.value(i).toString());
             }
         }
-        emit updated();
+        emit dataBaseUpdated();
         lastError = QString();
         return result;
     }

+ 1 - 1
src/experimental/adatabase.h

@@ -188,7 +188,7 @@ signals:
      * trigger an update to the models of the views displaying database contents in
      * the user interface so that a user is always presented with up-to-date information.
      */
-    void updated();
+    void dataBaseUpdated();
 };
 
 /*!

+ 35 - 2
src/gui/dialogues/newflight.ui

@@ -788,11 +788,18 @@
            <height>20</height>
           </size>
          </property>
+         <property name="font">
+          <font>
+           <pointsize>16</pointsize>
+           <weight>75</weight>
+           <bold>true</bold>
+          </font>
+         </property>
          <property name="toolTip">
           <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Once all the required items are filled out, the total time of flight will be displayed here.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
          </property>
          <property name="styleSheet">
-          <string notr="true">color: yellow;</string>
+          <string notr="true">color: rgb(237, 212, 0);</string>
          </property>
          <property name="frameShape">
           <enum>QFrame::NoFrame</enum>
@@ -833,6 +840,30 @@
          </property>
         </widget>
        </item>
+       <item row="10" column="3">
+        <widget class="QLabel" name="submissionReadyTextLabel">
+         <property name="text">
+          <string>Status:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="10" column="4">
+        <widget class="QLabel" name="submissonReadyLabel">
+         <property name="font">
+          <font>
+           <pointsize>16</pointsize>
+           <weight>75</weight>
+           <bold>true</bold>
+          </font>
+         </property>
+         <property name="styleSheet">
+          <string notr="true">color: rgb(237, 212, 0);</string>
+         </property>
+         <property name="text">
+          <string>INCOMPLETE</string>
+         </property>
+        </widget>
+       </item>
       </layout>
       <zorder>placeLabel2</zorder>
       <zorder>deptLocLineEdit</zorder>
@@ -889,6 +920,8 @@
       <zorder>placeLabel1</zorder>
       <zorder>calendarCheckBox</zorder>
       <zorder>picCompanyLabel</zorder>
+      <zorder>submissionReadyTextLabel</zorder>
+      <zorder>submissonReadyLabel</zorder>
      </widget>
      <widget class="QWidget" name="autoLoggingTab">
       <attribute name="title">
@@ -1441,7 +1474,7 @@
    <item row="1" column="1">
     <widget class="QPushButton" name="submitButton">
      <property name="enabled">
-      <bool>false</bool>
+      <bool>true</bool>
      </property>
      <property name="whatsThis">
       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add your flight to the logbook.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;You can only perform this action if all of the mandatory fields are filled.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>

+ 105 - 82
src/gui/dialogues/newflightdialog.cpp

@@ -46,12 +46,19 @@ static const auto AIRCRAFT_VALID_RGX   = QRegularExpression(
             "\\w+\\-?(\\w+)?");
 static const auto NAME_VALID_RGX       = QRegularExpression(
             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 );         // up to 4 last names
 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])?$");
 static const auto SELF_RX              = QRegularExpression(
             "self", QRegularExpression::CaseInsensitiveOption);
 
+static const auto MANDATORY_LINE_EDITS_DISPLAY_NAMES = QMap<int, QLatin1String> {
+    {0, QLatin1String("Date of Flight")}, {1, QLatin1String("Departure Airport")},
+    {2, QLatin1String("Destination Airport")}, {3, QLatin1String("Time Off Blocks")},
+    {4, QLatin1String("Time on Blocks")}, {5, QLatin1String("PIC Name")},
+    {6, QLatin1String("Aircraft Registration")}
+};
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///                                      Construction                                           ///
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -117,7 +124,7 @@ void NewFlightDialog::setup()
     updateEnabled = true;
     setupButtonGroups();
     setupRawInputValidation();
-    setupLineEditSignalsAndSlots();
+    setupSignalsAndSlots();
     readSettings();
 
     // Visually mark mandatory fields
@@ -130,18 +137,17 @@ void NewFlightDialog::setup()
 
     ui->doftLineEdit->setText(QDate::currentDate().toString(Qt::ISODate));
     emit ui->doftLineEdit->editingFinished();
-    ui->deptLocLineEdit->setFocus();
 
     if(ASettings::read("NewFlight/FunctionComboBox").toString() == "PIC"){
         ui->picNameLineEdit->setText("self");
         emit ui->picNameLineEdit->editingFinished();
     }
+    ui->deptLocLineEdit->setFocus();
 }
 void NewFlightDialog::readSettings()
 {
     DEB("Reading Settings...");
     QSettings settings;
-
     ui->FunctionComboBox->setCurrentText(ASettings::read("NewFlight/FunctionComboBox").toString());
     ui->ApproachComboBox->setCurrentText(ASettings::read("NewFlight/ApproachComboBox").toString());
     ui->PilotFlyingCheckBox->setChecked(ASettings::read("NewFlight/PilotFlyingCheckBox").toBool());
@@ -156,9 +162,6 @@ void NewFlightDialog::readSettings()
     ui->VfrCheckBox->setChecked(ASettings::read("NewFlight/VfrCheckBox").toBool());
     ui->FlightNumberLineEdit->setText(ASettings::read("flightlogging/flightnumberPrefix").toString());
     ui->calendarCheckBox->setChecked(ASettings::read("NewFlight/calendarCheckBox").toBool());
-
-    setPopUpCalendarEnabled(ASettings::read("NewFlight/calendarCheckBox").toBool());
-
     if (ASettings::read("NewFlight/FunctionComboBox").toString() == "Co-Pilot") {
         ui->picNameLineEdit->setText("");
         ui->secondPilotNameLineEdit->setText("self");
@@ -252,7 +255,6 @@ void NewFlightDialog::setupRawInputValidation()
         ui->picNameLineEdit,
         ui->acftLineEdit,
     };
-    mandatoryLineEditsGood.resize(mandatoryLineEdits.size());
     primaryTimeLineEdits = {
         ui->tofbTimeLineEdit,
         ui->tonbTimeLineEdit
@@ -262,11 +264,12 @@ void NewFlightDialog::setupRawInputValidation()
         ui->secondPilotNameLineEdit,
         ui->thirdPilotNameLineEdit
     };
+
+    mandatoryLineEditsGood.resize(mandatoryLineEdits.size());
 }
 
-void NewFlightDialog::setupLineEditSignalsAndSlots()
+void NewFlightDialog::setupSignalsAndSlots()
 {
-
     auto line_edits = this->findChildren<QLineEdit*>();
 
     for (const auto &line_edit : line_edits){
@@ -293,21 +296,13 @@ void NewFlightDialog::setupLineEditSignalsAndSlots()
         }
     }
     for (const auto &line_edit : mandatoryLineEdits) {
+        if(line_edit->objectName().contains("doft"))
+            break;
         QObject::connect(line_edit->completer(), QOverload<const QString &>::of(&QCompleter::highlighted),
                          this, &NewFlightDialog::onCompleter_highlighted);
         QObject::connect(line_edit->completer(), QOverload<const QString &>::of(&QCompleter::activated),
                          this, &NewFlightDialog::onCompleter_activated);
     }
-    QObject::connect(this, &NewFlightDialog::goodInputReceived,
-                     this, &NewFlightDialog::onGoodInputReceived);
-    QObject::connect(this, &NewFlightDialog::badInputReceived,
-                     this, &NewFlightDialog::onBadInputReceived);
-    QObject::connect(this, &NewFlightDialog::locationEditingFinished,
-                     this, &NewFlightDialog::onLocLineEdit_editingFinished);
-    QObject::connect(this, &NewFlightDialog::timeEditingFinished,
-                     this, &NewFlightDialog::onTimeLineEdit_editingFinished);
-    QObject::connect(this, &NewFlightDialog::mandatoryLineEditsFilled,
-                     this, &NewFlightDialog::onMandatoryLineEditsFilled);
 }
 
 
@@ -351,6 +346,7 @@ bool NewFlightDialog::eventFilter(QObject* object, QEvent* event)
             mandatoryLineEditsGood.setBit(mandatoryLineEdits.indexOf(line_edit), false);
             DEB("Editing " << line_edit->objectName());
             // set verification bit to false when entering a mandatory line edit
+            return false;
         }
         if (mandatoryLineEdits.contains(line_edit) && event->type() == QEvent::KeyPress) {
             // show completion menu when pressing down arrow
@@ -359,6 +355,16 @@ bool NewFlightDialog::eventFilter(QObject* object, QEvent* event)
                 DEB("Key down event.");
                 line_edit->completer()->complete();
             }
+            return false;
+        }
+        if (line_edit->objectName().contains("Name") && event->type() == QEvent::KeyPress) {
+            // show completion menu when pressing down arrow
+            QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
+            if (keyEvent->key() == Qt::Key_Down) {
+                DEB("Key down event.");
+                line_edit->completer()->complete();
+            }
+            return false;
         }
     }
     return false;
@@ -371,6 +377,11 @@ bool NewFlightDialog::eventFilter(QObject* object, QEvent* event)
  */
 void NewFlightDialog::fillDeductibleData()
 {
+    // check if mandatory line edits are valid
+    if (mandatoryLineEditsGood.count(true) != 7) {
+        return;
+    }
+
     //zero out labels and line edits to delete previous calculations
     QList<QLineEdit*>   LE = {ui->tSPSETimeLineEdit, ui->tSPMETimeLineEdit, ui->tMPTimeLineEdit,    ui->tIFRTimeLineEdit,
                               ui->tNIGHTTimeLineEdit,ui->tPICTimeLineEdit,  ui->tPICUSTimeLineEdit, ui->tSICTimeLineEdit,
@@ -405,8 +416,10 @@ void NewFlightDialog::fillDeductibleData()
         ui->tMPLabel->setText(block_time);
     }
     // TOTAL
-    ui->tblkLabel_2->setText("<b>" + block_minutes + "</b>");
-    ui->tblkLabel_2->setStyleSheet("color: green;");
+    ui->tblkLabel->setText("<b>" + block_time + "</b>");
+    ui->tblkLabel->setStyleSheet("color: green;");
+    ui->submissonReadyLabel->setText("Ready for Submission");
+    ui->submissonReadyLabel->setStyleSheet("color: green;");
     // IFR
     if(ui->IfrCheckBox->isChecked()){
         ui->tIFRTimeLineEdit->setText(block_time);
@@ -448,6 +461,8 @@ void NewFlightDialog::fillDeductibleData()
     case 4://Instructor
         ui->tFITimeLineEdit->setText(block_time);
         ui->tFILabel->setText(block_time);
+        ui->tPICTimeLineEdit->setText(block_time);
+        ui->tPICLabel->setText(block_time);
     }
 }
 /*!
@@ -552,7 +567,7 @@ TableData NewFlightDialog::collectInput()
         newData.insert("tFI", "");
         break;
     case 4://Instructor
-        newData.insert("tPIC", "");
+        newData.insert("tPIC", block_minutes);
         newData.insert("tPICUS", "");
         newData.insert("tSIC", "");
         newData.insert("tDUAL", "");
@@ -631,9 +646,9 @@ void NewFlightDialog::formFiller()
         for(const auto& leName : line_edits_names){
             if(rx.match(leName).hasMatch())  {
                 //DEB("Loc Match found: " << key << " - " << leName);
-                auto le = this->findChild<QLineEdit *>(leName);
-                if(le != nullptr){
-                    le->setText(flightEntry.getData().value(data_key));
+                auto line_edit = this->findChild<QLineEdit *>(leName);
+                if(line_edit != nullptr){
+                    line_edit->setText(flightEntry.getData().value(data_key));
                     line_edits_names.removeOne(leName);
                 }
                 break;
@@ -643,9 +658,9 @@ void NewFlightDialog::formFiller()
         for(const auto& leName : line_edits_names){
             if(rx.match(leName).hasMatch())  {
                 //DEB("Loc Match found: " << key << " - " << leName);
-                auto le = this->findChild<QLineEdit *>(leName);
-                if(le != nullptr){
-                    le->setText(flightEntry.getData().value(data_key));
+                auto line_edit = this->findChild<QLineEdit *>(leName);
+                if(line_edit != nullptr){
+                    line_edit->setText(flightEntry.getData().value(data_key));
                     line_edits_names.removeOne(leName);
                 }
                 break;
@@ -655,11 +670,11 @@ void NewFlightDialog::formFiller()
         for(const auto& leName : line_edits_names){
             if(rx.match(leName).hasMatch())  {
                 //DEB("Time Match found: " << key << " - " << leName);
-                auto le = this->findChild<QLineEdit *>(leName);
-                if(le != nullptr){
-                    DEB("Setting " << le->objectName() << " to " << ACalc::minutesToString(flightEntry.getData().value(data_key)));
-                    le->setText(ACalc::minutesToString(
-                                    flightEntry.getData().value(data_key)));
+                auto line_edits = this->findChild<QLineEdit *>(leName);
+                if(line_edits != nullptr){
+                    DEB("Setting " << line_edits->objectName() << " to " << ACalc::minutesToString(flightEntry.getData().value(data_key)));
+                    line_edits->setText(ACalc::minutesToString(
+                                            flightEntry.getData().value(data_key)));
                     line_edits_names.removeOne(leName);
                 }
                 break;
@@ -668,10 +683,10 @@ void NewFlightDialog::formFiller()
         rx = QRegularExpression(data_key + "Name\\w+?");
         for(const auto& leName : line_edits_names){
             if(rx.match(leName).hasMatch())  {
-                auto le = this->findChild<QLineEdit *>(leName);
-                if(le != nullptr){
+                auto line_edits = this->findChild<QLineEdit *>(leName);
+                if(line_edits != nullptr){
                     DEB(pilotsIdMap.key(1));
-                    le->setText(pilotsIdMap.key(flightEntry.getData().value(data_key).toInt()));
+                    line_edits->setText(pilotsIdMap.key(flightEntry.getData().value(data_key).toInt()));
                     line_edits_names.removeOne(leName);
                 }
                 break;
@@ -679,11 +694,12 @@ void NewFlightDialog::formFiller()
         }
     }
     //FunctionComboBox
-    QList<QLineEdit*> FCB = {ui->tPICTimeLineEdit,  ui->tPICUSTimeLineEdit, ui->tSICTimeLineEdit,
-                             ui->tDUALTimeLineEdit, ui->tFITimeLineEdit};
-    for(const auto& le : FCB){
-        if(le->text() != "00:00"){
-            QString name = le->objectName();
+    QList<QLineEdit*> function_combo_boxes = {ui->tPICTimeLineEdit, ui->tPICUSTimeLineEdit,
+                                              ui->tSICTimeLineEdit, ui->tDUALTimeLineEdit,
+                                              ui->tFITimeLineEdit};
+    for(const auto& line_edit : function_combo_boxes){
+        if(line_edit->text() != "00:00"){
+            QString name = line_edit->objectName();
             name.chop(12);
             name.remove(0,1);
             ui->FunctionComboBox->setCurrentText(name);
@@ -756,9 +772,10 @@ bool NewFlightDialog::isLessOrEqualThanBlockTime(const QString time_string)
         return true;
     } else {
         auto message_box = QMessageBox(this);
-        message_box.setText("Cannot be more than Total Time of Flight:<br><br><center><b>"
+        message_box.setWindowTitle("Error");
+        message_box.setText("The flight time you have entered is longer than the total blocktime:<br><center><b>"
                             + block_time.toString(TIME_FORMAT)
-                            + "</b></center><br>");
+                            + "</b></center>");
         message_box.exec();
         return false;
     }
@@ -831,7 +848,6 @@ void NewFlightDialog::on_cancelButton_clicked()
     reject();
 }
 
-// submit button is set enabled when all mandatory line edits are valid
 void NewFlightDialog::on_submitButton_clicked()
 {
     for (const auto &line_edit : mandatoryLineEdits) {
@@ -839,8 +855,18 @@ void NewFlightDialog::on_submitButton_clicked()
     }
     DEB("editing finished emitted. good count: " << mandatoryLineEditsGood.count(true));
     if (mandatoryLineEditsGood.count(true) != 7) {
+        QString error_message = "Not all mandatory entries are valid.<br>The following"
+                                " item(s) are empty or missing:<br><br><center><b>";
+        for (int i=0; i < mandatoryLineEditsGood.size(); i++) {
+            if (!mandatoryLineEditsGood[i]){
+                error_message.append(MANDATORY_LINE_EDITS_DISPLAY_NAMES.value(i) + "<br>");
+                mandatoryLineEdits[i]->setStyleSheet("border: 1px solid red");
+            }
+        }
+        error_message.append("</b></center><br>Please go back and fill in the required data.");
+
         auto message_box = QMessageBox(this);
-        message_box.setText("Not all mandatory entries are valid");
+        message_box.setText(error_message);
         message_box.exec();
         return;
     }
@@ -861,7 +887,6 @@ void NewFlightDialog::on_submitButton_clicked()
     } else {
         QDialog::accept();
     }
-
 }
 
 
@@ -879,7 +904,7 @@ void NewFlightDialog::onGoodInputReceived(QLineEdit *line_edit)
         mandatoryLineEditsGood.setBit(mandatoryLineEdits.indexOf(line_edit), true);
 
     if (mandatoryLineEditsGood.count(true) == 7)
-        emit mandatoryLineEditsFilled();
+        onMandatoryLineEditsFilled();
 
     DEB("Mandatory good: " << mandatoryLineEditsGood.count(true)
         << " (out of 7) " << mandatoryLineEditsGood);
@@ -891,14 +916,10 @@ void NewFlightDialog::onBadInputReceived(QLineEdit *line_edit)
     DEB(line_edit->objectName() << " - Bad input received - " << line_edit->text());
     line_edit->setStyleSheet("border: 1px solid red");
 
-    if (mandatoryLineEdits.contains(line_edit)) {
-        mandatoryLineEditsGood.setBit(mandatoryLineEdits.indexOf(line_edit), false);
-        DEB("Disabling commit button...");
-        ui->submitButton->setEnabled(false);
-    }
-
     DEB("Mandatory Good: " << mandatoryLineEditsGood.count(true) << " out of "
         << mandatoryLineEditsGood.size() << ". Array: " << mandatoryLineEditsGood);
+    ui->submissonReadyLabel->setText("INCOMPLETE");
+    ui->submissonReadyLabel->setStyleSheet("color: rgb(237, 212, 0);");
 }
 
 // capitalize input for dept, dest and registration input
@@ -916,13 +937,10 @@ void NewFlightDialog::onToUpperTriggered_textChanged(const QString &text)
 // update is disabled if the user chose to manually edit extra times
 void NewFlightDialog::onMandatoryLineEditsFilled()
 {
-    DEB(mandatoryLineEditsGood);
-    if(!ui->submitButton->isEnabled()) {
-        ui->submitButton->setEnabled(true);
-        ui->submitButton->setStyleSheet("border: 1px solid rgb(78, 154, 6);"
-                                        "color: rgb(78, 154, 6);");
-        DEB("Commit Button Enabled. Ready for commit!");
-    }
+    if (!(mandatoryLineEditsGood.count(true) == 7)) {
+        DEB("erroneously called.");
+        return;
+    };
 
     if (updateEnabled)
         fillDeductibleData();
@@ -960,7 +978,7 @@ void NewFlightDialog::on_doftLineEdit_editingFinished()
     auto date = QDate::fromString(text, Qt::ISODate);
     if (date.isValid()) {
         label->setText(date.toString(Qt::TextDate));
-        emit goodInputReceived(line_edit);
+        onGoodInputReceived(line_edit);
         return;
     }
 
@@ -973,12 +991,12 @@ void NewFlightDialog::on_doftLineEdit_editingFinished()
         if (date.isValid()) {
             line_edit->setText(date.toString(Qt::ISODate));
             label->setText(date.toString(Qt::TextDate));
-            emit goodInputReceived(line_edit);
+            onGoodInputReceived(line_edit);
             return;
         }
     }
     label->setText("Invalid Date.");
-    emit badInputReceived(line_edit);
+    onBadInputReceived(line_edit);
 }
 
 void NewFlightDialog::onCalendarWidget_clicked(const QDate &date)
@@ -1036,7 +1054,7 @@ void NewFlightDialog::onDoftLineEdit_entered()
 void NewFlightDialog::on_calendarCheckBox_stateChanged(int arg1)
 {
     ASettings::write("NewFlight/calendarCheckBox", ui->calendarCheckBox->isChecked());
-
+    DEB("Calendar check box state changed.");
     switch (arg1) {
     case 0: // unchecked
         setPopUpCalendarEnabled(false);
@@ -1055,15 +1073,15 @@ void NewFlightDialog::on_calendarCheckBox_stateChanged(int arg1)
 
 void NewFlightDialog::on_deptLocLineEdit_editingFinished()
 {
-    emit locationEditingFinished(ui->deptLocLineEdit, ui->deptNameLabel);
+    onLocationEditingFinished(ui->deptLocLineEdit, ui->deptNameLabel);
 }
 
 void NewFlightDialog::on_destLocLineEdit_editingFinished()
 {
-    emit locationEditingFinished(ui->destLocLineEdit, ui->destNameLabel);
+    onLocationEditingFinished(ui->destLocLineEdit, ui->destNameLabel);
 }
 
-void NewFlightDialog::onLocLineEdit_editingFinished(QLineEdit *line_edit, QLabel *name_label)
+void NewFlightDialog::onLocationEditingFinished(QLineEdit *line_edit, QLabel *name_label)
 {
     const auto &text = line_edit->text();
     //DEB(line_edit->objectName() << " Editing finished. " << text);
@@ -1079,12 +1097,12 @@ void NewFlightDialog::onLocLineEdit_editingFinished(QLineEdit *line_edit, QLabel
     if (airport_id == 0) {
         // to do: prompt user how to handle unknown airport
         name_label->setText("Unknown airport identifier");
-        emit badInputReceived(line_edit);
+        onBadInputReceived(line_edit);
         return;
     }
     line_edit->setText(airportIcaoIdMap.key(airport_id));
     name_label->setText(airportNameIdMap.key(airport_id));
-    emit goodInputReceived(line_edit);
+    onGoodInputReceived(line_edit);
 }
 
 /*
@@ -1095,18 +1113,22 @@ void NewFlightDialog::onTimeLineEdit_editingFinished()
 {
     auto sender_object = sender();
     auto line_edit = this->findChild<QLineEdit*>(sender_object->objectName());
-    //DEB(line_edit->objectName() << "Editing Finished -" << line_edit->text());
+    DEB(line_edit->objectName() << "Editing Finished -" << line_edit->text());
 
     line_edit->setText(ACalc::formatTimeInput(line_edit->text()));
     const auto time = QTime::fromString(line_edit->text(),TIME_FORMAT);
     if(time.isValid()){
         if(primaryTimeLineEdits.contains(line_edit)) {
-            emit goodInputReceived(line_edit);
+            onGoodInputReceived(line_edit);
         } else { // is extra time line edit
-
+            isLessOrEqualThanBlockTime(line_edit->text());
+            line_edit->setText("");
+            line_edit->setFocus();
+            return;
         }
     } else {
-        emit badInputReceived(line_edit);
+        if (!line_edit->text().isEmpty())
+            onBadInputReceived(line_edit);
     }
 }
 
@@ -1123,12 +1145,13 @@ void NewFlightDialog::on_acftLineEdit_editingFinished()
         DEB("Mapped: " << line_edit->text() << tailsIdMap.value(line_edit->text()));
         auto acft = aDB()->getTailEntry(tailsIdMap.value(line_edit->text()));
         ui->acftTypeLabel->setText(acft.type());
-        emit goodInputReceived(line_edit);
+        onGoodInputReceived(line_edit);
         return;
     }
 
     // try to fix input
-    if (!line_edit->completer()->currentCompletion().isEmpty()) {
+    if (!line_edit->completer()->currentCompletion().isEmpty()
+            && !line_edit->text().isEmpty()) {
         DEB("Trying to fix input...");
         line_edit->setText(line_edit->completer()->currentCompletion());
         emit line_edit->editingFinished();
@@ -1136,7 +1159,7 @@ void NewFlightDialog::on_acftLineEdit_editingFinished()
     }
 
     // to do: promp user to add new
-    emit badInputReceived(line_edit);
+    onBadInputReceived(line_edit);
     ui->acftTypeLabel->setText("Unknown Registration.");
     addNewTail(line_edit);
 }
@@ -1156,7 +1179,7 @@ void NewFlightDialog::onPilotNameLineEdit_editingFinished()
         line_edit->setText(pilotsIdMap.key(1));
         auto pilot = aDB()->getPilotEntry(1);
         ui->picCompanyLabel->setText(pilot.getData().value("company"));
-        emit goodInputReceived(line_edit);
+        onGoodInputReceived(line_edit);
         return;
     }
 
@@ -1164,7 +1187,7 @@ void NewFlightDialog::onPilotNameLineEdit_editingFinished()
         DEB("Mapped: " << line_edit->text() << pilotsIdMap.value(line_edit->text()));
         auto pilot = aDB()->getPilotEntry(pilotsIdMap.value(line_edit->text()));
         ui->picCompanyLabel->setText(pilot.getData().value("company"));
-        emit goodInputReceived(line_edit);
+        onGoodInputReceived(line_edit);
         return;
     }
 
@@ -1180,7 +1203,7 @@ void NewFlightDialog::onPilotNameLineEdit_editingFinished()
     }
 
     // to do: prompt user to add new
-    emit badInputReceived(line_edit);
+    onBadInputReceived(line_edit);
     addNewPilot(line_edit);
 }
 
@@ -1218,7 +1241,7 @@ void NewFlightDialog::on_PilotFlyingCheckBox_stateChanged(int)
 void NewFlightDialog::on_IfrCheckBox_stateChanged(int)
 {
     if (mandatoryLineEditsGood.count(true) == 7 && updateEnabled)
-        emit mandatoryLineEditsFilled();
+        onMandatoryLineEditsFilled();
 }
 
 void NewFlightDialog::on_manualEditingCheckBox_stateChanged(int arg1)
@@ -1242,7 +1265,7 @@ void NewFlightDialog::on_manualEditingCheckBox_stateChanged(int arg1)
         }
         updateEnabled = true;
         if (mandatoryLineEditsGood.count(true) == 7 && updateEnabled)
-            emit mandatoryLineEditsFilled();
+            onMandatoryLineEditsFilled();
         break;
     case 2:
         for(const auto& le : LE){

+ 40 - 17
src/gui/dialogues/newflightdialog.h

@@ -50,33 +50,31 @@ class NewFlightDialog : public QDialog
     Q_OBJECT
 
 public:
+    /*!
+     * \brief NewFlightDialog create a new flight and add it to the logbook.
+     */
     explicit NewFlightDialog(QWidget *parent = nullptr);
+    /*!
+     * \brief NewFlightDialog Edit an existing logbook entry.
+     */
     explicit NewFlightDialog(int row_id, QWidget *parent = nullptr);
     ~NewFlightDialog();
 
-signals:
-    void goodInputReceived(QLineEdit*);
-    void badInputReceived(QLineEdit*);
-    void locationEditingFinished(QLineEdit*, QLabel*);
-    void timeEditingFinished(QLineEdit*);
-    void mandatoryLineEditsFilled();
-
 private slots:
-    void onGoodInputReceived(QLineEdit*);
-    void onBadInputReceived(QLineEdit *);
+
+    /////// DEBUG
+        void onInputRejected();
+    /////// DEBUG
+
     void onToUpperTriggered_textChanged(const QString&);
     void onPilotNameLineEdit_editingFinished();
-    void onLocLineEdit_editingFinished(QLineEdit*, QLabel*);
+    void onLocationEditingFinished(QLineEdit*, QLabel*);
     void onTimeLineEdit_editingFinished();
-    void onMandatoryLineEditsFilled();
     void onCompleter_highlighted(const QString&);
     void onCompleter_activated(const QString &);
     void onCalendarWidget_clicked(const QDate &date);
     void onCalendarWidget_selected(const QDate &date);
     void onDoftLineEdit_entered();
-/////// DEBUG
-    void onInputRejected();
-/////// DEBUG
     void on_calendarCheckBox_stateChanged(int arg1);
     void on_doftLineEdit_editingFinished();
     void on_cancelButton_clicked();
@@ -95,40 +93,65 @@ private slots:
 private:
     Ui::NewFlight *ui;
 
+    /*!
+     * \brief a AFlightEntry object that is used to store either position data
+     * from an old entry, is used to fill the form for editing an entry, or is
+     * filled with new data for adding a new entry to the logbook.
+     */
     experimental::AFlightEntry flightEntry;
 
     QList<QLineEdit*> mandatoryLineEdits;
     QList<QLineEdit*> primaryTimeLineEdits;
     QList<QLineEdit*> pilotsLineEdits;
 
+    /*!
+     * \brief holds a bit for each mandatory line edit that is flipped
+     * according to its validity state
+     */
     QBitArray mandatoryLineEditsGood;
 
+    /*!
+     * To be used by the QCompleters
+     */
     QStringList pilotList;
     QStringList tailsList;
     QStringList airportList;
 
+    /*!
+     * \brief Used to map user input to database keys
+     */
     QMap<QString, int> pilotsIdMap;
     QMap<QString, int> tailsIdMap;
     QMap<QString, int> airportIcaoIdMap;
     QMap<QString, int> airportIataIdMap;
     QMap<QString, int> airportNameIdMap;
 
+    /*!
+     * \brief If the user elects to manually edit function times, automatic updating
+     * is disabled.
+     */
+    bool updateEnabled;
+
     void setup();
     void readSettings();
     void writeSettings();
     void setupButtonGroups();
     void setPopUpCalendarEnabled(bool state);
     void setupRawInputValidation();
-    void setupLineEditSignalsAndSlots();
+    void setupSignalsAndSlots();
     void formFiller();
     void fillDeductibleData();
-    experimental::TableData collectInput();
+
+    void onMandatoryLineEditsFilled();
+    void onGoodInputReceived(QLineEdit*);
+    void onBadInputReceived(QLineEdit *);
     bool eventFilter(QObject *object, QEvent *event);
-    bool updateEnabled;
     bool isLessOrEqualThanBlockTime(const QString time_string);
 
     void addNewTail(QLineEdit*);
     void addNewPilot(QLineEdit *);
+
+    experimental::TableData collectInput();
 };
 
 

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

@@ -144,7 +144,7 @@ void AircraftWidget::on_aircraftSearchLineEdit_textChanged(const QString &arg1)
     model->setFilter(ui->aircraftSearchComboBox->currentText() + " LIKE \"%" + arg1 + "%\"");
 }
 
-void AircraftWidget::onDatabaseChanged()
+void AircraftWidget::onDisplayModel_dataBaseUpdated()
 {
     //refresh view to reflect changes the user has made via a dialog.
     model->select();

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

@@ -56,7 +56,7 @@ private slots:
     void on_aircraftSearchLineEdit_textChanged(const QString &arg1);
 
 public slots:
-    void onDatabaseChanged();
+    void onDisplayModel_dataBaseUpdated();
 
 private:
     Ui::AircraftWidget *ui;

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

@@ -293,13 +293,13 @@ void LogbookWidget::on_flightSearchComboBox_currentIndexChanged(int)
     emit ui->showAllButton->clicked();
 }
 
-void LogbookWidget::onDatabaseChanged()
+void LogbookWidget::onDisplayModel_dataBaseUpdated()
 {
     //refresh view to reflect changes the user has made via a dialog.
     displayModel->select();
 }
 
-void LogbookWidget::onLogbookviewSelectionChanged(int view_id)
+void LogbookWidget::on_logbookViewSelectionChanged(int view_id)
 {
     prepareModelAndView(view_id);
 }

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

@@ -58,8 +58,8 @@ private slots:
     void on_flightSearchComboBox_currentIndexChanged(int);
 
 public slots:
-    void onDatabaseChanged();
-    void onLogbookviewSelectionChanged(int);
+    void onDisplayModel_dataBaseUpdated();
+    void on_logbookViewSelectionChanged(int);
 
 private:
     Ui::LogbookWidget *ui;

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

@@ -71,7 +71,7 @@ void PilotsWidget::on_pilotSearchLineEdit_textChanged(const QString &arg1)
     model->setFilter("\"" + ui->pilotsSearchComboBox->currentText() + "\" LIKE \"%" + arg1 + "%\" AND ID > 1");
 }
 
-void PilotsWidget::onDatabaseChanged()
+void PilotsWidget::onDisplayModel_dataBaseUpdated()
 {
     //refresh view to reflect changes the user has made via a dialog.
     model->select();

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

@@ -49,7 +49,7 @@ private slots:
     void on_pilotSearchLineEdit_textChanged(const QString &arg1);
 
 public slots:
-    void onDatabaseChanged();
+    void onDisplayModel_dataBaseUpdated();
 
 private:
     Ui::PilotsWidget *ui;

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

@@ -279,7 +279,7 @@ void SettingsWidget::themeGroup_toggled(int id)
 void SettingsWidget::on_logbookViewComboBox_currentIndexChanged(int index)
 {
     ASettings::write("logbook/view", index);
-    emit logbookviewSelectionChanged(index);
+    emit logbookViewSelectionChanged(index);
 }
 void SettingsWidget::on_pilotSortComboBox_currentIndexChanged(int index)
 {

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

@@ -70,7 +70,7 @@ private:
 
     void updatePersonalDetails();
 signals:
-    void logbookviewSelectionChanged(int view_id);
+    void logbookViewSelectionChanged(int view_id);
 };
 
 #endif // SETTINGSWIDGET_H