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 #include "src/classes/acompletiondata.h"
30 
31 namespace Ui {
32 class LogbookWidget;
33 }
34 
46 class LogbookWidget : public QWidget
47 {
48  Q_OBJECT
49 
50 public:
51  explicit LogbookWidget(ACompletionData &completion_data, QWidget *parent = nullptr);
52  ~LogbookWidget();
53 
54 private slots:
55  //void on_newFlightButton_clicked();
56  //void on_editFlightButton_clicked();
57  //void on_deleteFlightPushButton_clicked();
58  //void on_showAllButton_clicked();
59  void flightsTableView_selectionChanged();
60  void on_tableView_customContextMenuRequested(const QPoint &pos);
61  void on_actionDelete_Flight_triggered();
62  void on_actionEdit_Flight_triggered();
63  void on_tableView_doubleClicked();
64  void on_flightSearchLlineEdit_textChanged(const QString &arg1);
65  void on_flightSearchComboBox_currentIndexChanged(int);
66 
67 public slots:
68  void refresh();
69  void onLogbookWidget_viewSelectionChanged(SettingsWidget::SettingSignal signal);
70  void repopulateModel();
71 
72 private:
73  Ui::LogbookWidget *ui;
74 
75  QTableView* view;
76 
77  QSqlTableModel* displayModel;
78 
79  QItemSelectionModel* selectionModel;
80 
81  QMenu* menu;
82 
83  QVector<qint32> selectedFlights;
84 
85  void setupModelAndView(int view_id);
86  void connectSignalsAndSlots();
87 
88  ACompletionData completionData;
89 
90 protected:
94  void changeEvent(QEvent* event) override;
95 };
96 
97 #endif // LOGBOOKWIDGET_H
The ACompletionData class provides data to QCompleters and QHashs used for mapping user input to data...
Definition: acompletiondata.h:12
The LogbookWidget displays data from the database in a QSqlTableView fed by a QSqlQuery Model.
Definition: logbookwidget.h:47
void changeEvent(QEvent *event) override
Handles change events, like updating the UI to new localisation.
Definition: logbookwidget.cpp:111
void refresh()
LogbookWidget::refresh Refreshes the view to reflect changes in the database.
Definition: logbookwidget.cpp:246
void repopulateModel()
LogbookWidget::repopulateModel (public slot) - cleanly re-populates the model to cater for a change t...
Definition: logbookwidget.cpp:297
SettingSignal
enumerates Widgets that need to receive a signal when a setting is updated.
Definition: settingswidget.h:51