NewFlightDialog Class Reference

The NewFlightDialog is used to add or edit entries from the flights table in the database. More...

`#include <newflightdialog.h>`

Inheritance diagram for NewFlightDialog:

## Public Member Functions

| 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. More...
| NewFlightDialog (OPL::DbCompletionData &completion_data, int row_id, QWidget *parent=nullptr)
| NewFlightDialog - Creates a NewFlightDialog that can be used to edit an existing entry in the logbook. More...

## Protected Member Functions

bool | eventFilter (QObject *object, QEvent *event) override
| NewFlightDialog::eventFilter invalidates mandatory line edits on focus in. More...

## Detailed Description

The NewFlightDialog is used to add or edit entries from the flights table in the database.

NewFlightDialog offers two constructors, one is used to create a new flight entry from scratch, where the other one is used to edit an existing entry. This entry is identified by its ROW ID, which is used to retreive the entry data and pre-populate the user interface with the data from the database.

The flights table is the core of the application's database and care needs to be taken when interfacing with it.

To ensure only good data is written to the database, the ValidationState class is used. It contains a QBitArray with each bit representing a mandatory data point. The array is initialized to all false and progressively changed to true as entry data is validated. An entry can only be submitted if all the verification bits are set.

Inputs from the user are verified with a two-step process. The first level of verification is accomplished by QRegularExpressionValidator, which limits the user to only inputting generally acceptable data (like numbers for date or time, or characters for airport identifiers). If the input passes this sanity check, the line edits emit the editingFinished() signal, which triggers a more granular and sophisticated set of input verification, broadly based on cross-checking the entered data against known good values. The ACompletionData class is used to provide QHashs of known good values from the database and their respective ROW_IDs. If user-entered data has been matched to a known good database value, the data is considered acceptable. This means that in order to, for example, log a flight with a certain Pilot, that this pilot already has to exist in the pilots table. If this is not the case, the user is prompted to add a new pilot (or aircraft) to the database before proceeding. In order to make this matching process seamless for the user, the completionData also contains a set of QStringLists for each of the database tables which are used to create QCompleters that provide pop-up completion on the respective QLineEdits.

Once the user is satisfied with his entries, a final set of input verification is triggered and the entry is submitted to the database, see on_buttonBox_accepted() and Database::commit()

## Constructor & Destructor Documentation

## NewFlightDialog() [1/2]

NewFlightDialog::NewFlightDialog | ( | OPL::DbCompletionData & | completion_data,
|  | QWidget * | parent = `nullptr`
| ) |  |

explicit

NewFlightDialog - Creates a NewFlightDialog that can be used to add a new flight entry to the logbook.

Parameters

  completion_data | - contains QStringLists for the QCompleter to autocomplete Airport Codes, Pilot Names and aircraft registrationsn

## NewFlightDialog() [2/2]

NewFlightDialog::NewFlightDialog | ( | OPL::DbCompletionData & | completion_data,
|  | int | row_id,
|  | QWidget * | parent = `nullptr`
| ) |  |

explicit

NewFlightDialog - Creates a NewFlightDialog that can be used to edit an existing entry in the logbook.

Parameters

  completion_data | - contains QStringLists for the QCompleter to autocomplete Airport Codes, Pilot Names and aircraft registrationsn
  row_id | - The database ROW ID of the entry to be edited

## Member Function Documentation

## eventFilter()

bool NewFlightDialog::eventFilter | ( | QObject * | object,
|  | QEvent * | event
| ) |  |

overrideprotected

NewFlightDialog::eventFilter invalidates mandatory line edits on focus in.

Some of the QLineEdits have validators set that provide raw input validation. These validators have the side effect that if an input does not meet the raw input validation criteria, onEditingFinished() is not emitted when the line edit loses focus. This could lead to a line edit that previously had good input to be changed to bad input without the validation bit in validationState being unset, because the second step of input validation is only triggered when editingFinished() is emitted.

The documentation for this class was generated from the following files:

- src/gui/dialogues/newflightdialog.h
- src/gui/dialogues/newflightdialog.cpp