forked from foldynl/QLog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDxWidget.h
253 lines (215 loc) · 7.39 KB
/
DxWidget.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
#ifndef QLOG_UI_DXWIDGET_H
#define QLOG_UI_DXWIDGET_H
#include <QWidget>
#include <QtNetwork>
#include <QSortFilterProxyModel>
#include <QRegularExpression>
#include <QSqlRecord>
#include <QLabel>
#include "data/DxSpot.h"
#include "data/WCYSpot.h"
#include "data/WWVSpot.h"
#include "data/ToAllSpot.h"
#include "core/LogLocale.h"
#include "core/DxServerString.h"
#include "models/SearchFilterProxyModel.h"
#include "rig/Rig.h"
// in sec
#define DEDUPLICATION_TIME 3
// in kHz
#define DEDUPLICATION_FREQ_TOLERANCE 5
namespace Ui {
class DxWidget;
}
class DxTableModel : public QAbstractTableModel {
Q_OBJECT
public:
DxTableModel(QObject* parent = 0) : QAbstractTableModel(parent) {}
int rowCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
bool addEntry(DxSpot entry,
bool deduplicate = false,
qint16 dedup_interval = DEDUPLICATION_TIME,
double freq_tolerance = DEDUPLICATION_FREQ_TOLERANCE);
const DxSpot getSpot(const QModelIndex& index) const {return dxData.at(index.row());};
void clear();
private:
QList<DxSpot> dxData;
LogLocale locale;
};
class WCYTableModel : public QAbstractTableModel {
Q_OBJECT
public:
WCYTableModel(QObject* parent = 0) : QAbstractTableModel(parent) {}
int rowCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void addEntry(WCYSpot entry);
void clear();
private:
QList<WCYSpot> wcyData;
LogLocale locale;
};
class WWVTableModel : public QAbstractTableModel {
Q_OBJECT
public:
WWVTableModel(QObject* parent = 0) : QAbstractTableModel(parent) {}
int rowCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void addEntry(WWVSpot entry);
void clear();
private:
QList<WWVSpot> wwvData;
LogLocale locale;
};
class ToAllTableModel : public QAbstractTableModel {
Q_OBJECT
public:
ToAllTableModel(QObject* parent = 0) : QAbstractTableModel(parent) {}
int rowCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& parent = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void addEntry(ToAllSpot entry);
void clear();
private:
QList<ToAllSpot> toAllData;
LogLocale locale;
};
class DeleteHighlightedDXServerWhenDelPressedEventFilter : public QObject
{
Q_OBJECT
signals:
void deleteServerItem();
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
class DxWidget : public QWidget {
Q_OBJECT
public:
explicit DxWidget(QWidget *parent = 0);
~DxWidget();
public slots:
void toggleConnect();
void receive();
void send();
void connected();
void socketError(QAbstractSocket::SocketError);
void viewModeChanged(int);
void entryDoubleClicked(QModelIndex);
void actionFilter();
void adjusteServerSelectSize(QString);
void serverSelectChanged(int);
void setLastQSO(QSqlRecord);
void reloadSetting();
void prepareQSOSpot(QSqlRecord);
void setSearch(const QString &);
void setSearchStatus(bool);
void setSearchVisible();
void setSearchClosed();
void setDxTrend(QHash<QString, QHash<QString, QHash<QString, int>>>);
void recalculateTrend();
void setTunedFrequency(VFOID vfoid, double vfoFreq, double ritFreq, double xitFreq);
private slots:
void actionCommandSpotQSO();
void actionCommandShowHFStats();
void actionCommandShowVHFStats();
void actionCommandShowWCY();
void actionCommandShowWWV();
void actionConnectOnStartup();
void actionDeleteServer();
void actionForgetPassword();
void actionKeepSpots();
void actionClear();
void displayedColumns();
void trendDoubleClicked(int row, int column);
signals:
void tuneDx(DxSpot);
void tuneBand(QString);
void newSpot(DxSpot);
void newWCYSpot(WCYSpot);
void newWWVSpot(WWVSpot);
void newToAllSpot(ToAllSpot);
void newFilteredSpot(DxSpot);
private:
enum DXCConnectionState
{
DISCONNECTED = 0,
CONNECTING = 1,
CONNECTED = 2,
LOGIN_SENT = 3,
PASSWORD_SENT = 4,
OPERATION = 5
};
DxTableModel* dxTableModel;
WCYTableModel* wcyTableModel;
WWVTableModel* wwvTableModel;
ToAllTableModel* toAllTableModel;
SearchFilterProxyModel* dxTableProxyModel;
QTcpSocket* socket;
Ui::DxWidget *ui;
QRegularExpression moderegexp;
QRegularExpression contregexp;
QRegularExpression spottercontregexp;
QRegularExpression bandregexp;
uint dxccStatusFilter;
bool deduplicateSpots;
int deduplicatetime;
int deduplicatefreq;
QSet<QString> dxMemberFilter;
QSqlRecord lastQSO;
quint8 reconnectAttempts;
QTimer reconnectTimer;
DXCConnectionState connectionState;
DxServerString *connectedServerString;
QHash<QString, QHash<QString, QHash<QString, int>>> receivedTrendData;
QHash<QString, QHash<QString, int>> prevTrendDataForMyCont;
QHash<QString, QHash<QString, int>> trendDataForMyCont;
QStringList trendBandList;
QLabel *trendTableCornerLabel;
void connectCluster();
void disconnectCluster(bool tryReconnect = false);
void saveDXCServers();
QString modeFilterRegExp();
QString contFilterRegExp();
QString spotterContFilterRegExp();
QString bandFilterRegExp();
uint dxccStatusFilterValue();
bool spotDedupValue();
int getDedupTimeValue();
int getDedupFreqValue();
QStringList dxMemberList();
bool getAutoconnectServer();
void saveAutoconnectServer(bool);
bool getKeepQSOs();
void saveKeepQSOs(bool);
void sendCommand(const QString&,
bool switchToConsole = false);
void saveWidgetSetting();
void restoreWidgetSetting();
QStringList getDXCServerList(void);
void serverComboSetup();
void clearAllPasswordIcons();
void activateCurrPasswordIcon();
void processDxSpot(const QString &spotter,
const QString &freq,
const QString &call,
const QString &comment,
const QDateTime &dateTime = QDateTime());
QVector<int> dxcListHiddenCols() const;
BandPlan::BandPlanMode modeGroupFromComment(const QString &comment) const;
QString refFromComment(const QString &comment, bool &flag,
const QRegularExpression ®Ex,
const QString &refType, int justified) const;
void wwffRefFromComment(DxSpot &spot) const;
void potaRefFromComment(DxSpot &spot) const;
void sotaRefFromComment(DxSpot &spot) const;
void iotaRefFromComment(DxSpot &spot) const;
QColor getHeatmapColor(int value, int maxValue);
};
#endif // QLOG_UI_DXWIDGET_H