1 #ifndef DXCLUSTER_H
2 #define DXCLUSTER_H
3 /***************************************************************************
4     dxcluster.h  -  description
5        -------------------
6 begin                : oct 2011
7 copyright            : (C) 2011 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 #include <QWidget>
30 //#include <QtWidgets>
31 #include <QtWidgets>
32 #include <QTcpSocket>
33 #include <QObject>
34 #include "awards.h"
35 #include "world.h"
36 #include "utilities.h"
37 #include "dataproxy_sqlite.h"
38 
39 class QWidget;
40 class QTcpSocket;
41 
42 class DXClusterWidget : public QWidget
43 {
44      Q_OBJECT
45 
46  public:
47     DXClusterWidget(DataProxy_SQLite *dp, QWidget *parent );
48     DXClusterWidget(DataProxy_SQLite *dp, const QString &clusterToConnect, const int portToConnect, QWidget *parent );
49 
50     void setColors (const QString &_newOne, const QString &_needed, const QString &_worked, const QString &_confirmed, const QString &_default);
51     void setDXClusterSpotConfig(bool _showhf, bool _showvhf, bool _showwarc, bool _showworked, bool _showconfirmed, bool _showann, bool _showwwv, bool _showwcy );
52     void setDXClusterServer(const QString &clusterToConnect, const int portToConnect);
53     void setCurrentLog(const int _log);
54     bool isConnected();
55     void setMyQRZ(const QString &_qrz);
56     void setDXMarathon (const bool _enable);
57     void setSaveSpots (const bool _enable);
58     //void sendSpotToCluster(const QString &_dx, const QString &_freq);
59 
60 
61     ~DXClusterWidget();
62 
63 
64 private slots:
65     void slotClusterDisplayError(QAbstractSocket::SocketError socketError);
66     void slotClusterDataArrived();
67     void slotClusterSocketConnected();
68     void slotClusterSocketConnectionClosed();
69     void slotClusterSendToServer();
70     void slotClusterClearLineInput();
71     void slotClusterInputTextChanged();
72 
73     void slotClusterDXClusterWidgetItemDoubleClicked( QListWidgetItem * item );
74     void slotClusterDXClusterWidgetItemEntered( QListWidgetItem * item);
75     void slotClusterDXClusterWidgetItemSelected();
76 
77 signals:
78     void dxspotclicked(const QStringList &_qs); // DXSpotCall, DX-Freq, doubleClicked
79     //void dxspot(const QString &_spot); // The text string to be saved
80 
81 private:
82 
83     //void TESTADDSPOT(); // Just a test spot
84 
85     void initClass();
86     void connectToDXCluster();
87     QStringList readItem(QListWidgetItem * item);
88     bool checkIfNeedsToBePrinted(const QString &_DXEntity, const int _band, const int _mode);
89     void saveSpot (const QString &_spot);
90     bool openFile();
91     void addData(); //TO BE DELETED, JUST FOR TESTING PURPOSES
92 
93 
94     QTcpSocket *tcpSocket;
95     QListWidget *dxClusterListWidget;
96     QLineEdit *inputCommand;
97     QPushButton *sendButton;
98     QPushButton *clearButton;
99 
100     bool dxClusterConnected;
101     bool dxClusterAlreadyConnected;
102     QString server;
103     quint16 port;
104     quint16 blockSize;
105 
106     QColor dxSpotColor;
107 
108     World *world;
109     Awards *awards;
110     DataProxy_SQLite *dataProxy;
111     Utilities *util;
112 
113     bool showhf, showvhf, showwarc, showworked, showconfirmed, showann,  showwwv, showwcy;
114     bool dxClusterShowHF, dxClusterShowVHF, dxClusterShowWARC, dxClusterShowWorked, dxClusterShowConfirmed, dxClusterShowAnn, dxClusterShowWWV, dxClusterShowWCY;
115     bool showDxMarathon;
116 
117     QString myQrz;
118     int currentLog;
119     int constrid; // Just an id for the constructor to check who is being executed at one specific time
120 
121     QFile *saveSpotsFile;
122     bool saveSpots; // write/save the spots to a file
123 
124  };
125 
126 class dxClusterSpotItem : public QListWidgetItem {
127 
128 public:
129 
130     dxClusterSpotItem( QListWidget* parent, const QString& spot, const QColor& color );
131     ~dxClusterSpotItem();
132 
133 protected:
134 
135   QColor spotColor;
136 
137 };
138 
139 #endif // DXCLUSTER_H
140