logbookwidget.h
/*
*openPilotLog - A FOSS Pilot Logbook Application
*Copyright (C) 2020-2022 Felix Turowsky
*
*This program is free software: you can redistribute it and/or modify
*it under the terms of the GNU General Public License as published by
*the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
*This program is distributed in the hope that it will be useful,
*but WITHOUT ANY WARRANTY; without even the implied warranty of
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef LOGBOOKWIDGET_H
#define LOGBOOKWIDGET_H
#include <QWidget>
#include <QItemSelection>
#include <QSqlTableModel>
#include <QMessageBox>
#include <QDebug>
#include <QMenu>
#include <QTableView>
#include "src/gui/widgets/settingswidget.h"
#include "src/database/dbcompletiondata.h"
#include "src/opl.h"
namespace Ui {
class LogbookWidget;
}
class LogbookWidget : public QWidget
{
Q_OBJECT
public:
explicit LogbookWidget(OPL::DbCompletionData &completion_data, QWidget *parent = nullptr);
~LogbookWidget();
private slots:
void flightsTableView_selectionChanged();
void on_tableView_customContextMenuRequested(const QPoint &pos);
void on_actionDelete_Flight_triggered();
void on_tableView_doubleClicked();
void on_flightSearchLlineEdit_textChanged(const QString &arg1);
void on_flightSearchComboBox_currentIndexChanged(int);
void on_viewsComboBox_currentIndexChanged(int index);
void on_actionEdit_Flight_triggered();
void on_actionEdit_Sim_triggered();
public slots:
void refresh();
void onLogbookWidget_viewSelectionChanged(SettingsWidget::SettingSignal signal);
void repopulateModel();
private:
Ui::LogbookWidget *ui;
QTableView* view;
QSqlTableModel* displayModel;
QItemSelectionModel* selectionModel;
QMenu* menu;
QList<int> selectedEntries;
void setupModelAndView(int view_id);
void connectSignalsAndSlots();
const QString getFlightSummary(const OPL::FlightEntry &flight) const;
OPL::DbCompletionData completionData;
inline bool isFlight(int model_row_id) { return model_row_id > 0; }
protected:
void changeEvent(QEvent* event) override;
};
#endif // LOGBOOKWIDGET_H
LogbookWidget
The LogbookWidget displays data from the database in a QSqlTableView fed by a QSqlQuery Model.
Definition: logbookwidget.h:48
LogbookWidget::changeEvent
void changeEvent(QEvent *event) override
Handles change events, like updating the UI to new localisation.
Definition: logbookwidget.cpp:117
LogbookWidget::refresh
void refresh()
LogbookWidget::refresh Refreshes the view to reflect changes in the database.
Definition: logbookwidget.cpp:231
LogbookWidget::repopulateModel
void repopulateModel()
LogbookWidget::repopulateModel (public slot) - cleanly re-populates the model to cater for a change t...
Definition: logbookwidget.cpp:282
OPL::DbCompletionData
Provides data for QCompleters and QHashs.
Definition: dbcompletiondata.h:48
OPL::FlightEntry
A Row representing a Flight entry. See Row class for details.
Definition: row.h:133
SettingsWidget::SettingSignal
SettingSignal
enumerates Widgets that need to receive a signal when a setting is updated.
Definition: settingswidget.h:51