forked from foldynl/QLog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewContactWidget.h
375 lines (318 loc) · 10.4 KB
/
NewContactWidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
#ifndef QLOG_UI_NEWCONTACTWIDGET_H
#define QLOG_UI_NEWCONTACTWIDGET_H
#include <QWidget>
#include <QSqlRecord>
#include <QCompleter>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QHash>
#include <QFormLayout>
#include <QDoubleSpinBox>
#include <QToolButton>
#include "data/DxSpot.h"
#include "rig/Rig.h"
#include "core/CallbookManager.h"
#include "data/StationProfile.h"
#include "core/PropConditions.h"
#include "core/LogLocale.h"
#include "models/LogbookModel.h"
#include "ui/EditLine.h"
#include "data/DxSpot.h"
#include "core/MultiselectCompleter.h"
#include "data/POTAEntity.h"
#include "data/SOTAEntity.h"
#include "data/WWFFEntity.h"
namespace Ui {
class NewContactWidget;
}
enum CoordPrecision {
COORD_NONE = 0,
COORD_DXCC = 1,
COORD_GRID = 2,
COORD_FULL = 3
};
class NewContactDynamicWidgets
{
public:
QLabel *nameLabel;
NewContactEditLine *nameEdit;
QLabel *qthLabel;
NewContactEditLine *qthEdit;
QLabel *gridLabel;
NewContactEditLine *gridEdit;
QLabel *commentLabel;
NewContactEditLine *commentEdit;
QLabel *contLabel;
QComboBox *contEdit;
QLabel *ituLabel;
NewContactEditLine *ituEdit;
QLabel *cqzLabel;
NewContactEditLine *cqzEdit;
QLabel *stateLabel;
NewContactEditLine *stateEdit;
QLabel *countyLabel;
NewContactEditLine *countyEdit;
QLabel *ageLabel;
NewContactEditLine *ageEdit;
QLabel *vuccLabel;
NewContactEditLine *vuccEdit;
QLabel *dokLabel;
NewContactEditLine *dokEdit;
QLabel *iotaLabel;
NewContactEditLine *iotaEdit;
QLabel *potaLabel;
NewContactEditLine *potaEdit;
QLabel *sotaLabel;
NewContactEditLine *sotaEdit;
QLabel *wwffLabel;
NewContactEditLine *wwffEdit;
QLabel *sigLabel;
NewContactEditLine *sigEdit;
QLabel *sigInfoLabel;
NewContactEditLine *sigInfoEdit;
QLabel *emailLabel;
NewContactEditLine *emailEdit;
QLabel *urlLabel;
NewContactEditLine *urlEdit;
QLabel *satNameLabel;
NewContactEditLine *satNameEdit;
QLabel *satModeLabel;
QComboBox *satModeEdit;
QLabel *contestIDLabel;
NewContactEditLine *contestIDEdit;
QLabel *srxStringLabel;
NewContactEditLine *srxStringEdit;
QLabel *stxStringLabel;
NewContactEditLine *stxStringEdit;
QLabel *srxLabel;
NewContactEditLine *srxEdit;
QLabel *stxLabel;
NewContactEditLine *stxEdit;
QLabel *rxPWRLabel;
NewContactEditLine *rxPWREdit;
QLabel *powerLabel;
QDoubleSpinBox *powerEdit;
QLabel *rigLabel;
NewContactEditLine *rigEdit;
explicit NewContactDynamicWidgets(bool allocateWidgets,
QWidget *parent);
QWidget* getRowWidget(int index);
QWidget* getLabel(int index);
QWidget* getEditor(int index);
QStringList getAllFieldLabelNames() const;
int getIndex4FieldLabelName(const QString&) const;
QString getFieldLabelName4Index(int) const;
private:
struct DynamicWidget
{
QWidget* label;
QWidget* editor;
QWidget* rowWidget;
QString baseObjectName;
QString fieldLabelName;
};
template<typename WidgetType>
void initializeWidgets(LogbookModel::ColumnID DBIndexMapping,
const QString &objectName,
QLabel *&retLabel,
WidgetType *&retWidget);
// Mapping from DB Index to <Label, Editor>
QHash<int, DynamicWidget> widgetMapping;
QWidget *parent;
bool widgetsAllocated;
};
class NewContactWidget : public QWidget
{
Q_OBJECT
public:
explicit NewContactWidget(QWidget *parent = nullptr);
~NewContactWidget();
void assignPropConditions(PropConditions *);
QString getCallsign() const;
QString getName() const;
QString getRST() const;
QString getGreeting() const;
QString getQTH() const;
QString getMyCallsign() const;
QString getMyName() const;
QString getMyQTH() const;
QString getMyLocator() const;
QString getMySIG() const;
QString getMySIGInfo() const;
QString getMyIOTA() const;
QString getMySOTA() const;
QString getMyPOTA() const;
QString getMyWWFT() const;
QString getMyVUCC() const;
QString getMyPWR() const;
QString getBand() const;
QString getMode() const;
QString getSentNr() const;
QString getSentExch() const;
double getQSOBearing() const;
double getQSODistance() const;
bool getTabCollapseState() const;
signals:
void contactAdded(QSqlRecord record);
void newTarget(double lat, double lon);
void filterCallsign(QString call);
void userFrequencyChanged(VFOID, double, double, double);
void userModeChanged(VFOID, const QString &, const QString &mode,
const QString &subMode, qint32 width);
void markQSO(DxSpot spot);
void callboolImageUrl(const QString&);
void contestStarted(const QString contestID,
const QDateTime date);
void rigProfileChanged();
public slots:
void refreshRigProfileCombo();
void saveExternalContact(QSqlRecord record);
void readGlobalSettings();
void tuneDx(const DxSpot &spot);
void fillCallsignGrid(const QString &callsign, const QString& grid);
void prepareWSJTXQSO(const QString &callsign, const QString &grid);
void resetContact();
void saveContact();
// to receive RIG instructions
void changeFrequency(VFOID, double, double, double);
void changeModeWithoutSignals(const QString &mode, const QString &submode);
void changeModefromRig(VFOID, const QString &rawMode, const QString &mode,
const QString &subMode, qint32 width);
void changePower(VFOID, double power);
void rigConnected();
void rigDisconnected();
void setNearestSpot(const DxSpot &);
void setNearestSpotColor();
void setManualMode(bool);
void exitManualMode();
void refreshStationProfileCombo();
void refreshAntProfileCombo();
void stationProfileComboChanged(const QString&);
void setValuesFromActivity(const QString &);
void markContact();
void useNearestCallsign();
void setupCustomUi();
void resetSTXSeq();
void stopContest();
void refreshCallsignsColors();
void changeSRXStringLink(int);
private slots:
void handleCallsignFromUser();
void frequencyTXChanged();
void frequencyRXChanged();
void changeMode();
void subModeChanged();
void gridChanged();
void updateTime();
void updateTimeOff();
void startContactTimer();
void stopContactTimer();
void finalizeCallsignEdit();
void setCallbookFields(const QMap<QString, QString>& data);
void setMembershipList(const QString&, QMap<QString, ClubStatusQuery::ClubStatus>);
void propModeChanged(const QString&);
void sotaChanged(const QString&);
void sotaEditFinished();
void potaChanged(const QString&);
void potaEditFinished();
void wwffEditFinished();
void wwffChanged(const QString&);
void formFieldChangedString(const QString&);
void formFieldChanged();
void setCallbookStatusEnabled(bool);
void changeCallbookSearchStatus();
void satNameChanged();
void rigProfileComboChanged(const QString&);
void antProfileComboChanged(const QString&);
void webLookup();
void refreshSIGCompleter();
void refreshContestCompleter();
void tabsExpandCollapse();
void setContestFieldsState();
private:
void useFieldsFromPrevQSO(const QString &callsign,
const QString &grid = QString());
void setDxccInfo(const DxccEntity &curr);
void setDxccInfo(const QString &callsign);
void clearCallbookQueryFields();
void clearMemberQueryFields();
void readWidgetSettings();
void writeWidgetSetting();
void __modeChanged();
void updateTXBand(double freq);
void updateRXBand(double freq);
void updateCoordinates(double lat, double lon, CoordPrecision prec);
void clearCoordinates();
void updateDxccStatus();
void updatePartnerLocTime();
void setDefaultReport();
void addAddlFields(QSqlRecord &record, const StationProfile &profile);
bool eventFilter(QObject *object, QEvent *event);
bool isQSOTimeStarted();
void QSYContactWiping(double);
void connectFieldChanged();
void changeCallsignManually(const QString &);
void changeCallsignManually(const QString &, double);
void __changeFrequency(VFOID, double vfoFreq, double ritFreq, double xitFreq);
void showRXTXFreqs(bool);
void setComboBaseData(QComboBox *, const QString &);
void queryMemberList();
QList<QWidget*> setupCustomUiRow(QHBoxLayout *row, const QList<int>& widgetsList);
QList<QWidget*> setupCustomDetailColumn(QFormLayout *column, const QList<int>& widgetsList);
void setupCustomUiRowsTabOrder(const QList<QWidget *> &customWidgets);
void setBandLabel(const QString &);
void updateSatMode();
bool isPOTAValid(POTAEntity *entity);
bool isSOTAValid(SOTAEntity *entity);
bool isWWFFValid(WWFFEntity *entity);
bool shouldStartContest();
void startContest(const QDateTime &date);
void setSTXSeq();
void setSTXSeq(int number);
void updateNearestSpotDupe();
void checkDupe();
private:
Rig* rig;
double realRigFreq;
double realFreqForManualExit;
QString callsign;
double dxDistance; // QSO distance in km - used for ADIF and internal usage
DxccEntity dxccEntity;
QString defaultReport;
CallbookManager callbookManager;
QTimer* contactTimer;
Ui::NewContactWidget *ui;
NewContactDynamicWidgets *uiDynamic;
CoordPrecision coordPrec;
PropConditions *prop_cond;
QCompleter *satCompleter;
QCompleter *sotaCompleter;
MultiselectCompleter *potaCompleter;
QCompleter *wwffCompleter;
QCompleter *sigCompleter;
QCompleter *contestCompleter;
QTimeZone partnerTimeZone;
double QSOFreq;
qint32 bandwidthFilter;
bool rigOnline;
QMap<QString, QString> lastCallbookQueryData;
SOTAEntity lastSOTA;
POTAEntity lastPOTA;
WWFFEntity lastWWFF;
bool isManualEnterMode;
LogLocale locale;
QDateTime timeOff;
bool callbookSearchPaused;
QSettings settings;
Band bandTX;
Band bandRX;
QSqlQuery prevQSOExactMatchQuery;
QSqlQuery prevQSOBaseCallMatchQuery;
bool isPrevQSOExactMatchQuery;
bool isPrevQSOBaseCallMatchQuery;
DxSpot nearestSpot;
QToolButton *tabCollapseBtn;
};
#endif // QLOG_UI_NEWCONTACTWIDGET_H