2
0

airportwidget.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef AIRPORTWIDGET_H
  2. #define AIRPORTWIDGET_H
  3. #include <QWidget>
  4. #include <QSqlTableModel>
  5. #include <QTableView>
  6. namespace Ui {
  7. class AirportWidget;
  8. }
  9. class AirportWidget : public QWidget
  10. {
  11. Q_OBJECT
  12. public:
  13. explicit AirportWidget(QWidget *parent = nullptr);
  14. ~AirportWidget();
  15. signals:
  16. void airportDatabaseUpdated();
  17. private slots:
  18. void on_searchLineEdit_textChanged(const QString &arg1);
  19. void on_searchComboBox_currentIndexChanged(int index);
  20. void on_newAirportPushButton_clicked();
  21. void onSelectionChanged();
  22. void on_deletePushButton_clicked();
  23. void on_editAirportPushButton_clicked();
  24. void refresh();
  25. private:
  26. Ui::AirportWidget *ui;
  27. QSqlTableModel *model;
  28. QTableView *view;
  29. QList<int> selectedEntries;
  30. void setupModelAndeView();
  31. void setupSearch();
  32. inline const static QString TABLE_NAME = QStringLiteral("airports");
  33. inline const static QMap<int, QString> FILTER_MAP = {
  34. {0, QStringLiteral("icao LIKE \"%")},
  35. {1, QStringLiteral("iata LIKE \"%")},
  36. {2, QStringLiteral("name LIKE \"%")},
  37. {3, QStringLiteral("country LIKE \"%")},
  38. };
  39. inline const static QMap<int, QString> HEADER_MAP = {
  40. {0, QStringLiteral("ICAO")},
  41. {1, QStringLiteral("IATA")},
  42. {2, QStringLiteral("Name")},
  43. {3, QStringLiteral("Country")},
  44. };
  45. };
  46. #endif // AIRPORTWIDGET_H