Browse Source

refactoring of newFlight

fiffty-50 4 years ago
parent
commit
ec3dedb619
3 changed files with 19 additions and 6 deletions
  1. 17 4
      src/gui/dialogues/newflight.cpp
  2. 1 1
      src/gui/dialogues/newflight.h
  3. 1 1
      src/gui/widgets/homewidget.cpp

+ 17 - 4
src/gui/dialogues/newflight.cpp

@@ -87,8 +87,7 @@ NewFlight::NewFlight(QWidget *parent, Flight oldFlight) :
 {
 {
     ui->setupUi(this);
     ui->setupUi(this);
     setup();
     setup();
-    DEBUG("Work in progress");
-    formFiller();
+    formFiller(oldFlight);
 }
 }
 
 
 NewFlight::~NewFlight()
 NewFlight::~NewFlight()
@@ -183,9 +182,23 @@ void NewFlight::setup(){
     ui->newDeptLocLineEdit->setFocus();
     ui->newDeptLocLineEdit->setFocus();
 }
 }
 
 
-void NewFlight::formFiller()
+void NewFlight::formFiller(Flight oldFlight)
 {
 {
-
+    auto line_edits = parent()->findChildren<QLineEdit *>();
+    QStringList line_edits_names;
+    for(const auto& le : line_edits){
+        line_edits_names << le->objectName();
+    }
+    for(const auto& key : oldFlight.data.keys()){
+        auto rx = QRegularExpression(key + "\\w+?");
+        for(const auto& leName : line_edits_names){
+            DEBUG(leName << rx);
+            if(rx.match(leName).hasMatch())  {
+                DEBUG("Match found: " << key << " - " << rx.match(leName).captured(0));
+                break;
+            }
+        }
+    }
 }
 }
 
 
 /*
 /*

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

@@ -89,7 +89,7 @@ private:
 
 
     void setup();
     void setup();
 
 
-    void formFiller();
+    void formFiller(Flight oldFlight);
 
 
     void setupLineEdit(QLineEdit* line_edit, LineEditSettings settings);
     void setupLineEdit(QLineEdit* line_edit, LineEditSettings settings);
 
 

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

@@ -38,7 +38,7 @@ HomeWidget::~HomeWidget()
 
 
 void HomeWidget::on_pushButton_clicked()
 void HomeWidget::on_pushButton_clicked()
 {
 {
-    NewFlight nf(this);
+    NewFlight nf(this, Flight(10));
     nf.exec();
     nf.exec();
 }
 }