totalswidget.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 TOTALSWIDGET_H
  19. #define TOTALSWIDGET_H
  20. #include "QtWidgets/qlineedit.h"
  21. #include "src/gui/verification/timeinput.h"
  22. #include "src/opl.h"
  23. #include <QWidget>
  24. #include <QRegularExpressionValidator>
  25. namespace Ui {
  26. class TotalsWidget;
  27. }
  28. class TotalsWidget : public QWidget
  29. {
  30. Q_OBJECT
  31. public:
  32. enum WidgetType {TotalTimeWidget, PreviousExperienceWidget};
  33. explicit TotalsWidget(WidgetType widgetType, QWidget *parent = nullptr);
  34. ~TotalsWidget();
  35. private:
  36. Ui::TotalsWidget *ui;
  37. /*!
  38. * \brief m_rowData holds the data displayed in the line edits
  39. */
  40. OPL::RowData_T m_rowData;
  41. /*!
  42. * \brief ROW_ID the row ID for previous experience entries (1)
  43. */
  44. const static int ROW_ID = 1;
  45. void fillTotals(const WidgetType widgetType);
  46. void setup(const WidgetType widgetType);
  47. void connectSignalsAndSlots();
  48. bool verifyUserTimeInput(QLineEdit *line_edit, const TimeInput &input);
  49. bool updateTimeEntry(const QLineEdit* line_edit);
  50. bool updateMovementEntry(const QLineEdit* line_edit);
  51. private slots:
  52. void timeLineEditEditingFinished();
  53. void movementLineEditEditingFinished();
  54. };
  55. #endif // TOTALSWIDGET_H