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