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