openPilotLog
dbcompletiondata.h
1 /*
2  *openPilotLog - A FOSS Pilot Logbook Application
3  *Copyright (C) 2020-2022 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 DBCOMPLETIONDATA_H
19 #define DBCOMPLETIONDATA_H
20 
21 namespace OPL {
22 
27 enum class CompleterTarget
28 {
29  AirportIdentifierICAO,
30  AirportIdentifierIATA,
31  AirportIdentifier,
32  AirportNames,
33  Registrations,
34  Companies,
35  PilotNames,
36  AircraftTypes
37 };
38 
48 {
49 public:
53  void init();
54 
58  void update();
59  void updateTails();
60  void updatePilots();
61  void updateAirports();
62 
63  // Maps for input mapping DB key - user input
64  QHash<int, QString> pilotsIdMap;
65  QHash<int, QString> tailsIdMap;
66  QHash<int, QString> airportIcaoIdMap;
67  QHash<int, QString> airportIataIdMap;
68  QHash<int, QString> airportNameIdMap;
69  // Lists for QCompleter
70  QStringList pilotList;
71  QStringList tailsList;
72  QStringList airportList;
73 
78  static const QStringList getCompletionList(CompleterTarget target);
79 
84  static const QHash<int, QString> getIdMap(CompleterTarget target);
85 };
86 
87 } // namespace OPL
88 
89 #endif // DBCOMPLETIONDATA_H
Provides data for QCompleters and QHashs.
Definition: dbcompletiondata.h:48
void init()
init Retrieves Data and populates Lists and Maps
Definition: dbcompletiondata.cpp:24
static const QHash< int, QString > getIdMap(CompleterTarget target)
returns a QHash of a human-readable database value and its row id. Used in the Dialogs to map user in...
Definition: dbcompletiondata.cpp:124
static const QStringList getCompletionList(CompleterTarget target)
getCompletionList returns a QStringList of values for a QCompleter based on database values
Definition: dbcompletiondata.cpp:81
void update()
updates data from the user modifiable tables
Definition: dbcompletiondata.cpp:50
A namespace to collect constants and enums used throughout the application.
Definition: paths.cpp:3
CompleterTarget
The DatabaseTarget enum lists database items that are used by completers, for content matching or nee...
Definition: dbcompletiondata.h:28