klog
adif.h
1 #ifndef KLOG_ADIF_H
2 #define KLOG_ADIF_H
3 /***************************************************************************
4  adif.h - description
5  -------------------
6  begin : ago 2023
7  copyright : (C) 2023 by Jaime Robles
8  email : jaime@robles.es
9  ***************************************************************************/
10 
11 /*****************************************************************************
12  * This file is part of KLog. *
13  * *
14  * KLog is free software: you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation, either version 3 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * KLog is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with KLog. If not, see <https://www.gnu.org/licenses/>. *
26  * *
27  *****************************************************************************/
28 /*
29  This class implements general controls on ADIF standard
30  Refer to https://www.adif.org/
31 
32  This classs hould not need to query the DB neither the DataProxy Class
33 
34 */
35 #include <QDateTime>
36 #include <QObject>
37 #include <QString>
38 #include <QStringList>
39 #include <QtDebug>
40 #include <QtGlobal>
41 #include <QTimeZone>
42 #include "klogdefinitions.h"
43 
44 struct AdifMode {
45  QString mode;
46  QString cabrillo; // CW, PH, FM, RY, DG
47  QStringList submodes;
48 };
49 
50 class Adif : public QObject {
51  Q_OBJECT
52  //friend class tst_Adif;
53 
54 public:
55  Adif(const QString &_parentName);
56  ~Adif();
57  //void init();
58  QList<AdifMode> getModeList() const; // Return the full list of ADIF modes
59  ADIFField setPair(const QString &_pair);
60  bool isValidContinent(const QString &_s);
61  QStringList getContinents();
62  bool isValidFreq(const QString &_b); //>0
63  bool isValidPower(const double _b); //>0
64  bool isValidK_Index(const int _b); //0-9
65  bool isValidCQz(const int _b); //1-40
66  bool isValidITUz(const int _b); // 1-90
67  bool isValidDXCC(const int _b); // 0-522
68  bool isValidAge(const double _b); // 0-120
69  bool isValidDistance(const double _b); //>0.0
70  bool isValidAnt_EL(const double _b); //>=0-360
71  bool isValidAnt_AZ(const double _b); //>=-90-90
72  bool isValidA_Index(const double _b); //0-400
73  bool isValidIOTA_islandID(const int _b); //1-99999999
74  bool isValidNRBursts(const int _b); //>0
75  bool isValidPings(const int _b); //>0
76  bool isValidSFI(const int _b); //0-300
77  bool isValidSTX(const int _b); //>=0
78  bool isValidSRX(const int _b); //>=0
79  bool isValidFISTS(const int _b); //>0
80  bool isValidUKSMG(const int _b); //>0
81  bool isValidTenTen(const int _b); //>0
82  bool isValidLogId(const int _b); //>0
83  //bool isValidAltitude (const double _s); // > 10000 (10000 is a default value in KLog)
84  bool isValidAntPath(const QString &_s);
85  bool isValidMode (const QString &_s) const;
86  bool isValidSubMode (const QString &_s) const;
87  QString getModeFromSubmode(const QString &_submode) const;
88  bool isValidQSO_COMPLETE(const QString &_s); // "Y", "N", "NIL", "?"
89  QString getQSO_COMPLETEFromDB(const QString &_s); // Translates the DB value into an ADIF value
90  int setQSO_COMPLETEToDB(const QString &_s); // Translates the ADIF to a DB value
91 
92  bool isValidPOTA(const QString &_s); // TODO
93  bool isValidWWFF_Ref(const QString &_s); // TODO
94  bool isValidQSLRCVD(const QString &_s, bool _importing=true); // Y, I, or V) (V on import only)
95  bool isValidQSLSENT(const QString &_s); // Y, Q, or I
96 
97  void setLogLevel(DebugLogLevel _l);
98  QString getADIFField(const QString &_fieldName, const QString &_data);
99  QString getADIFBoolFromBool(const bool _b); // Will produce the ADIF format if a bool is received
100 
101 
102  QStringList getQSOUploadStatus (bool _fullName = false); // Returns the ADIF enumeration; fullname= true -> Yes-Upload
103  QStringList getQSLSentStatus (bool _fullName = false); // Returns the ADIF enumeration; fullname= true -> Yes-Sent
104  QStringList getQSLRecStatus (bool _fullName = false); // Returns the ADIF enumeration; fullname= true -> Yes-Sent
105 
106  QString getADIFDateStringFromLoTWDateTime(const QString &_lotwdatetime); // Returns the date when importing LoTW ADIF
107 
108 signals:
109  void debugLog (QString _func, QString _msg, DebugLogLevel _level);
110 
111 private:
112  void logEvent(const QString &_func, const QString &_msg, DebugLogLevel _level);
113  void InitializeHash();
114  void setARRLSect();
115  void setContinents();
116  void setSponsorsList();
117  void setModes();
118 
119  bool isValidCall(const QString &_c);
120 
121  QString parentName;
122  DebugLogLevel logLevel;
123  QHash<QString, QString> ADIFHash; // Name, type
124  QStringList notZeroFields; // Numeral ADIF fields where having a Zero makes no sense
125  QList<AdifMode> modeList; // List of modes/submodes, ...
126  QStringList ARRL_sects, continents, sponsorsList;
127 };
128 
129 #endif // ADIF_H
130 
Definition: adif.h:50
Definition: adif.h:44
Definition: klogdefinitions.h:106