openPilotLog
aircraftwidget.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 AIRCRAFTWIDGET_H
19 #define AIRCRAFTWIDGET_H
20 
21 #include <QWidget>
22 #include <QItemSelection>
23 #include <QSqlTableModel>
24 #include <QTableView>
25 #include "src/gui/widgets/settingswidget.h"
26 
27 
28 namespace Ui {
29 class AircraftWidget;
30 }
52 class AircraftWidget : public QWidget
53 {
54  Q_OBJECT
55 
56 public:
57  explicit AircraftWidget(QWidget *parent = nullptr);
58  ~AircraftWidget();
59 
60 private slots:
61  void tableView_selectionChanged();
62 
63  void tableView_headerClicked(int column);
64 
65  void on_deleteAircraftButton_clicked();
66 
67  void on_newAircraftButton_clicked();
68 
69  void onNewTailDialog_editingFinished();
70 
71  void on_aircraftSearchLineEdit_textChanged(const QString &arg1);
72 
73 public slots:
82 
87  void repopulateModel();
88 private:
89  Ui::AircraftWidget *ui;
90 
91  QSqlTableModel *model;
92 
93  QTableView *view;
94 
95  QItemSelectionModel* selection;
96 
97  qint32 sortColumn;
98 
102  QVector<qint32> selectedTails;
103 
104  void setupModelAndView();
105 
106  void connectSignalsAndSlots();
107 
108  void onDeleteUnsuccessful();
109 
110  inline void refreshView(){model->select();}
111 
112 protected:
116  void changeEvent(QEvent* event) override;
117 };
118 
119 #endif // AIRCRAFTWIDGET_H
AircraftWidget::onAircraftWidget_dataBaseUpdated
void onAircraftWidget_dataBaseUpdated()
Refreshes the view if the Database has been altered from outside the AircraftWidget.
Definition: aircraftwidget.cpp:93
SettingsWidget::SettingSignal
SettingSignal
enumerates Widgets that need to receive a signal when a setting is updated.
Definition: settingswidget.h:51
AircraftWidget::changeEvent
void changeEvent(QEvent *event) override
Handles change events, like updating the UI to new localisation.
Definition: aircraftwidget.cpp:98
AircraftWidget
The AircraftWidget is used to view, edit, delete or add new tails.
Definition: aircraftwidget.h:53
AircraftWidget::onAircraftWidget_settingChanged
void onAircraftWidget_settingChanged(SettingsWidget::SettingSignal signal)
invokes setupModelAndView() to account for changes the user has made in the SettingsWidget
Definition: aircraftwidget.cpp:85
AircraftWidget::repopulateModel
void repopulateModel()
AircraftWidget::repopulateModel (public slot) - re-populates the model to cater for a change to the d...
Definition: aircraftwidget.cpp:250