newpilotdialog.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. *openPilotLog - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020-2023 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 NEWPILOT_H
  19. #define NEWPILOT_H
  20. #include <QDialog>
  21. #include <QMessageBox>
  22. #include <QRegularExpression>
  23. #include <QRegularExpressionValidator>
  24. #include <QCompleter>
  25. #include "src/database/pilotentry.h"
  26. namespace Ui {
  27. class NewPilot;
  28. }
  29. /*!
  30. * \brief The NewPilotDialog enables adding new entries to the pilot table in the database
  31. * \details The NewPilotDialog offers two constructors, one is used to create a new Pilot Entry
  32. * from scratch, while the other one is used to edit an existing entry. The existing entry
  33. * is identified by its ROW ID in the database and is then retreived, its data being used
  34. * to pre-fill the UI to enable editing the existing data.
  35. *
  36. * A QCompleter provides in-line completion for the company field.
  37. *
  38. * No verification is done on the user input. Sqlite has full unicode support and names
  39. * come in all different forms and shapes around the world. In order to maintain a maximum
  40. * amount of flexibility, any unicode input is allowed.
  41. */
  42. class NewPilotDialog : public QDialog
  43. {
  44. Q_OBJECT
  45. public:
  46. explicit NewPilotDialog(QWidget *parent = nullptr);
  47. explicit NewPilotDialog(int rowId, QWidget *parent = nullptr);
  48. ~NewPilotDialog();
  49. private slots:
  50. void on_buttonBox_accepted();
  51. private:
  52. Ui::NewPilot *ui;
  53. OPL::PilotEntry pilotEntry;
  54. inline void setup();
  55. /*!
  56. * \brief formFiller - fills the line edits with the data retreived from the database.
  57. */
  58. void formFiller();
  59. /*!
  60. * \brief submitForm - retreives the input from the line edits and commits to the database.
  61. */
  62. void submitForm();
  63. };
  64. #endif // NEWPILOT_H