123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #ifndef LOGBOOKVIEWINFO_H
- #define LOGBOOKVIEWINFO_H
- #include "src/opl.h"
- #include <QtCore>
- namespace OPL {
- /*!
- * \brief The LogbookViewInfo class is a base class for classes that encapsulate information
- * about a LogbookView
- * \details In the logbook display, SQL views are used instead of raw table data, since in
- * some cases data is aggregated from different tables. Using views avoid
- */
- class LogbookViewInfo : public QObject {
- Q_OBJECT // enable tr()
- public:
-
- /*!
- * \brief Return the column in the view which contains the date of flight
- */
- static constexpr int getDateColumn(LogbookView view)
- {
- return DATE_COLUMNS.at(static_cast<int>(view));
- }
- /*!
- * \brief Return the column in the view which contains the aircrafts type
- */
- static constexpr int getTypeColumn(LogbookView view)
- {
- return TYPE_COLUMNS.at(static_cast<int>(view));
- }
-
- /*!
- * \brief Return the column(s) in the view which contain pilot names
- */
- static constexpr int getPicColumn(LogbookView view)
- {
- return PIC_COLUMNS.at(static_cast<int>(view));
- }
-
- /*!
- * \brief Return the column(s) in the view which contain Time entries
- */
- static constexpr std::vector<int> getTimeColumns(LogbookView view)
- {
- switch (view) {
- case LogbookView::Default:
- return { 3, 5, 6 };
- case LogbookView::DefaultWithSim:
- return { 3, 5, 6, 11 };
- case LogbookView::Easa:
- return { 3, 5, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20 };
- case LogbookView::EasaWithSim:
- return { 3, 5, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 22 };
- default:
- assert(((void)"View is not implemented", false));
- return { 0 };
- }
- }
- // translations need to be done at runtime
- static const QStringList getTableHeaders(LogbookView view)
- {
- switch (view) {
- case LogbookView::Default:
- return {
- QStringLiteral("flight_id"), // flight id column - hidden
- tr("Date of Flight"),
- tr("Dept"),
- tr("Time"),
- tr("Dest"),
- tr("Time"),
- tr("Total"),
- tr("Name PIC"),
- tr("Type"),
- tr("Registration"),
- tr("Flight Number"),
- tr("Remarks"),
- };
- case LogbookView::DefaultWithSim:
- return {
- QStringLiteral("flight_id"), // flight id column - hidden
- tr("Date of Flight"),
- tr("Dept"),
- tr("Time"),
- tr("Dest"),
- tr("Time"),
- tr("Total"),
- tr("Name PIC"),
- tr("Type"),
- tr("Registration"),
- tr("Sim Type"),
- tr("Time of Session"),
- tr("Remarks"),
- };
- case LogbookView::Easa:
- return {
- QStringLiteral("flight_id"), // flight id column - hidden
- tr("Date of Flight"),
- tr("Dept"),
- tr("Time"),
- tr("Dest"),
- tr("Time"),
- tr("Type"),
- tr("Registration"),
- tr("SP SE"),
- tr("SP ME"),
- tr("MP"),
- tr("Total"),
- tr("Name PIC"),
- tr("L/D"),
- tr("L/N"),
- tr("Night"),
- tr("IFR"),
- tr("PIC"),
- tr("SIC"),
- tr("Dual"),
- tr("FI"),
- tr("Remarks"),
- };
- case LogbookView::EasaWithSim:
- return {
- QStringLiteral("flight_id"), // flight id column - hidden
- tr("Date of Flight"),
- tr("Dept"),
- tr("Time"),
- tr("Dest"),
- tr("Time"),
- tr("Type"),
- tr("Registration"),
- tr("SP SE"),
- tr("SP ME"),
- tr("MP"),
- tr("Total"),
- tr("Name PIC"),
- tr("L/D"),
- tr("L/N"),
- tr("Night"),
- tr("IFR"),
- tr("PIC"),
- tr("SIC"),
- tr("Dual"),
- tr("FI"),
- tr("Sim Type"),
- tr("Time of Session"),
- tr("Remarks"),
- };
- default:
- assert(((void)"View is not implemented", false));
- return {};
- }
- }
- private:
- static constexpr std::array DATE_COLUMNS {
- 1, // Default
- 1, // Default With Sim
- 1, // Easa
- 1, // Easa With Sim
- 1, // Simulator Only
- };
- static constexpr std::array TYPE_COLUMNS {
- 8, // Default
- 8, // Default With Sim
- 6, // Easa
- 6, // Easa With Sim
- 1, // Simulator Only
- };
- static constexpr std::array PIC_COLUMNS {
- 7, // Default
- 7, // Default With Sim
- 12, // Easa
- 12, // Easa With Sim
- -1, // Simulator Only
- };
- };
- } // namespace OPL
- #endif // LOGBOOKVIEWINFO_H
|