| openPilotLog

opl.h
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
21 #include <QtCore>
22 #include <QMessageBox>
23 #include <QComboBox>
24 #include "src/database/adatabasetypes.h"
25
40 namespace Opl {
41
42 #if defined(__GNUC__) || defined(__clang__)
43 #define FUNC_IDENT __PRETTY_FUNCTION__
44 #elif defined(_MSC_VER)
45 #define FUNC_IDENT __FUNCSIG__
46 #else
47 #define FUNC_IDENT __func__
48 #endif
49
50 #define DEB qDebug() // Use for debugging
51 #define LOG qInfo() // Use for logging milestones (silently, will be written to log file and console out only)
52 #define TODO qCritical() << "TO DO:\t"
53
54 #define INFO(msg) Opl::ANotificationHandler::info(msg, this) // Use for messages of interest to the user (will be displayed in GUI)
55 #define WARN(msg) Opl::ANotificationHandler::warn(msg, this) // Use for warnings (will be displayed in GUI)
56 #define CRIT(msg) Opl::ANotificationHandler::crit(msg, this) // Use for critical warnings (will be displayed in GUI)
57
63 class ANotificationHandler {
64 public:
65 static inline void info(const QString msg, QWidget *parent = nullptr){
66
67 qInfo() << msg;
68 auto mb = QMessageBox(QMessageBox::Information, QLatin1String("Info"), msg, QMessageBox::StandardButton::Ok, parent);
69 mb.exec();
70 };
71 static inline void warn(const QString msg, QWidget *parent = nullptr){
72 qWarning() << msg;
73 auto mb = QMessageBox(QMessageBox::Warning, QLatin1String("Warning"), msg, QMessageBox::StandardButton::Ok, parent);
74 mb.exec();
75 };
76 static inline void crit(const QString msg, QWidget *parent = nullptr){
77 qCritical() << msg;
78 auto mb = QMessageBox(QMessageBox::Critical, QLatin1String("Warning"), msg, QMessageBox::StandardButton::Ok, parent);
79 mb.exec();
80 };
81 }; // class ANotificationHandler
82
83 enum class Translations {English, German, Spanish};
84
85 const static QMap<Opl::Translations, QString> L10N_FILES {
86 {Opl::Translations::English, QStringLiteral("l10n/openpilotlog_en")},
87 {Opl::Translations::German, QStringLiteral("l10n/openpilotlog_de")},
88 {Opl::Translations::Spanish, QStringLiteral("l10n/openpilotlog_es")},
89 };
90 static const QMap<Translations, QString> L10N_NAMES {
91 {Opl::Translations::English, QStringLiteral("English")},
92 {Opl::Translations::German, QStringLiteral("Deutsch")},
93 {Opl::Translations::Spanish, QStringLiteral("Español")},
94 };
95
100 enum PilotFunction {PIC = 0, PICUS = 1, SIC = 2, DUAL = 3, FI = 4};
101
102 static const QMap<PilotFunction, QLatin1String> PILOT_FUNCTIONS = {
103 {PilotFunction::PIC, QLatin1String("PIC")},
104 {PilotFunction::PICUS, QLatin1String("PICUS")},
105 {PilotFunction::SIC, QLatin1String("SIC")},
106 {PilotFunction::DUAL, QLatin1String("DUAL")},
107 {PilotFunction::FI, QLatin1String("FI")},
108 };
109
110 inline void loadPilotFunctios(QComboBox *combo_box)
111 {
112 for (int i = 0; i < Opl::PILOT_FUNCTIONS.size(); i++)
113 combo_box->addItem(Opl::PILOT_FUNCTIONS.value(Opl::PilotFunction(i)));
114 };
115
116 static const QList<QLatin1String> APPROACH_TYPES = {
117 QLatin1String("VISUAL"),
118 QLatin1String("ILS CAT I"),
119 QLatin1String("ILS CAT II"),
120 QLatin1String("ILS CAT III"),
121 QLatin1String("GLS"),
122 QLatin1String("MLS"),
123 QLatin1String("LOC"),
124 QLatin1String("LOC/DME"),
125 QLatin1String("RNAV"),
126 QLatin1String("RNAV (LNAV)"),
127 QLatin1String("RNAV (LNAV/VNAV)"),
128 QLatin1String("RNAV (LPV)"),
129 QLatin1String("RNAV (RNP)"),
130 QLatin1String("RNAV (RNP-AR)"),
131 QLatin1String("VOR"),
132 QLatin1String("VOR/DME"),
133 QLatin1String("NDB"),
134 QLatin1String("NDB/DME"),
135 QLatin1String("TACAN"),
136 QLatin1String("SRA"),
137 QLatin1String("PAR"),
138 QLatin1String("OTHER")
139 };
140
141 inline void loadApproachTypes(QComboBox *combo_box)
142 {
143 for (const auto & approach : Opl::APPROACH_TYPES)
144 combo_box->addItem(approach);
145 };
146
147 namespace Date {
148
153 enum ADateFormat {ISODate, DE, EN };
154
155 } // namespace opl::date
156
157 namespace Time {
158
159 enum FlightTimeFormat {Default, Decimal};
160
161 } // namespace opl::time
162
163 namespace Datetime {
164
165 enum DateTimeFormat {Default, Backup};
166
167 } // namespace opl::datetime
168
184 namespace Db {
185
186
187 // Table names
188 static const auto TABLE_FLIGHTS = QStringLiteral("flights");
189 static const auto TABLE_PILOTS = QStringLiteral("pilots");
190 static const auto TABLE_TAILS = QStringLiteral("tails");
191 static const auto TABLE_AIRCRAFT = QStringLiteral("aircraft");
192 static const auto TABLE_AIRPORTS = QStringLiteral("airports");
193 static const auto TABLE_CURRENCIES = QStringLiteral("currencies");
194
195 // Flights table columns
196 static const auto FLIGHTS_ROWID = QStringLiteral("flight_id");
197 static const auto FLIGHTS_DOFT = QStringLiteral("doft");
198 static const auto FLIGHTS_DEPT = QStringLiteral("dept");
199 static const auto FLIGHTS_DEST = QStringLiteral("dest");
200 static const auto FLIGHTS_TOFB = QStringLiteral("tofb");
201 static const auto FLIGHTS_TONB = QStringLiteral("tonb");
202 static const auto FLIGHTS_PIC = QStringLiteral("pic");
203 static const auto FLIGHTS_ACFT = QStringLiteral("acft");
204 static const auto FLIGHTS_TBLK = QStringLiteral("tblk");
205 static const auto FLIGHTS_TSPSE = QStringLiteral("tSPSE");
206 static const auto FLIGHTS_TSPME = QStringLiteral("tSPME");
207 static const auto FLIGHTS_TMP = QStringLiteral("tMP");
208 static const auto FLIGHTS_TNIGHT = QStringLiteral("tNIGHT");
209 static const auto FLIGHTS_TIFR = QStringLiteral("tIFR");
210 static const auto FLIGHTS_TPIC = QStringLiteral("tPIC");
211 static const auto FLIGHTS_TPICUS = QStringLiteral("tPICUS");
212 static const auto FLIGHTS_TSIC = QStringLiteral("tSIC");
213 static const auto FLIGHTS_TDUAL = QStringLiteral("tDUAL");
214 static const auto FLIGHTS_TFI = QStringLiteral("tFI");
215 static const auto FLIGHTS_TSIM = QStringLiteral("tSIM");
216 static const auto FLIGHTS_PILOTFLYING = QStringLiteral("pilotFlying");
217 static const auto FLIGHTS_TODAY = QStringLiteral("toDay");
218 static const auto FLIGHTS_TONIGHT = QStringLiteral("toNight");
219 static const auto FLIGHTS_LDGDAY = QStringLiteral("ldgDay");
220 static const auto FLIGHTS_LDGNIGHT = QStringLiteral("ldgNight");
221 static const auto FLIGHTS_AUTOLAND = QStringLiteral("autoland");
222 static const auto FLIGHTS_SECONDPILOT = QStringLiteral("secondPilot");
223 static const auto FLIGHTS_THIRDPILOT = QStringLiteral("thirdPilot");
224 static const auto FLIGHTS_APPROACHTYPE = QStringLiteral("approachType");
225 static const auto FLIGHTS_FLIGHTNUMBER = QStringLiteral("flightNumber");
226 static const auto FLIGHTS_REMARKS = QStringLiteral("remarks");
227
228 // tails table
229
230 static const auto TAILS_ROWID = QStringLiteral("tail_id");
231 static const auto TAILS_REGISTRATION = QStringLiteral("registration");
232 static const auto TAILS_COMPANY = QStringLiteral("company");
233 static const auto TAILS_MAKE = QStringLiteral("make");
234 static const auto TAILS_MODEL = QStringLiteral("model");
235 static const auto TAILS_VARIANT = QStringLiteral("variant");
236 static const auto TAILS_MULTIPILOT = QStringLiteral("multipilot");
237 static const auto TAILS_MULTIENGINE = QStringLiteral("multiengine");
238 static const auto TAILS_ENGINETYPE = QStringLiteral("engineType");
239 static const auto TAILS_WEIGHTCLASS = QStringLiteral("weightClass");
240
241 // pilots table
242
243 static const auto PILOTS_ROWID = QStringLiteral("pilot_id");
244 static const auto PILOTS_LASTNAME = QStringLiteral("lastname");
245 static const auto PILOTS_FIRSTNAME = QStringLiteral("firstname");
246 static const auto PILOTS_ALIAS = QStringLiteral("alias");
247 static const auto PILOTS_COMPANY = QStringLiteral("company");
248 static const auto PILOTS_EMPLOYEEID = QStringLiteral("employeeid");
249 static const auto PILOTS_PHONE = QStringLiteral("phone");
250 static const auto PILOTS_EMAIL = QStringLiteral("email");
251
252 // Currencies table
253 static const auto CURRENCIES_EXPIRYDATE = QStringLiteral("expiryDate");
254 static const auto CURRENCIES_DESCRIPTION = QStringLiteral("description");
255
256 // all tables
257 static const auto ROWID = QStringLiteral("ROWID");
258 static const auto NULL_TIME_hhmm = QStringLiteral("00:00");
259
260 static const auto DEFAULT_FLIGHT_POSITION = DataPosition(TABLE_FLIGHTS, 0);
261 static const auto DEFAULT_PILOT_POSITION = DataPosition(TABLE_PILOTS, 0);
262 static const auto DEFAULT_TAIL_POSITION = DataPosition(TABLE_TAILS, 0);
263 static const auto DEFAULT_AIRCRAFT_POSITION = DataPosition(TABLE_AIRCRAFT, 0);
264
265 } // namespace opl::db
266
267 namespace Assets {
268
269 static const auto LOGO = QStringLiteral(":/icons/opl-icons/logos/logo_text.png");
270 static const auto ICON_MAIN = QStringLiteral(":/icons/opl-icons/app/icon_main.png");
271 static const auto ICON_APPICON_LINUX = QStringLiteral(":/icons/opl-icons/app/icon_linux.svg");
272 static const auto ICON_APPICON_IOS = QStringLiteral(":/icons/opl-icons/app/icon_ios.svg");
273 static const auto ICON_APPICON_WIN = QStringLiteral(":/icons/opl-icons/app/icon_windows.ico");
274
275 static const auto ICON_TOOLBAR_HOME = QStringLiteral(":/icons/opl-icons/toolbar/thick/light/icon_home.svg");
276 static const auto ICON_TOOLBAR_NEW_FLIGHT = QStringLiteral(":/icons/opl-icons/toolbar/thick/light/icon_new_flight.svg");
277 static const auto ICON_TOOLBAR_LOGBOOK = QStringLiteral(":/icons/opl-icons/toolbar/thick/light/icon_logbook.svg");
278 static const auto ICON_TOOLBAR_AIRCRAFT = QStringLiteral(":/icons/opl-icons/toolbar/thick/light/icon_airplane.svg");
279 static const auto ICON_TOOLBAR_PILOT = QStringLiteral(":/icons/opl-icons/toolbar/thick/light/icon_pilot.svg");
280 static const auto ICON_TOOLBAR_SETTINGS = QStringLiteral(":/icons/opl-icons/toolbar/thick/light/icon_settings.svg");
281 static const auto ICON_TOOLBAR_QUIT = QStringLiteral(":/icons/opl-icons/toolbar/thick/light/icon_exit.svg");
282
283 static const auto ICON_TOOLBAR_BACKUP = QStringLiteral(":/icons/opl-icons/toolbar/thick/light/icon_backup.svg");
284
285 static const auto ICON_TOOLBAR_HOME_DARK = QStringLiteral(":/icons/opl-icons/toolbar/thick/dark/icon_home_dm.svg");
286 static const auto ICON_TOOLBAR_NEW_FLIGHT_DARK = QStringLiteral(":/icons/opl-icons/toolbar/thick/dark/icon_new_flight_dm.svg");
287 static const auto ICON_TOOLBAR_LOGBOOK_DARK = QStringLiteral(":/icons/opl-icons/toolbar/thick/dark/icon_logbook_dm.svg");
288 static const auto ICON_TOOLBAR_AIRCRAFT_DARK = QStringLiteral(":/icons/opl-icons/toolbar/thick/dark/icon_airplane_dm.svg");
289 static const auto ICON_TOOLBAR_PILOT_DARK = QStringLiteral(":/icons/opl-icons/toolbar/thick/dark/icon_pilot_dm.svg");
290 static const auto ICON_TOOLBAR_SETTINGS_DARK = QStringLiteral(":/icons/opl-icons/toolbar/thick/dark/icon_settings_dm.svg");
291 static const auto ICON_TOOLBAR_QUIT_DARK = QStringLiteral(":/icons/opl-icons/toolbar/thick/dark/icon_exit_dm.svg");
292
293 static const auto ICON_TOOLBAR_BACKUP_DARK = QStringLiteral(":/icons/opl-icons/toolbar/thick/dark/icon_backup_dm.svg");
294
295 }
296
297 } // namespace opl
298
299 #endif // OPLCONSTANTS_H
Opl::ANotificationHandler
The ANotificationHandler class handles displaying of user-directed messages. It displays information ...
Definition: opl.h:63
Opl
A namespace to collect constants and enums used throughout the application.
Definition: opl.h:40
Opl::PilotFunction
PilotFunction
PilotFunction Pilot in Command, Pilot in Command under Supervision, Second in Command (Co-Pilot),...
Definition: opl.h:100
DataPosition
Definition: adatabasetypes.h:44