Browse Source

new constructors for newflight dialog

fiffty-50 4 years ago
parent
commit
83fed79907
3 changed files with 28 additions and 3 deletions
  1. 1 1
      openPilotLog.pro.user
  2. 22 2
      src/gui/dialogues/newflight.cpp
  3. 5 0
      src/gui/dialogues/newflight.h

+ 1 - 1
openPilotLog.pro.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.11.0, 2020-11-17T21:22:09. -->
+<!-- Written by QtCreator 4.11.0, 2020-11-19T14:34:08. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>

+ 22 - 2
src/gui/dialogues/newflight.cpp

@@ -72,11 +72,31 @@ const auto PILOT_NAME_SQL_COL = SqlColumnNum(6);
 /*
  * Window Construction
  */
+//For adding a new Flight to the logbook
 NewFlight::NewFlight(QWidget *parent) :
     QDialog(parent),
     ui(new Ui::NewFlight)
 {
     ui->setupUi(this);
+    setup();
+}
+//For editing an existing flight
+NewFlight::NewFlight(QWidget *parent, Flight oldFlight) :
+    QDialog(parent),
+    ui(new Ui::NewFlight)
+{
+    ui->setupUi(this);
+    setup();
+    DEBUG("Work in progress");
+    formFiller();
+}
+
+NewFlight::~NewFlight()
+{
+    delete ui;
+}
+
+void NewFlight::setup(){
     auto db = QSqlDatabase::database("qt_sql_default_connection");
 
     const auto location_settings = \
@@ -163,9 +183,9 @@ NewFlight::NewFlight(QWidget *parent) :
     ui->newDeptLocLineEdit->setFocus();
 }
 
-NewFlight::~NewFlight()
+void NewFlight::formFiller()
 {
-    delete ui;
+
 }
 
 /*

+ 5 - 0
src/gui/dialogues/newflight.h

@@ -80,12 +80,17 @@ class NewFlight : public QDialog
 
 public:
     explicit NewFlight(QWidget *parent);
+    explicit NewFlight(QWidget *parent, Flight oldFlight);
     ~NewFlight();
 
     QStringList* getResult();
 
 private:
 
+    void setup();
+
+    void formFiller();
+
     void setupLineEdit(QLineEdit* line_edit, LineEditSettings settings);
 
     void nope();//error box