openPilotLog
pilotswidget.h
1 /*
2  *openPilotLog - A FOSS Pilot Logbook Application
3  *Copyright (C) 2020-2022 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 PILOTSWIDGET_H
19 #define PILOTSWIDGET_H
20 
21 #include <QWidget>
22 #include <QItemSelection>
23 #include <QSqlTableModel>
24 #include <QTableView>
25 #include "src/database/row.h"
26 #include "src/gui/widgets/settingswidget.h"
27 
28 namespace Ui {
29 class PilotsWidget;
30 }
52 class PilotsWidget : public QWidget
53 {
54  Q_OBJECT
55 
56 public:
57  explicit PilotsWidget(QWidget *parent = nullptr);
58  ~PilotsWidget();
59 
60 private slots:
61  void tableView_selectionChanged();
62  void tableView_headerClicked(int);
63  void on_newPilotButton_clicked();
64  void on_deletePilotButton_clicked();
65  void onDeleteUnsuccessful();
66  void onNewPilotDialog_editingFinished();
67  void on_pilotSearchLineEdit_textChanged(const QString &arg1);
68 
69 public slots:
78 
83  void repopulateModel();
84 private:
85  Ui::PilotsWidget *ui;
86 
87  QSqlTableModel *model;
88 
89  QTableView *view;
90 
91  QItemSelectionModel* selectionModel;
92 
93  qint32 sortColumn;
94 
95  QVector<qint32> selectedPilots;
96 
97  const QString getPilotName(const OPL::PilotEntry &pilot);
98 
99  const QString getFlightSummary(const OPL::FlightEntry &flight) const;
100 
101  void setupModelAndView();
102 
103  void connectSignalsAndSlots();
104 
105  inline void refreshView(){model->select();}
106 
107 protected:
111  void changeEvent(QEvent* event) override;
112 };
113 
114 #endif // PILOTSWIDGET_H
A Row representing a Flight entry. See Row class for details.
Definition: row.h:133
A Row representing a Pilot entry. See Row class for details.
Definition: row.h:110
The PilotsWidget is used to view, edit, delete or add new pilots.
Definition: pilotswidget.h:53
void onPilotsWidget_settingChanged(SettingsWidget::SettingSignal signal)
invokes setupModelAndView() to account for changes the user has made in the SettingsWidget
Definition: pilotswidget.cpp:86
void repopulateModel()
PilotsWidget::repopulateModel (public slot) - re-populates the model to cater for a change to the dat...
Definition: pilotswidget.cpp:232
void onPilotsWidget_databaseUpdated()
Refreshes the view if the Database has been altered from outside the AircraftWidget.
Definition: pilotswidget.cpp:92
void changeEvent(QEvent *event) override
Handles change events, like updating the UI to new localisation.
Definition: pilotswidget.cpp:79
SettingSignal
enumerates Widgets that need to receive a signal when a setting is updated.
Definition: settingswidget.h:51