openPilotLog
newflightdialog.h
1 /*
2  *openPilot Log - A FOSS Pilot Logbook Application
3  *Copyright (C) 2020 Felix Turowsky
4  *
5  *This program is free software: you can redistribute it and/or modify
6  *it under the terms of the GNU General Public License as published by
7  *the Free Software Foundation, either version 3 of the License, or
8  *(at your option) any later version.
9  *
10  *This program is distributed in the hope that it will be useful,
11  *but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *GNU General Public License for more details.
14  *
15  *You should have received a copy of the GNU General Public License
16  *along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 #ifndef NEWFLIGHT_H
19 #define NEWFLIGHT_H
20 
21 #include <QDialog>
22 #include <QRegularExpression>
23 #include <QMessageBox>
24 #include <QDebug>
25 #include <QCompleter>
26 #include <QStringList>
27 #include <QButtonGroup>
28 #include <QBitArray>
29 #include <QLineEdit>
30 #include <QCalendarWidget>
31 #include <QTabWidget>
32 #include <QKeyEvent>
33 
34 #include "src/gui/dialogues/newtaildialog.h"
35 #include "src/gui/dialogues/newpilotdialog.h"
36 
37 #include "src/experimental/adatabase.h"
38 #include "src/experimental/aflightentry.h"
39 #include "src/experimental/apilotentry.h"
40 #include "src/experimental/atailentry.h"
41 #include "src/functions/acalc.h"
42 #include "src/testing/atimer.h"
43 
44 namespace Ui {
45 class NewFlight;
46 }
47 
48 class NewFlightDialog : public QDialog
49 {
50  Q_OBJECT
51 
52 public:
56  explicit NewFlightDialog(QWidget *parent = nullptr);
60  explicit NewFlightDialog(int row_id, QWidget *parent = nullptr);
61  ~NewFlightDialog();
62 
63 private slots:
64 
66  void onInputRejected();
68 
69  void onToUpperTriggered_textChanged(const QString&);
70  void onPilotNameLineEdit_editingFinished();
71  void onLocationEditingFinished(QLineEdit*, QLabel*);
72  void onTimeLineEdit_editingFinished();
73  void onCompleter_highlighted(const QString&);
74  void onCompleter_activated(const QString &);
75  void onCalendarWidget_clicked(const QDate &date);
76  void onCalendarWidget_selected(const QDate &date);
77  void onDoftLineEdit_entered();
78  void on_calendarCheckBox_stateChanged(int arg1);
79  void on_doftLineEdit_editingFinished();
80  void on_cancelButton_clicked();
81  void on_submitButton_clicked();
82  void on_setAsDefaultButton_clicked();
83  void on_restoreDefaultButton_clicked();
84  void on_PilotFlyingCheckBox_stateChanged(int arg1);
85  void on_IfrCheckBox_stateChanged(int);
86  void on_manualEditingCheckBox_stateChanged(int arg1);
87  void on_ApproachComboBox_currentTextChanged(const QString &arg1);
88  void on_FunctionComboBox_currentIndexChanged(int index);
89  void on_deptLocLineEdit_editingFinished();
90  void on_destLocLineEdit_editingFinished();
91  void on_acftLineEdit_editingFinished();
92 
93 private:
94  Ui::NewFlight *ui;
95 
101  experimental::AFlightEntry flightEntry;
102 
103  QList<QLineEdit*> mandatoryLineEdits;
104  QList<QLineEdit*> primaryTimeLineEdits;
105  QList<QLineEdit*> pilotsLineEdits;
106 
111  QBitArray mandatoryLineEditsGood;
112 
116  QStringList pilotList;
117  QStringList tailsList;
118  QStringList airportList;
119 
123  QMap<QString, int> pilotsIdMap;
124  QMap<QString, int> tailsIdMap;
125  QMap<QString, int> airportIcaoIdMap;
126  QMap<QString, int> airportIataIdMap;
127  QMap<QString, int> airportNameIdMap;
128 
133  bool updateEnabled;
134 
135  void setup();
136  void readSettings();
137  void writeSettings();
138  void setupButtonGroups();
139  void setPopUpCalendarEnabled(bool state);
140  void setupRawInputValidation();
141  void setupSignalsAndSlots();
142  void formFiller();
143  void fillDeductibleData();
144 
145  void onMandatoryLineEditsFilled();
146  void onGoodInputReceived(QLineEdit*);
147  void onBadInputReceived(QLineEdit *);
148  bool eventFilter(QObject *object, QEvent *event);
149  bool isLessOrEqualThanBlockTime(const QString time_string);
150 
151  void addNewTail(QLineEdit*);
152  void addNewPilot(QLineEdit *);
153 
154  experimental::TableData collectInput();
155 };
156 
157 
158 #endif // NEWFLIGHT_H
experimental::AFlightEntry
Definition: aflightentry.h:9
NewFlightDialog
Definition: newflightdialog.h:49
NewFlightDialog::NewFlightDialog
NewFlightDialog(QWidget *parent=nullptr)
NewFlightDialog create a new flight and add it to the logbook.
Definition: newflightdialog.cpp:99