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 }
48 class AircraftWidget : public QWidget
49 {
50  Q_OBJECT
51 
52 public:
53  explicit AircraftWidget(QWidget *parent = nullptr);
54  ~AircraftWidget();
55 
56 private slots:
57  void tableView_selectionChanged();
58 
59  void tableView_headerClicked(int column);
60 
61  void on_deleteAircraftButton_clicked();
62 
63  void on_newAircraftButton_clicked();
64 
65  void onNewTailDialog_editingFinished();
66 
67  void on_aircraftSearchLineEdit_textChanged(const QString &arg1);
68 
69 public slots:
78 
83  void repopulateModel();
84 private:
85  Ui::AircraftWidget *ui;
86 
87  QSqlTableModel *model;
88 
89  QTableView *view;
90 
91  QItemSelectionModel* selection;
92 
93  qint32 sortColumn;
94 
98  QVector<qint32> selectedTails;
99 
100  void setupModelAndView();
101 
102  void connectSignalsAndSlots();
103 
104  void onDeleteUnsuccessful();
105 
106  inline void refreshView(){model->select();}
107 };
108 
109 #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
Widgets that need to receive a signal when a setting is updated.
Definition: settingswidget.h:44
AircraftWidget
The AircraftWidget is used to view, edit, delete or add new tails.
Definition: aircraftwidget.h:48
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:247