Browse Source

NFF Dialog now operational

- Added eventFilter() to invalidate a line edit on focus in event
- implemented fillWithEntryData() which takes an existing database entry and fills the UI with the entry data
- enabled Database submission and editing
- Dialog active as default in UI
Felix Turo 3 years ago
parent
commit
4342134097

+ 1 - 13
mainwindow.cpp

@@ -241,20 +241,8 @@ void MainWindow::on_actionHome_triggered()
 void MainWindow::on_actionNewFlight_triggered()
 void MainWindow::on_actionNewFlight_triggered()
 {
 {
     completionData.update();
     completionData.update();
-    //NewFlightDialog nf(completionData, this);
-    //nf.exec();
-
-    auto* nf = new NewFlightDialog(completionData, this);
-    //QObject::connect(nf,   &QDialog::accepted,
-    //                 this, &AircraftWidget::onNewTailDialog_editingFinished);
-    //QObject::connect(nf,   &QDialog::rejected,
-    //                 this, &AircraftWidget::onNewTailDialog_editingFinished);
-    ui->stackedWidget->addWidget(nf);
-    ui->stackedWidget->setCurrentWidget(nf);
-    nf->setWindowFlag(Qt::Widget);
-    nf->setAttribute(Qt::WA_DeleteOnClose);
+    auto* nf = new NewNewFlightDialog(completionData, this);
     nf->exec();
     nf->exec();
-    ui->stackedWidget->setCurrentWidget(logbookWidget);
 }
 }
 
 
 void MainWindow::on_actionLogbook_triggered()
 void MainWindow::on_actionLogbook_triggered()

+ 2 - 2
src/functions/acalc.h

@@ -235,8 +235,8 @@ struct NightTimeValues{
     {
     {
         nightMinutes = calculateNightTime(dept, dest, departure_time, block_minutes, night_angle);
         nightMinutes = calculateNightTime(dept, dest, departure_time, block_minutes, night_angle);
 
 
-        nightTime = ATime::fromMinutes(nightMinutes);
-        totalTime = ATime::fromMinutes(block_minutes);
+        nightTime = ATime::qTimefromMinutes(nightMinutes);
+        totalTime = ATime::qTimefromMinutes(block_minutes);
 
 
         if (nightMinutes == 0) { // all day
         if (nightMinutes == 0) { // all day
             takeOffNight = false;
             takeOffNight = false;

+ 1 - 1
src/functions/atime.h

@@ -76,7 +76,7 @@ inline double toDecimalHours(const QTime &time){
     return (time.hour() * 60 + time.minute()) / 60.0;
     return (time.hour() * 60 + time.minute()) / 60.0;
 }
 }
 
 
-inline QTime fromMinutes(int total_minutes)
+inline QTime qTimefromMinutes(int total_minutes)
 {
 {
     int minute = total_minutes % 60;
     int minute = total_minutes % 60;
     int hour = total_minutes / 60;
     int hour = total_minutes / 60;

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

@@ -362,7 +362,7 @@ void NewFlightDialog::fillDeductibleData()
         QString dept_date = ui->doftLineEdit->text() + 'T' + ATime::toString(tofb);
         QString dept_date = ui->doftLineEdit->text() + 'T' + ATime::toString(tofb);
         auto dept_date_time = QDateTime::fromString(dept_date, QStringLiteral("yyyy-MM-ddThh:mm"));
         auto dept_date_time = QDateTime::fromString(dept_date, QStringLiteral("yyyy-MM-ddThh:mm"));
         const int night_angle = ASettings::read(ASettings::FlightLogging::NightAngle).toInt();
         const int night_angle = ASettings::read(ASettings::FlightLogging::NightAngle).toInt();
-        auto night_time = ATime::fromMinutes(ACalc::calculateNightTime(
+        auto night_time = ATime::qTimefromMinutes(ACalc::calculateNightTime(
                                                  ui->deptLocLineEdit->text(),
                                                  ui->deptLocLineEdit->text(),
                                                  ui->destLocLineEdit->text(),
                                                  ui->destLocLineEdit->text(),
                                                  dept_date_time,
                                                  dept_date_time,
@@ -454,7 +454,7 @@ RowData_T NewFlightDialog::collectInput()
             + ATime::toString(tofb);
             + ATime::toString(tofb);
     const auto dept_date_time = QDateTime::fromString(dept_date, QStringLiteral("yyyy-MM-ddThh:mm"));
     const auto dept_date_time = QDateTime::fromString(dept_date, QStringLiteral("yyyy-MM-ddThh:mm"));
     const int night_angle = ASettings::read(ASettings::FlightLogging::NightAngle).toInt();
     const int night_angle = ASettings::read(ASettings::FlightLogging::NightAngle).toInt();
-    const auto night_time = ATime::fromMinutes(ACalc::calculateNightTime(
+    const auto night_time = ATime::qTimefromMinutes(ACalc::calculateNightTime(
                                              ui->deptLocLineEdit->text(),
                                              ui->deptLocLineEdit->text(),
                                              ui->destLocLineEdit->text(),
                                              ui->destLocLineEdit->text(),
                                              dept_date_time,
                                              dept_date_time,

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

@@ -209,7 +209,7 @@ private:
      */
      */
     inline QString minutesToString(const int minutes, Opl::Time::FlightTimeFormat format)
     inline QString minutesToString(const int minutes, Opl::Time::FlightTimeFormat format)
     {
     {
-        return ATime::toString(ATime::fromMinutes(minutes), format);
+        return ATime::toString(ATime::qTimefromMinutes(minutes), format);
     }
     }
 };
 };
 
 

+ 116 - 16
src/gui/dialogues/newnewflightdialog.cpp

@@ -18,9 +18,8 @@ NewNewFlightDialog::NewNewFlightDialog(ACompletionData &completion_data,
       ui(new Ui::NewNewFlightDialog),
       ui(new Ui::NewNewFlightDialog),
       completionData(completion_data)
       completionData(completion_data)
 {
 {
-    ui->setupUi(this);
-    flightEntry = AFlightEntry();
     init();
     init();
+    flightEntry = AFlightEntry();
     // Set up UI (New Flight)
     // Set up UI (New Flight)
     LOG << ASettings::read(ASettings::FlightLogging::Function);
     LOG << ASettings::read(ASettings::FlightLogging::Function);
     if(ASettings::read(ASettings::FlightLogging::Function).toString() == QLatin1String("PIC")){
     if(ASettings::read(ASettings::FlightLogging::Function).toString() == QLatin1String("PIC")){
@@ -38,6 +37,16 @@ NewNewFlightDialog::NewNewFlightDialog(ACompletionData &completion_data,
     emit ui->doftLineEdit->editingFinished();
     emit ui->doftLineEdit->editingFinished();
 }
 }
 
 
+NewNewFlightDialog::NewNewFlightDialog(ACompletionData &completion_data, RowId_T row_id, QWidget *parent)
+    : QDialog(parent),
+      ui(new Ui::NewNewFlightDialog),
+      completionData(completion_data)
+{
+    init();
+    flightEntry = aDB->getFlightEntry(row_id);
+    fillWithEntryData();
+}
+
 NewNewFlightDialog::~NewNewFlightDialog()
 NewNewFlightDialog::~NewNewFlightDialog()
 {
 {
     delete ui;
     delete ui;
@@ -45,6 +54,8 @@ NewNewFlightDialog::~NewNewFlightDialog()
 
 
 void NewNewFlightDialog::init()
 void NewNewFlightDialog::init()
 {
 {
+    // Setup UI
+    ui->setupUi(this);
     // Initialise line edit lists
     // Initialise line edit lists
     auto time_line_edits = new QList<QLineEdit*>{ui->tofbTimeLineEdit, ui->tonbTimeLineEdit};
     auto time_line_edits = new QList<QLineEdit*>{ui->tofbTimeLineEdit, ui->tonbTimeLineEdit};
     timeLineEdits = time_line_edits;
     timeLineEdits = time_line_edits;
@@ -58,6 +69,9 @@ void NewNewFlightDialog::init()
     // {doft = 0, dept = 1, dest = 2, tofb = 3, tonb = 4, pic = 5, acft = 6}
     // {doft = 0, dept = 1, dest = 2, tofb = 3, tonb = 4, pic = 5, acft = 6}
     mandatoryLineEdits = mandatory_line_edits;
     mandatoryLineEdits = mandatory_line_edits;
 
 
+    for (const auto& line_edit : *mandatoryLineEdits)
+        line_edit->installEventFilter(this);
+
     for (const auto & approach : Opl::ApproachTypes){
     for (const auto & approach : Opl::ApproachTypes){
         ui->approachComboBox->addItem(approach);
         ui->approachComboBox->addItem(approach);
     }
     }
@@ -124,6 +138,20 @@ void NewNewFlightDialog::setupSignalsAndSlots()
                          this, &NewNewFlightDialog::onPilotNameLineEdit_editingFinshed);
                          this, &NewNewFlightDialog::onPilotNameLineEdit_editingFinshed);
 }
 }
 
 
+bool NewNewFlightDialog::eventFilter(QObject *object, QEvent *event)
+{
+    auto line_edit = qobject_cast<QLineEdit*>(object);
+    if (line_edit != nullptr) {
+        if (mandatoryLineEdits->contains(line_edit) && event->type() == QEvent::FocusIn) {
+            // set verification bit to false when entering a mandatory line edit
+            validationState.invalidate(mandatoryLineEdits->indexOf(line_edit));
+            DEB << "Invalidating: " << line_edit->objectName();
+            return false;
+        }
+    }
+    return false;
+}
+
 void NewNewFlightDialog::readSettings()
 void NewNewFlightDialog::readSettings()
 {
 {
     ASettings settings;
     ASettings settings;
@@ -135,6 +163,70 @@ void NewNewFlightDialog::readSettings()
 
 
 }
 }
 
 
+/*!
+ * \brief NewNewFlightDialog::fillWithEntryData Takes an existing flight entry and fills the UI with its data
+ * to enable editing an existing flight.
+ */
+void NewNewFlightDialog::fillWithEntryData()
+{
+    DEB << "Restoring Flight: ";
+    DEB << flightEntry;
+
+    // Date of Flight
+    ui->doftLineEdit->setText(flightEntry.getData().value(Opl::Db::FLIGHTS_DOFT).toString());
+    // Location
+    ui->deptLocationLineEdit->setText(flightEntry.getData().value(Opl::Db::FLIGHTS_DEPT).toString());
+    ui->destLocationLineEdit->setText(flightEntry.getData().value(Opl::Db::FLIGHTS_DEST).toString());
+    // Times
+    ui->tofbTimeLineEdit->setText(ATime::toString(flightEntry.getData().value(Opl::Db::FLIGHTS_TOFB).toInt()));
+    ui->tonbTimeLineEdit->setText(ATime::toString(flightEntry.getData().value(Opl::Db::FLIGHTS_TONB).toInt()));
+    ui->acftLineEdit->setText(completionData.tailsIdMap.value(flightEntry.getData().value(Opl::Db::FLIGHTS_ACFT).toInt()));
+    ui->picNameLineEdit->setText(completionData.pilotsIdMap.value(flightEntry.getData().value(Opl::Db::FLIGHTS_PIC).toInt()));
+    ui->sicNameLineEdit->setText(completionData.pilotsIdMap.value(flightEntry.getData().value(Opl::Db::FLIGHTS_SECONDPILOT).toInt()));
+    ui->thirdPilotNameLineEdit->setText(completionData.pilotsIdMap.value(flightEntry.getData().value(Opl::Db::FLIGHTS_THIRDPILOT).toInt()));
+
+    for (const auto& le : *mandatoryLineEdits)
+        emit le->editingFinished();
+
+    //Function
+    const QHash<int, QLatin1String> functions = {
+        {0, Opl::Db::FLIGHTS_TPIC},
+        {1, Opl::Db::FLIGHTS_TPICUS},
+        {2, Opl::Db::FLIGHTS_TSIC},
+        {3, Opl::Db::FLIGHTS_TDUAL},
+        {4, Opl::Db::FLIGHTS_TFI},
+    };
+    for (int i = 0; i < 5; i++) { // QHash::iterator not guarenteed to be in ordetr
+        if(flightEntry.getData().value(functions.value(i)).toInt() != 0)
+            ui->functionComboBox->setCurrentIndex(i);
+    }
+    // Approach ComboBox
+    const QString& app = flightEntry.getData().value(Opl::Db::FLIGHTS_APPROACHTYPE).toString();
+    if(app != QString()){
+        ui->approachComboBox->setCurrentText(app);
+    }
+    // Task
+    bool PF = flightEntry.getData().value(Opl::Db::FLIGHTS_PILOTFLYING).toBool();
+    ui->pilotFlyingCheckBox->setChecked(PF);
+    // Flight Rules
+    bool time_ifr = flightEntry.getData().value(Opl::Db::FLIGHTS_TIFR).toBool();
+    ui->ifrCheckBox->setChecked(time_ifr);
+    // Take-Off and Landing
+    int TO = flightEntry.getData().value(Opl::Db::FLIGHTS_TODAY).toInt()
+            + flightEntry.getData().value(Opl::Db::FLIGHTS_TONIGHT).toInt();
+    int LDG = flightEntry.getData().value(Opl::Db::FLIGHTS_LDGDAY).toInt()
+            + flightEntry.getData().value(Opl::Db::FLIGHTS_LDGNIGHT).toInt();
+    ui->takeOffSpinBox->setValue(TO);
+    ui->landingSpinBox->setValue(LDG);
+    // Remarks
+    ui->remarksLineEdit->setText(flightEntry.getData().value(Opl::Db::FLIGHTS_REMARKS).toString());
+    // Flight Number
+    ui->flightNumberLineEdit->setText(flightEntry.getData().value(Opl::Db::FLIGHTS_FLIGHTNUMBER).toString());
+
+    for(const auto &line_edit : *mandatoryLineEdits)
+        emit line_edit->editingFinished();
+}
+
 void NewNewFlightDialog::onGoodInputReceived(QLineEdit *line_edit)
 void NewNewFlightDialog::onGoodInputReceived(QLineEdit *line_edit)
 {
 {
     DEB << line_edit->objectName() << " - Good input received - " << line_edit->text();
     DEB << line_edit->objectName() << " - Good input received - " << line_edit->text();
@@ -248,6 +340,11 @@ void NewNewFlightDialog::addNewPilot(QLineEdit& parent_line_edit)
     }
     }
 }
 }
 
 
+/*!
+ * \brief NewNewFlightDialog::prepareFlightEntryData reads the user input from the UI and converts it into
+ * the database format.
+ * \return RowData_T a map containing a row ready for database submission
+ */
 RowData_T NewNewFlightDialog::prepareFlightEntryData()
 RowData_T NewNewFlightDialog::prepareFlightEntryData()
 {
 {
     if(!validationState.allValid())
     if(!validationState.allValid())
@@ -312,6 +409,8 @@ RowData_T NewNewFlightDialog::prepareFlightEntryData()
         else
         else
             new_data.insert(function_times[i], QString());
             new_data.insert(function_times[i], QString());
     }
     }
+    if (ui->functionComboBox->currentIndex() == 4)
+        new_data.insert(Opl::Db::FLIGHTS_PIC, block_minutes); // Log FI time as PIC as well
     // Pilot flying / Pilot monitoring
     // Pilot flying / Pilot monitoring
     new_data.insert(Opl::Db::FLIGHTS_PILOTFLYING, ui->pilotFlyingCheckBox->isChecked());
     new_data.insert(Opl::Db::FLIGHTS_PILOTFLYING, ui->pilotFlyingCheckBox->isChecked());
     // Take-Off and Landing
     // Take-Off and Landing
@@ -422,6 +521,8 @@ void NewNewFlightDialog::onPilotNameLineEdit_editingFinshed()
     }
     }
 
 
     if (line_edit->text().isEmpty()) {
     if (line_edit->text().isEmpty()) {
+        if (line_edit->objectName() == QLatin1String("picNameLineEdit"))
+            validationState.invalidate(mandatoryLineEdits->indexOf(line_edit));
         return;
         return;
     }
     }
 
 
@@ -476,8 +577,6 @@ void NewNewFlightDialog::on_acftLineEdit_editingFinished()
     DEB << "acft_id: " << acft_id;
     DEB << "acft_id: " << acft_id;
 
 
     if (acft_id != 0) { // Success
     if (acft_id != 0) { // Success
-        auto acft = aDB->getTailEntry(acft_id);
-        ui->acftDisplayLabel->setText(acft.type());
         onGoodInputReceived(line_edit);
         onGoodInputReceived(line_edit);
         return;
         return;
     }
     }
@@ -491,7 +590,6 @@ void NewNewFlightDialog::on_acftLineEdit_editingFinished()
 
 
     // Mark as bad input and prompt for adding new tail
     // Mark as bad input and prompt for adding new tail
     onBadInputReceived(line_edit);
     onBadInputReceived(line_edit);
-    ui->acftDisplayLabel->setText(tr("Unknown Registration."));
     if (!(line_edit->text() == QString()))
     if (!(line_edit->text() == QString()))
         addNewTail(*line_edit);
         addNewTail(*line_edit);
 }
 }
@@ -557,6 +655,8 @@ void NewNewFlightDialog::on_functionComboBox_currentIndexChanged(int index)
 
 
 void NewNewFlightDialog::on_buttonBox_accepted()
 void NewNewFlightDialog::on_buttonBox_accepted()
 {
 {
+    for (const auto& line_edit : *mandatoryLineEdits)
+        emit line_edit->editingFinished();
     // If input verification is passed, continue, otherwise prompt user to correct
     // If input verification is passed, continue, otherwise prompt user to correct
     if (!validationState.allValid()) {
     if (!validationState.allValid()) {
         const auto display_names = QMap<ValidationItem, QString> {
         const auto display_names = QMap<ValidationItem, QString> {
@@ -581,22 +681,22 @@ void NewNewFlightDialog::on_buttonBox_accepted()
         return;
         return;
     }
     }
 
 
-
     // If input verification passed, collect input and submit to database
     // If input verification passed, collect input and submit to database
     auto newData = prepareFlightEntryData();
     auto newData = prepareFlightEntryData();
+    DEB << "Old Data: ";
+    DEB << flightEntry;
 
 
     //DEB << "Setting Data for flightEntry...";
     //DEB << "Setting Data for flightEntry...";
     flightEntry.setData(newData);
     flightEntry.setData(newData);
     DEB << "Committing: ";
     DEB << "Committing: ";
     DEB << flightEntry;
     DEB << flightEntry;
-    //if (!aDB->commit(flightEntry)) {
-    //    WARN(tr("The following error has ocurred:"
-    //                           "<br><br>%1<br><br>"
-    //                           "The entry has not been saved."
-    //                           ).arg(aDB->lastError.text()));
-    //    return;
-    //} else {
-    //    QDialog::accept();
-    //}
+    if (!aDB->commit(flightEntry)) {
+        WARN(tr("The following error has ocurred:"
+                               "<br><br>%1<br><br>"
+                               "The entry has not been saved."
+                               ).arg(aDB->lastError.text()));
+        return;
+    } else {
+        QDialog::accept();
+    }
 }
 }
-

+ 4 - 0
src/gui/dialogues/newnewflightdialog.h

@@ -90,6 +90,7 @@ class NewNewFlightDialog : public QDialog
 public:
 public:
 
 
     explicit NewNewFlightDialog(ACompletionData& completion_data, QWidget *parent = nullptr);
     explicit NewNewFlightDialog(ACompletionData& completion_data, QWidget *parent = nullptr);
+    explicit NewNewFlightDialog(ACompletionData& completion_data, RowId_T row_id, QWidget* parent = nullptr);
     ~NewNewFlightDialog();
     ~NewNewFlightDialog();
 
 
 private:
 private:
@@ -114,6 +115,7 @@ private:
     void setupRawInputValidation();
     void setupRawInputValidation();
     void setupSignalsAndSlots();
     void setupSignalsAndSlots();
     void readSettings();
     void readSettings();
+    void fillWithEntryData();
 
 
     void onGoodInputReceived(QLineEdit *line_edit);
     void onGoodInputReceived(QLineEdit *line_edit);
     void onBadInputReceived(QLineEdit *line_edit);
     void onBadInputReceived(QLineEdit *line_edit);
@@ -139,6 +141,8 @@ private slots:
     void on_pilotFlyingCheckBox_stateChanged(int arg1);
     void on_pilotFlyingCheckBox_stateChanged(int arg1);
     void on_approachComboBox_currentTextChanged(const QString &arg1);
     void on_approachComboBox_currentTextChanged(const QString &arg1);
     void on_functionComboBox_currentIndexChanged(int index);
     void on_functionComboBox_currentIndexChanged(int index);
+protected:
+    bool eventFilter(QObject* object, QEvent* event) override;
 };
 };
 
 
 
 

+ 293 - 266
src/gui/dialogues/newnewflightdialog.ui

@@ -6,101 +6,73 @@
    <rect>
    <rect>
     <x>0</x>
     <x>0</x>
     <y>0</y>
     <y>0</y>
-    <width>960</width>
-    <height>252</height>
+    <width>1022</width>
+    <height>262</height>
    </rect>
    </rect>
   </property>
   </property>
   <property name="windowTitle">
   <property name="windowTitle">
    <string>Dialog</string>
    <string>Dialog</string>
   </property>
   </property>
   <layout class="QGridLayout" name="gridLayout_4">
   <layout class="QGridLayout" name="gridLayout_4">
-   <item row="1" column="2">
-    <widget class="QToolButton" name="toolButton">
-     <property name="text">
-      <string>?</string>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="1">
-    <widget class="QPushButton" name="pushButton_2">
-     <property name="text">
-      <string>Details</string>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="5">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="enabled">
-      <bool>true</bool>
-     </property>
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="6">
-    <spacer name="rightSpacer">
+   <item row="0" column="0">
+    <spacer name="leftSpacer">
      <property name="orientation">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
       <enum>Qt::Horizontal</enum>
      </property>
      </property>
      <property name="sizeHint" stdset="0">
      <property name="sizeHint" stdset="0">
       <size>
       <size>
-       <width>48</width>
-       <height>20</height>
+       <width>23</width>
+       <height>203</height>
       </size>
       </size>
      </property>
      </property>
     </spacer>
     </spacer>
    </item>
    </item>
-   <item row="0" column="1" colspan="5">
+   <item row="0" column="1" colspan="3">
     <layout class="QGridLayout" name="gridLayout_3">
     <layout class="QGridLayout" name="gridLayout_3">
      <item row="0" column="0">
      <item row="0" column="0">
       <layout class="QGridLayout" name="gridLayout">
       <layout class="QGridLayout" name="gridLayout">
-       <item row="5" column="1">
-        <widget class="QLabel" name="tblkDisplayLabel">
+       <item row="0" column="0">
+        <widget class="QLabel" name="doftLabel">
          <property name="text">
          <property name="text">
-          <string>00:00</string>
+          <string>Date of flight</string>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="2" column="4">
-        <widget class="QLineEdit" name="sicNameLineEdit">
-         <property name="maximumSize">
-          <size>
-           <width>120</width>
-           <height>16777215</height>
-          </size>
+       <item row="4" column="3">
+        <widget class="QLabel" name="flightNumberLabel">
+         <property name="text">
+          <string>Flight Number</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="2" column="0">
-        <widget class="QLabel" name="destLabel">
+       <item row="2" column="3">
+        <widget class="QLabel" name="sicLabel">
          <property name="text">
          <property name="text">
-          <string>Destination</string>
+          <string>SIC</string>
          </property>
          </property>
-        </widget>
-       </item>
-       <item row="1" column="4">
-        <widget class="QLineEdit" name="picNameLineEdit">
-         <property name="maximumSize">
-          <size>
-           <width>120</width>
-           <height>16777215</height>
-          </size>
+         <property name="alignment">
+          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="0" column="0">
-        <widget class="QLabel" name="doftLabel">
+       <item row="4" column="0">
+        <widget class="QLabel" name="tonbLabel">
          <property name="text">
          <property name="text">
-          <string>Date of flight</string>
+          <string>On Blocks</string>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
        <item row="0" column="4">
        <item row="0" column="4">
         <widget class="QLineEdit" name="acftLineEdit">
         <widget class="QLineEdit" name="acftLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>160</width>
+           <height>0</height>
+          </size>
+         </property>
          <property name="maximumSize">
          <property name="maximumSize">
           <size>
           <size>
            <width>120</width>
            <width>120</width>
@@ -109,6 +81,26 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
+       <item row="0" column="3">
+        <widget class="QLabel" name="acftLabel">
+         <property name="text">
+          <string>Aircraft</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="3">
+        <widget class="QLabel" name="picLabel">
+         <property name="text">
+          <string>PIC</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+         </property>
+        </widget>
+       </item>
        <item row="5" column="0">
        <item row="5" column="0">
         <widget class="QLabel" name="tblkLabel">
         <widget class="QLabel" name="tblkLabel">
          <property name="text">
          <property name="text">
@@ -116,24 +108,47 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="4" column="2">
-        <widget class="QLabel" name="tonbSpacerLabel">
-         <property name="enabled">
-          <bool>false</bool>
+       <item row="5" column="3">
+        <widget class="QLabel" name="remarksLabel">
+         <property name="text">
+          <string>Remarks</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
          </property>
          </property>
+        </widget>
+       </item>
+       <item row="4" column="4">
+        <widget class="QLineEdit" name="flightNumberLineEdit">
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>160</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
+         <property name="maximumSize">
+          <size>
+           <width>120</width>
+           <height>16777215</height>
+          </size>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QLabel" name="deptLabel">
          <property name="text">
          <property name="text">
-          <string/>
+          <string>Departure</string>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="5" column="4">
-        <widget class="QLineEdit" name="remarksLineEdit">
+       <item row="0" column="1">
+        <widget class="QLineEdit" name="doftLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>160</width>
+           <height>0</height>
+          </size>
+         </property>
          <property name="maximumSize">
          <property name="maximumSize">
           <size>
           <size>
            <width>120</width>
            <width>120</width>
@@ -142,91 +157,99 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="3" column="2">
-        <widget class="QLabel" name="tofbSpacerLabel">
-         <property name="enabled">
-          <bool>false</bool>
+       <item row="2" column="0">
+        <widget class="QLabel" name="destLabel">
+         <property name="text">
+          <string>Destination</string>
          </property>
          </property>
+        </widget>
+       </item>
+       <item row="2" column="1">
+        <widget class="QLineEdit" name="destLocationLineEdit">
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>160</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
-         <property name="text">
-          <string/>
+         <property name="maximumSize">
+          <size>
+           <width>120</width>
+           <height>16777215</height>
+          </size>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="1" column="2">
-        <widget class="QLabel" name="deptNameLabel">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
+       <item row="0" column="2">
+        <widget class="QLabel" name="doftDisplayLabel">
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>200</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
-         <property name="font">
-          <font>
-           <italic>true</italic>
-          </font>
+         <property name="maximumSize">
+          <size>
+           <width>200</width>
+           <height>16777215</height>
+          </size>
          </property>
          </property>
          <property name="text">
          <property name="text">
           <string/>
           <string/>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="1" column="5">
-        <widget class="QLabel" name="picNameDisplayLabel">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
+       <item row="1" column="1">
+        <widget class="QLineEdit" name="deptLocationLineEdit">
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>160</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
-         <property name="text">
-          <string/>
-         </property>
-        </widget>
-       </item>
-       <item row="1" column="0">
-        <widget class="QLabel" name="deptLabel">
-         <property name="text">
-          <string>Departure</string>
+         <property name="maximumSize">
+          <size>
+           <width>120</width>
+           <height>16777215</height>
+          </size>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="2" column="5">
-        <widget class="QLabel" name="sicNameDisplayLabel">
+       <item row="1" column="2">
+        <widget class="QLabel" name="deptNameLabel">
          <property name="enabled">
          <property name="enabled">
           <bool>false</bool>
           <bool>false</bool>
          </property>
          </property>
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>200</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
+         <property name="maximumSize">
+          <size>
+           <width>200</width>
+           <height>16777215</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <italic>true</italic>
+          </font>
+         </property>
          <property name="text">
          <property name="text">
           <string/>
           <string/>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="3" column="0">
-        <widget class="QLabel" name="tofbLabel">
-         <property name="text">
-          <string>Off Blocks</string>
+       <item row="1" column="4">
+        <widget class="QLineEdit" name="picNameLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>160</width>
+           <height>0</height>
+          </size>
          </property>
          </property>
-        </widget>
-       </item>
-       <item row="4" column="4">
-        <widget class="QLineEdit" name="flightNumberLineEdit">
          <property name="maximumSize">
          <property name="maximumSize">
           <size>
           <size>
            <width>120</width>
            <width>120</width>
@@ -235,8 +258,14 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="0" column="1">
-        <widget class="QLineEdit" name="doftLineEdit">
+       <item row="2" column="4">
+        <widget class="QLineEdit" name="sicNameLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>160</width>
+           <height>0</height>
+          </size>
+         </property>
          <property name="maximumSize">
          <property name="maximumSize">
           <size>
           <size>
            <width>120</width>
            <width>120</width>
@@ -245,144 +274,115 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="4" column="3">
-        <widget class="QLabel" name="flightNumberLabel">
-         <property name="text">
-          <string>Flight Number</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
-         </property>
-        </widget>
-       </item>
-       <item row="5" column="5">
-        <widget class="QLabel" name="remarksSpacerLabel">
+       <item row="2" column="2">
+        <widget class="QLabel" name="destNameLabel">
          <property name="enabled">
          <property name="enabled">
           <bool>false</bool>
           <bool>false</bool>
          </property>
          </property>
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>200</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
+         <property name="maximumSize">
+          <size>
+           <width>200</width>
+           <height>16777215</height>
+          </size>
+         </property>
+         <property name="font">
+          <font>
+           <italic>true</italic>
+          </font>
+         </property>
          <property name="text">
          <property name="text">
           <string/>
           <string/>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="5" column="3">
-        <widget class="QLabel" name="remarksLabel">
+       <item row="3" column="0">
+        <widget class="QLabel" name="tofbLabel">
          <property name="text">
          <property name="text">
-          <string>Remarks</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+          <string>Off Blocks</string>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="3" column="3">
-        <widget class="QLabel" name="thirdPilotLabel">
-         <property name="text">
-          <string>Third Pilot</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+       <item row="3" column="2">
+        <widget class="QLabel" name="tofbSpacerLabel">
+         <property name="enabled">
+          <bool>false</bool>
          </property>
          </property>
-        </widget>
-       </item>
-       <item row="5" column="2">
-        <widget class="QLabel" name="submissionReadyLabel">
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>200</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
-         <property name="text">
-          <string/>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="4">
-        <widget class="QLineEdit" name="thirdPilotNameLineEdit">
          <property name="maximumSize">
          <property name="maximumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>200</width>
            <height>16777215</height>
            <height>16777215</height>
           </size>
           </size>
          </property>
          </property>
-        </widget>
-       </item>
-       <item row="2" column="3">
-        <widget class="QLabel" name="sicLabel">
          <property name="text">
          <property name="text">
-          <string>SIC</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+          <string/>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="3" column="1">
-        <widget class="QLineEdit" name="tofbTimeLineEdit">
+       <item row="4" column="2">
+        <widget class="QLabel" name="tonbSpacerLabel">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>200</width>
+           <height>0</height>
+          </size>
+         </property>
          <property name="maximumSize">
          <property name="maximumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>200</width>
            <height>16777215</height>
            <height>16777215</height>
           </size>
           </size>
          </property>
          </property>
+         <property name="text">
+          <string/>
+         </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="4" column="5">
-        <widget class="QLabel" name="flightNumberSpacerLabel">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
+       <item row="5" column="1">
+        <widget class="QLabel" name="tblkDisplayLabel">
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>160</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
          <property name="text">
          <property name="text">
-          <string/>
+          <string>00:00</string>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="1" column="3">
-        <widget class="QLabel" name="picLabel">
+       <item row="3" column="3">
+        <widget class="QLabel" name="thirdPilotLabel">
          <property name="text">
          <property name="text">
-          <string>PIC</string>
+          <string>Third Pilot</string>
          </property>
          </property>
          <property name="alignment">
          <property name="alignment">
           <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
           <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="0" column="5">
-        <widget class="QLabel" name="acftDisplayLabel">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
+       <item row="4" column="1">
+        <widget class="QLineEdit" name="tonbTimeLineEdit">
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>160</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
-         <property name="font">
-          <font>
-           <italic>true</italic>
-          </font>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-        </widget>
-       </item>
-       <item row="4" column="1">
-        <widget class="QLineEdit" name="tonbTimeLineEdit">
          <property name="maximumSize">
          <property name="maximumSize">
           <size>
           <size>
            <width>120</width>
            <width>120</width>
@@ -391,39 +391,30 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="2" column="2">
-        <widget class="QLabel" name="destNameLabel">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
+       <item row="5" column="4">
+        <widget class="QLineEdit" name="remarksLineEdit">
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>160</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
-         <property name="font">
-          <font>
-           <italic>true</italic>
-          </font>
-         </property>
-         <property name="text">
-          <string/>
+         <property name="maximumSize">
+          <size>
+           <width>120</width>
+           <height>16777215</height>
+          </size>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="0" column="3">
-        <widget class="QLabel" name="acftLabel">
-         <property name="text">
-          <string>Aircraft</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+       <item row="3" column="1">
+        <widget class="QLineEdit" name="tofbTimeLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>160</width>
+           <height>0</height>
+          </size>
          </property>
          </property>
-        </widget>
-       </item>
-       <item row="2" column="1">
-        <widget class="QLineEdit" name="destLocationLineEdit">
          <property name="maximumSize">
          <property name="maximumSize">
           <size>
           <size>
            <width>120</width>
            <width>120</width>
@@ -432,8 +423,14 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="1" column="1">
-        <widget class="QLineEdit" name="deptLocationLineEdit">
+       <item row="3" column="4">
+        <widget class="QLineEdit" name="thirdPilotNameLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>160</width>
+           <height>0</height>
+          </size>
+         </property>
          <property name="maximumSize">
          <property name="maximumSize">
           <size>
           <size>
            <width>120</width>
            <width>120</width>
@@ -442,43 +439,67 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="3" column="5">
-        <widget class="QLabel" name="thirdPilotNameDisplayLabel">
-         <property name="enabled">
-          <bool>false</bool>
-         </property>
+       <item row="5" column="2">
+        <widget class="QLabel" name="submissionReadyLabel">
          <property name="minimumSize">
          <property name="minimumSize">
           <size>
           <size>
-           <width>120</width>
+           <width>200</width>
            <height>0</height>
            <height>0</height>
           </size>
           </size>
          </property>
          </property>
+         <property name="maximumSize">
+          <size>
+           <width>200</width>
+           <height>16777215</height>
+          </size>
+         </property>
          <property name="text">
          <property name="text">
           <string/>
           <string/>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="4" column="0">
-        <widget class="QLabel" name="tonbLabel">
+      </layout>
+     </item>
+     <item row="0" column="1">
+      <widget class="Line" name="line_2">
+       <property name="orientation">
+        <enum>Qt::Vertical</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="2">
+      <layout class="QGridLayout" name="gridLayout_2">
+       <item row="0" column="0" colspan="2">
+        <widget class="QCheckBox" name="pilotFlyingCheckBox">
          <property name="text">
          <property name="text">
-          <string>On Blocks</string>
+          <string>Pilot Flying</string>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
        <item row="0" column="2">
        <item row="0" column="2">
-        <widget class="QLabel" name="doftDisplayLabel">
+        <widget class="QCheckBox" name="ifrCheckBox">
          <property name="text">
          <property name="text">
-          <string/>
+          <string>IFR</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QLabel" name="takeOffLabel">
+         <property name="text">
+          <string>Take Off</string>
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-      </layout>
-     </item>
-     <item row="0" column="1">
-      <layout class="QGridLayout" name="gridLayout_2">
        <item row="1" column="1">
        <item row="1" column="1">
         <widget class="QSpinBox" name="takeOffSpinBox"/>
         <widget class="QSpinBox" name="takeOffSpinBox"/>
        </item>
        </item>
+       <item row="1" column="2">
+        <widget class="QCheckBox" name="toNightCheckBox">
+         <property name="text">
+          <string>Night</string>
+         </property>
+        </widget>
+       </item>
        <item row="2" column="0">
        <item row="2" column="0">
         <widget class="QLabel" name="landingLabel">
         <widget class="QLabel" name="landingLabel">
          <property name="text">
          <property name="text">
@@ -486,6 +507,9 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
+       <item row="2" column="1">
+        <widget class="QSpinBox" name="landingSpinBox"/>
+       </item>
        <item row="2" column="2">
        <item row="2" column="2">
         <widget class="QCheckBox" name="ldgNightCheckBox">
         <widget class="QCheckBox" name="ldgNightCheckBox">
          <property name="text">
          <property name="text">
@@ -493,13 +517,6 @@
          </property>
          </property>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="0" column="0" colspan="2">
-        <widget class="QCheckBox" name="pilotFlyingCheckBox">
-         <property name="text">
-          <string>Pilot Flying</string>
-         </property>
-        </widget>
-       </item>
        <item row="3" column="0">
        <item row="3" column="0">
         <widget class="QLabel" name="functionLabel">
         <widget class="QLabel" name="functionLabel">
          <property name="text">
          <property name="text">
@@ -536,30 +553,6 @@
          </item>
          </item>
         </widget>
         </widget>
        </item>
        </item>
-       <item row="1" column="2">
-        <widget class="QCheckBox" name="toNightCheckBox">
-         <property name="text">
-          <string>Night</string>
-         </property>
-        </widget>
-       </item>
-       <item row="0" column="2">
-        <widget class="QCheckBox" name="ifrCheckBox">
-         <property name="text">
-          <string>IFR</string>
-         </property>
-        </widget>
-       </item>
-       <item row="1" column="0">
-        <widget class="QLabel" name="takeOffLabel">
-         <property name="text">
-          <string>Take Off</string>
-         </property>
-        </widget>
-       </item>
-       <item row="2" column="1">
-        <widget class="QSpinBox" name="landingSpinBox"/>
-       </item>
        <item row="4" column="0">
        <item row="4" column="0">
         <widget class="QLabel" name="approachLabel">
         <widget class="QLabel" name="approachLabel">
          <property name="text">
          <property name="text">
@@ -570,23 +563,57 @@
        <item row="4" column="1" colspan="2">
        <item row="4" column="1" colspan="2">
         <widget class="QComboBox" name="approachComboBox"/>
         <widget class="QComboBox" name="approachComboBox"/>
        </item>
        </item>
+       <item row="5" column="0" colspan="3">
+        <widget class="QLabel" name="spacerLabel">
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+       </item>
       </layout>
       </layout>
      </item>
      </item>
     </layout>
     </layout>
    </item>
    </item>
-   <item row="0" column="0">
-    <spacer name="leftSpacer">
+   <item row="0" column="4" rowspan="2">
+    <spacer name="rightSpacer">
      <property name="orientation">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
       <enum>Qt::Horizontal</enum>
      </property>
      </property>
      <property name="sizeHint" stdset="0">
      <property name="sizeHint" stdset="0">
       <size>
       <size>
-       <width>48</width>
-       <height>20</height>
+       <width>22</width>
+       <height>228</height>
       </size>
       </size>
      </property>
      </property>
     </spacer>
     </spacer>
    </item>
    </item>
+   <item row="1" column="1">
+    <widget class="QPushButton" name="pushButton_2">
+     <property name="text">
+      <string>Details</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="2">
+    <widget class="QToolButton" name="toolButton">
+     <property name="text">
+      <string>?</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="3">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="enabled">
+      <bool>true</bool>
+     </property>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
   </layout>
   </layout>
  </widget>
  </widget>
  <tabstops>
  <tabstops>

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

@@ -273,7 +273,7 @@ void LogbookWidget::on_actionEdit_Flight_triggered()
         //ui->stackedWidget->setCurrentWidget(logbookWidget);
         //ui->stackedWidget->setCurrentWidget(logbookWidget);
         //!
         //!
         //! \brief new_state
         //! \brief new_state
-        NewNewFlightDialog nff(completionData, this);
+        NewNewFlightDialog nff(completionData,selectedFlights.first(), this);
         ui->stackedWidget->addWidget(&nff);
         ui->stackedWidget->addWidget(&nff);
         ui->stackedWidget->setCurrentWidget(&nff);
         ui->stackedWidget->setCurrentWidget(&nff);
         nff.setWindowFlag(Qt::Widget);
         nff.setWindowFlag(Qt::Widget);