logbookviewinfo.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #ifndef LOGBOOKVIEWINFO_H
  2. #define LOGBOOKVIEWINFO_H
  3. #include "src/opl.h"
  4. #include <QtCore>
  5. namespace OPL {
  6. /*!
  7. * \brief The LogbookViewInfo class is a base class for classes that encapsulate information
  8. * about a LogbookView
  9. * \details In the logbook display, SQL views are used instead of raw table data, since in
  10. * some cases data is aggregated from different tables. Using views avoid
  11. */
  12. class LogbookViewInfo : public QObject {
  13. Q_OBJECT // enable tr()
  14. public:
  15. /*!
  16. * \brief Return the column in the view which contains the date of flight
  17. */
  18. static constexpr int getDateColumn(LogbookView view)
  19. {
  20. return DATE_COLUMNS.at(static_cast<int>(view));
  21. }
  22. /*!
  23. * \brief Return the column in the view which contains the aircrafts type
  24. */
  25. static constexpr int getTypeColumn(LogbookView view)
  26. {
  27. return TYPE_COLUMNS.at(static_cast<int>(view));
  28. }
  29. /*!
  30. * \brief Return the column(s) in the view which contain pilot names
  31. */
  32. static constexpr int getPicColumn(LogbookView view)
  33. {
  34. return PIC_COLUMNS.at(static_cast<int>(view));
  35. }
  36. /*!
  37. * \brief Return the column(s) in the view which contain Time entries
  38. */
  39. static constexpr std::vector<int> getTimeColumns(LogbookView view)
  40. {
  41. switch (view) {
  42. case LogbookView::Default:
  43. return { 3, 5, 6 };
  44. case LogbookView::DefaultWithSim:
  45. return { 3, 5, 6, 11 };
  46. case LogbookView::Easa:
  47. return { 3, 5, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20 };
  48. case LogbookView::EasaWithSim:
  49. return { 3, 5, 8, 9, 10, 11, 15, 16, 17, 18, 19, 20, 22 };
  50. default:
  51. assert(((void)"View is not implemented", false));
  52. return { 0 };
  53. }
  54. }
  55. // translations need to be done at runtime
  56. static const QStringList getTableHeaders(LogbookView view)
  57. {
  58. switch (view) {
  59. case LogbookView::Default:
  60. return {
  61. QStringLiteral("flight_id"), // flight id column - hidden
  62. tr("Date of Flight"),
  63. tr("Dept"),
  64. tr("Time"),
  65. tr("Dest"),
  66. tr("Time"),
  67. tr("Total"),
  68. tr("Name PIC"),
  69. tr("Type"),
  70. tr("Registration"),
  71. tr("Flight Number"),
  72. tr("Remarks"),
  73. };
  74. case LogbookView::DefaultWithSim:
  75. return {
  76. QStringLiteral("flight_id"), // flight id column - hidden
  77. tr("Date of Flight"),
  78. tr("Dept"),
  79. tr("Time"),
  80. tr("Dest"),
  81. tr("Time"),
  82. tr("Total"),
  83. tr("Name PIC"),
  84. tr("Type"),
  85. tr("Registration"),
  86. tr("Sim Type"),
  87. tr("Time of Session"),
  88. tr("Remarks"),
  89. };
  90. case LogbookView::Easa:
  91. return {
  92. QStringLiteral("flight_id"), // flight id column - hidden
  93. tr("Date of Flight"),
  94. tr("Dept"),
  95. tr("Time"),
  96. tr("Dest"),
  97. tr("Time"),
  98. tr("Type"),
  99. tr("Registration"),
  100. tr("SP SE"),
  101. tr("SP ME"),
  102. tr("MP"),
  103. tr("Total"),
  104. tr("Name PIC"),
  105. tr("L/D"),
  106. tr("L/N"),
  107. tr("Night"),
  108. tr("IFR"),
  109. tr("PIC"),
  110. tr("SIC"),
  111. tr("Dual"),
  112. tr("FI"),
  113. tr("Remarks"),
  114. };
  115. case LogbookView::EasaWithSim:
  116. return {
  117. QStringLiteral("flight_id"), // flight id column - hidden
  118. tr("Date of Flight"),
  119. tr("Dept"),
  120. tr("Time"),
  121. tr("Dest"),
  122. tr("Time"),
  123. tr("Type"),
  124. tr("Registration"),
  125. tr("SP SE"),
  126. tr("SP ME"),
  127. tr("MP"),
  128. tr("Total"),
  129. tr("Name PIC"),
  130. tr("L/D"),
  131. tr("L/N"),
  132. tr("Night"),
  133. tr("IFR"),
  134. tr("PIC"),
  135. tr("SIC"),
  136. tr("Dual"),
  137. tr("FI"),
  138. tr("Sim Type"),
  139. tr("Time of Session"),
  140. tr("Remarks"),
  141. };
  142. default:
  143. assert(((void)"View is not implemented", false));
  144. return {};
  145. }
  146. }
  147. private:
  148. static constexpr std::array DATE_COLUMNS {
  149. 1, // Default
  150. 1, // Default With Sim
  151. 1, // Easa
  152. 1, // Easa With Sim
  153. 1, // Simulator Only
  154. };
  155. static constexpr std::array TYPE_COLUMNS {
  156. 8, // Default
  157. 8, // Default With Sim
  158. 6, // Easa
  159. 6, // Easa With Sim
  160. 1, // Simulator Only
  161. };
  162. static constexpr std::array PIC_COLUMNS {
  163. 7, // Default
  164. 7, // Default With Sim
  165. 12, // Easa
  166. 12, // Easa With Sim
  167. -1, // Simulator Only
  168. };
  169. };
  170. } // namespace OPL
  171. #endif // LOGBOOKVIEWINFO_H