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