oplconstants.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 OPLCONSTANTS_H
  19. #define OPLCONSTANTS_H
  20. #include <QtCore>
  21. #include "src/database/adatabasetypes.h"
  22. /*!
  23. * \brief A namespace to collect constants and enums used throughout the application.
  24. *
  25. * \details The opl namespace collects enums and constants that are used throughout
  26. * the application and provide uniform access.
  27. *
  28. * The date, time and datetime namespaces include enums used to differentiate
  29. * date and time formats for QDate, QTime and QDateTime that deviate from standard values
  30. * included in the Qt Framework like Qt::ISODate and are to be used in conjunction with the
  31. * .toString() members of these classes.
  32. *
  33. * The db namespace contains constants for programatically accessing the database in a fast
  34. * and uniform manner.
  35. */
  36. namespace Opl {
  37. static const auto ApproachTypes = QStringList{
  38. QLatin1String("VISUAL"),
  39. QLatin1String("ILS CAT I"),
  40. QLatin1String("ILS CAT II"),
  41. QLatin1String("ILS CAT III"),
  42. QLatin1String("GLS"),
  43. QLatin1String("MLS"),
  44. QLatin1String("LOC"),
  45. QLatin1String("LOC/DME"),
  46. QLatin1String("RNAV"),
  47. QLatin1String("RNAV (LNAV)"),
  48. QLatin1String("RNAV (LNAV/VNAV)"),
  49. QLatin1String("RNAV (LPV)"),
  50. QLatin1String("RNAV (RNP)"),
  51. QLatin1String("RNAV (RNP-AR)"),
  52. QLatin1String("VOR"),
  53. QLatin1String("VOR/DME"),
  54. QLatin1String("NDB"),
  55. QLatin1String("NDB/DME"),
  56. QLatin1String("TACAN"),
  57. QLatin1String("SRA"),
  58. QLatin1String("PAR"),
  59. QLatin1String("OTHER")
  60. };
  61. namespace Date {
  62. enum DateFormat {Default, Text};
  63. } // namespace opl::date
  64. namespace Time {
  65. enum FlightTimeFormat {Default, Decimal};
  66. } // namespace opl::time
  67. namespace Datetime {
  68. enum DateTimeFormat {Default, Backup};
  69. } // namespace opl::datetime
  70. /*!
  71. * The opl::db namespace provides string literals to programatically access the database
  72. *
  73. * Example usage, do:
  74. * newData.insert(opl::db::FLIGHTS_DEP, ui->deptLocLineEdit->text());
  75. * newData.value(opl::db::AIRCRAFT_MULTIPILOT);
  76. *
  77. * instead of:
  78. * newData.insert("dept", ui->deptLocLineEdit->text());
  79. * newData.value("multipilot");
  80. *
  81. * Declaring these literals here avoids memory allocation at runtime for construction of temporary
  82. * qstrings like ("dept"). See https://doc.qt.io/qt-5/qstring.html#QStringLiteral and ensures
  83. * uniform use throughout the application.
  84. */
  85. namespace Db {
  86. // Table names
  87. static const auto TABLE_FLIGHTS = QLatin1String("flights");
  88. static const auto TABLE_PILOTS = QLatin1String("pilots");
  89. static const auto TABLE_TAILS = QLatin1String("tails");
  90. static const auto TABLE_AIRCRAFT = QLatin1String("aircraft");
  91. static const auto TABLE_AIRPORTS = QLatin1String("airports");
  92. // Flights table columns
  93. static const auto FLIGHTS_DOFT = QLatin1String("doft");
  94. static const auto FLIGHTS_DEPT = QLatin1String("dept");
  95. static const auto FLIGHTS_DEST = QLatin1String("dest");
  96. static const auto FLIGHTS_TOFB = QLatin1String("tofb");
  97. static const auto FLIGHTS_TONB = QLatin1String("tonb");
  98. static const auto FLIGHTS_PIC = QLatin1String("pic");
  99. static const auto FLIGHTS_ACFT = QLatin1String("acft");
  100. static const auto FLIGHTS_TBLK = QLatin1String("tblk");
  101. static const auto FLIGHTS_TSPSE = QLatin1String("tSPSE");
  102. static const auto FLIGHTS_TSPME = QLatin1String("tSPME");
  103. static const auto FLIGHTS_TMP = QLatin1String("tMP");
  104. static const auto FLIGHTS_TNIGHT = QLatin1String("tNIGHT");
  105. static const auto FLIGHTS_TIFR = QLatin1String("tIFR");
  106. static const auto FLIGHTS_TPIC = QLatin1String("tPIC");
  107. static const auto FLIGHTS_TPICUS = QLatin1String("tPICUS");
  108. static const auto FLIGHTS_TSIC = QLatin1String("tSIC");
  109. static const auto FLIGHTS_TDUAL = QLatin1String("tDUAL");
  110. static const auto FLIGHTS_TFI = QLatin1String("tFI");
  111. static const auto FLIGHTS_TSIM = QLatin1String("tSIM");
  112. static const auto FLIGHTS_PILOTFLYING = QLatin1String("pilotFlying");
  113. static const auto FLIGHTS_TODAY = QLatin1String("toDay");
  114. static const auto FLIGHTS_TONIGHT = QLatin1String("toNight");
  115. static const auto FLIGHTS_LDGDAY = QLatin1String("ldgDay");
  116. static const auto FLIGHTS_LDGNIGHT = QLatin1String("ldgNight");
  117. static const auto FLIGHTS_AUTOLAND = QLatin1String("autoland");
  118. static const auto FLIGHTS_SECONDPILOT = QLatin1String("secondPilot");
  119. static const auto FLIGHTS_THIRDPILOT = QLatin1String("thirdPilot");
  120. static const auto FLIGHTS_APPROACHTYPE = QLatin1String("approachType");
  121. static const auto FLIGHTS_FLIGHTNUMBER = QLatin1String("flightNumber");
  122. static const auto FLIGHTS_REMARKS = QLatin1String("remarks");
  123. // tails table
  124. static const auto TAILS_REGISTRATION = QLatin1String("registration");
  125. static const auto TAILS_COMPANY = QLatin1String("company");
  126. static const auto TAILS_MAKE = QLatin1String("make");
  127. static const auto TAILS_MODEL = QLatin1String("model");
  128. static const auto TAILS_VARIANT = QLatin1String("variant");
  129. static const auto TAILS_MULTIPILOT = QLatin1String("multipilot");
  130. static const auto TAILS_MULTIENGINE = QLatin1String("multiengine");
  131. static const auto TAILS_ENGINETYPE = QLatin1String("engineType");
  132. static const auto TAILS_WEIGHTCLASS = QLatin1String("weightClass");
  133. // pilots table
  134. static const auto PILOTS_LASTNAME = QLatin1String("lastname");
  135. static const auto PILOTS_FIRSTNAME = QLatin1String("firstname");
  136. static const auto PILOTS_ALIAS = QLatin1String("alias");
  137. static const auto PILOTS_COMPANY = QLatin1String("company");
  138. static const auto PILOTS_EMPLOYEEID = QLatin1String("employeeid");
  139. static const auto PILOTS_PHONE = QLatin1String("phone");
  140. static const auto PILOTS_EMAIL = QLatin1String("email");
  141. // all tables
  142. static const auto ROWID = QLatin1String("ROWID");
  143. static const auto NULL_TIME_hhmm = QLatin1String("00:00");
  144. static const auto DEFAULT_FLIGHT_POSITION = DataPosition(TABLE_FLIGHTS, 0);
  145. static const auto DEFAULT_PILOT_POSITION = DataPosition(TABLE_PILOTS, 0);
  146. static const auto DEFAULT_TAIL_POSITION = DataPosition(TABLE_TAILS, 0);
  147. static const auto DEFAULT_AIRCRAFT_POSITION = DataPosition(TABLE_AIRCRAFT, 0);
  148. } // namespace opl::db
  149. } // namespace opl
  150. #endif // OPLCONSTANTS_H