oplconstants.h 6.9 KB

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