| 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
29 namespace Ui {
30 class PilotsWidget;
31 }
53 class PilotsWidget : public QWidget
54 {
55 Q_OBJECT
56
57 public:
58 explicit PilotsWidget(QWidget *parent = nullptr);
59 ~PilotsWidget();
60
61 private slots:
62 void tableView_selectionChanged();
63 void tableView_headerClicked(int);
64 void on_newPilotButton_clicked();
65 void on_deletePilotButton_clicked();
66 void onDeleteUnsuccessful();
67 void onNewPilotDialog_editingFinished();
68 void on_pilotSearchLineEdit_textChanged(const QString &arg1);
69
70 public slots:
74 void onPilotsWidget_settingChanged(SettingsWidget::SettingSignal signal);
78 void onPilotsWidget_databaseUpdated();
79
84 void repopulateModel();
85 private:
86 Ui::PilotsWidget *ui;
87
88 QSqlTableModel *model;
89
90 QTableView *view;
91
92 QItemSelectionModel* selectionModel;
93
94 qint32 sortColumn;
95
96 QVector<qint32> selectedPilots;
97
98 void setupModelAndView();
99
100 void connectSignalsAndSlots();
101
102 inline void refreshView(){model->select();}
103
104 protected:
108 void changeEvent(QEvent* event) override;
109 };
110
111 #endif // PILOTSWIDGET_H
PilotsWidget
The PilotsWidget is used to view, edit, delete or add new pilots.
Definition: pilotswidget.h:54
PilotsWidget::onPilotsWidget_settingChanged
void onPilotsWidget_settingChanged(SettingsWidget::SettingSignal signal)
invokes setupModelAndView() to account for changes the user has made in the SettingsWidget
Definition: pilotswidget.cpp:84
PilotsWidget::repopulateModel
void repopulateModel()
PilotsWidget::repopulateModel (public slot) - re-populates the model to cater for a change to the dat...
Definition: pilotswidget.cpp:230
PilotsWidget::onPilotsWidget_databaseUpdated
void onPilotsWidget_databaseUpdated()
Refreshes the view if the Database has been altered from outside the AircraftWidget.
Definition: pilotswidget.cpp:90
PilotsWidget::changeEvent
void changeEvent(QEvent *event) override
Handles change events, like updating the UI to new localisation.
Definition: pilotswidget.cpp:77
SettingsWidget::SettingSignal
SettingSignal
enumerates Widgets that need to receive a signal when a setting is updated.
Definition: settingswidget.h:51