18 #ifndef NewFlightDialog_H
19 #define NewFlightDialog_H
27 #include "src/functions/time.h"
28 #include "src/database/database.h"
29 #include "src/database/dbcompletiondata.h"
31 #include "src/database/row.h"
48 enum ValidationItem {doft = 0, dept = 1, dest = 2, tofb = 3, tonb = 4, pic = 5, acft = 6};
50 void validate(
ValidationItem item) { validationArray[item] =
true;};
51 void validate(
int index) { validationArray[index] =
true;};
52 void invalidate(
ValidationItem item) { validationArray[item] =
false;}
53 void invalidate(
int index) { validationArray[index] =
false;}
54 inline bool allValid()
const {
return validationArray.count(
true) == 7;};
55 inline bool timesValid()
const {
return validationArray[ValidationItem::tofb] && validationArray[ValidationItem::tonb];}
56 inline bool locationsValid()
const {
return validationArray[ValidationItem::dept] && validationArray[ValidationItem::dest];}
57 inline bool nightDataValid()
const {
return timesValid() && locationsValid() && validationArray[ValidationItem::doft];}
58 inline bool acftValid()
const {
return validationArray[ValidationItem::acft];}
59 inline bool validAt(
int index)
const {
return validationArray[index];}
60 inline bool validAt(
ValidationItem item)
const {
return validationArray[item];}
63 void printValidationStatus()
const {
64 QString deb_string(
"\033[mValidation State:\tdoft\tdept\tdest\ttofb\ttonb\tpic\tacft\n");
65 deb_string +=
"\t\t\t\t";
66 for (
int i = 0; i < 7; i++) {
67 if (validationArray[i])
68 deb_string +=
"\t\033[32m" + QString::number(validationArray[i]);
70 deb_string +=
"\t\033[31m" + QString::number(validationArray[i]);
72 deb_string += QLatin1String(
"\u001b[38;5;75m");
73 qDebug().noquote() << deb_string;
76 QBitArray validationArray = QBitArray(7);
127 Ui::NewFlightDialog *ui;
141 static const inline QList<QLineEdit*>* timeLineEdits;
145 static const inline QList<QLineEdit*>* locationLineEdits;
149 static const inline QList<QLineEdit*>* pilotNameLineEdits;
154 static const inline QList<QLineEdit*>* mandatoryLineEdits;
155 static const inline QLatin1String
self = QLatin1String(
"self");
158 void setupRawInputValidation();
159 void setupSignalsAndSlots();
161 void fillWithEntryData();
168 void onGoodInputReceived(QLineEdit *line_edit);
174 void onBadInputReceived(QLineEdit *line_edit);
176 void updateBlockTimeLabel();
177 void updateNightCheckBoxes();
178 void setNightCheckboxes();
180 bool addNewTail(QLineEdit& parent_line_edit);
181 bool addNewPilot(QLineEdit& parent_line_edit);
184 bool checkPilotFunctionsValid();
185 OPL::RowData_T prepareFlightEntryData();
189 void toUpper(
const QString& text);
190 void onTimeLineEdit_editingFinished();
191 void onPilotNameLineEdit_editingFinshed();
192 void onLocationLineEdit_editingFinished();
193 void on_acftLineEdit_editingFinished();
194 void on_doftLineEdit_editingFinished();
195 void on_buttonBox_accepted();
196 void on_pilotFlyingCheckBox_stateChanged(
int arg1);
197 void on_approachComboBox_currentTextChanged(
const QString &arg1);
198 void on_functionComboBox_currentIndexChanged(
int index);
201 bool eventFilter(QObject*
object, QEvent* event)
override;
The NewFlightDialog is used to add or edit entries from the flights table in the database.
Definition: newflightdialog.h:108
bool eventFilter(QObject *object, QEvent *event) override
NewFlightDialog::eventFilter invalidates mandatory line edits on focus in.
Definition: newflightdialog.cpp:162
NewFlightDialog(OPL::DbCompletionData &completion_data, QWidget *parent=nullptr)
NewFlightDialog - Creates a NewFlightDialog that can be used to add a new flight entry to the logbook...
Definition: newflightdialog.cpp:32
Provides data for QCompleters and QHashs.
Definition: dbcompletiondata.h:48
A Row representing a Flight entry. See Row class for details.
Definition: row.h:133
The ValidationState class encapsulates a QBitArray that has a bit set (or unset) depending on wether ...
Definition: newflightdialog.h:40
ValidationItem
The ValidationItem enum contains the items that are mandatory for logging a flight: Date of Flight,...
Definition: newflightdialog.h:48