openPilotLog
logbookwidget.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 LOGBOOKWIDGET_H
19 #define LOGBOOKWIDGET_H
20 
21 #include <QWidget>
22 #include <QItemSelection>
23 #include <QSqlTableModel>
24 #include <QMessageBox>
25 #include <QDebug>
26 #include <QMenu>
27 #include <QTableView>
28 #include "src/gui/widgets/settingswidget.h"
29 
30 namespace Ui {
31 class LogbookWidget;
32 }
33 
45 class LogbookWidget : public QWidget
46 {
47  Q_OBJECT
48 
49 public:
50  explicit LogbookWidget(QWidget *parent = nullptr);
51  ~LogbookWidget();
52 
53 private slots:
54  void on_newFlightButton_clicked();
55  void on_editFlightButton_clicked();
56  void on_deleteFlightPushButton_clicked();
57  void on_showAllButton_clicked();
58  void flightsTableView_selectionChanged();
59  void on_tableView_customContextMenuRequested(const QPoint &pos);
60  void on_actionDelete_Flight_triggered();
61  void on_actionEdit_Flight_triggered();
62  void on_tableView_doubleClicked();
63  void on_flightSearchLlineEdit_textChanged(const QString &arg1);
64  void on_flightSearchComboBox_currentIndexChanged(int);
65 
66 public slots:
67  void refresh();
68  void onLogbookWidget_viewSelectionChanged(SettingsWidget::SettingSignal signal);
69  void repopulateModel();
70 
71 private:
72  Ui::LogbookWidget *ui;
73 
74  QTableView* view;
75 
76  QSqlTableModel* displayModel;
77 
78  QItemSelectionModel* selectionModel;
79 
80  QMenu* menu;
81 
82  QVector<qint32> selectedFlights;
83 
84  void setupModelAndView(int view_id);
85  void connectSignalsAndSlots();
86 
87 protected:
91  void changeEvent(QEvent* event) override;
92 };
93 
94 #endif // LOGBOOKWIDGET_H
LogbookWidget
The LogbookWidget displays data from the database in a QSqlTableView fed by a QSqlQuery Model.
Definition: logbookwidget.h:46
LogbookWidget::repopulateModel
void repopulateModel()
LogbookWidget::repopulateModel (public slot) - cleanly re-populates the model to cater for a change t...
Definition: logbookwidget.cpp:317
LogbookWidget::refresh
void refresh()
LogbookWidget::refresh Refreshes the view to reflect changes in the database.
Definition: logbookwidget.cpp:266
LogbookWidget::changeEvent
void changeEvent(QEvent *event) override
Handles change events, like updating the UI to new localisation.
Definition: logbookwidget.cpp:111
SettingsWidget::SettingSignal
SettingSignal
enumerates Widgets that need to receive a signal when a setting is updated.
Definition: settingswidget.h:51