Kaynağa Gözat

Fixed autopopulate for new Tail

Autopopulation of the registration when adding a new tail during adding a new flight, the registration now correctly auto-populates.

Also fixed a bug where empty pilot names in NewFlightDialog would autopopulate to first QCompleter Suggestion
Felix Turowsky 1 yıl önce
ebeveyn
işleme
f454665036

+ 14 - 2
src/gui/dialogues/newflightdialog.cpp

@@ -521,6 +521,9 @@ void NewFlightDialog::onTimeLineEdit_editingFinished()
 void NewFlightDialog::onPilotNameLineEdit_editingFinshed()
 {
     auto line_edit = this->findChild<QLineEdit*>(sender()->objectName());
+    if(line_edit->text() == QString())
+        return;
+
     if(!verifyUserInput(line_edit, PilotInput(line_edit->text()))) {
         if(!addNewDatabaseElement(line_edit, OPL::DbTable::Pilots))
             onBadInputReceived(line_edit);
@@ -556,9 +559,18 @@ void NewFlightDialog::on_acftLineEdit_editingFinished()
         return;
     }
 
-    if(!verifyUserInput(line_edit, TailInput(line_edit->text())))
-        if(!addNewDatabaseElement(line_edit, OPL::DbTable::Tails))
+    const QString input = line_edit->text(); // keep around for adding new tail if needed
+
+    if(!verifyUserInput(line_edit, TailInput(line_edit->text()))) {
+        // re-populate user input to hand through to NewTailDialog
+        {
+            QSignalBlocker blocker(line_edit);
+            line_edit->setText(input);
+        }
+        if(!addNewDatabaseElement(line_edit, OPL::DbTable::Tails)) {
             onBadInputReceived(line_edit);
+        }
+    }
 
     const auto space = QLatin1Char(' ');
     if(line_edit->text().contains(space))

+ 13 - 0
src/gui/dialogues/newflightdialog.ui

@@ -516,11 +516,24 @@
   </layout>
  </widget>
  <tabstops>
+  <tabstop>doftLineEdit</tabstop>
   <tabstop>deptLocationLineEdit</tabstop>
   <tabstop>destLocationLineEdit</tabstop>
   <tabstop>tofbTimeLineEdit</tabstop>
   <tabstop>tonbTimeLineEdit</tabstop>
+  <tabstop>functionComboBox</tabstop>
   <tabstop>approachComboBox</tabstop>
+  <tabstop>flightRulesComboBox</tabstop>
+  <tabstop>pilotFlyingCheckBox</tabstop>
+  <tabstop>acftLineEdit</tabstop>
+  <tabstop>picNameLineEdit</tabstop>
+  <tabstop>sicNameLineEdit</tabstop>
+  <tabstop>thirdPilotNameLineEdit</tabstop>
+  <tabstop>flightNumberLineEdit</tabstop>
+  <tabstop>remarksLineEdit</tabstop>
+  <tabstop>takeOffSpinBox</tabstop>
+  <tabstop>landingSpinBox</tabstop>
+  <tabstop>calendarPushButton</tabstop>
  </tabstops>
  <resources/>
  <connections>

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

@@ -21,7 +21,7 @@
 #include "ui_newtail.h"
 #include "src/opl.h"
 
-NewTailDialog::NewTailDialog(QString new_registration, QWidget *parent) :
+NewTailDialog::NewTailDialog(const QString &new_registration, QWidget *parent) :
     EntryEditDialog(parent),
     ui(new Ui::NewTail)
 {

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

@@ -65,7 +65,7 @@ public:
      * \brief NewTailDialog - create a new ATailEntry and submit it to the database
      * \param new_registration - when called from the NewFlightDialog, pre-fills the registration already entered.
      */
-    explicit NewTailDialog(QString new_registration, QWidget *parent = nullptr);
+    explicit NewTailDialog(const QString &new_registration, QWidget *parent = nullptr);
     /*!
      * \brief NewTailDialog - edit an existing Tail Entry
      * \param row_id - the ROW_ID of the entry to be edited in the database